Ubuntu · Boot & system hardening

Restrict the kernel log buffer to privileged users

When it fails: Unprivileged users can read the kernel log buffer. The kernel log can reveal addresses, hardware details and errors useful to an attacker.

CB-UBU-BOOT-003lowactiveautomatedautomated fixprofile core

As released in v0.1.0 (beta). Current state.

Description

The kernel.dmesg_restrict sysctl controls who can read the kernel ring buffer with dmesg or /dev/kmsg. With 1, only processes with the CAP_SYSLOG capability can read it.

Ubuntu kernels are built with this restriction on by default from 22.04 on, so the check passes on a fresh install and guards against it being turned off. The Ubuntu 20.04 kernel (5.4) is not: the check fails on a fresh 20.04 install and the fix turns it on.

Rationale

Kernel messages often contain memory addresses, driver and firmware versions, and traces of failed operations. Reading them helps a local attacker tune a kernel exploit.

Impact

Unprivileged users can no longer run dmesg. Administrators use sudo dmesg or journalctl -k, which needs membership of the adm or systemd-journal group.

Setting

Locationsysctl `kernel.dmesg_restrict`, persisted in `/etc/sysctl.d/`
Default1 (0 on 20.04)
Recommended1

Audit

Run sysctl kernel.dmesg_restrict. The value must be 1. Then check that no sysctl configuration file sets it to 0.

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

running

Running value of kernel.dmesg_restrict.

key: kernel.dmesg_restrict
value: 1

Remediation

Create /etc/sysctl.d/60-cirsec.conf containing kernel.dmesg_restrict = 1, remove any other assignment of this key, then run sysctl --system.

Restartnone
Disruptionlow

Rollback

Remove the line from /etc/sysctl.d/60-cirsec.conf and run sysctl -w kernel.dmesg_restrict=0.

set

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

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

FrameworkIDRelationNote
ANSSI-BP-028 - Recommandations de configuration d'un système GNU/Linux2.0R9partialR9 lists several kernel settings; this control covers kernel.dmesg_restrict.
NIST SP 800-53 Rev. 55.1.1SI-11related

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

Threats mitigated

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, BIOS boot. Fails on a fresh install (0); generated fix sets 1; kept after reboot; second remediate leaves it alone.
Verified2026-10-19 by Sn0wAlice on 22.04, Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic, BIOS boot. Passes on a fresh install (1); still passes 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, BIOS boot. Passes on a fresh install (1); still passes 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, BIOS boot. Passes on a fresh install (1); still passes after remediation and reboot.
Introduced inv0.1.0
Created, updated2026-10-19, 2026-10-19
Translationsfr