Oracle MySQL Enterprise Edition 8.0 Benchmark v1.2.0
Oracle MySQL Enterprise Edition 8.0 Benchmark v1.2.0
Page 1
Table of Contents
Terms of Use ................................................................................................................. 1
Table of Contents .......................................................................................................... 2
Overview ........................................................................................................................ 5
Intended Audience................................................................................................................. 5
Consensus Guidance ............................................................................................................ 6
Typographical Conventions .................................................................................................. 7
Recommendation Definitions ....................................................................................... 8
Title ......................................................................................................................................... 8
Assessment Status................................................................................................................ 8
Automated .............................................................................................................................................. 8
Manual ..................................................................................................................................................... 8
Profile ..................................................................................................................................... 8
Description ............................................................................................................................. 8
Rationale Statement .............................................................................................................. 8
Impact Statement ................................................................................................................... 9
Audit Procedure ..................................................................................................................... 9
Remediation Procedure......................................................................................................... 9
Default Value .......................................................................................................................... 9
References ............................................................................................................................. 9
CIS Critical Security Controls® (CIS Controls®) ................................................................... 9
Additional Information........................................................................................................... 9
Profile Definitions .................................................................................................................10
Acknowledgements ..............................................................................................................12
Recommendations ...................................................................................................... 13
1 Operating System Level Configuration ............................................................................13
1.1 Place Databases on Non-System Partitions (Manual) .......................................................................... 14
1.2 Use Dedicated Least Privileged Account for MySQL Daemon/Service (Automated) ............................ 17
1.3 Disable MySQL Command History (Automated) ................................................................................... 19
1.4 Verify That the MYSQL_PWD Environment Variable is Not in Use (Automated) .................................. 21
1.5 Ensure Interactive Login is Disabled (Automated) ................................................................................ 23
1.6 Verify That 'MYSQL_PWD' is Not Set in Users' Profiles (Automated)................................................... 25
1.7 Ensure MySQL is Run Under a Sandbox Environment (Manual) .......................................................... 27
Page 2
2.1.3 Secure Backup Credentials (Manual) ................................................................................................ 35
2.1.4 The Backups Should be Properly Secured (Manual) ......................................................................... 36
2.1.5 Point-in-Time Recovery (Automated) ................................................................................................. 38
2.1.6 Disaster Recovery (DR) Plan (Manual) .............................................................................................. 40
2.1.7 Backup of Configuration and Related Files (Manual) ......................................................................... 42
2.2 Data Encryption ............................................................................................................................. 43
2.2.1 Ensure Binary and Relay Logs are Encrypted (Automated) ............................................................... 44
2.3 Dedicate the Machine Running MySQL (Manual) ................................................................................. 46
2.4 Do Not Specify Passwords in the Command Line (Manual).................................................................. 48
2.5 Do Not Reuse Usernames (Manual) ..................................................................................................... 50
2.6 Ensure Non-Default, Unique Cryptographic Material is in Use (Manual)............................................... 52
2.7 Ensure 'password_lifetime' is Less Than or Equal to '365' (Automated) ............................................... 53
2.8 Ensure Password Resets Require Strong Passwords (Automated) ...................................................... 55
2.9 Require Current Password for Password Reset (Automated) ............................................................... 57
2.10 Use Dual Passwords to Enable Higher Frequency Password Rotation (Manual) ............................... 58
2.11 Lock Out Accounts if Not Currently in Use (Manual) ........................................................................... 60
2.12 Ensure AES Encryption Mode for AES_ENCRYPT/AES_DECRYPT is Configured Correctly
(Automated) ................................................................................................................................................ 62
2.13 Ensure Socket Peer-Credential Authentication is Used Appropriately (Manual) ................................. 64
2.14 Ensure MySQL is Bound to an IP Address (Automated) ..................................................................... 66
2.15 Limit Accepted Transport Layer Security (TLS) Versions (Automated) ............................................... 68
2.16 Require Client-Side Certificates (X.509) (Automated) ......................................................................... 70
2.17 Ensure Only Approved Ciphers are Used (Automated)....................................................................... 72
2.18 Implement Connection Delays to Limit Failed Login Attempts (Automated)........................................ 74
4 General .............................................................................................................................100
4.1 Ensure the Latest Security Patches are Applied (Manual) .................................................................. 101
4.2 Ensure Example or Test Databases are Not Installed on Production Servers (Automated) ............... 103
4.3 Ensure 'allow-suspicious-udfs' is Set to 'OFF' (Automated) ................................................................ 105
4.4 Harden Usage for 'local_infile' on MySQL Clients (Automated) .......................................................... 107
4.5 Ensure 'mysqld' is Not Started With '--skip-grant-tables' (Automated) ................................................ 109
4.6 Ensure Symbolic Links are Disabled (Automated) .............................................................................. 111
4.7 Ensure the 'daemon_memcached' Plugin is Disabled (Automated) .................................................... 113
4.8 Ensure the 'secure_file_priv' is Configured Correctly (Automated) ..................................................... 115
4.9 Ensure 'sql_mode' Contains 'STRICT_ALL_TABLES' (Automated) .................................................... 117
4.10 Use MySQL TDE for At-Rest Data Encryption (Automated) ............................................................. 119
Page 3
5.5 Ensure 'SHUTDOWN' is Not Granted to Non-Administrative Users (Manual)..................................... 131
5.6 Ensure 'CREATE USER' is Not Granted to Non-Administrative Users (Manual) ................................ 133
5.7 Ensure 'GRANT OPTION' is Not Granted to Non-Administrative Users (Manual) .............................. 135
5.8 Ensure 'REPLICATION SLAVE' is Not Granted to Non-Administrative Users (Manual) ..................... 137
5.9 Ensure DML/DDL Grants are Limited to Specific Databases and Users (Manual) .............................. 139
5.10 Securely Define Stored Procedures and Functions DEFINER and INVOKER (Manual) ................... 141
7 Authentication..................................................................................................................161
7.1 Ensure default_authentication_plugin is Set to a Secure Option (Automated) .................................... 162
7.2 Ensure Passwords are Not Stored in the Global Configuration (Automated) ...................................... 164
7.3 Ensure Passwords are Set for All MySQL Accounts (Automated) ...................................................... 166
7.4 Set 'default_password_lifetime' to Require a Yearly Password Change (Automated) ........................ 168
7.5 Ensure Password Complexity Policies are in Place (Automated) ....................................................... 170
7.6 Ensure No Users Have Wildcard Hostnames (Automated) ................................................................. 173
7.7 Ensure No Anonymous Accounts Exist (Automated) .......................................................................... 174
8 Network ............................................................................................................................176
8.1 Ensure 'require_secure_transport' is Set to 'ON' and/or 'have_ssl' is Set to 'YES' (Automated) ......... 177
8.2 Ensure 'ssl_type' is Set to 'ANY', 'X509', or 'SPECIFIED' for All Remote Users (Automated) ............. 179
8.3 Set Maximum Connection Limits for Server and per User (Manual) ................................................... 181
9 Replication .......................................................................................................................183
9.1 Ensure Replication Traffic is Secured (Manual) .................................................................................. 184
9.2 Ensure 'SOURCE_SSL_VERIFY_SERVER_CERT' is Set to 'YES' or '1' (Automated) ...................... 186
9.3 Ensure 'master_info_repository' is Set to 'TABLE' (Automated) .......................................................... 188
9.4 Ensure 'super_priv' is Not Set to 'Y' for Replication Users (Automated).............................................. 189
Page 4
Overview
All CIS Benchmarks focus on technical configuration settings used to maintain and/or
increase the security of the addressed technology, and they should be used in
conjunction with other essential cyber hygiene tasks like:
• Monitoring the base operating system for vulnerabilities and quickly updating with
the latest security patches
• Monitoring applications and libraries for vulnerabilities and quickly updating with
the latest security patches
In the end, the CIS Benchmarks are designed as a key component of a comprehensive
cybersecurity program.
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.
Page 5
Consensus Guidance
This CIS Benchmark was created using a consensus review process comprised of a
global community of subject matter experts. The process combines real world
experience with data-based information to create technology specific guidance to assist
users to secure their environments. 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/.
Page 6
Typographical Conventions
The following typographical conventions are used throughout this guide:
Convention Meaning
Page 7
Recommendation Definitions
The following defines the various components included in a CIS recommendation as
applicable. If any of the components are not applicable it will be noted or the
component will not be included in the recommendation.
Title
Concise description for the recommendation's intended configuration.
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
Represents recommendations for which assessment of a technical control can be fully
automated and validated to a pass/fail state. Recommendations will include the
necessary information to implement automation.
Manual
Represents recommendations for which assessment of a technical control cannot be
fully automated and requires all or some manual steps to validate that the configured
state is set as expected. The expected state can vary depending on the environment.
Profile
A collection of recommendations for securing a technology or a supporting platform.
Most benchmarks include at least a Level 1 and Level 2 Profile. Level 2 extends Level 1
recommendations and is not a standalone profile. The Profile Definitions section in the
benchmark provides the definitions as they pertain to the recommendations included for
the technology.
Description
Detailed information pertaining to the setting with which the recommendation is
concerned. In some cases, the description will include the recommended value.
Rationale Statement
Detailed reasoning for the recommendation to provide the user a clear and concise
understanding on the importance of the recommendation.
Page 8
Impact Statement
Any security, functionality, or operational consequences that can result from following
the recommendation.
Audit Procedure
Systematic instructions for determining if the target system complies with the
recommendation
Remediation Procedure
Systematic instructions for applying recommendations to the target system to bring it
into compliance according to the recommendation.
Default Value
Default value for the given setting in this recommendation, if known. If not known, either
not configured or not defined will be applied.
References
Additional documentation relative to the recommendation.
Additional Information
Supplementary information that does not correspond to any other field but may be
useful to the user.
Page 9
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:
Page 10
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.
Page 11
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
Walter York
Editor
Tim Harrison, Center for Internet Security
Robin Drake
Page 12
Recommendations
1 Operating System Level Configuration
This section contains recommendations related to the Operating System on which the
MySQL database server is running.
Page 13
1.1 Place Databases on Non-System Partitions (Manual)
Profile Applicability:
• Obtain the location of the datadir and other MySQL database files by executing
the following SQL statement:
• 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.
Page 14
Remediation:
Perform the following steps to remediate this setting for the datadir:
Note: On some Linux distributions you may need to additionally modify apparmor
settings. For example, on a Ubuntu 14.04.1 system edit the file
/etc/apparmor.d/usr.sbin.mysqld so that the datadir access is appropriate.
The original might look like this:
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
Page 15
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 16
1.2 Use Dedicated Least Privileged Account for MySQL
Daemon/Service (Automated)
Profile Applicability:
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, it's best to
avoid providing shell access to such an account.
Shell access can be removed using the following command at a terminal prompt:
/usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || :
/usr/sbin/useradd -M -N -g mysql -o -r -d /var/lib/mysql -s /bin/false \
-c "MySQL Server" -u 27 mysql >/dev/null 2>&1 || :
References:
1. https://dev.mysql.com/doc/refman/8.0/en/changing-mysql-user.html
2. https://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_user
Page 17
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:
Page 18
1.3 Disable MySQL Command History (Automated)
Profile Applicability:
Remediation:
For MySQL Client perform the following steps to remediate this setting:
Page 19
o Start shell and list show options using \option -l
o Set to no history using the command \option --persist
history.autoSave=1
Default Value:
By default, the MySQL command history file is located in $HOME/.mysql_history.
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
Page 20
1.4 Verify That the MYSQL_PWD Environment Variable is Not in
Use (Automated)
Profile Applicability:
Default Value:
Not set.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/environment-variables.html
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
Page 21
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 22
1.5 Ensure Interactive Login is Disabled (Automated)
Profile Applicability:
Page 23
usermod -s /sbin/nologin mysql
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 24
1.6 Verify That 'MYSQL_PWD' is Not Set in Users' Profiles
(Automated)
Profile Applicability:
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:
grep MYSQL_PWD /home/*/.{bashrc,profile,bash_profile}
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
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 25
Controls
Control IG 1 IG 2 IG 3
Version
Page 26
1.7 Ensure MySQL is Run Under a Sandbox Environment
(Manual)
Profile Applicability:
Description:
Use of the chroot() system call at startup, Systemd with settings to achieve isolation, or
docker will put MySQL in a Sandbox environment.
Rationale:
Running MySQL in a Sandbox environment may reduce the impact of a MySQL-born
vulnerability by making portions of the file system inaccessible to the MySQL instance.
Impact:
Use of the chroot option somewhat limits LOAD DATA INFILE and SELECT ... INTO
OUTFILE.
Audit:
Perform the following steps for each mySQL instance to assess this recommendation:
The returned value should specify a valid path which differs from the datadir. No
results implies 'chroot' is not in use.
If something other than (root) is listed beside the PID, e.g. Main PID: <PID>
(root), this is a pass. No results implies mysql is not managed by systemd.
Page 27
$ docker -v
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
0fc229e3df77 mysql "docker…" 1 hour ago Up 1 hour
0.0.0.0:3306->3306/tcp, mysql-server
:::3306-
>3306/tcp,
33060/tcp
Remediation:
Perform one of the following steps to remediate this setting:
Page 28
$ sudo groupadd mysql
$ sudo useradd -r -g mysql -s /bin/false mysql
[Unit]
Description=MySQL Server
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
References:
1. https://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_chroot
2. https://dev.mysql.com/doc/refman/8.0/en/docker-mysql-getting-started.html
3. https://hub.docker.com/r/mysql/mysql-server
Page 29
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 30
2 Installation and Planning
This section contains important considerations when deploying MySQL services to your
production network and defining the configuration. The recommendations made herein
are not scored from a benchmark perspective and generally align with best current
practices as conveyed in most control frameworks.
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.
The second consideration is for an administrator to connect to a MySQL instance and
change or add to the configuration options using the SET PERSIST command. This
persists system variables in mysqld-auto.cnf which is located in the MySQL datadir by
default. The file permissions on mysqld-auto.cnf are by default more restrictive than
my.cnf (no world permissions).
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.
Page 31
2.1 Backup and Disaster Recovery
Page 32
2.1.1 Backup Policy in Place (Manual)
Profile Applicability:
Remediation:
Create a backup policy and backup schedule.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 33
2.1.2 Verify Backups are Good (Manual)
Profile Applicability:
Controls
Control IG 1 IG 2 IG 3
Version
Page 34
2.1.3 Secure Backup Credentials (Manual)
Profile Applicability:
Controls
Control IG 1 IG 2 IG 3
Version
Page 35
2.1.4 The Backups Should be Properly Secured (Manual)
Profile Applicability:
If you are running the MySQL Enterprise Backup verify that the backup uses --encrypt.
For example:
$ mysqlbackup --defaults-file=/home/dbadmin/my.cnf --backup-
image=/home/admin/backups/my.mbi \
--backup-dir=/home/admin/backup-tmp --encrypt-password backup-to-image
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.
Page 36
Remediation:
Implement encryption, properly restrict filesystem permissions, protect and backup
encryption keys.
For example, if you run MySQL Enterprise Backup include --encrypt-password
$ mysqlbackup --defaults-file=/home/dbadmin/my.cnf --backup-
image=/home/admin/backups/my.mbi \
--backup-dir=/home/admin/backup-tmp --encrypt-password backup-to-image
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
Page 37
2.1.5 Point-in-Time Recovery (Automated)
Profile Applicability:
Page 38
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
Page 39
2.1.6 Disaster Recovery (DR) Plan (Manual)
Profile Applicability:
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
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 40
Controls
Control IG 1 IG 2 IG 3
Version
Page 41
2.1.7 Backup of Configuration and Related Files (Manual)
Profile Applicability:
Remediation:
Add any omitted files to the backup.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 42
2.2 Data Encryption
This section contains recommendations for securing data at rest and in transit for
MySQL.
Page 43
2.2.1 Ensure Binary and Relay Logs are Encrypted (Automated)
Profile Applicability:
Remediation:
To remediate misconfiguration, run this command:
SET GLOBAL binlog_encryption=ON;
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.
Default Value:
The default for binlog_encryption is OFF.
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
Page 44
Additional Information:
It is necessary to install a keyring plugin prior to configuring encryption.
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
Page 45
2.3 Dedicate the Machine Running MySQL (Manual)
Profile Applicability:
Page 46
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 47
2.4 Do Not Specify Passwords in the Command Line (Manual)
Profile Applicability:
Audit:
Check the process or task list if the password is visible.
Check the shell or command history if the password is visible.
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.
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.
Page 48
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
Page 49
2.5 Do Not Reuse Usernames (Manual)
Profile Applicability:
• system accounts
• a person
• an application
Remediation:
Add/Remove users so that each user is only used for one specific purpose.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 50
Controls
Control IG 1 IG 2 IG 3
Version
Page 51
2.6 Ensure Non-Default, Unique Cryptographic Material is in Use
(Manual)
Profile Applicability:
1. https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html
Page 52
2.7 Ensure 'password_lifetime' is Less Than or Equal to '365'
(Automated)
Profile Applicability:
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:
The global password lifetime is set using default_password_lifetime. If the value of
default_password_lifetime is greater than 0, it indicates the permitted password
lifetime.
Execute the following command to check the global password lifetime:
SELECT VARIABLE_NAME, VARIABLE_VALUE
FROM performance_schema.global_variables where VARIABLE_NAME like
'default_password_lifetime';
A value greater than 365 implies a fail.
When the global password lifetime is less than or equal to 365, or not configured, each
user account shall be checked by executing the following command:
SELECT user, host, password_lifetime from mysql.user where password_lifetime
= 0 OR password_lifetime >= 365;
A lack of results implies compliance.
Note: A value of 0 implies the password never expires.
Remediation:
To configure the global password lifetime to 365 by executing the following command:
set persist default_password_lifetime = 365;
Alternatively, configure the password lifetime for each user returned by the audit
procedure by executing the following command:
Page 53
ALTER USER '<username>'@'<localhost>' PASSWORD EXPIRE INTERVAL 365 DAY;
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.
Page 54
2.8 Ensure Password Resets Require Strong Passwords
(Automated)
Profile Applicability:
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:
To assess this recommendation run the following statement:
SELECT VARIABLE_NAME, VARIABLE_VALUE
FROM performance_schema.global_variables where VARIABLE_NAME in
('password_history', 'password_reuse_interval');
A value of 0 indicates that NO policy is defined for the associated variable.
The password_history variable indicates the number of subsequent account password
changes that must occur before the password can be reused. The password_history
should be greater than or equal to 5, thus attempts to use any of the prior five, or more,
passwords for this account will be denied.
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.
Remediation:
Set a global policy that passwords may not be reused for a minimum of five password
changes:
Page 55
SET PERSIST password_history = 5;
Set a global policy that passwords have a lifetime to approximately one year (in days)
SET PERSIST password_reuse_interval = 365;
Default Value:
Both password_history and password_reuse_interval are 0 (off) by default.
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
Page 56
2.9 Require Current Password for Password Reset (Automated)
Profile Applicability:
Remediation:
Set the value to ON
SET PERSIST password_require_current=ON;
Default Value:
The password_require_current is OFF by default.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_password_require_current
Page 57
2.10 Use Dual Passwords to Enable Higher Frequency Password
Rotation (Manual)
Profile Applicability:
Description:
Dual passwords act as a tool to encourage password rotations in cases where a
synchronized password change is not viable. By having a time delta to have old and
new passwords in place, the process of replacing old passwords with new passwords
within applications is simplified.
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:
SELECT user, host FROM mysql.user WHERE length(user_attributes-
>"$.additional_password")>0;
If an account has a dual password and the process of password rotation has completed,
this is a fail.
Remediation:
To set dual passwords execute the following ALTER command:
ALTER USER '<user>'@'<hostname>'
IDENTIFIED BY '<new_password>'
RETAIN CURRENT PASSWORD;
Once the new password has been distributed DISCARD the old password using ALTER:
Page 58
ALTER USER '<user>'@'<hostname>'
DISCARD OLD PASSWORD;
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.
Password expiration is based on the policy set by the default_password_lifetime or by
explicit settings on a per account basis.
To assess when passwords were last changed on accounts and when, or if, they will
expire run the following
select user, host, password_last_changed,
IF(IFNULL(password_lifetime, CAST(@@default_password_lifetime as
signed))<1,'NEVER',
concat(
cast(
IFNULL(password_lifetime, @@default_password_lifetime) as signed)
+ cast(datediff(password_last_changed, now()) as signed), " days")) as
days_till_expires
from mysql.user;
Applications will fail to authenticate when days_till_expires reaches 0.
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.
Page 59
2.11 Lock Out Accounts if Not Currently in Use (Manual)
Profile Applicability:
Remediation:
To lock accounts - example:
ALTER USER 'jeffrey'@'localhost' ACCOUNT LOCK;
To unlock accounts - example
ALTER USER 'jeffrey'@'localhost' ACCOUNT UNLOCK;
Note: Works for CREATE as well. It is good practice to LOCK an account if created ahead
of time.
Default Value:
Accounts are unlocked by default.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/account-locking.html
Additional Information:
When a client attempts to connect to a locked account, the attempt fails.
Page 60
Access denied for user 'user_name'@'host_name'.
Account is locked.
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:
show global status like 'Locked_connects';
The error log will contain the message ER_ACCOUNT_HAS_BEEN_LOCKED.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 61
2.12 Ensure AES Encryption Mode for
AES_ENCRYPT/AES_DECRYPT is Configured Correctly
(Automated)
Profile Applicability:
Remediation:
Add the following lines to the MySQL server's /etc/my.cnf:
For example, if Block Encryption Mode for aes-256 CBC
block_encryption_mode=aes-256-cbc
Or, run the following command:
set persist block_encryption_mode='aes-256-cbc';
Restart the server for this change to take effect.
Page 62
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
Page 63
2.13 Ensure Socket Peer-Credential Authentication is Used
Appropriately (Manual)
Profile Applicability:
Description:
The server-side auth_socket authentication plugin, authenticates clients that connect to
the MySQL server from the local host through the Unix socket file. Users authenticated
by the auth_socket need not specify a password when connecting to the server.
However, users authenticated by the auth_socket plugin are restricted from connecting
remotely; they can only connect from the local host through the Unix socket file. This
method is only suitable in situations where the server administrator OS account access
is restricted.
Rationale:
This method may be desirable in specific cases, including:
• 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:
Things to consider when using the operating system to authenticate users:
• 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.
Page 64
Audit:
To assess this recommendation run the following:
SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE 'auth%';
To determine users who can use auth socket:
select user, host, plugin from mysql.user where plugin = 'auth_socket';
If this is enabled and the organization does not allow use of this feature, this is a fail.
If host is not the localhost or an unauthorized user is listed, 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:
CREATE USER '<user>'@'localhost' IDENTIFIED WITH auth_socket;
The user can then login using:
mysql -u <user>
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-configure-authentication.html#secure-deployment-auth-socket
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 65
2.14 Ensure MySQL is Bound to an IP Address (Automated)
Profile Applicability:
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.
References:
1. https://dev.mysql.com/doc/mysql-secure-deployment-guide/8.0/en/secure-
deployment-secure-connections.html
Page 66
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 67
2.15 Limit Accepted Transport Layer Security (TLS) Versions
(Automated)
Profile Applicability:
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:
Connections attempting to use an unsupported version of TLS or Cipher will fail.
Audit:
To list the versions of TLS the server accepts, run the following statement:
select @@tls_version;
If the list includes TLSv1 and/or TLSv1.1, this is a fail.
To view current connections and the version of SSL in use run:
select * from performance_schema.status_by_thread where VARIABLE_NAME like
'ssl_version';
If the list includes, TLSv1 and/or TLSv1.1, this is a fail.
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.
Remediation:
Set the version(s) of TLS you wish to accept in mysql.conf specify TLS and Ciphers.
For example to only accept TLS 1.3 set tls_version in my.conf:
tls_version=TLSv1.3
If TLS 1.3 is not supported on the Operating System then set to TLS 1.2:
Page 68
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:
All TLS and cipher versions are enabled by default.
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
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 69
2.16 Require Client-Side Certificates (X.509) (Automated)
Profile Applicability:
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.
Page 70
• ‘mysql.infoschema’@’localhost’
• ‘mysql.session’@’localhost’
• ‘mysql.sys’@’localhost’
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 71
2.17 Ensure Only Approved Ciphers are Used (Automated)
Profile Applicability:
Remediation:
Set ssl_cipher and tls_ciphersuites in the mysql.conf to an approved cipher suite:
tls_ciphersuites='TLS_AES_256_GCM_SHA384'
ssl_cipher='ECDHE-ECDSA-AES128-GCM-SHA256'
OR
Execute the following commands:
set persist ssl_cipher='ECDHE-ECDSA-AES128-GCM-SHA256';
set persist tls_ciphersuites='TLS_AES_256_GCM_SHA384';
References:
1. https://dev.mysql.com/doc/refman/8.0/en/encrypted-connection-protocols-
ciphers.html#encrypted-connection-cipher-configuration
Page 72
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 73
2.18 Implement Connection Delays to Limit Failed Login Attempts
(Automated)
Profile Applicability:
Description:
MySQL Server can enable administrators to introduce an increasing delay in server
response to clients after a certain number of consecutive failed connection attempts.
Rationale:
Delaying connection attempts provides a deterrent that slows down brute force attacks
that attempt to access MySQL user accounts.
Audit:
Determine if the plugins for delaying connections are installed.
SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE 'connection%';
Two rows should be returned showing ACTIVE status.
CONNECTION_CONTROL | ACTIVE
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS | ACTIVE
If both plugins are not active, this is a fail.
Next assess the setting for the connection controls by running
SELECT VARIABLE_NAME, VARIABLE_VALUE
FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE
'connection_control%';
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.
If connection_control_failed_connections_threshold is less than 5 (attempts), this is
a fail.
If connection_control_min_connection_delay is less than 60000 (ms - 1 minute), this is
a fail.
Max delay connection_control_max_connection_delay is 0 or less than 1920000 (ms, 32
minutes) a, this is a fail.
Finally, assess the failed login attempts.
Page 74
select host, user, JSON_EXTRACT(user_attributes,
'$.Password_locking.failed_login_attempts') as failed_login_attempts from
mysql.user;
If failed login attempts is less than 12 this is a fail.
Remediation:
Add the following lines to my.cnf:
[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
Delays are in milliseconds for server response to failed connection attempt.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/connection-control.html
CIS Controls:
Page 75
3 File Permissions
File Permissions are critical for keeping the data and configuration of the MySQL server
secure.
Page 76
3.1 Ensure 'datadir' Has Appropriate Permissions (Automated)
Profile Applicability:
Or
Remediation:
Execute the following commands at a terminal prompt:
Page 77
chmod 750 <datadir>
chown mysql:mysql <datadir>
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
Page 78
3.2 Ensure 'log_bin_basename' Files Have Appropriate
Permissions (Automated)
Profile Applicability:
Page 79
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:
chmod 660 <log file>
chown mysql:mysql <log file>
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
Page 80
3.3 Ensure 'log_error' Has Appropriate Permissions (Automated)
Profile Applicability:
Page 81
Remediation:
Execute the following command for each log file location requiring corrected
permissions and ownership:
chmod 600 <log file>
chown mysql:mysql <log file>
References:
1. https://dev.mysql.com/doc/refman/8.0/en/error-log.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
Page 82
3.4 Ensure 'slow_query_log' Has Appropriate Permissions
(Automated)
Profile Applicability:
Page 83
2. Execute the following SQL statement to determine the location of
slow_query_log_file:
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)
Default Value:
Slow query log is off by default.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 84
Controls
Control IG 1 IG 2 IG 3
Version
Page 85
3.5 Ensure 'relay_log_basename' Files Have Appropriate
Permissions (Automated)
Profile Applicability:
ls -l | egrep "^-(?![r|w]{2}-[r|w]{2}----
.*mysql\s*mysql).*<relay_log_basename>.*$
Page 86
Remediation:
Execute the following command for each log file location requiring corrected
permissions and ownership:
chmod 660 <log file>
chown mysql:mysql <log file>
Default Value:
<datadir> + '/' + <hostname> + '-relay-bin'
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 87
3.6 Ensure 'general_log_file' Has Appropriate Permissions
(Automated)
Profile Applicability:
Page 88
ls -l <general_log_file>
If general_log is 0 or OFF (disabled) and the log file exists, remove the old general log
file.
If general_log is 1 or ON (enabled) review the permissions
ls -l <general_log_file> grep '^-rw-------.*mysql.*mysql'
Lack of output implies compliance.
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.
Default Value:
The variable general_log is set to OFF by default. The variable general_log_file is set
to <host_name>.log by default.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/query-log.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 89
Controls
Control IG 1 IG 2 IG 3
Version
Page 90
3.7 Ensure SSL Key Files Have Appropriate Permissions
(Automated)
Profile Applicability:
1. Locate the SSL keys and certs in use by executing the following SQL statement.
To show all ssl variables:
Page 91
SELECT * FROM performance_schema.global_variables
WHERE
REGEXP_LIKE(VARIABLE_NAME,'^.*ssl_(ca|capath|cert|crl|crlpath|key)$')
AND VARIABLE_VALUE <> '';
Note: Any mysqlx_% values that are null default to the classic protocols
equivalent value.
Remediation:
Execute the following commands at a terminal prompt to remediate these settings using
the Value from the audit procedure:
chown mysql:mysql <ssl_file>
chmod 400 <ssl_file>
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.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 92
3.8 Ensure Plugin Directory Has Appropriate Permissions
(Automated)
Profile Applicability:
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.
chmod 550 <plugin_dir Value> #(or use 554)
chown mysql:mysql <plugin_dir Value>
References:
1. https://dev.mysql.com/doc/refman/8.0/en/install-plugin.html
Page 93
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 94
3.9 Ensure 'audit_log_file' Has Appropriate Permissions
(Automated)
Profile Applicability:
Page 95
chmod 660 <audit_log_file>
chown mysql:mysql <audit_log_file>
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 96
3.10 Secure MySQL Keyring (Automated)
Profile Applicability:
Page 97
Keyring OKV / KMIP compatible Plugin
Page 98
Remediation:
If no keyring plugin or keyring file plugin is configured, instructions for configuring a
keyring plugin or keyring file plugin may found at:
• 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:
chmod 750 <keyring file>
chown mysql:mysql <keyring file>
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
Page 99
4 General
This section contains recommendations related to various parts of the database server.
Page 100
4.1 Ensure the Latest Security Patches are Applied (Manual)
Profile Applicability:
1. http://www.oracle.com/technetwork/topics/security/alerts-086861.html
2. http://dev.mysql.com/doc/relnotes/mysql/8.0/en/
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
Page 101
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 102
4.2 Ensure Example or Test Databases are Not Installed on
Production Servers (Automated)
Profile Applicability:
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:
SELECT * FROM information_schema.SCHEMATA where SCHEMA_NAME not in
('mysql','information_schema', 'sys', 'performance_schema');
If this is a production system, and a database name includes an example database this
is a finding.
Common example database names are:
• employees
• world
• world_x
• sakila
• airportdb
• menagerie
Remediation:
Execute the following SQL statement to drop an example database:
DROP DATABASE <database name>;
Default Value:
By default, MySQL 8.0 does not contain any example or test databases.
References:
1. http://dev.mysql.com/doc/refman/8.0/en/mysql-secure-installation.html
Page 103
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 104
4.3 Ensure 'allow-suspicious-udfs' is Set to 'OFF' (Automated)
Profile Applicability:
Rationale:
Preventing shared libraries that do not contain user-defined functions from loading will
reduce the attack surface of the server.
Audit:
Perform the following to determine if the recommended state is in place:
Remediation:
Perform the following to establish the recommended state:
Default Value:
OFF
References:
1. https://dev.mysql.com/doc/extending-mysql/8.0/en/adding-loadable-
function.html#loadable-function-security
2. http://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_allow-suspicious-udfs
Page 105
Additional Information:
This option has no corresponding state in SHOW VARIABLES.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 106
4.4 Harden Usage for 'local_infile' on MySQL Clients (Automated)
Profile Applicability:
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:
Check the version of MySQL clients and connectors.
For example:
$ mysqlsh --version
$ mysql --version
The version should be 8.0.21 or higher.
For connectors inspect the library in use.
Most connectors provide functions which return version information.
For C - libmysqlclient has:
const char *mysql_get_client_info(void)
If clients have not been upgraded to 8.0.21 check the value of local_infile.
Execute the following SQL statement:
SHOW VARIABLES WHERE Variable_name = 'local_infile';
If clients are older than 8.0.21 or if local_infile is not in use, ensure the value returned
is 0.
Remediation:
Upgrade all MySQL clients and connectors to 8.0.21 or higher.
Page 107
In the case where using local_infile is needed, the following changes further harden
security:
On client side, secure by:
Limiting the location from where data can be read using --load-data-local-dir.
mysql --local-infile=0 --load-data-local-dir=/my/local/data
Adding TLS connection to assure server identity by requiring verification.
mysql --local-infile=0 --load-data-local-dir=/my/local/data --ssl-
mode=VERIFY_IDENTITY
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. https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_load-file
2. https://dev.mysql.com/doc/refman/8.0/en/load-data.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 108
4.5 Ensure 'mysqld' is Not Started With '--skip-grant-tables'
(Automated)
Profile Applicability:
Rationale:
If this option is used, all clients of the affected server will have unrestricted access to all
databases.
Audit:
Perform the following to determine if the recommended state is in place:
• Open the MySQL configuration (e.g., my.cnf) file and search for skip-grant-tables
• Ensure skip-grant-tables is set to FALSE
Remediation:
Perform the following to establish the recommended state:
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:
This option has no SHOW VARIABLES counterpart.
Page 109
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 110
4.6 Ensure Symbolic Links are Disabled (Automated)
Profile Applicability:
Remediation:
Perform the following actions to remediate this setting:
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
2. http://dev.mysql.com/doc/refman/8.0/en/server-
options.html#option_mysqld_symbolic-links
Page 111
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
v7 13 Data Protection
Data Protection
Page 112
4.7 Ensure the 'daemon_memcached' Plugin is Disabled
(Automated)
Profile Applicability:
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:
Execute the following SQL statement to assess this recommendation:
SELECT * FROM information_schema.plugins WHERE
PLUGIN_NAME='daemon_memcached';
Ensure that no rows are returned.
Remediation:
To remediate this setting, issue the following command in the MySQL command-line
client:
uninstall plugin daemon_memcached;
This uninstalls the memcached plugin from the MySQL server.
Default Value:
disabled
References:
1. http://dev.mysql.com/doc/refman/8.0/en/innodb-memcached-security.html
Page 113
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 114
4.8 Ensure the 'secure_file_priv' is Configured Correctly
(Automated)
Profile Applicability:
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:
SHOW GLOBAL VARIABLES WHERE Variable_name = 'secure_file_priv';
The Value should either contain NULL (thus is disabled entirely) or a valid path. If set to
an empty string this is a fail.
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:
Page 115
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
Page 116
4.9 Ensure 'sql_mode' Contains 'STRICT_ALL_TABLES'
(Automated)
Profile Applicability:
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:
Applications relying on the MySQL database should be aware that STRICT_ALL_TABLES
is in use, such that error conditions are handled appropriately.
Audit:
To audit for this recommendation, execute the following query:
SHOW VARIABLES LIKE 'sql_mode';
+---------------+-----------------------------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------------------------+
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE, |
| | NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO, |
| | NO_ENGINE_SUBSTITUTION |
+---------------+-----------------------------------------------------------+
If STRICT_ALL_TABLES is not in the list returned, this is a fail.
Remediation:
Set STRICT_ALL_TABLES to the sql_mode in the server's global configuration, for example:
Page 117
SET GLOBAL sql_mode
='STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO
_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
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. https://dev.mysql.com/doc/refman/8.0/en/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
Page 118
4.10 Use MySQL TDE for At-Rest Data Encryption (Automated)
Profile Applicability:
Page 119
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
Execute these commands:
#### 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: This will lock the 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';
Run MySQL Enterprise Backup with encryption.
For example:
$ mysqlbackup --defaults-file=/home/dbadmin/my.cnf --backup-
image=/home/admin/backups/my.mbi \
--backup-dir=/home/admin/backup-tmp --encrypt-password backup-to-image
Default Value:
At rest encryption is off by default.
Administrators can force tables or tablespaces to be encrypted for all schemas by
default by setting in my.cnf.
default-table-encryption=ON
or Per schema by defining DEFAULT ENCRYPTION:
CREATE {DATABASE | SCHEMA} ...
| DEFAULT ENCRYPTION [=] {'Y' | 'N'}
References:
1. https://dev.mysql.com/doc/refman/8.0/en/innodb-data-encryption.html
Page 120
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
Page 121
5 MySQL Permissions
This section contains recommendations about user privileges.
Page 122
5.1 Ensure Only Administrative Users Have Full Database Access
(Manual)
Profile Applicability:
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:
Execute the following SQL statement(s) to assess this recommendation:
select * from information_schema.user_privileges
where grantee not like ('\'mysql.%localhost\'');
Ensure all users returned are administrative users with minimal privileges required.
The above query ignores MySQL internal reserved accounts.
Remediation:
Perform the following actions to remediate this setting:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/information-schema-user-privileges-
table.html
2. https://dev.mysql.com/doc/refman/8.0/en/reserved-accounts.html
Page 123
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
Page 124
5.2 Ensure 'FILE' is Not Granted to Non-Administrative Users
(Manual)
Profile Applicability:
Description:
The FILE privilege is used to allow or disallow a user from reading and writing files on
the server host. Any user with the FILE 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 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:
Execute the following SQL statement to audit this setting:
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE PRIVILEGE_TYPE = 'FILE';
Ensure only administrative users are returned in the result set.
Remediation:
Perform the following steps to remediate this setting:
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. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_file
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
Page 125
Additional Information:
See also: secure_file_priv system settings.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 126
5.3 Ensure 'PROCESS' is Not Granted to Non-Administrative
Users (Manual)
Profile Applicability:
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:
Execute the following SQL statement to audit this setting:
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE PRIVILEGE_TYPE = 'PROCESS';
Ensure only administrative users are returned in the result set.
Remediation:
Perform the following steps to remediate this setting:
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. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_process
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
Page 127
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 128
5.4 Ensure 'SUPER' is Not Granted to Non-Administrative Users
(Manual)
Profile Applicability:
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.
The SUPER privilege shown in the INFORMATION_SCHEMA.USER_PRIVILEGES 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.
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:
Execute the following SQL statement to audit this setting:
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE PRIVILEGE_TYPE = 'SUPER’;
Ensure only administrative users are returned in the result set.
Page 129
Remediation:
Perform the following steps to remediate this setting:
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. https://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
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 130
5.5 Ensure 'SHUTDOWN' is Not Granted to Non-Administrative
Users (Manual)
Profile Applicability:
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:
Execute the following SQL statement to audit this setting:
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE PRIVILEGE_TYPE = 'SHUTDOWN';
Ensure only administrative users are returned in the result set.
Remediation:
Perform the following steps to remediate this setting:
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. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_shutdown
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
Page 131
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 132
5.6 Ensure 'CREATE USER' is Not Granted to Non-Administrative
Users (Manual)
Profile Applicability:
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:
Execute the following SQL statement to audit this setting:
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE PRIVILEGE_TYPE = 'CREATE USER';
Ensure only administrative users are returned in the result set.
Remediation:
Perform the following steps to remediate this setting:
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. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_create-
user
Page 133
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 134
5.7 Ensure 'GRANT OPTION' is Not Granted to Non-
Administrative Users (Manual)
Profile Applicability:
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 OPTION privilege allows a principal to grant other principals additional
privileges. This may be used by an attacker to compromise MySQL.
Audit:
Execute the following SQL statements to audit this setting:
SELECT DISTINCT GRANTEE
FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE IS_GRANTABLE = 'YES';
Ensure only administrative users are returned in the result set.
Remediation:
Perform the following steps to remediate this setting:
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. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#priv_grant-
option
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
Page 135
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 136
5.8 Ensure 'REPLICATION SLAVE' is Not Granted to Non-
Administrative Users (Manual)
Profile Applicability:
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:
Execute the following SQL statement to audit this setting:
SELECT GRANTEE
FROM INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE PRIVILEGE_TYPE = 'REPLICATION SLAVE';
Ensure only accounts designated for replica users are granted this privilege.
Remediation:
Perform the following steps to remediate this setting:
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 REPLICATION SLAVE privilege from users
who shouldn't have it.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/privileges-
provided.html#priv_replication-slave
2. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html#privileges-
provided-summary
Page 137
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 138
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:
Execute the following SQL statement to audit this setting:
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:
Perform the following steps to remediate this setting:
1. Enumerate the unauthorized users, hosts, and databases returned in the result
set of the audit procedure
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):
Page 139
REVOKE SELECT ON <host>.<database> FROM <user>;
REVOKE INSERT ON <host>.<database> FROM <user>;
REVOKE UPDATE ON <host>.<database> FROM <user>;
REVOKE DELETE ON <host>.<database> FROM <user>;
REVOKE CREATE ON <host>.<database> FROM <user>;
REVOKE DROP ON <host>.<database> FROM <user>;
REVOKE ALTER ON <host>.<database> FROM <user>;
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 140
5.10 Securely Define Stored Procedures and Functions DEFINER
and INVOKER (Manual)
Profile Applicability:
Description:
Stored procedure and stored function declarations include a definition of permissions
which can be used to escalate permissions. It's important to inspect these settings to
ensure they do not unnecessarily escalate privileges.
Rationale:
A stored procedure or function that improperly escalates privileges may provide
unintended access rights which can be improperly used.
Audit:
Run the following:
SHOW PROCEDURE STATUS;
SHOW FUNCTION STATUS;
Inspect Definer and Invoker security types.
If DEFINER is a powerful user consider that user's permissions.
If INVOKER then the rights for the stored procedure or function are that of the user
executing these.
Review code using
SHOW CREATE PROCEDURE <name>;
SHOW CREATE FUNCTION <name>;
For more details on Procedures and Functions
SELECT * FROM information_schema.routines;
For more details on Procedures and Functions input and output parameters.
SELECT * FROM information_schema.parameters;
Remediation:
Drop and recreate stored procedures and functions using proper DEFINER and
INVOKER settings, or other code changes.
Page 141
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
Page 142
6 Auditing and Logging
This section provides guidance with respect to MySQL's logging behavior.
Page 143
6.1 Ensure 'log_error' is configured correctly (Automated)
Profile Applicability:
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:
Execute the following SQL statement to audit this setting:
SHOW variables LIKE 'log_error';
Ensure the Value returned is a path to a file and not ./stderr.err.
Remediation:
Perform the following actions to remediate this setting:
Default Value:
./stderr.err
References:
1. https://dev.mysql.com/doc/refman/8.0/en/error-log.html
Page 144
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 145
6.2 Ensure Log Files are Stored on a Non-System Partition
(Automated)
Profile Applicability:
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:
Execute the following SQL statement to assess this recommendation:
SELECT @@global.log_bin_basename;
Ensure the value returned does not indicate root (/), /var, or /usr.
Remediation:
Perform the following actions to remediate this setting:
References:
1. https://dev.mysql.com/doc/refman/8.0/en/binary-log.html
2. https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 146
Controls
Control IG 1 IG 2 IG 3
Version
Page 147
6.3 Ensure 'log_error_verbosity' is Set to '2' (Automated)
Profile Applicability:
Rationale:
This might help to detect malicious behavior by logging communication errors and
aborted connections.
Audit:
Execute the following SQL statement to assess this recommendation:
SHOW GLOBAL VARIABLES LIKE 'log_error_verbosity';
Ensure the Value returned equals 2.
Remediation:
Perform the following actions to remediate this setting:
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
Page 148
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 149
6.4 Ensure 'log-raw' is Set to 'OFF' (Automated)
Profile Applicability:
Remediation:
Perform the following actions to remediate this setting:
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
Page 150
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 151
6.5 Ensure Audit Filters Capture Connection Attempts (Manual)
Profile Applicability:
Page 152
{ "timestamp": "2020-03-19 20:13:40", "id": 0, "class": "connection",
"event": "connect", "connection_id": 30, "account": { "user": "", "host":
"localhost" }, "login": { "user": "app_developer", "os": "", "ip":
"127.0.0.1", "proxy": "" }, "connection_data": { "connection_type": "ssl",
"status": 1045, "db": "" } }
Successful Connections will show a successful status value - "status": 0
{ "timestamp": "2020-03-19 21:04:13", "id": 1, "class": "connection",
"event": "connect", "connection_id": 38, "account": { "user": "newuser",
"host": "localhost" }, "login": { "user": "newuser", "os": "", "ip":
"127.0.0.1", "proxy": "" }, "connection_data": { "connection_type": "ssl",
"status": 0, "db": "", "connection_attributes": { "_pid": "4971", "_os":
"macos10.14", "_platform": "x86_64", "_client_version": "8.0.18",
"_client_name": "libmysql", "program_name": "MySQLWorkbench" } } },
Remediation:
To remediate this configuration setting, execute one of the following SQL statements:
Log All connections – Successful and Failed:
SET @f = '{ "filter": { "class": { "name": "connection" } } }';
SELECT audit_log_filter_set_filter('log__all_conn_events', @f);
SELECT audit_log_filter_set_user('%', 'log_all_conn_events');
Or Log Only Failed Connections:
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');
Default Value:
The default value for audit_log_connection_policy is ALL.
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
Page 153
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
Page 154
6.6 Ensure ALL Events are Audited (Automated)
Profile Applicability:
Remediation:
Create Log All Filter:
Page 155
SELECT audit_log_filter_set_filter('log_all', '{ "filter": { "log": true }
}');
Apply to all logins:
SELECT audit_log_filter_set_user('%', 'log_all');
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
Page 156
6.7 Set audit_log_strategy to SYNCHRONOUS or
SEMISYNCRONOUS (Automated)
Profile Applicability:
Description:
The audit_log_strategy must be set to SYNCHRONOUS or SEMISYNCHRONOUS
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:
To assess this recommendation, execute the following SQL statement:
SHOW GLOBAL VARIABLES LIKE 'audit_log_strategy';
The result should be SYNCHRONOUS or SEMISYNCHRONOUS
Remediation:
To remediate this configuration:
Default Value:
ASYNCHRONOUS
References:
1. https://dev.mysql.com/doc/refman/8.0/en/audit-log-
reference.html#sysvar_audit_log_strategy
Page 157
Additional Information:
Also consider the load strategy.
audit-log= ON, FORCE, or FORCE_PLUS_PERMANENT
For example, most secure is to set --audit-log=FORCE_PLUS_PERMANENT
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
Page 158
6.8 Ensure the Audit Plugin Can't be Unloaded (Automated)
Profile Applicability:
Rationale:
This disables unloading on the plugin.
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:
To assess this recommendation, execute the following SQL statement:
SELECT LOAD_OPTION FROM information_schema.plugins WHERE
PLUGIN_NAME='audit_log';
The result must be FORCE_PLUS_PERMANENT
Remediation:
To remediate this setting, follow these steps:
audit_log = 'FORCE_PLUS_PERMANENT'
Default Value:
ON
References:
1. https://dev.mysql.com/doc/refman/8.0/en/audit-log-
reference.html#option_mysqld_audit-log
Page 159
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 160
7 Authentication
This section contains configuration recommendations that pertain to the authentication
mechanisms of MySQL.
Page 161
7.1 Ensure default_authentication_plugin is Set to a Secure
Option (Automated)
Profile Applicability:
Description:
The –default-authentication-plugin system variable governs two things:
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:
Execute the following SQL statement to assess this recommendation:
SHOW VARIABLES WHERE Variable_name = 'default_authentication_plugin';
Ensure the Value field is not set to mysql_native_password.
Remediation:
Configure mysql to default to the caching_sha2_password plugin.
Require caching_sha2_password plugin to be used by default for new accounts.
Edit my.cnf, in the section [mysqld] add:
default_authentication_plugin=caching_sha2_password
Determine if any users are using mysql_native_password.
Page 162
select host, user, plugin from mysql.user;
Migrate these users from mysql_native_password.
ALTER USER user
IDENTIFIED WITH caching_sha2_password IDENTIFIED BY RANDOM PASSWORD
PASSWORD EXPIRE;
Provide users the random password value through a secure mechanism - on next login
they will be forced to change the password.
Default Value:
New users default to caching_sha2_password. Migrated users will initially be
mysql_native or other authentication method.
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
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 163
7.2 Ensure Passwords are Not Stored in the Global Configuration
(Automated)
Profile Applicability:
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:
To assess this recommendation, perform the following steps:
Remediation:
Use the mysql_config_editor to store authentication credentials in .mylogin.cnf in
encrypted form.
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
Additional Information:
There must not be a password in any of the sections of the global configuration.
Page 164
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 165
7.3 Ensure Passwords are Set for All MySQL Accounts
(Automated)
Profile Applicability:
Description:
Blank passwords allow a user to login without using a password.
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);
No rows will be returned if all accounts have a password set.
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.
Note: Replace <user>, <host> with appropriate values.
References:
1. https://dev.mysql.com/doc/refman/8.0/en/assigning-passwords.html
Page 166
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 167
7.4 Set 'default_password_lifetime' to Require a Yearly Password
Change (Automated)
Profile Applicability:
Description:
Password expiry provides passwords with a time bounded lifetime.
Rationale:
The default_password_lifetime global variable prevents a password being set for an
indefinite period. Excessive password expiration requirements do more harm than good,
because these requirements make users select predictable passwords, composed of
sequential words and numbers that are closely related to each other. More importantly,
when events occur that could compromise password security account passwords
should be expired immediately.
Impact:
Scripted clients or users dependent on automated login in a controlled environment will
need to consider their authentication procedures. The server will accept the user but the
user is placed in restricted mode. In restricted mode, operations performed within the
session result in an error until the user establishes a new account password.
Audit:
Execute the following SQL statements to assess this recommendation:
SHOW VARIABLES LIKE 'default_password_lifetime';
The result should not be 0 and less than or equal to 365.
Remediation:
To remediate this recommendation, execute the following command:
SET GLOBAL default_password_lifetime=365;
Default Value:
360
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
Page 168
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 169
7.5 Ensure Password Complexity Policies are in Place
(Automated)
Profile Applicability:
Description:
Password complexity includes password characteristics such as length, case,
numerical, and character sets.
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:
Execute the following to see if the password validation component is installed:
select * from mysql.component where component_urn like '%validate_password';
If no rows are returned, this check fails.
Execute the following SQL statements to assess this recommendation:
SHOW VARIABLES LIKE 'validate_password%';
The result set from the above statement should show:
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:
Page 170
The following may make the password complexity too difficult, use sparingly.
Remediation:
Install component_validate_password component:
INSTALL COMPONENT 'file://component_validate_password';
Persist following configuration:
SET PERSIST validate_password.length=14;
SET PERSIST validate_password.check_user_name=ON;
SET PERSIST validate_password.dictionary_file=<path to dictionary file>;
SET PERSIST validate_password.policy=STRONG;
Optionally set one or more of these - ensuring complexity is not overly onerous
SET PERSIST validate_password.mixed_case_count=1;
SET PERSIST validate_password.number_count=1;
SET PERSIST validate_password.special_char_count=1;
And change passwords for users which have passwords which are identical to their
username.
Default Value:
By default component_validate_password is not installed.
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
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.
Page 171
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 172
7.6 Ensure No Users Have Wildcard Hostnames (Automated)
Profile Applicability:
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:
Execute the following SQL statement to assess this recommendation:
SELECT user, host FROM mysql.user WHERE host = '%';
Ensure no rows are returned.
Remediation:
Perform the following actions to remediate this setting:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 173
7.7 Ensure No Anonymous Accounts Exist (Automated)
Profile Applicability:
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
3. https://dev.mysql.com/doc/refman/8.0/en/proxy-users.html#proxy-users-conflicts
Page 174
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 175
8 Network
This section contains recommendations related to how the MySQL server uses the
network.
Page 176
8.1 Ensure 'require_secure_transport' is Set to 'ON' and/or
'have_ssl' is Set to 'YES' (Automated)
Profile Applicability:
Description:
All network traffic must use SSL/TLS when traveling over untrusted networks.
Rationale:
Enabling Secure Sockets Layer (SSL) will allow clients to encrypt network traffic and
verify the identity of the server. The SSL/TLS-protected MySQL protocol helps to
prevent eavesdropping and man-in-the-middle attacks.
Impact:
Enabling SSL could have impact on network traffic inspection.
Audit:
Execute the following SQL statements to assess this recommendation:
Check the global default.
select @@require_secure_transport;
Ensure the returned Value is ON or '1'
SHOW variables WHERE variable_name = 'have_ssl';
Or if MySQL is built with OpenSSL:
SHOW variables WHERE variable_name = 'have_openssl';
Ensure the Value returned is YES.
Note: have_openssl is an alias for have_ssl when MySQL is built with OpenSSL.
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:
set persist require_secure_transport=ON;
Default Value:
DISABLED
Page 177
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
4. https://dev.mysql.com/doc/refman/8.0/en/server-system-
variables.html#sysvar_have_openssl
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 178
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:
The SSL/TLS-protected MySQL protocol helps to prevent eavesdropping and man-in-
the-middle attacks.
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:
Execute the following SQL statements to assess this recommendation:
SELECT user, host, ssl_type FROM mysql.user
WHERE NOT HOST IN ('::1', '127.0.0.1', 'localhost');
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:
Use the ALTER USER statement to require the use of SSL:
ALTER USER 'my_user'@'app1.example.com' REQUIRE X509;
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)
Page 179
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
Page 180
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:
To check global (default) concurrent-sessions settings in the MySQL database server,
to check the per user default run the query:
SELECT VARIABLE_NAME, VARIABLE_VALUE
FROM performance_schema.global_variables
WHERE VARIABLE_NAME LIKE 'max_%connections';
If the value of max_user_connections is 0 this means there is “no limit”.
If the value of max_connections is not set, there is no limit.
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';
If the value is 0 this means the global value of max_user_connections applies.
If no limits are configured this is a fail.
Remediation:
Connect to the MySQL Database as an administrator.
For example, to set the global default per user to 50 run the command:
SET PERSIST max_user_connections=50;
To control the maximum number of clients the server permits to connect simultaneously,
set the max_connections system variable:
Page 181
SET PERSIST max_connections=1000;
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:
ALTER USER 'fred'@'localhost'
WITH MAX_CONNECTIONS_PER_HOUR 5
MAX_USER_CONNECTIONS 2;
Default Value:
The default value of max_connections is 151, max_user_connections is 0 (unlimited, thus
limited by max_connections).
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
Page 182
9 Replication
Everything related to replicating data from one server to another.
Page 183
9.1 Ensure Replication Traffic is Secured (Manual)
Profile Applicability:
• 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.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 184
Controls
Control IG 1 IG 2 IG 3
Version
Page 185
9.2 Ensure 'SOURCE_SSL_VERIFY_SERVER_CERT' is Set to
'YES' or '1' (Automated)
Profile Applicability:
Description:
In the MySQL REPLICA (SLAVE is deprecated as of 8.0.22) context the setting
SOURCE_SSL_VERIFY_SERVER_CERT (MASTER_SSL_VERIFY_SERVER_CERT is deprecated as of
8.0.22) indicates whether the REPLICA should verify the SOURCE's certificate. This
configuration item may be set to Yes or No, and unless SSL has been enabled on the
REPLICA, the value will be ignored.
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:
To assess this recommendation, issue the following statement:
select ssl_verify_server_cert from mysql.slave_master_info;
Verify the value of ssl_verify_server_cert is 1.
Page 186
Remediation:
To remediate this setting, you must use the CHANGE SOURCE TO command.
From 8.0.23:
STOP REPLICA; -- required if replication was already running
CHANGE REPLICATION SOURCE TO SOURCE_SSL_VERIFY_SERVER_CERT=1;
START REPLICA; -- required if you want to restart replication
Prior to 8.0.23:
STOP SLAVE; -- required if replication was already running
CHANGE MASTER TO MASTER_SSL_VERIFY_SERVER_CERT=1;
START SLAVE; -- required if you want to restart replication
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
Page 187
9.3 Ensure 'master_info_repository' is Set to 'TABLE' (Automated)
Profile Applicability:
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:
Execute the following SQL statement to assess this recommendation:
SHOW GLOBAL VARIABLES LIKE 'master_info_repository';
The result should be TABLE instead of FILE.
Note: There also should not be a source.info or master.info file in the datadir.
Remediation:
Perform the following actions to remediate this setting:
Default Value:
TABLE
References:
1. https://dev.mysql.com/doc/refman/8.0/en/replication-options-
replica.html#sysvar_master_info_repository
Page 188
9.4 Ensure 'super_priv' is Not Set to 'Y' for Replication Users
(Automated)
Profile Applicability:
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:
Execute the following SQL statement to audit this setting:
select user, host from mysql.user where user='repl' and Super_priv = 'Y';
No rows should be returned.
If you wish to validate permissions in more detail:
select * from mysql.user where user='repl'\G
The following columns should return Y.
Page 189
*************************** 1. row ***************************
Select_priv: Y
Reload_priv: Y
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
Remediation:
Execute the following steps to remediate this setting:
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):
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
Page 190
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 191
10 MySQL InnoDB Cluster / Group Replication
MySQL InnoDB cluster provides a complete high availability solution for MySQL.
MySQL Shell includes AdminAPI which enables you to easily configure and administer
a group of at least three MySQL server instances to function as an InnoDB cluster.
Each MySQL server instance runs MySQL Group Replication, which provides the
mechanism to replicate data within InnoDB clusters, with built-in failover. AdminAPI
removes the need to work directly with Group Replication in InnoDB clusters.
Various things can be configured to enhance the security of MySQL InnoDB Cluster.
Page 192
10.1 Ensure All Group Replication Traffic is Secured (Manual)
Profile Applicability:
Remediation:
Edit my.cnf and set group_replication_ssl_mode, for example:
group_replication_ssl_mode=REQUIRED
Acceptable values are:
Page 193
• VERIFY_IDENTITY - Like VERIFY_CA, but additionally verify that the server
certificate matches the host to which the connection is being established.
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
Page 194
10.2 Allowlist Approved Servers Belonging to a MySQL InnoDB
Cluster (Manual)
Profile Applicability:
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:
Example - to configure a cluster to only accept connections from servers at addresses
203.0.113.0/24 and 198.51.100.110. The whitelist can also include host names, which
are resolved only when a connection request is made by another server.
• From 8.0.22:
• Prior to 8.0.22:
Page 195
mysql-js> cluster.addInstance("icadmin@ic-3:3306", {ipWhitelist:
"203.0.113.0/24, 198.51.100.110"})
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
Page 196
Appendix: Summary Table
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 197
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 198
CIS Benchmark Recommendation Set
Correctly
Yes No
3 File Permissions
4 General
Page 199
CIS Benchmark Recommendation Set
Correctly
Yes No
5 MySQL Permissions
Page 200
CIS Benchmark Recommendation Set
Correctly
Yes No
7 Authentication
Page 201
CIS Benchmark Recommendation Set
Correctly
Yes No
8 Network
8.3 Set Maximum Connection Limits for Server and per User
(Manual)
9 Replication
Page 202
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 203
Appendix: Change History
Date Version Changes for this version
Apr 14, 2021 1.0.0 Least Priv MySQL Account should not
have shell access (Ticket 10283)
Page 204
Date Version Changes for this version
Apr 14, 2021 1.0.0 Add section - limit host IP using bind
(Ticket 10363)
Apr 14, 2021 1.0.0 Add to dual password audit the following
SQL (Ticket 10373)
Page 205
Date Version Changes for this version
Apr 14, 2021 1.0.0 Change title and update content (Ticket
10323)
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)
Page 206
Date Version Changes for this version
Apr 14, 2021 1.0.0 Better to set global policy than per user.
(Ticket 10296)
Apr 14, 2021 1.0.0 First reference link is not existing (Ticket
12331)
Page 207
Date Version Changes for this version
Page 208