{
  "id": "CB-UBU-AUDIT-007",
  "standard": "ubuntu",
  "version": "0.1.0",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUDIT-007",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUDIT-007.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUDIT-007.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-007",
    "title": "Rotate log files with logrotate",
    "finding": {
      "title": "Text log files are never rotated",
      "description": "Without logrotate, files such as /var/log/dpkg.log grow forever and old entries are never archived or removed."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "low"
    },
    "assessment": "automated",
    "tags": [
      "logrotate",
      "logging"
    ],
    "description": "`logrotate` renames, compresses and removes the text log files under `/var/log/` following\n`/etc/logrotate.conf` and the files that packages drop in `/etc/logrotate.d/`. Ubuntu installs it\nby default and starts it every day with `logrotate.timer`.\n\nThis control requires the `logrotate` package and its timer to be enabled.\n",
    "rationale": "Logs that are never rotated end up filling the file system, which stops the services that need\nto write, or are deleted by hand in a hurry. Rotation keeps a predictable history.\n",
    "impact": "Old rotated files are deleted after the number of rotations set in each logrotate file (4 weeks\nby default in `/etc/logrotate.conf`). Keep a remote copy when a longer history is required.\n",
    "notes": "The systemd journal rotates itself (CB-UBU-AUDIT-001) and auditd rotates its own logs\n(CB-UBU-AUDIT-013); logrotate handles the remaining text files.\n",
    "setting": {
      "location": "logrotate package, logrotate.timer",
      "default_value": "Not installed on cloud images",
      "recommended_value": "Installed, timer enabled"
    },
    "audit": {
      "manual": "1. Run `dpkg-query -W -f='${Status}\\n' logrotate`. It must end with `installed`.\n2. Run `systemctl is-enabled logrotate.timer`. It must print `enabled`.\n3. Review `/etc/logrotate.conf` and `/etc/logrotate.d/` against the site retention policy.\n",
      "checks": [
        {
          "id": "package",
          "engine": "package",
          "description": "logrotate is installed.",
          "spec": {
            "name": "logrotate",
            "state": "installed"
          }
        },
        {
          "id": "timer",
          "engine": "systemd-unit",
          "description": "logrotate.timer is enabled.",
          "spec": {
            "unit": "logrotate.timer",
            "state": "enabled"
          }
        }
      ]
    },
    "remediation": {
      "manual": "Run `apt-get install logrotate`, then `systemctl enable --now logrotate.timer`.\n",
      "effects": {
        "restart": "none",
        "disruption": "none",
        "lockout_risk": false
      },
      "rollback": "Run `apt-get purge logrotate`.\n",
      "scripts": [
        {
          "id": "package",
          "from_check": "package"
        },
        {
          "id": "timer",
          "from_check": "timer"
        }
      ]
    },
    "references": [
      {
        "title": "logrotate(8), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man8/logrotate.8.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 (R71)",
        "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": "R71",
        "relation": "partial"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AU-4",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "cwe",
        "id": "CWE-400"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-AUDIT-001",
        "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": "Passes on stock image (logrotate installed, logrotate.timer enabled)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Passes on stock image (logrotate installed, logrotate.timer enabled)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Passes on stock image (logrotate installed, logrotate.timer enabled)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Passes on stock image (logrotate installed, logrotate.timer enabled)."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}