-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL identifiers and string literals aren't escaped in migration.go #537
Comments
Your report is appreciated. Please star this repository to motivate its developers! ⭐ |
Thanks for the report @grahamhoyes |
Some details on a possible fix, I am not familiar with go or gorm so there may be inaccuracies:
|
I'm working on setting up a Homer install backed by a Google Cloud SQL Postgres database which uses IAM authentication. When doing so, the database user's username is of the form
[email protected]
.This causes issues with most of the code in migrations/migration.go due to a lack of escaping/quoting for identifiers with just using
fmt.Sprintf
- the-
and@
s are a syntax error:For this to work properly, the username needs to be double-quoted:
A similar issue exists when creating a new user due to the password being unescaped - any
'
s in the password will cause a syntax error at best. Worst case, this code is also vulnerable to SQL injection if there is anywhere that untrusted/unsanitized user inputs are accepted.I am unfamiliar with the go landscape and Homer's database layer - if parameter binding is possible, that would be the ideal solution. If not, here is an example implementation of proper quoting for identifiers (users, column names, database names, etc) and here for literal strings (like the password). Note that these are just examples I'm familiar with, be aware of that repo's BSD 3-Clause license.
Relevant logs from homer, with fake names:
The text was updated successfully, but these errors were encountered: