3.4 Ensure 'slow_query_log' Has Appropriate Permissions

Information

MySQL can operate using a variety of log files, each used for different purposes. These are the binary log (which can be encrypted), error log, slow query log, relay log, general log, and in the enterprise edition, the audit log (which can be encrypted). Because these are files on the host operating system, they are subject to the permissions and ownership structure provided by the host and may be accessible by users other than the MySQL user. Additionally, using secure key management and at rest MySQL encryption can further protect data from OS users.

Much of the information about the state of MySQL exists in MySQL, the MySQL performance_schema or informations_schema. If you can get the information you need from within MySQL that is more secure as it does not require OS access. If you are not going to use log files it is best to first disable (don't enable) and remove any prior logs.

Rationale:

Limiting the accessibility of these objects will protect the confidentiality, integrity, and availability of the MySQL logs.

Impact:

Changing the permissions of the log files may impact monitoring tools which use a log file adapter. Also, the slow query log can be used for performance analysis by application developers.

The information about the performance exists in MySQL performance_schema or sys schema views. In cases where the information you need is within a running MySQL, disable the slow query log and instead use these methods as they are more secure and do not require OS login and access.

Solution

Set slow query log to OFF (instead use SYS schema views or query Performance_Schema)

SET @@GLOBAL.slow_query_log = OFF;

If slow query is enabled, execute the following command to correct permissions and ownership:

chmod 660 <log file>
chown mysql:mysql <log file>

Default Value:

Slow query log is off by default.

See Also

https://workbench.cisecurity.org/files/3859

Item Details

Category: ACCESS CONTROL, MEDIA PROTECTION

References: 800-53|AC-3, 800-53|AC-5, 800-53|AC-6, 800-53|MP-2, CSCv7|14.6

Plugin: Unix

Control ID: 728a452b98f634a5f8b89151df72080a7373633fcfacc473b9f09c32b8d62854