CIS Oracle MySQL Enterprise Edition 8.0 Benchmark v1.1.0
CIS Oracle MySQL Enterprise Edition 8.0 Benchmark v1.1.0
Terms of Use
Please see the below link for our current terms of use:
https://www.cisecurity.org/cis-securesuite/cis-securesuite-membership-terms-of-use/
1 | P a g e
Table of Contents
2 | P a g e
3 | P a g e
4 | P a g e
5 | P a g e
6 | P a g e
Overview
This document, CIS Oracle MySQL Enterprise Edition 8.0 Benchmark, provides prescriptive
guidance for establishing a secure configuration posture for MySQL Enterprise Edition 8.0.
This guide was tested against MySQL Enterprise Edition 8.0 running on Ubuntu Linux, but
applies to other Linux distributions as well. To obtain the latest version of this guide, please
visit http://benchmarks.cisecurity.org. If you have questions, comments, or have identified
ways to improve this guide, please write us at [email protected].
Intended Audience
This document is intended for system and application administrators, security specialists,
auditors, help desk, and platform deployment personnel who plan to develop, deploy,
assess, or secure solutions that incorporate Oracle MySQL Enterprise Edition 8.0.
Consensus Guidance
This benchmark was created using a consensus review process comprised of subject
matter experts. Consensus participants provide perspective from a diverse set of
backgrounds including consulting, software development, audit and compliance, security
research, operations, government, and legal.
Each CIS benchmark undergoes two phases of consensus review. The first phase occurs
during initial benchmark development. During this phase, subject matter experts convene
to discuss, create, and test working drafts of the benchmark. This discussion occurs until
consensus has been reached on benchmark recommendations. The second phase begins
after the benchmark has been published. During this phase, all feedback provided by the
Internet community is reviewed by the consensus team for incorporation in the
benchmark. If you are interested in participating in the consensus process, please visit
https://workbench.cisecurity.org/.
7 | P a g e
Typographical Conventions
The following typographical conventions are used throughout this guide:
Convention Meaning
Stylized Monospace font Used for blocks of code, command, and script examples.
Text should be interpreted exactly as presented.
Monospace font Used for inline code, commands, or examples. Text should
be interpreted exactly as presented.
<italic font in brackets> Italic texts set in angle brackets denote a variable
requiring substitution for a real value.
Assessment Status
An assessment status is included for every recommendation. The assessment status
indicates whether the given recommendation can be automated or requires manual steps
to implement. Both statuses are equally important and are determined and supported as
defined below:
Automated
Manual
8 | P a g e
Profile Definitions
The following configuration profiles are defined by this Benchmark:
Items in this profile apply to MySQL Enterprise Edition 8.0 running on Linux and
intend to:
This profile extends the "Level 1 - MySQL RDBMS on Linux" profile. Items in this
profile apply to MySQL Enterprise Edition 8.0 running on Linux and exhibit one or
more of the following characteristics:
Items in this profile apply to MySQL Enterprise Edition 8.0 and intend to:
Note: the intent of this profile is to include checks that can be assessed by remotely
connecting to a MySQL RDBMS. Therefore, file system-related checks are not
contained in this profile.
This profile extends the "Level 1 - MySQL RDBMS" profile. Items in this profile apply
to MySQL Enterprise Edition 8.0 and exhibit one or more of the following
characteristics:
9 | P a g e
Note: the intent of this profile is to include checks that can be assessed by remotely
connecting to a MySQL RDBMS. Therefore, file system-related checks are not
contained in this profile.
10 | P a g e
Acknowledgements
This benchmark exemplifies the great things a community of users, vendors, and subject matter
experts can accomplish through consensus collaboration. The CIS community thanks the entire
consensus team with special recognition to the following individuals who contributed greatly to
the creation of this guide:
Author
Michael Frank
Contributor
Sara Archacki
Harin Vadodaria
Matthias Dominick
Editor
Tim Harrison, Center for Internet Security
Robin Drake
11 | P a g e
Recommendations
1 Operating System Level Configuration
This section contains recommendations related to the Operating System on which the
MySQL database server is running.
Description:
It is generally accepted that host operating systems should include different filesystem
partitions for different purposes. One set of filesystems is typically called system partitions,
and these are generally reserved for host system/application operation. The other set of
filesystems is typically called "non-system partitions", and such locations are generally
reserved for storing data.
Rationale:
Moving the database off the system partition will reduce the probability of denial of service
caused by exhaustion of available disk space to the operating system.
Impact:
Moving database files and directories to a non-system partition may be difficult depending
on whether there was only a single partition when the operating system was set up and
whether there are additional non-system partitions available.
Audit:
• Obtain the location of the datadir and other MySQL database files by executing the
following SQL statement
12 | P a g e
'relay_log_info_file') order by
VARIABLE_NAME;
• Using the value returned for the datadir, and other results from the above query,
execute the following in a system terminal
df -h <directory>
The output returned from the df command above should not include root (/), /var,
or /usr.
Remediation:
Perform the following steps to remediate this setting for the datadir:
Alter those two paths to be the new location you chose above. For example, if that
new location were /media/mysql, then the /etc/apparmor.d/usr.sbin.mysqld file
should include something like this:
Default Value:
Not Applicable.
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-permissions.html
13 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
14 | P a g e
Description:
As with any service installed on a host, it can be provided with its own user context.
Providing a dedicated user to the service provides the ability to precisely constrain the
service within the larger host context.
Rationale:
Utilizing a least privilege account for MySQL to execute as needed may reduce the impact of
a MySQL-born vulnerability. A restricted account will be unable to access resources
unrelated to MySQL, such as operating system configurations.
Audit:
Note: It is assumed that the MySQL user is mysql. Additionally, you may consider running
sudo -l as the MySQL user or to check the sudoers file.
Remediation:
Create a user which is only used for running MySQL and directly related processes. This
user must not have administrative rights to the system. Additionally, its best to avoid
providing shell access to such an account.
Shell access can be removed using the following command at a terminal prompt:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html
15 | P a g e
2. https://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_user
Additional Information:
The root user may be used to start the MySQL service on Linux/UNIX, but then it must be
configured to drop privileges by specifying a service specific user in the my.cnf or my.ini
file.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
16 | P a g e
Description:
On Linux/UNIX, the MySQL client and MySQL Shell log statements executed interactively to
a history file. The default MySQL Client file is named .mysql_history in the user's home
directory. The files are split by language and named history.sql, history.js and
history.py. Most interactive commands run in the MySQL client application are saved to a
history file. The MySQL command history should be disabled. By default, the MySQL Shell
does not save history between sessions.
Rationale:
Disabling the MySQL Client and MySQL Shell command history reduces the probability of
exposing sensitive information, such as passwords, encryption keys, or other sensitive data
or information.
Audit:
For each file returned determine whether that file is symbolically linked to /dev/null.
Remediation:
For MySQL Client perform the following steps to remediate this setting:
17 | P a g e
Additionally, another way to prevent history from being recorded is to use --batch option.
For MySQL Shell perform the following steps to remediate this setting:
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/mysql-logging.html
2. https://bugs.mysql.com/bug.php?id=72158
3. https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-working-with-
history.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
18 | P a g e
Description:
MySQL can read a default database password from an environment variable called
MYSQL_PWD. Avoiding use of this environment variable can better safeguard the
confidentiality of MySQL credentials.
Rationale:
Using the MYSQL_PWD environment variable implies MySQL credentials are stored as clear
text.
Audit:
This may return one entry for the process which is executing the grep command.
Remediation:
Check which users and/or scripts are setting MYSQL_PWD and change them to use a more
secure method.
Default Value:
Not set.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/environment-variables.html
19 | P a g e
2. https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html
3. https://dev.mysql.com/doc/refman/8.0/en/pluggable-authentication.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
20 | P a g e
Description:
When created, the MySQL user may have interactive access to the operating system, which
means that the MySQL user could login to the host as any other user would.
Rationale:
Preventing the MySQL user from logging in interactively may reduce the impact of a
compromised MySQL account. There is also more accountability, as accessing the operating
system where the MySQL server lies will require the user's own account. Interactive access
by the MySQL user is unnecessary and should be disabled.
Impact:
This setting will prevent the MySQL administrator from interactively logging into the
operating system using the MySQL user. Instead, the administrator will need to log in using
one's own account.
Audit:
Remediation:
Or
21 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
22 | P a g e
Description:
MySQL can read a default database password from an environment variable called
MYSQL_PWD.
Rationale:
Use of the MYSQL_PWD environment variable implies MySQL credentials are stored as clear
text. Avoiding use of this environment variable may increase assurance that the
confidentiality of MySQL credentials is preserved.
Audit:
To assess this recommendation, check if MYSQL_PWD is set in login scripts using the
following command:
Remediation:
Check which users and/or scripts are setting MYSQL_PWD and change them to use a more
secure method.
Default Value:
Not set.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/environment-variables.html
23 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
24 | P a g e
The first consideration is related to the configuration options via the MySQL configuration
file (e.g., my.cnf) and placing options under the proper section of [mysqld]. Options placed
in the my.cnf configuration file should not prefix with a double dash (--). On Linux
systems, my.cnf is located in the /etc/ directory.
Finally, configuration options can also be placed on the command line by modifying the
MySQL startup script. The startup script is system dependent and based on your operating
system.
25 | P a g e
Description:
Rationale:
Backing up MySQL databases, including mysql, will help ensure the availability of data in
the event of an incident.
Impact:
Audit:
Remediation:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
26 | P a g e
Description:
Rationale:
Verifying that backups are occurring appropriately will help ensure data availability in the
event of an incident.
Impact:
Without a well-tested backup, it might be hard to recover from an incident if the backup
procedure contains errors or doesn't include all required data.
Audit:
Remediation:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
27 | P a g e
Description:
Rationale:
A database user with the least amount of privileges required to perform backup is needed.
The credentials for this user should be protected.
Impact:
When the backup credentials are not properly secured, then they might be abused to gain
access to the server. The backup user needs an account with many privileges, so an
attacker might potentially gain (almost) complete access to the server.
Audit:
Remediation:
28 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
29 | P a g e
Description:
The backup files will contain all data in the databases. Filesystem permissions and/or
encryption should be used to prevent unauthorized users from gaining access to the
backups.
Rationale:
Impact:
If an unauthorized user can access backups, then they have access to all data in the
database. This is true for unencrypted backups and for encrypted backups if the encryption
key is stored along with the backup.
Audit:
If you are running the MySQL Enterprise Backup verify that the backup uses --encrypt.
For example:
30 | P a g e
If --encrypt-password is not included the backup is not encrypted and this is a fail.
Mysqlbackup includes encryption, secure backup of keys, and support for secured archival
storage.
Remediation:
Mysqlbackup includes not just the database data, but also provides for secure backup of
keys, and support for secured archival storage.
References:
1. https://dev.mysql.com/doc/mysql-enterprise-backup/8.0/en/meb-encrypted-
innodb.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
31 | P a g e
Description:
Enabling binlogs is not sufficient. The binlogs need to be backed up to separate media. The
restore procedure should be created and tested. The data in the binlog files may contain
sensitive information which needs be stored in the proper location with restrictive
permissions and may require encryption. Binlogs can grow quite large and take up a large
amount of space so auto remove needs to be put into place.
Rationale:
Using binlogs can reduce the amount of information lost when recovering from a backup.
Impact:
Without point-in-time recovery, any data which was stored between the last backup and
the time of a disaster might not be recoverable.
Audit:
Check if binlogs are enabled and if there is a restore procedure. Check to see if --binlog-
expire-logs-second is set.
Note: Consider implementing MySQL Enterprise Backup which includes support for at rest
encryption of any MySQL Encrypted data files including the binary and relay log files.
Remediation:
32 | P a g e
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-
log.html#sysvar_binlog_expire_logs_seconds
2. https://dev.mysql.com/doc/refman/8.0/en/point-in-time-recovery-binlog.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
33 | P a g e
Description:
MySQL Cluster (group replication), MySQL Replica Sets (asynchronous replication) or both
may be used.
A replica in a different data center and offsite backups may be used. There should be
information regarding the Recovery Time Objective (RTO), i.e., how long recovery will take,
and if the recovery site has the same capacity. Additionally, delayed replicas can be a
valuable part of a DR plan. Network (default) and at rest encryption should be used to
protect data.
Rationale:
Impact:
Without a well-tested disaster recovery plan, it might not be possible to recover in time.
Audit:
Remediation:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/group-replication-security.html
2. https://dev.mysql.com/doc/refman/8.0/en/replication-security.html
34 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
35 | P a g e
Description:
Rationale:
Including all configuration, log, key, certificates, and customized files in any backup will
ensure the backup can fully restore an instance.
Audit:
Check if these files are in use and are saved in the backup.
Remediation:
36 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
37 | P a g e
Description:
The binlog_encryption system variable may be used to configure encryption of the binary
and relay logs. This may be configured to ON even if binary logging is not enabled in order
to encrypt relay log files.
Rationale:
The database, and thus the binary and relay logs, may contain sensitive information.
Encrypting the binary and relay logs protects all data stored in these logs from internal and
external threats.
Audit:
Remediation:
If you receive the error message below, you need to install keyring. For instructions see
Section 6.4.4, “The MySQL Keyring” in the MySQL documentation.
ERROR 3794 (HY000): Unable to recover binlog encryption master key, please
check if keyring plugin is loaded.
38 | P a g e
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/replication-binlog-encryption.html
2. https://dev.mysql.com/doc/mysql-enterprise-backup/8.0/en/advanced.encrypted-
binlog-relaylog.html
3. https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-
log.html#sysvar_binlog_encryption
Additional Information:
Consider implementing MySQL Enterprise Backup which includes support for at rest
encryption of any MySQL Encrypted data files including the binary and relay log files.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
39 | P a g e
Description:
Rationale:
The attack surface is reduced on a server with only the underlying operating system,
MySQL server software, and any security or operational tooling that may be additionally
installed. A smaller attack surface reduces the probability of the data within MySQL being
compromised.
Impact:
Care must be taken that applications or services that are required for proper operation of
the operating system are not removed.
Additional hardware and operating system licenses may be required to make the
architectural change.
Audit:
Verify there are no other roles enabled for the underlying operating system and that no
additional applications or services unrelated to the proper operation of the MySQL server
software are installed.
Remediation:
Remove excess applications or services and/or remove unnecessary roles from the
underlying operating system.
40 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
41 | P a g e
Description:
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:
Audit:
Remediation:
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.
42 | P a g e
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.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html
2. https://dev.mysql.com/doc/refman/8.0/en/password-security-user.html
3. https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-pluggable-password-
store.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
43 | P a g e
Description:
Database user accounts should not be reused for multiple applications or users.
Rationale:
Utilizing unique database accounts across applications will reduce the impact of a
compromised MySQL account.
Impact:
If a user is reused, then a compromise of this user will compromise multiple parts of the
system and/or application.
Audit:
Each user (excluding mysql reserved users) should be linked to one of these
• system accounts
• a person
• an application
Remediation:
Add/Remove users so that each user is only used for one specific purpose.
44 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
45 | P a g e
Description:
The cryptographic material used by MySQL, such as digital certificates and encryption keys,
should be used only for MySQL and only for one instance. Default cryptographic material
should not be used since it is not unique to the instance.
Rationale:
If an attacker gains access to shared cryptographic material, including default material, the
attacker can reuse that material to impersonate the MySQL server or otherwise
compromise its operations.
Impact:
Audit:
Review all cryptographic material. If it is default, used for other MySQL instances and/or
for purposes other than MySQL then this is a finding.
Review the server certificate by running
The output for the auto generated pem will look something like:
subject= /CN=MySQL_Server_8.0.21_Auto_Generated_Server_Certificate
If no rows return, the check is a pass since the certificate is not MySQL auto-generated.
Remediation:
Generate new certificates, keys, and other cryptographic material as needed for each
affected MySQL instance.
46 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html
47 | P a g e
Description:
Password expiration provides users with a unique time bounded password lifetime.
Rationale:
Allows additional security factors pertinent to a specific user to provide further password
security; predetermined by varying security needs and usability requirements in a system
or organization.
Audit:
When the global password lifetime is less than 365, or not configured, each user account
shall be checked by executing the following command:
Remediation:
To configure the global password lifetime to 365 by executing the following command:
48 | P a g e
Alternatively, configure the password lifetime for each user returned by the audit
procedure by executing the following command:
Default Value:
NULL
References:
1. https://csrc.nist.gov/csrc/media/publications/sp/800-118/archive/2009-04-
21/documents/draft-sp800-118.pdf
2. https://dev.mysql.com/doc/refman/8.0/en/validate-password.html
Additional Information:
When a user's password_lifetime is set to NULL it takes on the value set in global
default_password_lifetime variable.
If this recommendation becomes Scored, this will be moved to Section 7 or its equivalent in
a future release.
49 | P a g e
Description:
Passwords that are too complex in nature make it harder for users to remember, leading to
bad practices. In addition, composition requirements provide no defense against common
attack types such as social engineering or insecure password storage. In keeping with the
overall goal of having users create a password that is not overly weak, it's best to have at
least 14 characters for a password only account.
Rationale:
By enforcing practical and secure policies, end user cooperation grows. In general, longer
passwords are better (harder to crack), but a forced password length requirement can
cause user behavior that is predictable and undesirable. Having a reasonable minimum
length with no maximum character limit increases the resulting average password length
used and thus increases the security of that password.
Impact:
Enforcing too much complexity or length may be difficult for users to memorize. This may
cause users to use predictable patterns or other bad practices, resulting in weaker
passwords.
Audit:
50 | P a g e
Remediation:
Set password policies in accordance with the organizationally defined policy and security
best practices:
Use with care. Passwords that are too complex in nature make it harder for users to
remember, leading to bad practices.
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/validate-password.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
51 | P a g e
Description:
Disabling password reuse, enforcing password strength, and denying reuse can be
implemented to prevent successful usage of stolen or previously guessed passwords by
malicious users.
Restricted accounts using passwords on the basis of the number of password changes and
length ensure a password cannot be chosen from a specified number of the most recent
passwords.
Rationale:
Repeated use of old passwords can increase risk of a compromise. This may lead to access
by malicious users who have discovered a user's prior password(s).
Audit:
The password_reuse_interval defines the global policy for controlling reuse of previous
passwords based on time elapsed. For an account password used previously, this variable
indicates the number of days that must pass before the password can be reused.
Password should not be reused over the period of a year. The value of
password_reuse_interval should be greater than or equal to 365.
52 | P a g e
Remediation:
Set a global policy that passwords may not be reused for a minimum of five password
changes:
Set a global policy that passwords have a lifetime to approximately one year (in days)
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/password-
management.html#password-reuse-policy
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
53 | P a g e
Description:
Rationale:
Requiring a prior password for password reset enables DBAs to prevent users from
changing a password without proving that they know the current password. Such changes
could otherwise occur, for example, if one user walks away from a terminal session
temporarily without logging out, and a malicious user uses the session to change the
original user's MySQL password. This can have unfortunate consequences; the most
problematic being the malicious user can access MySQL with the user's changed
credentials.
Audit:
Remediation:
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_password_require_current
54 | P a g e
Description:
Rationale:
Too often passwords used by applications are not changed regularly because of the
difficulty in timing for propagating the new password, keeping the applications connected,
and connection failures due to race conditions. If it is difficult to perform a synchronized
change you can optionally use dual passwords to simplify the task of password rotation.
Impact:
If the original password isn't removed upon completion of the password rotation process,
the potential risk for a compromise is increased.
Audit:
To determine which users currently have dual passwords, run the following command:
If an account has a dual password and the process of password rotation has completed, this
is a fail.
Remediation:
55 | P a g e
Once the new password has been distributed DISCARD the old password using ALTER:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/password-management.html#dual-
passwords
Additional Information:
You may wish to first assess the state of passwords on your MySQL Server.
To assess when passwords were last changed on accounts and when, or if, they will expire
run the following
If NEVER returns for an account and the password has not be rotated in a long period of time
it is recommended that action be taken to set a new password.
56 | P a g e
Description:
If users with accounts will not be using their account for some time, to reduce the risk of
attacks or inappropriate account usage or if suspicions exist that an account might be
under attack, disabling the account will secure it and once it's ready to resume use it can
easily be re-enabled.
Rationale:
Audit:
Accounts not in use and MySQL Reserved accounts should show as locked (Y).
Remediation:
Note: Works for CREATE as well. It is good practice to LOCK an account if created ahead of
time.
Default Value:
57 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/a…
Additional Information:
The server increments the Locked_connects status variable that indicates the number of
attempts to connect to a locked account. To view the Locked_conects execute this query:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
58 | P a g e
Description:
A block encryption mode with a Cypher Block Chaining (CBC) mode value and key length of
256 is recommended when using the AES_ENCRYPT() and AES_DECRYPT() functions for
encryption.
Rationale:
Impact:
Audit:
select @@block_encryption_mode;
Where * is one of the following - ECB, CBC, CFB1, CFB8, CFB128, OFB
Remediation:
block_encryption_mode=aes-256-cbc
59 | P a g e
Default Value:
aes-128-ecb
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-block-encryption-mode.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
60 | P a g e
Description:
Rationale:
• The Linux system where MySQL is running is dedicated to the MySQL server and
only the MySQL DBA and OS Admin have access.
• When control over user authentication is centralized in the operating system.
• It is desirable that audit trails in the database and operating system can use the
same user names.
• For certain other narrow installation use cases auth_socket may be desirable.
• Only local connections for a user.
Impact:
• The user must have an operating system account on the computer which must be
accessed.
• If a user has logged in using this method and steps away from the terminal, another
user could easily log in because this user does not need any passwords or
credentials. This could pose a serious security problem.
• When an operating system is used to authenticate database users, managing
distributed database environments and database links requires special care. Special
care must also be taken not to leave such a terminal unlocked and unattended.
Hence, we recommend that you carefully evaluate your requirements before opting
for auth_socket.
• This will not work where distributed connections are required.
61 | P a g e
Audit:
If this is enabled and the organization does not allow use of this feature, this is a fail.
Remediation:
Add these options under the [mysqld] option group in the MySQL /etc/my.cnf:
plugin-load-add=auth_socket.so
auth_socket=FORCE_PLUS_PERMANENT
For example:
For an OS user which can login to MySQL using auth_socket:
mysql -u <user>
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-configure-authentication.html
62 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
63 | P a g e
Description:
By default, the MySQL server accepts TCP/IP connections from MySQL user accounts on all
server host IPv6 and IPv4 interfaces. You can make this configuration more restrictive by
setting the bind_address configuration option to a specific IPv4 or IPv6 address so that the
server only accepts TCP/IP connections on that address.
Rationale:
Limiting the IP address provides additional controls and restrictions on how client
applications can connect to MySQL. If not configured to a specific IP all IPs for this server
can be used to connect to MySQL.
Audit:
Remediation:
For example, to have the MySQL server only accept connections on a specific IPv4 address,
add an entry similar to this under the [mysqld] option group in the MySQL /etc/my.cnf:
bind_address=192.0.2.24
In this case, clients can connect to the server using --host=192.0.2.24. Connections on
other server host addresses are not permitted.
Default Value:
Not set.
64 | P a g e
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-secure-connections.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
65 | P a g e
Description:
MySQL supports multiple protocols of TLS. The higher the version the stronger the security
and/or better the performance.
Rationale:
Requiring clients attempting to connect to MySQL to use higher versions of TLS to better
protect data in transit.
Impact:
Audit:
To list the versions of TLS the server accepts, run the following statement:
select @@tls_version;
MySQL negotiates to the highest version of TLS, if connections are using older TLS versions,
those clients will need to be upgraded to newer MySQL Connectors or community drivers
that support newer versions of TLS.
66 | P a g e
Remediation:
Set the version(s) of TLS you wish to accept in mysql.conf specify TLS and Ciphers.
tls_version=TLSv1.3
If TLS 1.3 is not supported on the Operating System then set to TLS 1.2:
tls_version=TLSv1.2
Note: with this setting, only clients that support the specified TLS version(s) are able to
establish an encrypted connection to the server.
Default Value:
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-secure-connections.html
2. https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-
ciphers.html#encrypted-connection-protocol-configuration
67 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
68 | P a g e
Description:
Client-side certificates may be used as proof of identity as well as to encrypt data in transit.
Rationale:
Audit:
Remediation:
For accounts created with a REQUIRE X509 clause, clients must specify at least --ssl-cert
and --ssl-key. In addition, --ssl-ca (or --ssl-capath) is recommended so that the public
certificate provided by the server can be verified.
For example:
mysql --ssl-ca=ca.pem \
--ssl-cert=client-cert.pem \
--ssl-key=client-key.pem
69 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html
Additional Information:
The audit procedure excludes these internal user accounts from evaluation because, by
default, they are created with an invalid password and are locked to disallow access.
• ‘mysql.infoschema’@’localhost’
• ‘mysql.session’@’localhost’
• ‘mysql.sys’@’localhost’
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
70 | P a g e
Description:
MySQL supports multiple encryption ciphers. Ciphers can vary in strength, speed and
overhead.
Rationale:
Requiring clients attempting to connect to MySQL to use strong ciphers protects data in
transit.
Impact:
Audit:
Remediation:
tls_ciphersuites='TLS_AES_256_GCM_SHA384'
ssl_cipher='ECDHE-ECDSA-AES128-GCM-SHA256'
OR
Execute the following commands:
71 | P a g e
Default Value:
ECDHE-ECDSA-AES128-GCM-SHA256
ECDHE-ECDSA-AES256-GCM-SHA384
ECDHE-RSA-AES128-GCM-SHA256
ECDHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-AES128-SHA256
ECDHE-RSA-AES128-SHA256
ECDHE-ECDSA-AES256-SHA384
ECDHE-RSA-AES256-SHA384
DHE-RSA-AES128-GCM-SHA256
DHE-DSS-AES128-GCM-SHA256
DHE-RSA-AES128-SHA256
DHE-DSS-AES128-SHA256
DHE-DSS-AES256-GCM-SHA384
DHE-RSA-AES256-SHA256
DHE-DSS-AES256-SHA256
ECDHE-RSA-AES128-SHA
ECDHE-ECDSA-AES128-SHA
ECDHE-RSA-AES256-SHA
ECDHE-ECDSA-AES256-SHA
DHE-DSS-AES128-SHA
DHE-RSA-AES128-SHA
TLS_DHE_DSS_WITH_AES_256_CBC_SHA
DHE-RSA-AES256-SHA
AES128-GCM-SHA256
DH-DSS-AES128-GCM-SHA256
ECDH-ECDSA-AES128-GCM-SHA256
AES256-GCM-SHA384
DH-DSS-AES256-GCM-SHA384
ECDH-ECDSA-AES256-GCM-SHA384
AES128-SHA256
DH-DSS-AES128-SHA256
ECDH-ECDSA-AES128-SHA256
AES256-SHA256
DH-DSS-AES256-SHA256
ECDH-ECDSA-AES256-SHA384
AES128-SHA
DH-DSS-AES128-SHA
ECDH-ECDSA-AES128-SHA
AES256-SHA
DH-DSS-AES256-SHA
ECDH-ECDSA-AES256-SHA
DHE-RSA-AES256-GCM-SHA384
DH-RSA-AES128-GCM-SHA256
ECDH-RSA-AES128-GCM-SHA256
DH-RSA-AES256-GCM-SHA384
ECDH-RSA-AES256-GCM-SHA384
DH-RSA-AES128-SHA256
ECDH-RSA-AES128-SHA256
DH-RSA-AES256-SHA256
ECDH-RSA-AES256-SHA384
ECDHE-RSA-AES128-SHA
ECDHE-ECDSA-AES128-SHA
ECDHE-RSA-AES256-SHA
ECDHE-ECDSA-AES256-SHA
72 | P a g e
DHE-DSS-AES128-SHA
DHE-RSA-AES128-SHA
TLS_DHE_DSS_WITH_AES_256_CBC_SHA
DHE-RSA-AES256-SHA
AES128-SHA
DH-DSS-AES128-SHA
ECDH-ECDSA-AES128-SHA
AES256-SHA
DH-DSS-AES256-SHA
ECDH-ECDSA-AES256-SHA
DH-RSA-AES128-SHA
ECDH-RSA-AES128-SHA
DH-RSA-AES256-SHA
ECDH-RSA-AES256-SHA
DES-CBC3-SHA
References:
1. https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-
ciphers.html#encrypted-connection-cipher-configuration
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
73 | P a g e
Description:
Rationale:
Delaying connection attempts provides a deterrent that slows down brute force attacks
that attempt to access MySQL user accounts.
Audit:
CONNECTION_CONTROL | ACTIVE
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS | ACTIVE
Time doubling throttling (in minutes) between each retry (0, 1, 2, 4, 8, etc.) with a
permanent account lockout (IT reset required) after 12 retries.
74 | P a g e
Remediation:
[mysqld]
plugin-load-add=connection_control.so
connection-control=FORCE_PLUS_PERMANENT
connection-control-failed-login-attempts=FORCE_PLUS_PERMANENT
connection_control_failed_connections_threshold=5
connection_control_min_connection_delay=60000
connection_control_max_connection_delay=1920000
References:
1. https://dev.mysql.com/doc/refman/8.0/en/connection-control.html
CIS Controls:
75 | P a g e
3 File Permissions
File Permissions are critical for keeping the data and configuration of the MySQL server
secure.
Description:
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL database. If someone other than the MySQL user is allowed to
read files from the data directory, it may be possible to read data from the mysql.user
table which contains passwords. Additionally, the ability to create files can lead to denial of
service, or might otherwise allow someone to gain access to specific data by manually
creating a file with a view definition.
Audit:
Or
76 | P a g e
Remediation:
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-permissions.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
77 | P a g e
Description:
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.
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL logs.
Impact:
Changing the permissions and ownership of the relay logs and binary log files might have
impact on external tools.
If the permissions on the relay logs and binary log files are accidentally changed to exclude
the user account which is used to run the MySQL service, then this might break replication.
The binary log file can be used for point-in-time recovery so this can also affect backup,
restore, and disaster recovery procedures.
Audit:
78 | P a g e
ls -l | egrep '^-(?![r|w]{2}-[r|w]{2}----
.*mysql\s*mysql).*<log_bin_basename>.*$'
Remediation:
Execute the following command for each log file location requiring corrected permissions
and ownership:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/password-logging.html
2. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-permissions.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
79 | P a g e
Description:
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. In cases where the information you need is
within a running MySQL, use these methods as they are more secure as do not require OS
login and access.
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL logs.
Impact:
Changing the permissions of the error log files might have impact on monitoring tools
which use an error log file adapter.
Audit:
80 | P a g e
Remediation:
Execute the following command for each log file location requiring corrected permissions
and ownership:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/error-log.html
2. https://dev.mysql.com/doc/mysql-secure-deployment-guide/5.7/en/secure-
deployment-permissions.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
81 | P a g e
Description:
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.
Audit:
82 | P a g e
ls -l | egrep "^-(?![r|w]{2}-[r|w]{2}----
.*mysql\s*mysql).*<slow_query_log_file>.*$
If the slow query log is disabled, remove any old slow query log files.
Remediation:
Set slow query log to OFF (instead use SYS schema views or query Performance_Schema)
If slow query is enabled, execute the following command to correct permissions and
ownership:
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html
83 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
84 | P a g e
Description:
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 (which can be
encrypted), 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.
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL logs.
Impact:
If the permissions on the relay logs and binary log files are accidentally changed to exclude
the user account which is used to run the MySQL service, then this might break replication.
The binary log file can be used for point in time recovery so this can also affect backup,
restore and disaster recovery procedures.
Audit:
ls -l | egrep "^-(?![r|w]{2}-[r|w]{2}----
.*mysql\s*mysql).*<relay_log_basename>.*$
85 | P a g e
Remediation:
Execute the following command for each log file location requiring corrected permissions
and ownership:
Default Value:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
86 | P a g e
Description:
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 (which can be
encrypted), 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, or existence, of these log files will protect the confidentiality,
integrity, and availability of the MySQL logs.
Impact:
Changing the permissions of the general log files may impact monitoring tools which use a
log file adapter.
Audit:
1. Execute the following SQL statement to determine the Values of general_log and
general_log_file:
87 | P a g e
ls -l <general_log_file>
If general_log is 0 or OFF (disabled) and the log file exists, remove the old general log file.
Remediation:
If you can, use MySQL SYS, PERFORMANCE_SCHEMA, or MySQL Auditing as these are more
secure options.
By default the general_log is disabled (0 or OFF). It's most secure to disable the
general_log.
If you must use general_log then assure the permissions are correct. Execute the following
command for each log file location requiring corrected permissions and ownership:
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/query-log.html
88 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
89 | P a g e
Description:
When configured to use SSL/TLS, MySQL relies on Secure Sockets Layer (SSL) key files,
which are stored on the host's filesystem. These SSL key files are subject to the host's
permissions and ownership structure.
MySQL 8.0 provides ways to create the SSL certificate, SSL key files and RSA key-pair files
required to support encrypted connections using SSL and secure password exchange using
RSA over unencrypted connections, if those files are missing the server will attempt to
autogenerate these files at startup if compiled with OpenSSL.
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL database and the communication with the client.
If the contents of the SSL key file are known to an attacker, he or she might impersonate the
server. This can be used for a man-in-the-middle attack.
Depending on the SSL cipher suite, the key might also be used to decipher previously
captured network traffic.
Impact:
If the permissions or ownership for the SSL key file are configured incorrectly, this can
cause SSL to be disabled when MySQL is restarted or can cause MySQL not to start at all.
If other applications are using the same key pair, then changing the permissions or
ownership of the SSL key file will affect this application. If this were to occur a new key pair
must be generated for MySQL.
Audit:
1. Locate the SSL keys and certs in use by executing the following SQL statement. To
show all ssl variables:
90 | P a g e
Note: Any mysqlx_% values that are null default to the classic protocols equivalent
value.
ls -l | egrep "^-(?!r-{8}.*mysql\s*mysql).*<ssl_file>.*$
Remediation:
Execute the following commands at a terminal prompt to remediate these settings using
the Value from the audit procedure:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/encrypted-connections.html
2. https://dev.mysql.com/doc/refman/8.0/en/creating-ssl-rsa-files-using-mysql.html
Additional Information:
If SSL is not configured this recommendation is not applicable. By default MySQL enables
SSL. Using SSL is highly recommended.
91 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
92 | P a g e
Description:
The plugin directory is the location of the MySQL plugins. Plugins are storage engines or
user defined functions (UDFs).
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL database. If someone can modify plugins then these plugins might
be loaded when the server starts and the code will get executed.
Impact:
Users other than the MySQL user will no longer be able to update and add/remove plugins
unless they're able to switch to the MySQL user.
Audit:
To assess this recommendation, execute the following SQL statement to discover the Value
of plugin_dir:
Then, execute the following command at a terminal prompt (using the discovered
plugin_dir Value) to determine the permissions and ownership.
Remediation:
To remediate these settings, execute the following commands at a terminal prompt using
the plugin_dir Value from the audit procedure. MySQL server must not be allowed to
write to this location.
93 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/install-plugin.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
94 | P a g e
Description:
MySQL can operate using a variety of log files, each used for different purposes. These are
the binary log, error log, slow query log, relay log, audit log and general log. 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.
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of the MySQL logs.
Impact:
Changing the permissions and ownership of the audit log file may have an impact on who
can access and edit the audit log. Such changes can affect monitoring tools which maybe
using a log file adapter or scripted alternatives. Also, the audit log may be used for alerting
by infrastructure teams which can affect real-time audit capability.
Audit:
To assess this recommendation, execute the following SQL statement to discover the
audit_log_file value:
95 | P a g e
Remediation:
Execute the following commands for the audit_log_file discovered in the audit
procedure:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
96 | P a g e
Description:
When configured to use a Keyring plugin, internal MySQL components and plugins may
securely store sensitive information for later retrieval. Associated files for the selected
keyring type should have proper permissions.
Rationale:
Limiting the accessibility of these objects will protect the confidentiality, integrity, and
availability of internal MySQL component and plugin information.
Audit:
Perform the following steps applicable to the plugin in use to assess this recommendation:
97 | P a g e
Remediation:
98 | P a g e
• KMIP - https://dev.mysql.com/doc/refman/8.0/en/keyring-okv-
plugin.html#keyring-okv-configuration
• OCI Vault - https://dev.mysql.com/doc/refman/8.0/en/keyring-oci-plugin.html
• Hashicorp - https://dev.mysql.com/doc/refman/8.0/en/keyring-hashicorp-
plugin.html#keyring-hashicorp-plugin-configuration
• AWS - https://dev.mysql.com/doc/refman/8.0/en/keyring-aws-
plugin.html#keyring-aws-plugin-configuration
Execute the following command for each Keyring file location requiring corrected
permissions:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/keyring-system-variables.html
Additional Information:
Use of keyring_file is intended for development and testing and will not pass most
security regulatory requirements.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
99 | P a g e
4 General
This section contains recommendations related to various parts of the database server.
Description:
Periodically, updates to MySQL server are released to resolve bugs, mitigate vulnerabilities,
and provide new features. It is recommended that MySQL installations are up to date with
the latest security updates.
Rationale:
Maintaining currency with MySQL patches will help reduce risk associated with known
vulnerabilities present in the MySQL server.
Without the latest security patches MySQL might have known vulnerabilities which could
be used by an attacker to gain access.
Impact:
Audit:
Execute the following SQL statement to identify the MySQL server version:
Now compare the version with the security announcements from Oracle and/or the OS if
the OS packages are used.
Remediation:
Install the latest patches for your version or upgrade to the latest version.
References:
1. http://www.oracle.com/technetwork/topics/security/alerts-086861.html
2. http://dev.mysql.com/doc/relnotes/mysql/8.0/en/
100 | P a g e
3. https://nvd.nist.gov/vuln/search/results?form_type=Advanced&results_type=over
view&search_type=all&cpe_vendor=cpe%3A%2F%3Aoracle&cpe_product=cpe%3A
%2F%3Aoracle%3Amysql&cpe_version=cpe%3A%2F%3Aoracle%3Amysql%3A8.0
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
101 | P a g e
Description:
The default MySQL installation does not contain any example or test databases. However, it
is a good idea to review for common example databases and ensure they have been
removed from production systems.
Rationale:
Dropping example databases will reduce the attack surface of the MySQL server.
Audit:
Execute the following SQL statement to determine if the test database is present:
If this is a production system, and a database name includes an example database this is a
finding.
Common example database names are:
• sakila
• world
• world_x
• menagerie
Remediation:
Default Value:
By default, MySQL 8.0 does not contain any example or test databases.
102 | P a g e
References:
1. http://dev.mysql.com/doc/refman/8.0/en/mysql-secure-installation.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
103 | P a g e
Description:
This option prevents attaching arbitrary shared library functions as user-defined functions
by checking for at least one corresponding method named _init, _deinit, _reset, _clear,
or _add.
Rationale:
Preventing shared libraries that do not contain user-defined functions from loading will
reduce the attack surface of the server.
Audit:
Remediation:
Default Value:
OFF
References:
1. https://dev.mysql.com/doc/extending-mysql/8.0/en/adding-loadable-
function.html#loadable-function-security
104 | P a g e
2. http://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_allow-suspicious-udfs
Additional Information:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
105 | P a g e
Description:
The local_infile parameter dictates whether files located on the MySQL client's
computer can be loaded or selected via LOAD DATA INFILE or SELECT local_file.
Rationale:
For MySQL client programs and connectors prior to 8.0.21, disabling local_infile reduces
an attacker's ability to read sensitive files off the affected server via an SQL injection
vulnerability.
Impact:
Disabling local_infile will impact the functionality of solutions that rely on it.
Audit:
$ mysqlsh --version
$ mysql --version
If clients have not been upgraded to 8.0.21 check the value of local_infile.
106 | P a g e
If clients are older than 8.0.21 or if local_infile is not in use, ensure the value returned is
0.
Remediation:
In the case where using local_infile is needed, the following changes further harden
security:
Limiting the location from where data can be read using --load-data-local-dir.
If local_infile is not in use or if clients are not upgraded - add the following line to the
[mysqld] section of the MySQL configuration file and restart the MySQL service:
local-infile=0
Default Value:
0 (OFF)
References:
1. http://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_load-file
2. http://dev.mysql.com/doc/refman/8.0/en/load-data.html
107 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
108 | P a g e
Description:
This option causes mysqld to start without using the privilege system.
Rationale:
If this option is used, all clients of the affected server will have unrestricted access to all
databases.
Audit:
• Open the MySQL configuration (e.g., my.cnf) file and search for skip-grant-tables
• Ensure skip-grant-tables is set to FALSE
Remediation:
skip-grant-tables = FALSE
References:
1. http://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_skip-grant-tables
Additional Information:
109 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
110 | P a g e
Description:
Rationale:
Prevents symbolic links from being used for database files. This is especially important
when MySQL is executing as root as arbitrary files may be overwritten. The symbolic-
links option might allow someone to direct actions by the MySQL server to other files
and/or directories.
Audit:
Remediation:
Note: If skip_symbolic_links does not exist, add it to the configuration file in the mysqld
section.
References:
1. http://dev.mysql.com/doc/refman/8.0/en/symbolic-links.html
111 | P a g e
2. http://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_symbolic-links
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
v7 13 Data Protection
Data Protection
112 | P a g e
Description:
The InnoDB memcached Plugin allows users to access data stored in InnoDB with the
memcached protocol.
Rationale:
By default, the plugin doesn't do authentication, which means that anyone with access to
the TCP/IP port of the plugin can access and modify the data. However, not all data is
exposed by default.
Audit:
Remediation:
To remediate this setting, issue the following command in the MySQL command-line client:
Default Value:
disabled
References:
1. http://dev.mysql.com/doc/refman/8.0/en/innodb-memcached-security.html
113 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
114 | P a g e
Description:
The secure_file_priv option restricts to paths used by LOAD DATA INFILE or SELECT
local_file. It is recommended that this option be set to a file system location that contains
only resources expected to be loaded by MySQL. Even better, if data import/export using
LOAD DATA INFILE or SELECT local_file is not used, the functionality should be disabled
entirely by setting --secure-file-priv to NULL.
Rationale:
Setting secure_file_priv reduces an attacker's ability to read sensitive files off the
affected server via a SQL injection vulnerability.
Impact:
Solutions that rely on loading data from various sub-directories may be negatively
impacted by this change. Consider consolidating load directories under a common parent
directory.
The server checks the value of secure_file_priv at startup and writes a warning to the
error log if the value is insecure. A non-NULL value is considered insecure if it is empty, or
the value is the data directory or a subdirectory of it, or a directory that is accessible by all
users.
Audit:
Execute the following SQL statement and ensure one row is returned:
The Value should either contain NULL (thus is disabled entirely) or a valid path. If set to an
empty string this is a fail.
115 | P a g e
Remediation:
If you are not going to use this feature, remove secure_file_priv from the [mysqld]
section of the MySQL configuration file and restart the MySQL service.
If you need this feature add the following line to the [mysqld] section of the MySQL
configuration file and restart the MySQL service:
secure_file_priv=<path_to_load_directory>
Default Value:
No value set.
References:
1. http://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_secure_file_priv
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
v7 13 Data Protection
Data Protection
116 | P a g e
Description:
When data changing statements are made (i.e., INSERT, UPDATE), MySQL can handle invalid
or missing values differently depending on whether strict SQL mode is enabled. When strict
SQL mode is enabled, data may not be truncated or otherwise "adjusted" to make the data
changing statement work.
Rationale:
Without strict mode the server tries to proceed with the action when an error might have
been a more secure choice. For example, by default MySQL will truncate data if it does not
fit in a field, which can lead to unknown behavior, or be leveraged by an attacker to
circumvent data validation.
Impact:
Audit:
Remediation:
Add STRICT_ALL_TABLES to the sql_mode in the server's configuration file, for example:
117 | P a g e
Default Value:
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR
_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
References:
1. http://dev.mysql.com/doc/refman/8.0/en/server-sql-mode.html
Additional Information:
The sql_mode is a set and might contain more elements than just STRICT_ALL_TABLES.
There is a global sql_mode and a per session sql_mode. The per session sql_mode is based
on the global sql_mode on initialization and might be changed by the application.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
118 | P a g e
Description:
Transparent Data Encryption (TDE) at-rest encryption protects your critical data by
enabling data-at-rest encryption in the database. It protects the privacy of your
information, prevents data breaches and helps meet regulatory requirements.
Rationale:
File system based encryption does a good job of protecting against data theft on devices
unable to limit physical access. It does not, however, protect against users who have or gain
access to the operating system, backups, over the network copies, etc. Encrypting data from
mysqld adds an additional layer of data protection.
Audit:
SELECT
INNODB_TABLESPACES.NAME,
INNODB_TABLESPACES.ENCRYPTION
FROM information_schema.INNODB_TABLESPACES
WHERE NAME NOT IN ('innodb_temporary','sys/sys_config');
If any tables or tablespaces show encryption as N and are therefore not encrypted, this is a
fail.
Backup data should be encrypted at rest as well. If you are running the MySQL Enterprise
Backup verify that the backup uses --encrypt.
119 | P a g e
For example:
Remediation:
Edit my.cnf:
# AUDIT LOG
sudo vi /etc/my.cnf
[mysqld]
audit-log=FORCE_PLUS_PERMANENT
audit-log-format=JSON
audit-log-encryption=AES
#### BINLOG
>set persist binlog_encryption=ON;
# DO NOT USE GENERAL LOG OR SLOW LOGS - USE AUDIT AND PERFORMANCE_SCHEMA.
>SET PERSIST general_log = 'OFF';
Run ALTER to enable encryption (note will lock table as table is encrypted).
# TABLESPACES, TABLES
ALTER TABLESPACE <tablespacename> ENCRYPTION = 'Y';
// if innodb file per table (indicated by schemaname/tablename in report)
ALTER TABLE <tablename> ENCRYPTION = 'Y';
#Encrypt the system tablespace
ALTER TABLESPACE mysql ENCRYPTION = 'Y';
Default Value:
120 | P a g e
Administrators can force tables or tablespaces to be encrypted for all schemas by default
by setting in my.cnf.
default-table-encryption=ON
References:
1. https://dev.mysql.com/doc/refman/8.0/en/innodb-data-encryption.html
2. https://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_table_encryption_privilege_check
3. https://dev.mysql.com/doc/refman/8.0/en/create-database.html
4. https://dev.mysql.com/doc/refman/8.0/en/replication-binlog-encryption.html
5. https://dev.mysql.com/doc/refman/8.0/en/audit-log-logging-
configuration.html#audit-log-file-encryption
6. https://dev.mysql.com/doc/mysql-enterprise-backup/8.0/en/meb-encrypted-
innodb.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
121 | P a g e
5 MySQL Permissions
This section contains recommendations about user privileges.
Description:
The mysql.user, mysql.db, and other mysql tables ending in _priv list a variety of
privileges that can be granted (or denied) to MySQL users. Some of the privileges of
concern include: Select_priv, Insert_priv, Update_priv, Delete_priv, Drop_priv, and so
on. Typically, these privileges should not be available to every MySQL user and often are
reserved for administrative use only. The information_schema.user_privileges provides
a consolidated view of all user privileges.
Rationale:
Limiting the accessibility of the mysql database will protect the confidentiality, integrity,
and availability of the data housed within MySQL. A user which has direct access to mysql.*
might view password hashes, change permissions, or alter or destroy information
intentionally or unintentionally.
Audit:
Ensure all users returned are administrative users with minimal privileges required.
Remediation:
122 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/reserved-accounts.html
Additional Information:
Consideration should be made for which privileges are required by each user requiring
interactive database access.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
123 | P a g e
Description:
The File_priv privilege found in the mysql.user table is used to allow or disallow a user
from reading and writing files on the server host. Any user with the File_priv right
granted has the ability to:
• Read files from the local file system that are readable by the MySQL server (this
includes world-readable files).
• Write files to the local file system where the MySQL server has write access.
Rationale:
The File_priv right allows mysql users to read files from disk and to write files to disk.
This may be leveraged by an attacker to further compromise MySQL. It should be noted
that the MySQL server should not overwrite existing files.
Audit:
Remediation:
1. Enumerate the non-administrative users found in the result set of the audit
procedure.
2. For each user, issue the following SQL statement (replace <user> with the non-
administrative user):
124 | P a g e
References:
1. http://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_file
Additional Information:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
125 | P a g e
Description:
The PROCESS privilege found in the mysql.user table determines whether a given user can
see statement execution information for all sessions.
Rationale:
The PROCESS privilege allows principals to view currently executing MySQL statements
beyond their own, including statements used to manage passwords. This may be leveraged
by an attacker to compromise MySQL or to gain access to potentially sensitive data.
Impact:
Users denied the PROCESS privilege may also be denied use of SHOW ENGINE.
Audit:
Remediation:
1. Enumerate the non-administrative users found in the result set of the audit
procedure
2. For each user, issue the following SQL statement (replace <user> with the non-
administrative user:
126 | P a g e
References:
1. http://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_process
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
127 | P a g e
Description:
The SUPER privilege is a powerful and far-reaching privilege and should not be granted
lightly. In MySQL 8.0, SUPER is deprecated and will be removed in a future version of
MySQL.
In MySQL 8.0, SUPER is deprecated and will be removed in a future version of MySQL.
Migrating Accounts from SUPER to Dynamic Privileges is recommended.
Rationale:
The SUPER privilege allows principals to perform many actions, including view and
terminate currently executing MySQL statements (including statements used to manage
passwords). This privilege also provides the ability to configure MySQL, such as
enable/disable logging, alter data, disable/enable features. Limiting the accounts that have
the SUPER privilege reduces the chances that an attacker can exploit these capabilities.
It is more secure to migrate administrative users off SUPER and instead assign the specific
and minimal set of mysql Dynamic Privileges needed to perform their tasks.
Impact:
When the SUPER privilege is denied to a given user, that user will be unable to take
advantage of certain capabilities, such as certain mysqladmin options.
Audit:
128 | P a g e
Remediation:
1. Enumerate the non-administrative users found in the result set of the audit
procedure
2. For each user, issue the following SQL statement (replace <user> with the non-
administrative user:
References:
1. http://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_super
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
129 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
130 | P a g e
Description:
The SHUTDOWN privilege simply enables use of the shutdown option to the mysqladmin
command, which allows a user with the SHUTDOWN privilege the ability to shut down the
MySQL server.
Rationale:
The SHUTDOWN privilege allows principals to shutdown MySQL. This may be leveraged by an
attacker to negatively impact the availability of MySQL.
Audit:
Remediation:
1. Enumerate the non-administrative users found in the result set of the audit
procedure.
2. For each user, issue the following SQL statement (replace <user> with the non-
administrative user):
References:
1. http://dev.mysql.com/doc/refman/8.0/en/privileges-
provided.html#priv_shutdown
131 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
132 | P a g e
Description:
The CREATE USER privilege governs the right of a given user to add or remove users, change
existing users' names, or revoke existing users' privileges.
Rationale:
Reducing the number of users granted the CREATE USER right minimizes the number of
users able to add/drop users, alter existing users' names, and manipulate existing users'
privileges.
Impact:
Users that are denied the CREATE USER privilege will not only be unable to create a user, but
they may be unable to drop a user, rename a user, or otherwise revoke a given user's
privileges.
Audit:
Remediation:
1. Enumerate the non-administrative users found in the result set of the audit
procedure
2. For each user, issue the following SQL statement (replace <user> with the non-
administrative user):
133 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
134 | P a g e
Description:
The GRANT OPTION privilege exists in different contexts (mysql.user, mysql.db) for the
purpose of governing the ability of a privileged user to manipulate the privileges of other
users.
Rationale:
The GRANT privilege allows a principal to grant other principals additional privileges. This
may be used by an attacker to compromise MySQL.
Audit:
Remediation:
1. Enumerate the non-administrative users found in the result sets of the audit
procedure
2. For each user, issue the following SQL statement (replace <user> with the non-
administrative user:
References:
1. http://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_grant-
option
135 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
136 | P a g e
Description:
The REPLICATION SLAVE privilege governs whether a given user (in the context of the
source server) can request updates that have been made on the source server.
Rationale:
The REPLICATION SLAVE privilege allows a principal to fetch binlog files containing all data
changing statements and/or changes to table data from the source. This may be used by an
attacker to read/fetch sensitive data from MySQL.
Audit:
Ensure only accounts designated for replica users are granted this privilege.
Remediation:
1. Enumerate the non-replica users found in the result set of the audit procedure
2. For each user, issue the following SQL statement (replace <user> with the non-
replica user):
Use the REVOKE statement to remove the SUPER privilege from users who shouldn't
have it.
137 | P a g e
References:
1. http://dev.mysql.com/doc/refman/8.0/en/privileges-
provided.html#priv_replication-slave
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
138 | P a g e
5.9 Ensure DML/DDL Grants are Limited to Specific Databases and Users
(Manual)
Profile Applicability:
Description:
DML/DDL includes the set of privileges used to modify or create data structures. This
includes INSERT, SELECT, UPDATE, DELETE, DROP, CREATE, and ALTER privileges.
Rationale:
INSERT, SELECT, UPDATE, DELETE, DROP, CREATE, and ALTER are powerful privileges in any
database. Such privileges should be limited only to those users requiring such rights. By
limiting the users with these rights and ensuring that they are limited to specific databases,
the attack surface of the database is reduced.
Audit:
SELECT User,Host,Db
FROM mysql.db
WHERE Select_priv='Y'
OR Insert_priv='Y'
OR Update_priv='Y'
OR Delete_priv='Y'
OR Create_priv='Y'
OR Drop_priv='Y'
OR Alter_priv='Y';
Ensure all users returned are permitted to have these privileges on the indicated
databases.
Remediation:
1. Enumerate the unauthorized users, hosts, and databases returned in the result set of
the audit procedure
139 | P a g e
2. For each user, issue the following SQL statement (replace <user> with the
unauthorized user, <host> with host name, and <database> with the database
name):
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
140 | P a g e
Description:
Rationale:
Audit:
For more details on Procedures and Functions input and output parameters.
141 | P a g e
Remediation:
Drop and recreate stored procedures and functions using proper DEFINER and INVOKER
settings, or other code changes.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/create-procedure.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
142 | P a g e
Description:
The error log contains information about events such as mysqld starting and stopping,
when a table needs to be checked or repaired, and, depending on the host operating
system, stack traces when mysqld fails.
Rationale:
Enabling error logging can increase the ability to detect malicious attempts against MySQL,
and other critical messages. For example, if the error log is not enabled then a connection
error could go unnoticed.
When configured to stderr MySQL will send log data to the console. Logging to the console
is useful, but remember it is ephemeral. This is not recommended due to the fact that
logging to console does not provide a means to force restricted access via permissions
strictly to MySQL and dedicated MySQL audit accounts. This may compromise the
confidentiality of the MySQL log data. Furthermore use caution if co-mingling log data from
multiple sources as that can complicate log inspection. Additionally from a security
auditing perspective, it’s difficult and error prone to verify logging is correct using stderr
or redirected stderr.
Audit:
Remediation:
143 | P a g e
Default Value:
./stderr.err
References:
1. http://dev.mysql.com/doc/refman/8.0/en/error-log.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
144 | P a g e
Description:
MySQL log files can be set in the MySQL configuration to exist anywhere on the filesystem.
It is common practice to ensure that the system filesystem is left uncluttered by application
logs. System filesystems include the root, /var, or /usr.
Rationale:
Moving the MySQL logs off the system partition will reduce the probability of denial of
service via the exhaustion of available disk space to the operating system.
Audit:
SELECT @@global.log_bin_basename;
Ensure the value returned does not indicate root (/), /var, or /usr.
Remediation:
References:
1. http://dev.mysql.com/doc/refman/8.0/en/binary-log.html
2. http://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html
145 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
146 | P a g e
Description:
Rationale:
This might help to detect malicious behavior by logging communication errors and aborted
connections.
Audit:
Remediation:
log_error_verbosity = 2
Default Value:
The option is enabled (2) - errors and warning events are logged - by default.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_log_error_verbosity
147 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
148 | P a g e
Description:
The log-raw MySQL option determines whether passwords are rewritten by the server so
as not to appear in log files as plain text. If log-raw is enabled, then passwords are written
to the various log files (general query log, slow query log, and binary log) in plain
text.
Rationale:
With raw logging of passwords enabled someone with access to the log files might see plain
text passwords.
Audit:
Remediation:
log-raw = OFF
Default Value:
OFF
References:
1. https://dev.mysql.com/doc/refman/8.0/en/password-logging.html
2. https://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_log-raw
149 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
150 | P a g e
Description:
Rationale:
The audit_log_filter_set_filter function which defines auditing filters. The users for
which filter(s) apply is defined by audit_log_filter_set_user. One or more filters can be
created to log connections success and/or failure.
Impact:
If the audit rule and application of the rule to targeted or all users is not properly
configured, it will not log failed connections, successful connections or any other
connection related events.
Audit:
Determine whether the filters and users assigned to filter meet your security, business, and
regulatory requirements. If they do not, this is a fail.
Test your filters by attempting successful and failed connections or other events that
should be captured in the audit trail and review the audit log to confirm those events were
captured.
151 | P a g e
For example:
Successful Connections will have json fields:
Remediation:
To remediate this configuration setting, execute one of the following SQL statements:
SET @f='
{
"filter": {
"log": false,
"class": {
"name": "connection",
"event": [
{ "name": "connect", "log" : { "not": { "field": { "name":
"status", "value": 0 } } } },
{ "name": "disconnect", "log": false }
]
}
}
}';
select @f;
SELECT audit_log_filter_set_filter('log_conn_events', @f);
SELECT audit_log_filter_set_user('%', 'log_conn_events');
152 | P a g e
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/audit-log-filtering.html
2. https://dev.mysql.com/doc/refman/8.0/en/audit-log.html
Additional Information:
Prior legacy modes of defining audit filters, although simple to use, were not specific
enough to define precise auditing rules - and thus required too much storage - resulting in
"over" auditing. Additionally MySQL audit filters can not only log events but act as firewall
rules by using an abort() definition in a filter.
See:
https://dev.mysql.com/doc/refman/8.0/en/audit-log-legacy-filtering.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
153 | P a g e
Description:
Rationale:
This filter to log all, and binding to all, users must be set to ensure all event information is
written to the audit log.
Impact:
Logging all events can result in very large audit files. In the case where the database is
extremely active it may be more appropriate to be more selective when defining audit
filters.
Audit:
Must return a filter name with a filter defined to log everything, for example:
+---------+---------------------------+
| NAME | FILTER |
+---------+---------------------------+
| log_all | {"filter": {"log": true}} |
+---------+---------------------------+
154 | P a g e
Ensure the filter to log_all (name can vary) is applied to all users.
+------+------+------------+
| USER | HOST | FILTERNAME |
+------+------+------------+
| % | | log_all |
+------+------+------------+
Remediation:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/audit-log-filtering.html
Additional Information:
If an appropriate filter and binding of the filter to users is not in place then audit events
related to all events won't be written to the audit log file.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
155 | P a g e
Description:
Rationale:
This setting controls how information is written to the audit log. It can be set to
SYNCHRONOUS to make it fully durable or other settings which are less durable but have less
performance overhead.
Impact:
If this setting is set to PERFORMANCE or ASYNCHRONOUS audit events might be lost in case of a
crash or when the server somehow can't write to the audit log file.
Audit:
Remediation:
Default Value:
ASYNCHRONOUS
156 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/audit-log-
reference.html#sysvar_audit_log_strategy
Additional Information:
This tells the server to load the plugin and prevent it from being removed while the server
is running.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
157 | P a g e
Description:
Rationale:
Impact:
If someone can unload the plugin it would be possible to perform actions on the database
without audit events being logged to the audit log. If the audit log plugin can be unloaded
the audit log can be temporarily or permanently disabled.
Audit:
Remediation:
audit_log = 'FORCE_PLUS_PERMANENT'
Default Value:
ON
158 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/audit-log-
reference.html#option_mysqld_audit-log
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
159 | P a g e
7 Authentication
This section contains configuration recommendations that pertain to the authentication
mechanisms of MySQL.
Description:
Caching SHA-2 Authentication is the new default in MySQL 8.0. It provides stronger
password protection than the prior Native Authentication and provides better performance
than SHA2 Authentication. Alternatively, there are additional methods to securely connect
using Lightweight Directory Access Protocol (LDAP) and Active Directory authentication.
Rationale:
MySQL Native Authentication relies on the Secure Hash Algorithm 1 (SHA1) algorithm and
the National Institute of Standards and Technology (NIST) has suggested to stop using it.
The MySQL Native Authentication plugin leverages this weak hashing algorithm that can be
quickly brute forced.
Audit:
160 | P a g e
Remediation:
default_authentication_plugin=caching_sha2_password
Provide users the random password value through a secure mechanism - on next login they
will be forced to change the password.
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-
series.html#upgrade-caching-sha2-password-compatibility-issues
2. https://dev.mysql.com/doc/refman/8.0/en/authentication-plugins.html
161 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
162 | P a g e
Description:
The [client] section of the MySQL configuration file allows setting a user and password to
be used. Verify the password option is not used in the global configuration file (my.cnf).
Rationale:
Using the password parameter may negatively impact the confidentiality of the user's
password.
Impact:
The global configuration is by default readable for all users on the system. This is needed
for global defaults (prompt, port, socket, etc.). If a password is present in this file then all
users on the system may be able to access it.
Audit:
Remediation:
If not possible, use the user-specific options file, .my.cnf., and restricting file access
permissions to the user identity.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html
163 | P a g e
Additional Information:
There must not be a password in any of the sections of the global configuration.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
164 | P a g e
7.3 Ensure Passwords are Set for All MySQL Accounts (Automated)
Profile Applicability:
Description:
Rationale:
Without a password only knowing the username and the list of allowed hosts will allow
someone to connect to the server and assume the identity of the user. This, in effect,
bypasses authentication mechanisms.
Audit:
Execute the following SQL query to determine if any users have a blank password:
SELECT User,host
FROM mysql.user
WHERE (plugin IN('mysql_native_password', 'mysql_old_password','')
AND (LENGTH(authentication_string) = 0
OR authentication_string IS NULL))
OR (plugin='sha256_password' AND LENGTH(authentication_string) = 0);
Remediation:
For each row returned from the audit procedure, reset the password for the given user
using the following statement (as an example):
ALTER USER
<user>@<host> IDENTIFIED BY RANDOM PASSWORD PASSWORD EXPIRE;
This resets the password temporarily to a RANDOM string and returns that temporary
password as a result.
The user can then use this temporary password to login and is forced to set the password
to one of their choosing upon login.
165 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
166 | P a g e
Description:
Rationale:
Impact:
Audit:
Remediation:
Default Value:
360
167 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/password-management.html
2. https://dev.mysql.com/doc/refman/8.0/en/expired-password-handling.html
Additional Information:
Research: Is it true, upon connection, a client can reset its own password after expiry
regardless of the variable disconnect_on_expired_password?
https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#
sysvar_disconnect_on_expired_password disconnect_on_expired_password is set to ON
by default, so therefore, doesn't place the user into sandbox mode and should just
disconnect the user. The sandbox mode allows the user the opportunity to change their
own password.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
168 | P a g e
Description:
Rationale:
Complex passwords help mitigate dictionary, brute forcing, and other password attacks.
This recommendation prevents users from choosing weak passwords which can easily be
guessed.
Audit:
New passwords should be checked against a dictionary file that contains values known to
be commonly-used, expected, or compromised. For example, the list should include, but is
not limited to:
169 | P a g e
• Context-specific words, such as the name of the service, the username, and
derivatives thereof
• validate_password.dictionary_file should point to a dictionary file of common
words used in passwords.
The following may make the password complexity too difficult, use sparingly.
Remediation:
Optionally set one or more of these - ensuring complexity is not overly onerous
And change passwords for users which have passwords which are identical to their
username.
Default Value:
validate_password.length=8
validate_password.mixed_case_count=1
validate_password.number_count=1
validate_password.policy=MEDIUM
validate_password.special_char_count=1
References:
1. https://dev.mysql.com/doc/refman/8.0/en/validate-password.html
170 | P a g e
Additional Information:
The 'validate password plugin' can be used instead of the password validation component
to enforce password complexity polices; however, it is deprecated and will be removed in a
future release.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
171 | P a g e
Description:
MySQL can make use of host wildcards when granting permissions to users on specific
databases. For example, you may grant a given privilege to '<user>'@'%'.
Rationale:
Avoiding the use of wildcards within hostnames helps control the specific locations from
which a given user may connect to and interact with the database.
Audit:
Remediation:
172 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
173 | P a g e
Description:
Anonymous accounts are users with empty usernames (''). Anonymous accounts have no
passwords, so anyone can use them to connect to the MySQL server.
Rationale:
Removing anonymous accounts will help ensure that only identified and trusted principals
are capable of interacting with MySQL.
Impact:
Any applications relying on anonymous database access will be adversely affected by this
change.
Audit:
The above query will return zero rows if no anonymous accounts are present.
Remediation:
1. Enumerate the anonymous users returned from executing the audit procedure.
2. For each anonymous user, DROP or assign them a name.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/mysql-secure-installation.html
2. https://dev.mysql.com/doc/refman/8.0/en/default-privileges.html
174 | P a g e
3. https://dev.mysql.com/doc/refman/8.0/en/proxy-users.html#proxy-users-
conflicts
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
175 | P a g e
8 Network
This section contains recommendations related to how the MySQL server uses the network.
Description:
All network traffic must use SSL/TLS when traveling over untrusted networks.
Rationale:
Impact:
Enabling Secure Sockets Layer (SSL) will allow clients to encrypt network traffic and verify
the identity of the server. This could have impact on network traffic inspection.
Audit:
select @@require_secure_transport;
Note: have_openssl is an alias for have_ssl when MySQL is built with OpenSSL.
176 | P a g e
Remediation:
Follow the procedures as documented in the MySQL 8.0 Reference Manual to setup SSL.
Set global policy to force SSL for all connections:
Default Value:
DISABLED
References:
1. https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html
2. https://dev.mysql.com/doc/refman/8.0/en/connection-options.html
3. https://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_require_secure_transport
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
177 | P a g e
8.2 Ensure 'ssl_type' is Set to 'ANY', 'X509', or 'SPECIFIED' for All Remote
Users (Automated)
Profile Applicability:
Description:
All network traffic must use SSL/TLS when traveling over untrusted networks.
SSL/TLS should be enforced on a per-user basis for users which enter the system through
the network.
Rationale:
Impact:
When SSL/TLS is enforced then clients which do not use SSL will not be able to connect. If
the server is not configured for SSL/TLS then accounts for which SSL/TLS is mandatory
will not be able to connect.
Audit:
Ensure the ssl_type for each user returned is equal to X509, or SPECIFIED.
Note: ANY means the connection must be using TLS and could optionally provide a client-
side certificate.
Remediation:
178 | P a g e
Note: REQUIRE SSL only enforces SSL. There are additional options REQUIRE ISSUER,
REQUIRE SUBJECT which can be used to further restrict the connection.
Default Value:
On the server-side SSL is ON by default --ssl (permits but does not require secure
connections) and require_secure_transport is OFF (turning ON allows only secure
connections)
References:
1. https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html
2. https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-tls
3. https://dev.mysql.com/doc/refman/8.0/en/connection-
options.html#option_general_ssl
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
179 | P a g e
8.3 Set Maximum Connection Limits for Server and per User (Manual)
Profile Applicability:
Description:
Limiting concurrent connections to a MySQL server can be used to reduce risk of Denial of
Service (DoS) attacks performed by exhausting connection resources.
Rationale:
Limiting the number of concurrent sessions at the server and per user level helps to reduce
the risk of DoS attacks. MySQL provides mechanisms to limit the number of simultaneous
connections that can be made at the server level or by any given account.
Audit:
Also check the values on a per user basis run the following
select user, host, max_user_connections from mysql.user where user not like
'mysql.%' and user not like 'root';
Remediation:
For example, to set the global default per user to 50 run the command:
180 | P a g e
To control the maximum number of clients the server permits to connect simultaneously,
set the max_connections system variable:
Additionally, this max user connections can be set per user as well as for a given period of
time period using CREATE or ALTER.
For example:
Default Value:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/user-resources.html
2. https://dev.mysql.com/doc/refman/8.0/en/connection-
interfaces.html#connection-interfaces-volume-management
181 | P a g e
9 Replication
Everything related to replicating data from one server to another.
Description:
The replication traffic between servers should be secured. Security measures should
include ensuring the confidentiality and integrity of the traffic, and performing mutual
authentication between the servers before performing replication.
Rationale:
The replication traffic should be secured as it gives access to all transferred information
and might leak passwords.
Impact:
When the replication traffic is not secured someone might be able to capture passwords
and other sensitive information when sent to the replica.
Audit:
Check if the replication traffic is using one or more of the following to provide
confidentiality and integrity for the traffic, and mutual authentication for the servers:
• A private network
• A VPN
• SSL/TLS
• A SSH Tunnel
Remediation:
Secure the network traffic using one or more technologies to provide confidentiality and
integrity for the traffic, and mutual authentication for the servers.
182 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
183 | P a g e
Description:
Rationale:
When SSL is in use certificate verification is important to authenticate the party to which a
connection is being made. In this case, the REPLICA (client) should verify the SOURCE's
(server's) certificate to authenticate the SOURCE prior to continuing the connection.
Impact:
When using CHANGE REPLICATION SOURCE TO, (CHANGE MASTER is deprecated as of 8.0.23)
be aware of the following:
Audit:
184 | P a g e
Remediation:
To remediate this setting, you must use the CHANGE SOURCE TO command.
From 8.0.23:
Prior to 8.0.23:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/change-replication-source-to.html
2. https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
185 | P a g e
Description:
Rationale:
The password which the client uses is stored in the SOURCE info repository, which by
default is a plaintext file. The TABLE SOURCE info repository is a bit safer, but with filesystem
access it's still possible to gain access to the password the REPLICA is using.
Audit:
Note: There also should not be a source.info or master.info file in the datadir.
Remediation:
Default Value:
TABLE
186 | P a g e
References:
1. https://dev.mysql.com/doc/refman/8.0/en/replication-options-
replica.html#sysvar_master_info_repository
187 | P a g e
Description:
The SUPER privilege found in the mysql.user table governs the use of a variety of MySQL
features. These features include, CHANGE MASTER TO, KILL, mysqladmin kill option, PURGE
BINARY LOGS, SET GLOBAL, mysqladmin debug option, logging control, and more.
Rationale:
The SUPER privilege allows principals to perform many actions, including view and
terminate currently executing MySQL statements (including statements used to manage
passwords). This privilege also provides the ability to configure MySQL, such as
enable/disable logging, alter data, disable/enable features. Limiting the accounts that have
the SUPER privilege reduces the chances that an attacker can exploit these capabilities.
Impact:
When the SUPER privilege is denied to a given user, that user will be unable to take
advantage of certain capabilities, such as certain mysqladmin options.
Audit:
select user, host from mysql.user where user='repl' and Super_priv = 'Y';
188 | P a g e
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_user_priv: Y
BACKUP_ADMIN
CLONE_ADMIN
PERSIST_RO_VARIABLES_ADMIN
REPLICATION_SLAVE_ADMIN
SYSTEM_VARIABLES_ADMIN
Note: Substitute your replication user's name for repl in the above queries.
Remediation:
1. Enumerate the replication users found in the result set of the audit procedure
2. For each replication user, issue the following SQL statement (replace repl with your
replication user's name):
Note: Prior to 8.0.21 if MySQL Replica Set was used to create the replications administrator
(call to dba.configureReplicaSetInstance in MySQL Shell) after performing the above
revoke you will need to grant the following dynamic privilege.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_super
2. https://dev.mysql.com/doc/refman/8.0/en/deploying-innodb-replicasets.html
189 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
190 | P a g e
Description:
MySQL can make use of host wildcards when granting permissions to users on specific
databases. For example, you may grant a given privilege to '<user>'@'%'.
Rationale:
Avoiding the use of wildcards within hostnames helps control the specific locations from
which a given user may connect to and interact with the database.
Audit:
SELECT user, host FROM mysql.user WHERE user='repl' AND host = '%';
Remediation:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/deploying-innodb-replicasets.html
Additional Information:
When creating a user for replication manually with the CREATE USER command or using the
MySQL Replica Set command dba.configureReplicaSetInstance limit hosts initially.
For example:
191 | P a g e
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
192 | P a g e
Various things can be configured to enhance the security of MySQL InnoDB Cluster.
Description:
Rationale:
SSL encryption ensures data cannot be seen over the network for Group Replication.
Audit:
193 | P a g e
select @@group_replication_ssl_mode;
Remediation:
group_replication_ssl_mode=REQUIRED
References:
1. https://dev.mysql.com/doc/refman/8.0/en/group-replication-secure-socket-layer-
support-ssl.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
194 | P a g e
Description:
Optionally, specify an allowlist of approved servers that belong to the MySQL InnoDB
Cluster.
Rationale:
When using MySQL InnoDB Cluster by specifying the allowlist explicitly, you can increase
the security of your cluster as only servers in the allowlist are allowed to connect to the
cluster.
Audit:
Open MySQL Shell and execute the following command to crate the allowlist of servers.
This list is comma separated list, surrounded by quotes. For example:
select @@group_replication_ip_allowlist
• Prior to 8.0.22:
select @@group_replication_ip_whitelist;
The result set from the above statement should be the IPv4, IPv6, or host names allowed to
join the MySQL InnoDB Cluster (Group).
Remediation:
• From 8.0.22:
195 | P a g e
• Prior to 8.0.22:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/mysql-innodb-cluster-working-with-
cluster.html#mysql-innodb-cluster-securing
2. https://dev.mysql.com/doc/refman/8.0/en/group-replication-ip-address-
permissions.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
196 | P a g e
197 | P a g e
198 | P a g e
200 | P a g e
Apr 14, 2021 1.0.0 Least Priv MySQL Account should not
have shell access (Ticket 10283)
201 | P a g e
Apr 14, 2021 1.0.0 Add section - limit host IP using bind
(Ticket 10363)
202 | P a g e
Apr 14, 2021 1.0.0 Need to rewrite this entirely. Old and
dated. (Ticket 10312)
Apr 14, 2021 1.0.0 Should show all files for ssl (Ticket
10314)
203 | P a g e
Apr 14, 2021 1.0.0 Better to set global policy than per
user. (Ticket 10296)
204 | P a g e
205 | P a g e