-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
MDEV-28823 Secure mariadb-secure-installation output file with chmod #4016
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
base: 10.6
Are you sure you want to change the base?
Conversation
|
Thanks for the fix. I'm thinking the original premise of touch/chmod is incorrect. There there's a very small race condition where the file can be opened, before the chmod is applied, and then read when its its later populated. Probably best fixed with |
Thanks for reviewing my PR and providing suggestion, I will make the required changes soon. |
Side note: I believe this script is a historical artifact from 20+ years ago and no longer serves any purpose. Anyone installing MariaDB will have a secure installation out-of-the-box. We should not perpetuate any assumptions that the default installation is somehow insecure and running this script somehow helps, as it does not. This whole script could probably be replaced with an |
I don't disagree. Attempts and making it non-breaking where apparently too invasive (bb-10.4-anel-mysql-secureinstall) |
Fix security issue where temporary output files containing SQL commands and password hashes were created with default permissions (world-readable). Modified prepare() function to create and umask the $output $config and $command files. It is more secure than chmod as files can be opened, before the chmod is applied, and then read when its its later populated. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
Thank you Otto for the detailed explanation about the script's historical context. I have made the requested changes - using umask instead of touch/chmod to avoid the race condition, and rebased the PR to target the 10.6 branch as this is a security fix. I apologize for the delay in making these updates. Please let me know if any further changes are needed. Thank you |
Description
This commit addresses a security issue in the
mariadb-secure-installation
script where the temporary output file containing SQL commands and potentially password hashes was being created with default permissions (typically world-readable).The fix involves modifying the
prepare()
function to:$output
file explicitly usingtouch
before it's usedumask 0077
to restrict access to owner only before file creationAll new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
How can this PR be tested?
Run the original
mariadb-secure-installation
script and observe file permissions:The
.my.output.*
file will have-rw-r--r--
permissionsWith the patched version:
The
.my.output.*
file will have-rw-------
permissionsResults from my testing
Before changes
After Changes
Basing the PR against the correct MariaDB version
PR quality check
CODING_STANDARDS.md
file and my PR conforms to this where appropriate.