Skip to content

Add nosuid Option to /opt

An XCCDF Rule

Description

The nosuid mount option can be used to prevent execution of setuid programs in /opt. The SUID and SGID permissions should not be required in this directory. Add the nosuid option to the fourth column of /etc/fstab for the line which controls mounting of /opt.

Rationale

The presence of SUID and SGID executables should be tightly controlled. The /opt directory contains additional software packages. Users should not be able to execute SUID or SGID binaries from this directory.

ID
xccdf_org.ssgproject.content_rule_mount_option_opt_nosuid
Severity
Medium
References
Updated



Remediation - Ansible

- name: 'Add nosuid Option to /opt: Check information associated to mountpoint'
  command: findmnt --fstab '/opt'
  register: device_name
  failed_when: device_name.rc > 1
  changed_when: false
  when: ( ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman",

Remediation - Anaconda Pre-Install Instructions


part /opt --mountoptions="nosuid"

Remediation - Shell Script

# Remediation is applicable only in certain platforms
if ( [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && findmnt --kernel "/opt" > /dev/null || findmnt --fstab "/opt" > /dev/null ); then

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