Skip to content

Database audit fixes

Configuration & Hardening: fixing all 7 checks

The configuration and hardening audit covers how the engine is run and backed up: the OS user it executes as, installer defaults left in place, pending engine patches and who can read your dumps.

Most skips here mean nothing was found to look at rather than nothing was wrong: the two backup checks search only /var/backups, /backup, /opt/backup, /srv/backup and /root/backups, three levels deep, for .sql, .sql.gz, .dump and .bak files, so dumps kept anywhere else report SKIP. The service user check skips when no mysqld, mariadbd, postgres, mongod or redis-server process is running at that moment, and Insecure Database Defaults and Transaction Log Placement skip without a root socket login to the engine.

CtrlOpsConfiguration & Hardening audit7 CHECKS
Checks in this audit
7
Rated high severity
4
Need root or sudo
5
Automated run time
~19s

Transcribed from the database-security-hardening audit script. For what the audit covers rather than how to fix it, see the Configuration & Hardening checklist, or how the CtrlOps Security Audit runs.

Every check

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.

  1. 01Database Service UserChecks whether running database engines execute as a dedicated unprivileged user rather than rootSeverity: HIGHNo root neededCan return FAIL · SKIP · PASS
  2. 02Insecure Database DefaultsChecks each detected engine for installer defaults left in place after setupSeverity: LOWNeeds rootCan return WARN · SKIP · PASS
  3. 03Database PatchesChecks for pending package and security updates for the installed database enginesSeverity: HIGHNo root neededCan return FAIL · WARN · SKIP · PASS
  4. 04Transaction Log PlacementChecks whether transaction and binary logs share the same disk as the database data filesSeverity: LOWNeeds rootCan return WARN · SKIP · PASS
  5. 05Scheduled Database BackupsChecks cron jobs and systemd timers for a scheduled database backupSeverity: MEDIUMNeeds rootCan return WARN · PASS
  6. 06Backup File PermissionsChecks whether database dump files in common backup paths are world-readableSeverity: HIGHNeeds rootCan return FAIL · SKIP · PASS
  7. 07Backup EncryptionWhether database dumps are encrypted at restSeverity: HIGHNeeds rootCan return FAIL · WARN · SKIP · PASS

Shared script behaviour

How the Configuration & Hardening 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.

The preamble

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.

Why checks skip

A SKIP is never a pass

A skipped check verified nothing at all. The most common cause is privilege: 5 of the 7 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.

rootThe audit runs as UID 0.Every privileged branch runs directly. No check skips for lack of permission.
nopasssudo -n true succeeds, so the account has passwordless sudo.Privileged commands run through sudo -n.
passA sudo password was supplied in the CtrlOps audit settings and accepted.Privileged commands run through sudo -S.
noneSKIPNone 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.

Keep going

FAQ

Configuration & Hardening questions

Can't find your answer? Join Discord

  • The check greps /etc/crontab, /etc/cron.d and the cron.hourly, cron.daily, cron.weekly and cron.monthly directories, plus /var/spool/cron when it has root, for mysqldump, mariadb-dump, pg_dump, pg_basebackup, mongodump, xtrabackup, mariabackup, borg or restic, then falls back to any systemd timer whose unit name contains backup or dump. Anything scheduled elsewhere is a false WARN: provider snapshots, a backup server that pulls over SSH, Kubernetes CronJobs, WAL archiving through archive_command, pgBackRest or Barman. A cron line that calls a wrapper script matches only if the script name itself contains one of those keywords, because the script body is never read.

  • It means every dump file the check could see is not world-readable, and nothing beyond that. It reads file modes only, so a 700 parent directory is not credited and a loose one is not penalised, and it looks nowhere outside the five backup paths, including offsite copies. Run without root it cannot enter /root/backups and says so in the message. Whether those dumps are encrypted is a separate check, and a mode 600 plaintext dump is still the whole database in one file.

  • On Debian and Ubuntu the count comes from a simulated apt-get upgrade filtered to mysql, mariadb, postgres, mongo and redis packages, and it becomes a FAIL rather than a WARN only when a matching line mentions security. Upgrading those packages restarts the engine on most distributions, so plan it as a maintenance window rather than running it inline. The numbers come from the cached package lists, so refresh with apt update first if the host has not done so recently, and note that held packages, tarball installs and engines inside containers never appear here at all.

Stop juggling tools. Start managing fleets.

PuTTY
Termius
MobaXterm
WinSCP
SecureCRT
Royal TS
Warp
CtrlOps14 tools left
Webmin
aaPanel
RunCloud
Dokploy
IP spreadsheet
bash (2)
sticky notes

One app. All your servers. No context switching. Free to start, free to leave.

Start instantly · No credit card · Cancel anytime

Your privacy preferences. We use product analytics to improve CtrlOps. Google Analytics cookies and live chat stay off until you allow them. Cookie policy