Ubuntu · Logging & auditing

Run rsyslog and create its log files with restricted permissions

When it fails: rsyslog is installed but does not run, or writes logs readable by everyone. 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.

CB-UBU-AUDIT-005lowactiveautomatedautomated fixprofile core

Description

When rsyslog is the chosen logging system, its service must be enabled and running, and the files it creates must not be readable by other users: the last $FileCreateMode in /etc/rsyslog.conf and /etc/rsyslog.d/*.conf must be 0640 or stricter.

The choice between the journal alone and rsyslog is left to the administrator: this control does not install rsyslog. CB-UBU-AUDIT-002 aligns the journal forwarding with that choice.

Rationale

rsyslog is what writes /var/log/syslog, /var/log/auth.log and forwards messages to a log server. When it is stopped, those files and the remote copy stop without any error. A restrictive creation mode keeps new and rotated log files private to root and the adm group.

Impact

None known. Ubuntu already ships $FileCreateMode 0640 (files owned by syslog:adm).

Applies when

Detected: when: rsyslog is installed A scanner reports the control not applicable when one is false.

Only when rsyslog is installed. Ubuntu Server installs rsyslog by default, which is then the chosen logging system; removing it leaves the systemd journal alone.

Setting

Locationrsyslog.service, /etc/rsyslog.conf, /etc/rsyslog.d/
DefaultEnabled, $FileCreateMode 0640
RecommendedEnabled and active, $FileCreateMode 0640 or stricter

Audit

  1. Run systemctl is-enabled rsyslog and systemctl is-active rsyslog. They must print enabled and active.
  2. Run grep -h '^\s*\$FileCreateMode' /etc/rsyslog.conf /etc/rsyslog.d/*.conf | tail -n 1. The mode must be 0640 or stricter.

Automated: every check must pass. Scanners report each check by its id.

service

rsyslog.service is enabled.

unit: rsyslog.service
state: enabled

active

rsyslog.service is running.

script: |
  o=$(systemctl is-active rsyslog 2>/dev/null)
  echo "rsyslog: ${o:-unknown}"
  [ "$o" = active ]

file-mode

Last $FileCreateMode of the rsyslog configuration.

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)
  echo "\$FileCreateMode ${m:-unset (rsyslog default 0644)}"
  [ -n "$m" ] && [ $((0$m & 0137)) -eq 0 ]

Remediation

  1. Run systemctl enable --now rsyslog.
  2. Create /etc/rsyslog.d/60-cirsec.conf with $FileCreateMode 0640 and run systemctl restart rsyslog.
Restartservice: rsyslog
Disruptionnone

Rollback

Delete /etc/rsyslog.d/60-cirsec.conf and run systemctl restart rsyslog.

service

Generated from check service: the engine writes the fix for every output, it sets the expected value and the check runs again after.

file-mode

f=/etc/rsyslog.d/60-cirsec.conf
cb_backup "$f"
printf '%s\n' '# Written by CIRSEC Baselines CB-UBU-AUDIT-005' '$FileCreateMode 0640' >"$f"
chmod 644 "$f"

Handwritten code reads parameters from CB_<NAME> environment variables. Each release turns these fixes into remediate.sh and an Ansible role per profile: dry run by default, a fix runs only when its check fails.

References

Mappings

How this control relates to the other framework's: equivalent, stricter, looser, partial or related.

Threats mitigated

  • related CB-UBU-AUDIT-002 Forward the journal to rsyslog only when rsyslog is the chosen logger

People and lifecycle

Authors
Verified2026-10-19 by Sn0wAlice on 20.04, Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic. Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and reboot.
Verified2026-10-19 by Sn0wAlice on 22.04, Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic. Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and reboot.
Verified2026-10-19 by Sn0wAlice on 24.04, Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic. Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and reboot.
Verified2026-10-19 by Sn0wAlice on 26.04, Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic. Passes on stock image (rsyslog active, $FileCreateMode 0640); kept after remediation and reboot.
Introduced inv0.1.0
Created, updated2026-10-19, 2026-10-19
Translationsfr