Disallow kernel profiling by unprivileged users
Sets kernel.perf_event_paranoid = 2 so unprivileged users cannot profile the kernel or raw CPU events.
Checked against the resolved running state (e.g. sshd -T, sysctl, systemctl show), catches drop-ins and Includes a file read would miss. Caveat: runtime ≠ persistence; a value correct now may not survive a reboot.
Pavois asserts the effective configuration, the live, resolved state, not a file. File-based scanners (OVAL/SCAP, Lynis) miss Includes, drop-ins and runtime defaults; this check sees what is actually applied.
A mapping is a cross-reference to where each standard places this requirement, anchored and cross-validated, not a claim of equivalence. A passing check is evidence toward these references, how to read it.
Why this rule matters
The Perf subsystem can expose detailed CPU, memory and instruction-level behaviour. If unprivileged users can profile the kernel, that telemetry can reveal sensitive information about kernel internals and side channels usable in exploitation. kernel.perf_event_paranoid = 2 disallows raw tracepoint, kernel and CPU-event access for unprivileged users, restricting profiling to privileged contexts.
What Pavois checks
Pavois reads the live kernel value with kernel_parameter('kernel.perf_event_paranoid') (equivalent to sysctl kernel.perf_event_paranoid), not a /etc/sysctl.d/*.conf line. A file declaring 2 is irrelevant if a later drop-in, a boot parameter, or a runtime sysctl -w left the kernel at a more permissive 1, 0 or -1. Only the effective parameter proves what unprivileged users are actually allowed to do.
describe kernel_parameter('kernel.perf_event_paranoid') do
its('value') { should cmp 2 }
end
describe command("grep -hsE '^[[:space:]]*kernel.perf_event_paranoid[[:space:]]*=[[:space:]]*2([[:space:]]|$)' /etc/sysctl.conf /etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf 2>/dev/null") do
its('stdout') { should match(/\S/) }
endHow to verify it is applied
Run sysctl kernel.perf_event_paranoid. Expected output:
kernel.perf_event_paranoid = 2
Inspect & investigate
No dedicated log line. Confirm with sysctl kernel.perf_event_paranoid. The effect is observable: as an unprivileged user, perf top or perf record -a will fail with a permission error referencing perf_event_paranoid once the value is 2.
Remediation
Pavois's harden plan uses the sysctl resource to set kernel.perf_event_paranoid = 2, persists it in a Pavois-managed drop-in under /etc/sysctl.d/, and applies it live (no reboot). Apply it with pavois harden apply.
Pavois applies this with its own harden engine, the plan below, not a shell script:
| key | kernel.perf_event_paranoid |
|---|---|
| resource | sysctl |
| value | 2 |
pavois harden plan localwhere the target is local, a user@host SSH alias, or a container , Docs
Impact & precautions
Risk if not applied: unprivileged users can profile the kernel, leaking internals and side-channel data useful for exploitation.
Precautions before applying:
- This breaks unprivileged profiling. Developers, CI runners, or observability agents that run
perfas a non-root user will lose access. Grant theCAP_PERFMON/CAP_SYS_ADMINcapability or run those tools privileged where genuinely needed. - No application or boot lockout risk; the change is fully reversible at runtime.
Standards mapping
| Standard | Reference | Type | Version | Confidence |
|---|---|---|---|---|
| ANSSI BP-028 | R9 | direct | 2.0 | high |
| NIST | AC-6 | supporting | 800-53 Rev 5 · 800-171 Rev 2 (pinned) | medium |
Each reference is a cross-reference anchored in the upstream benchmark and cross-validated against the SCAP Security Guide and ansible-lockdown, not a claim of equivalence. Direct = a prescriptive, line-level requirement; supporting = an abstract control family (NIST) the check provides evidence toward. How to read a mapping.