Ubuntu · Logging & auditing

Build the AIDE database and check file integrity every day

When it fails: File integrity is never checked. Without a reference database and a regular check, AIDE cannot report modified system files.

CB-UBU-AUDIT-034mediumactiveautomatedautomated fixprofile core

Description

AIDE needs a reference database, /var/lib/aide/aide.db, built with aideinit from the current state of the system. aide-common then runs a daily check, which compares the files with the database and writes a report to /var/log/aide/ (and mails it when a mail transport is installed):

  • from Ubuntu 24.04 (AIDE 0.18 and later), with dailyaidecheck.timer;
  • on Ubuntu 20.04 and 22.04 (AIDE 0.16 and 0.17), with the cron job /etc/cron.daily/aide, which CRON_DAILY_RUN=no in /etc/default/aide turns off.

This control requires the database to exist and the daily check to be enabled.

Build the database once the system is in its intended state: run this fix after the other hardening fixes, or rebuild the database afterwards with aideinit -y -f, otherwise the first reports list every change made by the hardening.

Rationale

The database is the trusted reference; the daily check turns it into detection. Without either, an installed AIDE gives a false sense of protection.

Impact

Building the database reads every covered file: a few minutes and a short burst of disk activity. The daily check does the same. After legitimate changes (upgrades, configuration), review the report and update the database (aide --update, then replace aide.db with aide.db.new).

Setting

Location/var/lib/aide/aide.db, dailyaidecheck.timer (20.04 and 22.04 - /etc/cron.daily/aide)
DefaultNo database; daily check enabled when aide-common is installed
RecommendedDatabase present, daily check enabled

Audit

  1. Run ls -l /var/lib/aide/aide.db. The file must exist and not be empty.
  2. Ubuntu 24.04 and later: run systemctl is-enabled dailyaidecheck.timer. It must print enabled. Ubuntu 20.04 and 22.04: /etc/cron.daily/aide must be executable and /etc/default/aide must not set CRON_DAILY_RUN=no.
  3. Read the last report in /var/log/aide/ and check that differences are explained.

Automated: every check must pass. Scanners report each check by its id.

database

The AIDE reference database exists.

script: |
  if [ -s /var/lib/aide/aide.db ]; then
    ls -l /var/lib/aide/aide.db
  else
    echo "/var/lib/aide/aide.db missing or empty"
    exit 1
  fi

timer

dailyaidecheck.timer is enabled.

unit: dailyaidecheck.timer
state: enabled

cron

The daily AIDE cron job is present and not turned off (AIDE 0.16 and 0.17).

script: |
  [ -x /etc/cron.daily/aide ] || { echo "/etc/cron.daily/aide missing or not executable"; exit 1; }
  v=$(sed -n 's/^[[:space:]]*CRON_DAILY_RUN=//p' /etc/default/aide 2>/dev/null | tail -n 1 | tr -d "\"'")
  echo "/etc/cron.daily/aide present, CRON_DAILY_RUN=${v:-yes (default)}"
  [ "${v:-yes}" = yes ]

Remediation

  1. Run aideinit -y -f and wait for it to finish (a few minutes).
  2. Ubuntu 24.04 and later: run systemctl enable --now dailyaidecheck.timer. Ubuntu 20.04 and 22.04: run chmod 755 /etc/cron.daily/aide and set CRON_DAILY_RUN=yes (or remove the line) in /etc/default/aide.
Restartnone
Disruptionlow

Rollback

Run systemctl disable --now dailyaidecheck.timer (20.04 and 22.04: set CRON_DAILY_RUN=no in /etc/default/aide) and delete /var/lib/aide/aide.db.

database

command -v aideinit >/dev/null 2>&1 || { echo "AIDE is not installed" >&2; exit 1; }
# umask 027: aideinit would otherwise create its logs readable by everyone
[ -s /var/lib/aide/aide.db ] || (umask 027; aideinit -y -f)

timer

Generated from check timer: the engine writes the fix for every output, it sets the expected value and the check runs again after.

cron

[ -f /etc/cron.daily/aide ] || { echo "AIDE is not installed" >&2; exit 1; }
chmod 755 /etc/cron.daily/aide
if grep -Eq '^[[:space:]]*CRON_DAILY_RUN=' /etc/default/aide 2>/dev/null; then
  cb_backup /etc/default/aide
  sed -i 's/^[[:space:]]*CRON_DAILY_RUN=.*/CRON_DAILY_RUN=yes/' /etc/default/aide
fi

Handwritten code reads parameters from CB_<NAME> environment variables. Each release turns these fixes into remediate.sh and an Ansible role per profile: dry run by default, a fix runs only when its check fails.

References

Mappings

How this control relates to the other framework's: equivalent, stricter, looser, partial or related.

Threats mitigated

People and lifecycle

Authors
Verified2026-10-19 by Sn0wAlice on 20.04, Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic. Fails on stock image; aideinit builds aide.db (about 10 min on 1 vCPU), cron.daily/aide present; passes after reboot.
Verified2026-10-19 by Sn0wAlice on 22.04, Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic. Fails on stock image; aideinit builds aide.db (about 10 min on 1 vCPU), cron.daily/aide present; passes after reboot.
Verified2026-10-19 by Sn0wAlice on 24.04, Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic. Fails on stock image; aideinit builds aide.db, dailyaidecheck.timer enabled; passes after reboot.
Verified2026-10-19 by Sn0wAlice on 26.04, Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic. Fails on stock image; aideinit builds aide.db, dailyaidecheck.timer enabled; passes after reboot.
Introduced inv0.1.0
Created, updated2026-10-19, 2026-10-19
Translationsfr