{
  "id": "CB-UBU-AUDIT-005",
  "standard": "ubuntu",
  "version": "0.1.0",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUDIT-005",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUDIT-005.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUDIT-005.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-005",
    "title": "Run rsyslog and create its log files with restricted permissions",
    "finding": {
      "title": "rsyslog is installed but does not run, or writes logs readable by everyone",
      "description": "An installed but stopped rsyslog silently loses the text logs and remote copies it should produce; files created with a wide mode leak their content."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "low"
    },
    "assessment": "automated",
    "tags": [
      "rsyslog",
      "logging"
    ],
    "applicability": {
      "facts": [
        "rsyslog"
      ],
      "conditions": "Only when rsyslog is installed. Ubuntu Server installs rsyslog by default, which is then the\nchosen logging system; removing it leaves the systemd journal alone.\n"
    },
    "description": "When rsyslog is the chosen logging system, its service must be enabled and running, and the\nfiles it creates must not be readable by other users: the last `$FileCreateMode` in\n`/etc/rsyslog.conf` and `/etc/rsyslog.d/*.conf` must be `0640` or stricter.\n",
    "rationale": "rsyslog is what writes `/var/log/syslog`, `/var/log/auth.log` and forwards messages to a log\nserver. When it is stopped, those files and the remote copy stop without any error. A restrictive\ncreation mode keeps new and rotated log files private to root and the `adm` group.\n",
    "impact": "None known. Ubuntu already ships `$FileCreateMode 0640` (files owned by `syslog:adm`).\n",
    "notes": "The choice between the journal alone and rsyslog is left to the administrator: this control does\nnot install rsyslog. CB-UBU-AUDIT-002 aligns the journal forwarding with that choice.\n",
    "setting": {
      "location": "rsyslog.service, /etc/rsyslog.conf, /etc/rsyslog.d/",
      "default_value": "Enabled, $FileCreateMode 0640",
      "recommended_value": "Enabled and active, $FileCreateMode 0640 or stricter"
    },
    "audit": {
      "manual": "1. Run `systemctl is-enabled rsyslog` and `systemctl is-active rsyslog`. They must print\n   `enabled` and `active`.\n2. Run `grep -h '^\\s*\\$FileCreateMode' /etc/rsyslog.conf /etc/rsyslog.d/*.conf | tail -n 1`. The\n   mode must be `0640` or stricter.\n",
      "checks": [
        {
          "id": "service",
          "engine": "systemd-unit",
          "description": "rsyslog.service is enabled.",
          "spec": {
            "unit": "rsyslog.service",
            "state": "enabled"
          }
        },
        {
          "id": "active",
          "engine": "shell",
          "description": "rsyslog.service is running.",
          "spec": {
            "script": "o=$(systemctl is-active rsyslog 2>/dev/null)\necho \"rsyslog: ${o:-unknown}\"\n[ \"$o\" = active ]\n"
          }
        },
        {
          "id": "file-mode",
          "engine": "shell",
          "description": "Last $FileCreateMode of the rsyslog configuration.",
          "spec": {
            "script": "m=$(cat /etc/rsyslog.conf /etc/rsyslog.d/*.conf 2>/dev/null | sed -n 's/^[[:space:]]*\\$FileCreateMode[[:space:]]\\{1,\\}\\([0-7]\\{3,4\\}\\).*/\\1/p' | tail -n 1)\necho \"\\$FileCreateMode ${m:-unset (rsyslog default 0644)}\"\n[ -n \"$m\" ] && [ $((0$m & 0137)) -eq 0 ]\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "1. Run `systemctl enable --now rsyslog`.\n2. Create `/etc/rsyslog.d/60-cirsec.conf` with `$FileCreateMode 0640` and run\n   `systemctl restart rsyslog`.\n",
      "effects": {
        "restart": "service",
        "services": [
          "rsyslog"
        ],
        "disruption": "none",
        "lockout_risk": false
      },
      "rollback": "Delete `/etc/rsyslog.d/60-cirsec.conf` and run `systemctl restart rsyslog`.\n",
      "scripts": [
        {
          "id": "service",
          "from_check": "service"
        },
        {
          "id": "file-mode",
          "engine": "shell",
          "content": "f=/etc/rsyslog.d/60-cirsec.conf\ncb_backup \"$f\"\nprintf '%s\\n' '# Written by CIRSEC Baselines CB-UBU-AUDIT-005' '$FileCreateMode 0640' >\"$f\"\nchmod 644 \"$f\"\n"
        }
      ]
    },
    "references": [
      {
        "title": "rsyslog.conf(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/rsyslog.conf.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 (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-9",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1562.006"
      },
      {
        "framework": "cwe",
        "id": "CWE-532"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-AUDIT-002",
        "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 (rsyslog active, $FileCreateMode 0640); kept after remediation and 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": "Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and 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": "Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and 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": "Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and reboot."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}