Skip to content

Add noexec Option to /var

An XCCDF Rule

Description

The noexec mount option can be used to prevent binaries from being executed out of /var. Add the noexec option to the fourth column of /etc/fstab for the line which controls mounting of /var.

Rationale

The /var directory contains variable system data such as logs, mails and caches. No binaries should be executed from this directory.

ID
xccdf_org.ssgproject.content_rule_mount_option_var_noexec
Severity
Medium
References
Updated



Remediation - Ansible

- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - CCE-83330-1
  - configure_strategy

Remediation - Anaconda Pre-Install Instructions


part /var --mountoptions="noexec"

Remediation - Shell Script

# Remediation is applicable only in certain platforms
if ( ! ( { rpm --quiet -q kernel ;} && { rpm --quiet -q rpm-ostree ;} && { rpm --quiet -q bootc ;} ) && ! ( [ -f /.dockerenv ] || [ -f /run/.containerenv ] ) ) && { findmnt --kernel "/var" > /dev/null || findmnt --fstab "/var" > /dev/null; }; then

function perform_remediation {
    
        # the mount point /var has to be defined in /etc/fstab