2.4 Do Not Specify Passwords in the Command Line

Information

When a command is executed on the command line, for example mysql -u admin -p password or mysqlsh -u admin -p password, the password may be visible in the user's shell/command history or in the process list.

Rationale:

If the password is visible in the process list or user's shell/command history, an attacker will be able to access the MySQL database using the stolen credentials.

Impact:

Depending on the remediation chosen, additional steps may need to be undertaken like:

Entering a password when prompted.

Ensuring the file permissions on .my.cnf is restricted yet accessible by the user.

Using mysql_config_editor to encrypt the authentication credentials in .mylogin.cnf.

Use a pluggable secure password store, e.g., a keychain.

In the case of shell don't authenticate until mysqlsh is started, then use connect

Additionally, not all scripts/applications may be able to use .mylogin.cnf.

NOTE: Nessus has not performed this check. Please review the benchmark to ensure target compliance.

Solution

MySQL Client:

Use -p without password and then enter the password when prompted, use a properly secured .my.cnf file, or store authentication information in encrypted format in .mylogin.cnf.

MySQL Shell:

Use without password and then enter the password when prompted, store authentication information in encrypted format in .mylogin.cnf, enter shell then authenticate using connect command (Note: this also ensures the username is not exposed on the command), or use mysqlsh pluggable password store, e.g., a keychain.

See Also

https://workbench.cisecurity.org/benchmarks/15112

Item Details

Category: ACCESS CONTROL, IDENTIFICATION AND AUTHENTICATION, SYSTEM AND COMMUNICATIONS PROTECTION

References: 800-53|AC-17(2), 800-53|IA-5, 800-53|IA-5(1), 800-53|SC-8, 800-53|SC-8(1), CSCv7|16.4

Plugin: Unix

Control ID: a1e0a0cd760883f378c2aedd1295453f2b92c95e17350f0c89942c7454eb429e