Mount Remote Filesystems with nodev
An XCCDF Rule
Description
Add the nodev
option to the fourth column of /etc/fstab
for the line which controls mounting of
any NFS mounts.
Rationale
Legitimate device files should only exist in the /dev directory. NFS mounts should not present device files to users.
- ID
- xccdf_org.ssgproject.content_rule_mount_option_nodev_remote_filesystems
- Severity
- Medium
- References
- Updated
Remediation - Ansible
- name: Get nfs and nfs4 mount points, that don't have nodev
command: findmnt --fstab --types nfs,nfs4 -O nonodev -n -P
register: points_register
check_mode: false
changed_when: false
failed_when: false
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
vfstype_points=()
readarray -t vfstype_points < <(grep -E "[[:space:]]nfs[4]?[[:space:]]" /etc/fstab | awk '{print $2}')