1.7 Ensure MariaDB is Run Under a Sandbox Environment

Information

Use of the chroot() system call at startup, Systemd with settings to achieve isolation, or docker will put MariaDB in a Sandbox environment.

Rationale:

Running MariaDB in a Sandbox environment may reduce the impact of a MariaDB-born vulnerability by making portions of the file system inaccessible to the MariaDB instance.

Impact:

Use of the chroot option somewhat limits LOAD DATA INFILE and SELECT ... INTO OUTFILE.

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

Solution

Perform one of the following steps to remediate this setting:

Configure MariaDB to use chroot:

Choose a non-system partition <chroot location> for MariaDB

Add chroot=<chroot_location> to the my.cnf option file

Configure MariaDB to run under systemd:

If MariaDB is managed by systemd and running, stop the service:

$ sudo systemctl stop <mysqld>.service

If a mysql user and group do not already exist, create them:

$ sudo groupadd mysql
$ sudo useradd -r -g mysql -s /bin/false mysql

Set the ownership of the base directory:

$ sudo chown -R mysql:mysql /usr/local/mysql/

Create or modify the <mysqld>.service file in /lib/systemd/system to include the following entries, if not already present:

[Unit]
Description=MariaDB Server

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql

If MariaDB was not already managed by systemd execute this command:

$ sudo systemctl daemon-reload

Start the MariaDB server:

$ sudo systemctl start <mariadb>.service

If you would like MariaDB to automatically run at startup execute this command:

$ sudo systemctl enable <mariadb>.service

Follow documentation in the references for standing up MariaDB in a Docker container.

See Also

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

Item Details

Category: SYSTEM AND COMMUNICATIONS PROTECTION

References: 800-53|SC-4, CSCv7|2.10

Plugin: MySQLDB

Control ID: 3400b8a2a109ff2b1d59e06b192a31f7e8f9cc7431d25002375669d4ef003458