{
  "id": "CB-UBU-AUDIT-009",
  "standard": "ubuntu",
  "version": "0.1.1",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.1/CB-UBU-AUDIT-009",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.1/CB-UBU-AUDIT-009.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.1/CB-UBU-AUDIT-009.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-009",
    "title": "Encrypt and authenticate the rsyslog connection to the log server",
    "finding": {
      "title": "Logs are sent to the log server without TLS",
      "description": "Log messages cross the network in clear text and can be read, altered or sent to a rogue server."
    },
    "status": "active",
    "profiles": [
      "server-hardened",
      "desktop-hardened"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "rsyslog",
      "logging",
      "remote",
      "tls"
    ],
    "applicability": {
      "facts": [
        "rsyslog"
      ],
      "conditions": "Only when rsyslog is the logging system. With the journal alone, `systemd-journal-upload`\nalways uses HTTPS (CB-UBU-AUDIT-008).\n"
    },
    "description": "rsyslog encrypts its forwarding with the GnuTLS network stream driver from the\n`rsyslog-gnutls` package. This control requires:\n\n- the `rsyslog-gnutls` package;\n- a forwarding action (`omfwd` or the legacy `@@host`) using the `gtls` driver in TLS-only mode\n  (`StreamDriverMode=\"1\"`);\n- the CA certificate that signs the log server certificate (`DefaultNetstreamDriverCAFile` or\n  `StreamDriver.CAFile`), and server authentication by certificate name\n  (`StreamDriverAuthMode=\"x509/name\"`).\n",
    "rationale": "Logs carry user names, addresses and sometimes secrets. TLS keeps them confidential and intact\nin transit, and certificate checks stop an attacker from posing as the log server.\n",
    "impact": "Requires a log server that accepts TLS (port 6514 by convention) and a certificate chain to\ndistribute. A wrong CA or name makes rsyslog queue messages instead of sending them.\n",
    "setting": {
      "location": "/etc/rsyslog.conf, /etc/rsyslog.d/",
      "default_value": "No forwarding",
      "recommended_value": "omfwd with StreamDriver gtls, StreamDriverMode 1, StreamDriverAuthMode x509/name and a CA file"
    },
    "audit": {
      "manual": "1. Run `dpkg-query -W -f='${Status}\\n' rsyslog-gnutls`. It must end with `installed`.\n2. In `/etc/rsyslog.conf` and `/etc/rsyslog.d/*.conf`, find the forwarding action. It must use\n   `StreamDriver=\"gtls\"` (or `$DefaultNetstreamDriver gtls`), `StreamDriverMode=\"1\"` and\n   `StreamDriverAuthMode=\"x509/name\"`.\n3. `DefaultNetstreamDriverCAFile` (or `StreamDriver.CAFile`) must name an existing CA file.\n",
      "checks": [
        {
          "id": "gnutls",
          "engine": "package",
          "description": "rsyslog-gnutls is installed.",
          "spec": {
            "name": "rsyslog-gnutls",
            "state": "installed"
          }
        },
        {
          "id": "forward-tls",
          "engine": "shell",
          "description": "A forwarding action that uses the gtls driver in TLS-only mode.",
          "spec": {
            "script": "c=$(cat /etc/rsyslog.conf /etc/rsyslog.d/*.conf 2>/dev/null | grep -Ev '^[[:space:]]*(#|$)')\nif ! printf '%s\\n' \"$c\" | grep -Eiq 'type=\"?omfwd|[[:space:]]@@?[^[:space:]]'; then\n  echo \"no forwarding action\"\n  exit 1\nfi\nd=no m=no\nprintf '%s\\n' \"$c\" | grep -Eiq 'StreamDriver(Name)?[[:space:]]*=[[:space:]]*\"?gtls|DefaultNetstreamDriver[[:space:]]*=?[[:space:]]*\"?gtls' && d=yes\nprintf '%s\\n' \"$c\" | grep -Eiq 'StreamDriverMode[[:space:]]*=?[[:space:]]*\"?1' && m=yes\necho \"forwarding found, gtls driver: $d, TLS-only mode: $m\"\n[ \"$d\" = yes ] && [ \"$m\" = yes ]\n"
          }
        },
        {
          "id": "ca-auth",
          "engine": "shell",
          "description": "CA file configured and server authenticated by certificate name.",
          "spec": {
            "script": "c=$(cat /etc/rsyslog.conf /etc/rsyslog.d/*.conf 2>/dev/null | grep -Ev '^[[:space:]]*(#|$)')\nca=$(printf '%s\\n' \"$c\" | sed -n 's/.*\\(DefaultNetstreamDriverCAFile\\|StreamDriver\\.CAFile\\)[[:space:]]*=\\{0,1\\}[[:space:]]*\"\\{0,1\\}\\([^\"[:space:])]*\\).*/\\2/p' | tail -n 1)\na=no\nprintf '%s\\n' \"$c\" | grep -Eiq 'StreamDriverAuthMode[[:space:]]*=?[[:space:]]*\"?x509/name' && a=yes\necho \"CA file: ${ca:-none}, x509/name authentication: $a\"\n[ -n \"$ca\" ] && [ -s \"$ca\" ] && [ \"$a\" = yes ]\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "1. Run `apt-get install rsyslog-gnutls`.\n2. Copy the CA certificate of the log server to `/etc/ssl/certs/log-ca.pem`.\n3. Create `/etc/rsyslog.d/60-remote.conf`:\n   ```\n   global(DefaultNetstreamDriverCAFile=\"/etc/ssl/certs/log-ca.pem\")\n   *.* action(type=\"omfwd\" target=\"<server>\" port=\"6514\" protocol=\"tcp\"\n              StreamDriver=\"gtls\" StreamDriverMode=\"1\" StreamDriverAuthMode=\"x509/name\"\n              StreamDriverPermittedPeers=\"<server>\"\n              queue.type=\"LinkedList\" queue.filename=\"fwd\" queue.saveOnShutdown=\"on\"\n              action.resumeRetryCount=\"-1\")\n   ```\n4. Run `rsyslogd -N1` to check the syntax, then `systemctl restart rsyslog`.\n",
      "effects": {
        "restart": "none",
        "disruption": "none",
        "lockout_risk": false
      },
      "rollback": "Remove `/etc/rsyslog.d/60-remote.conf` and restart rsyslog.\n",
      "scripts": [
        {
          "id": "gnutls",
          "from_check": "gnutls"
        }
      ]
    },
    "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",
        "note": "R71 asks for protected log transfer; this control covers TLS for rsyslog."
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "SC-8",
        "relation": "related"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AU-9(2)",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1557"
      },
      {
        "framework": "cwe",
        "id": "CWE-319"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-AUDIT-008",
        "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 as expected (no TLS forwarding); fix installs rsyslog-gnutls; forwarding and CA stay site-specific (pass path not tested)."
      },
      {
        "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 as expected (no TLS forwarding); fix installs rsyslog-gnutls; forwarding and CA stay site-specific (pass path not tested)."
      },
      {
        "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 as expected (no TLS forwarding); fix installs rsyslog-gnutls; forwarding and CA stay site-specific (pass path not tested)."
      },
      {
        "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 as expected (no TLS forwarding); fix installs rsyslog-gnutls; forwarding and CA stay site-specific (pass path not tested)."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}