{
  "id": "CB-UBU-AUDIT-034",
  "standard": "ubuntu",
  "version": "0.1.1",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.1/CB-UBU-AUDIT-034",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.1/CB-UBU-AUDIT-034.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.1/CB-UBU-AUDIT-034.yml",
  "profiles_effective": [
    "core",
    "server",
    "server-hardened",
    "desktop",
    "desktop-hardened"
  ],
  "license": "Text CC BY 4.0, code Apache-2.0",
  "attribution": "CIRSEC Baselines, https://baselines.cirsec.org",
  "control": {
    "id": "CB-UBU-AUDIT-034",
    "title": "Build the AIDE database and check file integrity every day",
    "finding": {
      "title": "File integrity is never checked",
      "description": "Without a reference database and a regular check, AIDE cannot report modified system files."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "aide",
      "integrity",
      "systemd"
    ],
    "description": "AIDE needs a reference database, `/var/lib/aide/aide.db`, built with `aideinit` from the\ncurrent state of the system. `aide-common` then runs a daily check, which compares the files\nwith the database and writes a report to `/var/log/aide/` (and mails it when a mail transport\nis installed):\n\n- from Ubuntu 24.04 (AIDE 0.18 and later), with `dailyaidecheck.timer`;\n- on Ubuntu 20.04 and 22.04 (AIDE 0.16 and 0.17), with the cron job `/etc/cron.daily/aide`,\n  which `CRON_DAILY_RUN=no` in `/etc/default/aide` turns off.\n\nThis control requires the database to exist and the daily check to be enabled.\n",
    "rationale": "The database is the trusted reference; the daily check turns it into detection. Without either,\nan installed AIDE gives a false sense of protection.\n",
    "impact": "Building the database reads every covered file: a few minutes and a short burst of disk\nactivity. The daily check does the same. After legitimate changes (upgrades, configuration),\nreview the report and update the database (`aide --update`, then replace `aide.db` with\n`aide.db.new`).\n",
    "notes": "Build the database once the system is in its intended state: run this fix after the other\nhardening fixes, or rebuild the database afterwards with `aideinit -y -f`, otherwise the first\nreports list every change made by the hardening.\n",
    "setting": {
      "location": "/var/lib/aide/aide.db, dailyaidecheck.timer (20.04 and 22.04 - /etc/cron.daily/aide)",
      "default_value": "No database; daily check enabled when aide-common is installed",
      "recommended_value": "Database present, daily check enabled"
    },
    "audit": {
      "manual": "1. Run `ls -l /var/lib/aide/aide.db`. The file must exist and not be empty.\n2. Ubuntu 24.04 and later: run `systemctl is-enabled dailyaidecheck.timer`. It must print\n   `enabled`. Ubuntu 20.04 and 22.04: `/etc/cron.daily/aide` must be executable and\n   `/etc/default/aide` must not set `CRON_DAILY_RUN=no`.\n3. Read the last report in `/var/log/aide/` and check that differences are explained.\n",
      "checks": [
        {
          "id": "database",
          "engine": "shell",
          "description": "The AIDE reference database exists.",
          "spec": {
            "script": "if [ -s /var/lib/aide/aide.db ]; then\n  ls -l /var/lib/aide/aide.db\nelse\n  echo \"/var/lib/aide/aide.db missing or empty\"\n  exit 1\nfi\n"
          }
        },
        {
          "id": "timer",
          "engine": "systemd-unit",
          "description": "dailyaidecheck.timer is enabled.",
          "versions": [
            "24.04",
            "26.04"
          ],
          "spec": {
            "unit": "dailyaidecheck.timer",
            "state": "enabled"
          }
        },
        {
          "id": "cron",
          "engine": "shell",
          "description": "The daily AIDE cron job is present and not turned off (AIDE 0.16 and 0.17).",
          "versions": [
            "20.04",
            "22.04"
          ],
          "spec": {
            "script": "[ -x /etc/cron.daily/aide ] || { echo \"/etc/cron.daily/aide missing or not executable\"; exit 1; }\nv=$(sed -n 's/^[[:space:]]*CRON_DAILY_RUN=//p' /etc/default/aide 2>/dev/null | tail -n 1 | tr -d \"\\\"'\")\necho \"/etc/cron.daily/aide present, CRON_DAILY_RUN=${v:-yes (default)}\"\n[ \"${v:-yes}\" = yes ]\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "1. Run `aideinit -y -f` and wait for it to finish (a few minutes).\n2. Ubuntu 24.04 and later: run `systemctl enable --now dailyaidecheck.timer`. Ubuntu 20.04 and\n   22.04: run `chmod 755 /etc/cron.daily/aide` and set `CRON_DAILY_RUN=yes` (or remove the line)\n   in `/etc/default/aide`.\n",
      "effects": {
        "restart": "none",
        "disruption": "low",
        "lockout_risk": false
      },
      "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`.\n",
      "scripts": [
        {
          "id": "database",
          "engine": "shell",
          "content": "command -v aideinit >/dev/null 2>&1 || { echo \"AIDE is not installed\" >&2; exit 1; }\n# umask 027: aideinit would otherwise create its logs readable by everyone\n[ -s /var/lib/aide/aide.db ] || (umask 027; aideinit -y -f)\n"
        },
        {
          "id": "timer",
          "from_check": "timer"
        },
        {
          "id": "cron",
          "engine": "shell",
          "versions": [
            "20.04",
            "22.04"
          ],
          "content": "[ -f /etc/cron.daily/aide ] || { echo \"AIDE is not installed\" >&2; exit 1; }\nchmod 755 /etc/cron.daily/aide\nif grep -Eq '^[[:space:]]*CRON_DAILY_RUN=' /etc/default/aide 2>/dev/null; then\n  cb_backup /etc/default/aide\n  sed -i 's/^[[:space:]]*CRON_DAILY_RUN=.*/CRON_DAILY_RUN=yes/' /etc/default/aide\nfi\n"
        }
      ]
    },
    "references": [
      {
        "title": "aideinit(8), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man8/aideinit.8.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "systemd.timer(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/systemd.timer.5.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "ANSSI-BP-028 v2.0 - Recommandations de configuration d'un système GNU/Linux (R76)",
        "url": "https://messervices.cyber.gouv.fr/documents-guides/fr_np_linux_configuration-v2.0.pdf",
        "publisher": "ANSSI",
        "kind": "guide",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R76",
        "relation": "equivalent"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "SI-7(1)",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1036.005"
      },
      {
        "framework": "cwe",
        "id": "CWE-353"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-AUDIT-032",
        "type": "requires"
      },
      {
        "id": "CB-UBU-AUDIT-033",
        "type": "requires"
      },
      {
        "id": "CB-UBU-AUDIT-035",
        "type": "related"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic",
        "notes": "Fails on stock image; aideinit builds aide.db (about 10 min on 1 vCPU), cron.daily/aide present; passes after reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Fails on stock image; aideinit builds aide.db (about 10 min on 1 vCPU), cron.daily/aide present; passes after reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Fails on stock image; aideinit builds aide.db, dailyaidecheck.timer enabled; passes after reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Fails on stock image; aideinit builds aide.db, dailyaidecheck.timer enabled; passes after reboot."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}