1.1.2.4.1 Ensure separate partition exists for /var

Information

The /var directory is used by daemons and other system services to temporarily store dynamic data. Some directories created by these processes may be world-writable.

The reasoning for mounting /var on a separate partition is as follows.

The default installation only creates a single / partition. Since the /var directory may contain world writable files and directories, there is a risk of resource exhaustion. It will essentially have the whole disk available to fill up and impact the system. In addition, other operations on the system could fill up the disk unrelated to /var and cause unintended behavior across the system as the disk is full. See man auditd.conf for details.

Configuring /var as its own file system allows an administrator to set additional mount options such as nodev and nosuid . These options limit an attacker's ability to create exploits on the system. noexec is not applied to /var, which legitimately hosts executable content used by the package manager and services, so restricting execution there would break normal operation. Other options allow for specific behavior. See man mount for exact details regarding filesystem-independent and filesystem-specific options.

For example, a setuid program is normally patched by replacing the file -- the package manager writes a new file and renames it into place, creating a new inode -- not by modifying the running binary. An attacker who pre-created a hard link to that program (on the same filesystem) keeps a working copy of the old, vulnerable binary after it is patched: their hard link still references the original inode, so nothing is "broken." Because a hard link cannot span filesystems, placing /var on a separate partition helps prevent this by keeping world-writable locations off the filesystem that holds the system's setuid programs.

/var stores variable system data that must persist, so it must reside on persistent (non-volatile) storage.

Solution

Configure /var as a separate mount on persistent (non-volatile) storage.

New installations: During installation, create a custom partitioning layout and assign a separate partition or logical volume to /var.

Existing systems: Create a new filesystem for /var and add it to the mount table. For example, using LVM (adjust the volume group, size, and device to suit the host):

# lvcreate -L <size> -n var <vg_name>
# mkfs.ext4 /dev/<vg_name>/var

Add the mount to /etc/fstab :

/dev/<vg_name>/var /var ext4 defaults,nodev,nosuid 0 0

Migrate the existing contents into the new filesystem and activate the mount using the repartitioning steps in the section overview, then run mount /var (or reboot).

Impact:

Resizing filesystems is a common activity in cloud-hosted servers. Separate filesystem partitions may prevent successful resizing or may require the installation of additional tools solely for the purpose of resizing operations. The use of these additional tools may introduce their own security considerations.

See Also

https://workbench.cisecurity.org/benchmarks/27890

Item Details

Category: ACCESS CONTROL, CONFIGURATION MANAGEMENT, MEDIA PROTECTION

References: 800-53|AC-3, 800-53|AC-5, 800-53|AC-6, 800-53|CM-7, 800-53|MP-2, CSCv7|14.6

Plugin: Unix

Control ID: 0d3636ab623bc3d4436139e5060c1eb5632febf38eb7d2e19f12aa7da88b2bac