Closed ericpromislow closed 6 years ago
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/158741786
The labels on this github issue will be updated when the story is started.
Hey @ericpromislow, thanks for reporting the issue and including all the details.
We took a look at the problem today. It seems like YAML quoting is part of the problem, and the other part that you found is coming from seeding the DBs, Users, and Passwords in here: https://github.com/cloudfoundry/mariadb_ctrl/blob/master/mariadb_helper/seeder/seeder.go
We were able to solve this problem, but in doing so, we found several other spots that also take DB user passwords that need to be escaped. Some of those are directed to SQL, others end up in mysql defaults files. The escaping between the two is totally different.
While this is a solvable problem, at this point we feel like the code complexity introduced by it is not worth the value provided by escaping the strings.
The release assumes a level of trust with the Operator deploying it. So while it is possible for the Operator to inject sql statements via the password, they are already in possession of the admin credentials.
The current recommended way of generating passwords is using the bosh cli with a --vars-store
or using credhub from the bosh director itself. The passwords generated by these two methods do not contain characters that need escaping.
... and I actually agree that you can achieve the needed entropy in a password by selecting N1
characters from a small set of candidates over N2
characters (where N2 < N1
) from the full set of printable characters, but wanted to raise the issue. These passwords all live within the CF universe, and aren't subject to issues where end-users enter their own passwords and get disallowed character
error messages when trying to create harder-to-guess passwords.
Agreed. Thanks for raising the issue. I think it was something we hadn't really considered before and it gave us a chance to dig around and see exactly what the risks were.
Feature Request Info
Problem you are trying to solve
Help us understand the problem you are facing. Please provide as much context as possible.
I did this:
and then deployed to a bosh-lite, and got this error message for the mysql job:
In /var/vcap/jobs/mysql/config, there are two key lines of code:
The value is fine in an unquoted yaml string, as shown in this irb session:
The error message suggests there's some unsafe SQL injection taking place somewhere -- not in this repo, as the only hit on
PreseededDatabases
is in the template with the above yaml.Also, I would quote a string like this with double-quotes, backslash-escape any double-quotes and hex-encode a few other characters to support non-alnum characters in password fields -- see https://github.com/cloudfoundry/capi-release/commit/f76291eeb82a8f04629b9a74281c7b96dc6a2703 for details
Proposed solution/feature
What is the proposed solution and why do you think it is the best approach to the problem above.
Outlined above
Would you want to open an PR for this feature?
Sure, I'll do this next week. Easy to quote the yaml; it would be helpful if someone could point to which mysql client is failing to inject the password correctly, or how characters in the password field like quotation marks should be encoded.
Bug Report Info
Currently:
What is the current broken behavior?
Expected:
What the correct behavior should be?
Steps to Reproduce:
see above
Deployment Context:
This is on a bosh-lite
Reference: