{
  "id": "CB-UBU-AUDIT-013",
  "standard": "ubuntu",
  "version": "main",
  "url": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-AUDIT-013",
  "json": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-AUDIT-013.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-AUDIT-013.yml",
  "profiles_effective": [
    "server-hardened",
    "desktop-hardened"
  ],
  "license": "Text CC BY 4.0, code Apache-2.0",
  "attribution": "CIRSEC Baselines, https://baselines.cirsec.org",
  "control": {
    "id": "CB-UBU-AUDIT-013",
    "title": "Keep audit logs instead of rotating them away",
    "finding": {
      "title": "Old audit logs are deleted automatically",
      "description": "auditd rotates its logs and deletes the oldest one, so a busy system or a deliberate flood erases the audit history."
    },
    "status": "active",
    "profiles": [
      "server-hardened",
      "desktop-hardened"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "auditd",
      "retention"
    ],
    "description": "`/etc/audit/auditd.conf` decides what auditd does when its log reaches `max_log_file`\nmegabytes. Ubuntu ships `max_log_file_action = ROTATE` with `num_logs = 5`: the oldest file is\ndeleted at each rotation. This control requires:\n\n- `max_log_file` of at least {{ max_log_file }} MB;\n- `max_log_file_action = keep_logs`: auditd rotates the file but never deletes old ones.\n\nArchiving or removing old audit logs then becomes a deliberate task of the administrator, and\nrunning out of space is handled by CB-UBU-AUDIT-014.\n",
    "rationale": "The audit log is evidence. Automatic deletion lets an attacker push the records of their\nactions out of the history by generating noise.\n",
    "impact": "Audit logs accumulate in `/var/log/audit/` until they are archived. Plan the space, ideally a\ndedicated partition (CB-UBU-AUDIT-014 reacts when it runs low).\n",
    "setting": {
      "location": "/etc/audit/auditd.conf",
      "default_value": "max_log_file = 8, max_log_file_action = ROTATE",
      "recommended_value": "max_log_file >= {{ max_log_file }}, max_log_file_action = keep_logs"
    },
    "parameters": [
      {
        "name": "max_log_file",
        "type": "integer",
        "description": "Minimum size of one audit log file before rotation.",
        "unit": "MB",
        "default": 8,
        "minimum": 1,
        "maximum": 4096
      }
    ],
    "audit": {
      "manual": "Run `grep -Ei '^\\s*max_log_file(_action)?\\s*=' /etc/audit/auditd.conf`. `max_log_file` must be\nat least {{ max_log_file }} and `max_log_file_action` must be `keep_logs`.\n",
      "checks": [
        {
          "id": "retention",
          "engine": "shell",
          "description": "max_log_file and max_log_file_action in auditd.conf.",
          "spec": {
            "script": "f=/etc/audit/auditd.conf\n[ -r \"$f\" ] || { echo \"$f not found: auditd is not installed\"; exit 1; }\nget() { sed -n \"s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*\\([^[:space:]]*\\).*/\\1/p\" \"$f\" | tail -n 1; }\ns=$(get max_log_file) a=$(get max_log_file_action | tr 'A-Z' 'a-z')\necho \"max_log_file=${s:-unset} max_log_file_action=${a:-unset}\"\ncase $s in '' | *[!0-9]*) exit 1 ;; esac\n[ \"$s\" -ge \"$CB_MAX_LOG_FILE\" ] && [ \"$a\" = keep_logs ]\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "In `/etc/audit/auditd.conf`, set `max_log_file = {{ max_log_file }}` (or more) and\n`max_log_file_action = keep_logs`, then run `systemctl restart auditd`.\n",
      "effects": {
        "restart": "service",
        "services": [
          "auditd"
        ],
        "disruption": "none",
        "lockout_risk": false
      },
      "rollback": "Set `max_log_file_action = ROTATE` back in `/etc/audit/auditd.conf` and restart auditd.\n",
      "scripts": [
        {
          "id": "auditd-conf",
          "engine": "shell",
          "content": "f=/etc/audit/auditd.conf\n[ -f \"$f\" ] || { echo \"$f not found: auditd is not installed\" >&2; exit 1; }\ncb_backup \"$f\"\nset_kv() {\n  sed -i \"/^[[:space:]]*$1[[:space:]]*=/d\" \"$f\"\n  printf '%s = %s\\n' \"$1\" \"$2\" >>\"$f\"\n}\ns=$(sed -n 's/^[[:space:]]*max_log_file[[:space:]]*=[[:space:]]*\\([0-9]*\\).*/\\1/p' \"$f\" | tail -n 1)\nif [ -z \"$s\" ] || [ \"$s\" -lt \"$CB_MAX_LOG_FILE\" ]; then set_kv max_log_file \"$CB_MAX_LOG_FILE\"; fi\nset_kv max_log_file_action keep_logs\n"
        }
      ]
    },
    "references": [
      {
        "title": "auditd.conf(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/auditd.conf.5.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R73",
        "relation": "related"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AU-11",
        "relation": "related"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AU-4",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1070.002"
      },
      {
        "framework": "cwe",
        "id": "CWE-779"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-AUDIT-011",
        "type": "requires"
      },
      {
        "id": "CB-UBU-AUDIT-014",
        "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 after auditd install (ROTATE, num_logs 5); fix sets keep_logs; 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 after auditd install (ROTATE, num_logs 5); fix sets keep_logs; 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 after auditd install (ROTATE, num_logs 5); fix sets keep_logs; 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 after auditd install (ROTATE, num_logs 5); fix sets keep_logs; passes after reboot."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}