Ubuntu · Boot & system hardening

Hide kernel addresses from users

When it fails: Kernel memory addresses are exposed through /proc and other interfaces. Leaked kernel addresses defeat kernel address randomization and help local privilege escalation exploits.

CB-UBU-BOOT-002mediumactiveautomatedautomated fixprofile core

Description

The kernel.kptr_restrict sysctl controls whether kernel pointers printed through %pK (for example in /proc/kallsyms and /proc/modules) are shown. With 1, they are hidden from users without the CAP_SYSLOG capability. With 2, they are hidden from everyone, including root.

Ubuntu ships 1 (/etc/sysctl.d/10-kernel-hardening.conf, /usr/lib/sysctl.d/55-kernel-hardening.conf on 26.04), which hides pointers from unprivileged users only, so the check fails with the default parameter. The value can be raised at runtime; lowering it needs no reboot either.

Rationale

Kernel exploits need the address of kernel structures and functions. The kernel randomizes its own layout at boot, but a single leaked pointer is enough to undo that randomization. Hiding pointers removes an easy source of leaks for a local attacker.

Impact

With 2, profiling and tracing tools run as root (perf, some eBPF tools) see zeroed kernel addresses and cannot resolve kernel symbols. Use 1 on hosts where administrators need them.

Setting

Locationsysctl `kernel.kptr_restrict`, persisted in `/etc/sysctl.d/`
Default1
RecommendedAt least {{ kptr_restrict }}

Parameters

ParameterCoreServerServer hardenedDesktopDesktop hardenedBounds
kptr_restrictinteger. Minimum value of kernel.kptr_restrict. 1 hides pointers from unprivileged users, 2 from everyone.222221 to 2

The value used is your override (tailoring file), else the profile's, else the one of the profile it extends, else the default. Bounds limit what an override may set.

Audit

Run sysctl kernel.kptr_restrict. The value must be at least {{ kptr_restrict }}. Then check that no sysctl configuration file sets a lower value.

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

running

Running value of kernel.kptr_restrict.

key: kernel.kptr_restrict
operator: '>='
value: '{{ kptr_restrict }}'

Remediation

Create /etc/sysctl.d/60-cirsec.conf containing kernel.kptr_restrict = {{ kptr_restrict }}, 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.kptr_restrict=1.

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 recommends 2 among other kernel settings; this control covers kernel.kptr_restrict only.
NIST SP 800-53 Rev. 55.1.1SC-30related

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 (1); generated fix sets 2; 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. Fails on a fresh install (1); generated fix sets 2; kept after reboot; second remediate leaves it alone.
Verified2026-10-19 by Sn0wAlice on 24.04, Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic, BIOS boot. Fails on a fresh install (1); generated fix sets 2; kept after reboot; second remediate leaves it alone.
Verified2026-10-19 by Sn0wAlice on 26.04, Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic, BIOS boot. Fails on a fresh install (1); generated fix sets 2; kept after reboot; second remediate leaves it alone.
Introduced inv0.1.0
Created, updated2026-10-19, 2026-10-19
Translationsfr