Stack Protector buffer overflow detection
Requires the kernel to be built with CONFIG_STACKPROTECTOR=y, inserting stack canaries to detect buffer overflows.
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
CONFIG_STACKPROTECTOR=y makes the compiler insert a stack canary, a guard value placed before the return address of vulnerable functions. If a buffer overflow overwrites the saved return address, it must first clobber the canary; the kernel detects the mismatch on function return and panics instead of jumping to attacker-controlled code. This turns a silent kernel code-execution bug into a controlled crash, neutralizing classic stack-smashing exploits.
What Pavois checks
Pavois reads the build configuration of the running kernel via /boot/config-$(uname -r) or /proc/config.gz and confirms CONFIG_STACKPROTECTOR=y. Reading the effective config of the booted kernel proves the canary protection is compiled into the kernel in use, not merely present in some installed default.
describe command("C=/boot/config-$(uname -r); if [ -r \"$C\" ]; then cat \"$C\"; elif zcat /proc/config.gz 2>/dev/null | head -1 | grep -q .; then zcat /proc/config.gz; else echo PAVOIS_NO_KERNEL_CONFIG; fi | grep -E '^(CONFIG_STACKPROTECTOR=|PAVOIS_NO_KERNEL_CONFIG)'") do
its('stdout') { should_not match(/PAVOIS_NO_KERNEL_CONFIG/) }
its('stdout') { should match(/^CONFIG_STACKPROTECTOR=y$/) }
endHow to verify it is applied
grep '^CONFIG_STACKPROTECTOR=' /boot/config-$(uname -r) || zcat /proc/config.gz | grep '^CONFIG_STACKPROTECTOR='
Expected output: CONFIG_STACKPROTECTOR=y.
Inspect & investigate
When a canary is overwritten the kernel emits a fatal message before panicking, inspect dmesg or journalctl -k for stack-protector: Kernel stack is corrupted in: .... Otherwise this is a static build-time protection with no routine log output; confirm it with the grep command above.
Remediation
No automated remediation is shipped: CONFIG_STACKPROTECTOR is a compile-time kernel option and cannot be enabled at runtime. The fix is to boot a kernel built with it enabled, the stock distribution kernels for the supported OSes already do. For a custom kernel, set CONFIG_STACKPROTECTOR=y (and ideally CONFIG_STACKPROTECTOR_STRONG=y) and rebuild.
Pavois applies this with its own harden engine, the plan below, not a shell script:
| resource | kernel_build |
|---|
pavois harden plan localwhere the target is local, a user@host SSH alias, or a container , Docs
Impact & precautions
Without stack-protector, a stack buffer overflow in kernel code can directly overwrite the return address and lead to arbitrary code execution rather than a contained crash. Precautions: the only remedy is a kernel change requiring a reboot, schedule a maintenance window and keep the prior kernel in GRUB as a fallback. Runtime overhead is negligible (canary check on a subset of functions), so there is no practical performance reason to leave it off.
Standards mapping
| Standard | Reference | Type | Version | Confidence |
|---|---|---|---|---|
| ANSSI BP-028 | R15 | direct | 2.0 | high |
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.