Mount Remote Filesystems with noexec
An XCCDF Rule
Description
Add the noexec
option to the fourth column of /etc/fstab
for the line which controls mounting of
any NFS mounts.
Rationale
The noexec mount option causes the system not to execute binary files. This option must be used for mounting any file system not containing approved binary files as they may be incompatible. Executing files from untrusted file systems increases the opportunity for unprivileged users to attain unauthorized administrative access.
- ID
- xccdf_org.ssgproject.content_rule_mount_option_noexec_remote_filesystems
- Severity
- Medium
- References
- Updated
Remediation - Ansible
- name: Get nfs and nfs4 mount points, that don't have noexec
command: findmnt --fstab --types nfs,nfs4 -O nonoexec -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}')