Add nodev Option to /dev/shm
Mounts the /dev/shm shared-memory tmpfs with the nodev option so device files there are not interpreted.
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
/dev/shm is a world-writable tmpfs used for shared memory. The only legitimate place for device files is /dev on the root partition (the sole exception being chroot jails). Mounting /dev/shm with nodev makes the kernel ignore any character or block device nodes created there, preventing an attacker from planting a device file (e.g. a copy of /dev/mem or a disk device) to bypass access controls.
What Pavois checks
Pavois reads the effective mount via mount('/dev/shm') and asserts the resolved options include nodev. Because /dev/shm is mounted by systemd (dev-shm.mount) and not always present in /etc/fstab, only the live mount table reliably shows its real options, a file-based scanner reading fstab could report a false pass or miss the mount entirely.
describe mount('/dev/shm') do
its('options') { should include 'nodev' }
end
describe command("{ findmnt --fstab -no OPTIONS /dev/shm 2>/dev/null; grep -hsE '[[:space:]]/dev/shm[[:space:]]' /etc/fstab 2>/dev/null; systemctl show -p Options -- $(systemd-escape -p --suffix=mount /dev/shm 2>/dev/null) 2>/dev/null; } | grep -ow 'nodev'") do
its('stdout') { should match(/\S/) }
endHow to verify it is applied
Run findmnt /dev/shm (or findmnt -no OPTIONS /dev/shm) and confirm nodev is present, e.g. rw,nosuid,nodev,noexec,relatime.
Inspect & investigate
Use findmnt /dev/shm to see the active options and systemctl show dev-shm.mount -p Options for the systemd-managed value. Attempts to use a device node on a nodev mount fail at open time.
Remediation
This rule has no automated harden plan: apply it manually. Add an explicit /dev/shm entry to /etc/fstab such as tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0, then mount -o remount /dev/shm (or systemctl restart dev-shm.mount) and verify with findmnt /dev/shm.
Pavois applies this with its own harden engine, the plan below, not a shell script:
| device | tmpfs |
|---|---|
| fstype | tmpfs |
| mount_point | /dev/shm |
| option | nodev |
| resource | mount |
pavois harden plan localwhere the target is local, a user@host SSH alias, or a container , Docs
Impact & precautions
Without nodev, an attacker with write access to /dev/shm could create device nodes to read or write raw memory/disk and bypass file permissions. Applying nodev is low risk: no normal application creates device files in shared memory. Precaution: a remount of /dev/shm is non-disruptive, but note that processes already holding shared-memory segments are unaffected; verify with findmnt after the change.
Standards mapping
| Standard | Reference | Type | Version | Confidence |
|---|---|---|---|---|
| CIS | 1.1.2.2.2 | direct | per OS, see the benchmark table | high |
| NIST | AC-6, AC-6(1), CM-6(a), CM-7(a), CM-7(b), MP-7 | 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.