← All rules
SOCLE-CLD-MNT-023// Mountsmediumeffective runtime

Add noexec Option to /var

Mount /var with the noexec option so binaries cannot be executed from it.

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.

A pass proves✓ running now✓ on disk✓ survives rebootthe qualified verdict →
Debian 12CIS 1.1.0Debian 13CIS 1.0.0FedoraRHEL 10 / Rocky 10 / AlmaLinux 10RHEL 8 / Rocky 8 / AlmaLinux 8CIS 4.0.0RHEL 9 / Rocky 9 / AlmaLinux 9CIS 2.0.0Ubuntu 22.04CIS 3.0.0Ubuntu 24.04CIS 1.0.0Ubuntu 26.04
One check, maps to 1 standard

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 /var directory holds variable, frequently writable system data (logs, mail spools, caches). Mounting it noexec removes a common foothold: an attacker who drops a payload into a writable /var subtree (e.g. a web cache or spool) cannot execute it directly, blocking a typical privilege-escalation or persistence step.

What Pavois checks

Pavois reads the effective mount options via mount('/var'), which reflects the kernel's live view of the filesystem. This catches options applied at runtime (remounts, systemd mount units, /etc/fstab overrides by drop-ins) that a scanner parsing /etc/fstab alone would miss.

describe mount('/var') do
  its('options') { should include 'noexec' }
end
describe command("{ findmnt --fstab -no OPTIONS /var 2>/dev/null; grep -hsE '[[:space:]]/var[[:space:]]' /etc/fstab 2>/dev/null; systemctl show -p Options -- $(systemd-escape -p --suffix=mount /var 2>/dev/null) 2>/dev/null; } | grep -ow 'noexec'") do
  its('stdout') { should match(/\S/) }
end

How to verify it is applied

Run findmnt /var (or findmnt -no OPTIONS /var) and confirm noexec appears in the options list. Example: findmnt -no OPTIONS /varrw,nosuid,nodev,noexec,relatime.

Inspect & investigate

Inspect mount state with findmnt /var and mount | grep ' /var '. A blocked execution attempt surfaces as a Permission denied error when running a binary from /var; kernel mount events appear in journalctl -k or dmesg.

Remediation

There is no automated harden plan for this rule, because /var must be a separate partition to carry mount options independently. Apply it manually: ensure /var is its own filesystem, add noexec to its /etc/fstab entry (or systemd mount unit), then mount -o remount /var and reboot to confirm persistence.

Pavois applies this with its own harden engine, the plan below, not a shell script:

commandawk -v m=/var -v o=noexec '$0!~/^[[:space:]]*#/&&$2==m{n=split($4,a,",");h=0;for(i=1;i<=n;i++)if(a[i]==o)h=1;if(!h)$4=$4","o}{print}' /etc/fstab >/etc/.fstab.pav && cat /etc/.fstab.pav >/etc/fstab && rm -f /etc/.fstab.pav; mountpoint -q /var && mount -o remount,noexec /var || true
namemount-var-noexec
not_ifawk -v m=/var '$2==m&&$0!~/^[[:space:]]*#/{print $4}' /etc/fstab | tr , '\n' | grep -qx noexec
resourceexec
pavois harden plan local

where the target is local, a user@host SSH alias, or a container , Docs

Impact & precautions

What can break: legitimate software that runs executables from under /var (some container runtimes use /var/lib/..., package post-install scripts, certain agents) will fail with Permission denied. Precautions: before enforcing, audit what executes from /var (grep your services, test in staging). If /var is not already a separate partition, repartitioning requires careful data migration; on an existing system this is a planned maintenance task, not a live remount. Verify with a reboot so the option survives.

Standards mapping

StandardReferenceTypeVersionConfidence
ANSSI BP-028R28direct2.0high

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.

Sources & references