Add nodev Option to Non-Root Local Partitions
An XCCDF Rule
Description
Thenodev
mount option prevents files from being interpreted as
character or block devices. Legitimate character and block devices should
exist only in the /dev
directory on the root partition or within
chroot jails built for system services.
Add the nodev
option to the fourth column of
/etc/fstab
for the line which controls mounting of
any non-root local partitions.
Rationale
The nodev
mount option prevents files from being
interpreted as character or block devices. The only legitimate location
for device files is the /dev
directory located on the root partition.
The only exception to this is chroot jails, for which it is not advised
to set nodev
on these filesystems.
- ID
- xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
- Severity
- Medium
- References
- Updated
Remediation Templates
An Ansible Snippet
- name: Gather the package facts
package_facts:
manager: auto
tags:
- NIST-800-53-AC-6
- NIST-800-53-AC-6(1)
A 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 ] ) ); then
MOUNT_OPTION="nodev"
# Create array of local non-root partitions
readarray -t partitions_records < <(findmnt --mtab --raw --evaluate | grep "^/\w" | grep -v "^/proc" | grep "\s/dev/\w")