Add nosuid Option to /dev/shm
Mounts the /dev/shm shared-memory tmpfs with the nosuid option so setuid/setgid bits on its files are ignored.
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 presence of SUID and SGID executables must be tightly controlled. /dev/shm is a world-writable temporary (shared-memory) filesystem where users should never be able to run setuid/setgid programs. Mounting it with nosuid makes the kernel ignore those bits, so a SUID-root binary copied there cannot be used to escalate privileges.
What Pavois checks
Pavois reads the effective mount via mount('/dev/shm') and asserts the resolved options include nosuid. Since /dev/shm is mounted by systemd (dev-shm.mount) and may be absent from /etc/fstab, only the live mount table shows its true options, file-based scanning can pass falsely or miss the mount.
describe mount('/dev/shm') do
its('options') { should include 'nosuid' }
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 'nosuid'") do
its('stdout') { should match(/\S/) }
endHow to verify it is applied
Run findmnt /dev/shm (or findmnt -no OPTIONS /dev/shm) and confirm nosuid is present, e.g. rw,nosuid,nodev,noexec,relatime.
Inspect & investigate
Use findmnt /dev/shm for active options and systemctl show dev-shm.mount -p Options for the systemd value. A SUID binary executed from a nosuid mount simply runs without elevated privileges; auditd EXECVE/SYSCALL records in /var/log/audit/audit.log can corroborate the attempt.
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 | nosuid |
| resource | mount |
pavois harden plan localwhere the target is local, a user@host SSH alias, or a container , Docs
Impact & precautions
Without nosuid, a SUID-root binary planted in /dev/shm could be used for privilege escalation. Applying nosuid is low risk: legitimate shared-memory use does not rely on setuid files. Precaution: the remount is non-disruptive; combine it with nodev and noexec for full hardening of this tmpfs and confirm with findmnt afterwards.
Standards mapping
| Standard | Reference | Type | Version | Confidence |
|---|---|---|---|---|
| CIS | 1.1.2.2.3 | 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.