[MDEV-28823] mariadb-secure-installation chmod sql output file Created: 2022-06-13 Updated: 2023-03-04 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Scripts & Clients |
| Affects Version/s: | 10.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | MG | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | beginner-friendly | ||
| Description |
|
The prepare() function should include $output along with $config and $command |
| Comments |
| Comment by Anant Verma [ 2022-08-23 ] | ||||||||||||||
|
I'd like to work on this. | ||||||||||||||
| Comment by Anant Verma [ 2022-08-23 ] | ||||||||||||||
|
To confirm, the prepare function should also create and add permissions to the output file, right? | ||||||||||||||
| Comment by MG [ 2022-08-23 ] | ||||||||||||||
|
Yes, the problem is that the $output file doesn't get the chmod and is world readable while `mariadb-secure-installation` is running. After launching `mariadb-secure-installation` and hitting <enter> for no password (first question), we can see:
Above, the read bits are less secure for `.my.output.2257` than other files but so far there is no sensitive content in the file. If we answer no for "Switch to unix_socket authentication [Y/n]" it prompts for "Change the root password? [Y/n]". After answering yes to change the password, there is a moment where the password hash is in the file, eg:
This isn't a problem for the files $config and $command because the prepare() function calls chmod on them before they are used. It should be safe after doing this for $output in prepare because the file is truncated/written later in `do_query()` but never explicitly rm/create:
| ||||||||||||||
| Comment by Debjyoti Ghosh [ 2023-03-04 ] | ||||||||||||||
|
I am working on this issue. | ||||||||||||||
| Comment by MG [ 2023-03-04 ] | ||||||||||||||
|
@Debjyoti Three files are defined as variables early in the script:
Later, the prepare() function creates two of these files with the touch command and then improves security of those two files with the chmod command. The issue here is that $output is not also created in this way, but instead the file first exists when the do_query() function runs and appends to (creates) this file, resulting in file permissions based on the user shell's default umask. | ||||||||||||||
| Comment by Debjyoti Ghosh [ 2023-03-04 ] | ||||||||||||||
|
yes, found it, but i am not able to run the mariadb-secure-installation script. | ||||||||||||||
| Comment by MG [ 2023-03-04 ] | ||||||||||||||
|
@Debjyoti You can install MariaDB on a Unix-like system such as Linux or MacOS: https://mariadb.com/kb/en/binary-packages/ Afterward, the shell script mysql_secure_installation / mariadb-secure-installation will be available for use as a post-install tool: |