Rule ID
SV-286188r1292185_rule
Version
V1R1
CCIs
Information systems are capable of providing a wide variety of functions and services. Some of the functions and services, provided by default, may not be necessary to support essential organizational operations (e.g., key missions, functions). It is detrimental for applications to provide or install by default functionality exceeding requirements or mission objectives. Applications must adhere to the principles of least functionality by providing only essential capabilities. MariaDB may spawn additional external processes to execute procedures that are defined in MariaDB but stored in external host files (external procedures). The spawned process used to execute the external procedure may operate within a different OS security context than MariaDB and provide unauthorized access to the host system.
Log in to the MariaDB Enterprise Server as a database administrator. Verify whether the "local_infile" option is enabled: SHOW GLOBAL VARIABLES LIKE 'local_infile'; If "local_infile" is enabled (ON), review all database accounts and their assigned privileges to ensure only authorized users have the ability to perform file operations. List all database accounts: SELECT USER, HOST FROM mysql.global_priv; Execute the following for each account returned: SHOW GRANTS FOR 'user'@'host'; Replace user and host with the values returned from the previous query. Review each grant for the presence of: FILE GRANT OPTION Review the grants assigned to each role using: SHOW GRANTS FOR role_name; Review the output to determine whether the FILE privilege or the ability to grant that privilege has been assigned only to authorized users or roles. If local_infile is enabled and any unauthorized user or role possesses the FILE privilege or GRANT OPTION, this is a finding.
To disable LOAD DATA LOCAL INFILE, run the following command as the database administrator (shown here as root). Disable local_infile for the running server: SET GLOBAL local_infile = OFF; Configure the server startup option to make the change persistent across server restarts: [mariadb] local_infile=OFF Restart the MariaDB Enterprise server, if required, for the configuration change to take effect. If local_infile must remain enabled to support operational requirements, then ensure only authorized users have the FILE privilege. Review database accounts: SELECT USER, HOST FROM mysql.global_priv; Review the assigned privileges for each account returned: SHOW GRANTS FOR 'user'@'host'; If an unauthorized account has the FILE privilege, revoke it: REVOKE FILE ON *.* FROM 'user'@'host'; If an unauthorized account has the GRANT OPTION privilege, revoke the unauthorized privilege or revoke the privileges that include GRANT OPTION. Review the privileges assigned to each role: SHOW GRANTS FOR role_name; Revoke the FILE privilege from any role that is not authorized to perform file operations. Verify the following after making the changes: SHOW GLOBAL VARIABLES LIKE 'local_infile'; Returns only authorized users or roles retain the FILE privilege.