Database audit fixes
Least-Privilege Permissions: fixing all 6 checks
The least-privilege audit queries mysql.user, pg_roles and pg_hba.conf for the grants that turn one SQL injection into server-wide access: the % wildcard host, FILE, SUPER and superuser.
All six checks read the engine's own catalogue, so each needs a working root login to it (mysql -N -e "SELECT 1" as root, or psql as the postgres user), and a database that is up but unreachable to the audit account reports six skips rather than six passes. A host carrying only the mysql or psql client still counts as having the engine, so it skips the same way even though there is no server on it.
Transcribed from the database-security-least-privilege audit script. For what the audit covers rather than how to fix it, see the Least-Privilege Permissions checklist.
Find your finding
Listed in the order the audit runs them. Take the check name from the third field of the result line and open its page.
MySQL Wildcard Hosts
SoonChecks for MySQL accounts using the % wildcard host, which accept connections from any address
MediumNeeds root3 resultsMySQL FILE Privilege
SoonChecks whether any non-system MySQL account holds the FILE privilege to read and write server files
MediumNeeds root3 resultsMySQL File Import/Export
SoonChecks whether MySQL secure_file_priv confines file import/export and whether local_infile is enabled
MediumNeeds root3 resultsMySQL Admin Accounts
SoonChecks for MySQL accounts holding SUPER beyond the expected system accounts
MediumNeeds root3 resultsPostgreSQL Superusers
SoonChecks for PostgreSQL superuser roles beyond the built-in postgres role
MediumNeeds root3 resultsPostgreSQL Allowed Hosts
SoonChecks pg_hba.conf for host entries that accept connections from any address
MediumNeeds root3 results
How the Least-Privilege Permissions audit reads your server
Every check in this audit runs after the same preamble, and several of its results only make sense once you know what that preamble could and could not see.
All need root socket access (MYOK / PGOK).
Engine detection: HAS_MY, HAS_PG, HAS_MG, HAS_RD are set from client binaries, server processes or config directories. MYOK=1 only if mysql -N -e 'SELECT 1' works as root over the socket; PGOK=1 only if su postgres -c 'psql -X -tAc "SELECT 1"' works. RDCONF is /etc/redis/redis.conf or /etc/redis.conf; MGCONF is /etc/mongod.conf. Containerised databases are not detected by these probes; audit them with the Docker checks or exec into the container.
A SKIP is never a pass
A skipped check verified nothing at all. The most common cause is privilege: 6 of the 6 checks in this audit need root for a complete result. Before every run, each script works out which of four privilege modes it is in.
| Mode | How it is reached | What it means for your results |
|---|---|---|
root | The audit runs as UID 0. | Every privileged branch runs directly. No check skips for lack of permission. |
nopass | sudo -n true succeeds, so the account has passwordless sudo. | Privileged commands run through sudo -n. |
pass | A sudo password was supplied in the CtrlOps audit settings and accepted. | Privileged commands run through sudo -S. |
none | None of the above worked. | CAN_ROOT=0. Every privileged branch returns SKIP with a "Need root" message rather than guessing. |
If many checks skip with a “need root” message, run the audit as root, grant the audit account sudo (with or without NOPASSWD), or supply the sudo password in the CtrlOps audit settings.
Least-Privilege Permissions questions
Run all 6 Least-Privilege Permissions checks, in one click
CtrlOps runs this audit over your existing SSH connection - no agents, no scripts to manage. $7/user/month after a 1 month free trial - no credit card required.
✓ Start instantly·✓ No credit card·✓ No sneaky autorenewals