on RHEL/CentOS 7.9 there is by default tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
A security rule says that it must be mounted with the secure options of nosuid, nodev, and noexec.
Why does RHEL not automatically include noexec
when it is already using the other two?
Is it a good idea or bad idea (with explanation) to use the noexec
option for /dev/shm
specifically? And if it is a good idea how do you go about making it happen, because a corresponding mount statement is not in /etc/fstab
reference: U_RHEL_7_V3R6_STIG_SCAP_1-2_Benchmark.zip
Anyone on the internet can download it from https://public.cyber.mil/stigs/downloads/ under operating systems / redhat7 and read the following:
Rule Title: The Red Hat Enterprise Linux operating system must
mount /dev/shm with secure options.
Discussion: The "noexec" mount option causes the system to not 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.
The "nodev" mount option causes the system to not interpret character or
block special devices. Executing character or block special devices from
untrusted file systems increases the opportunity for unprivileged users
to attain unauthorized administrative access.
The "nosuid" mount option causes the system to not execute "setuid" and
"setgid" files with owner privileges. This option must be used for
mounting any file system not containing approved "setuid" and "setguid"
files. Executing files from untrusted file systems increases the
opportunity for unprivileged users to attain unauthorized administrative
access.
Check Text: Verify that the "nodev","nosuid", and "noexec" options are
configured for /dev/shm:
cat /etc/fstab | grep /dev/shm
tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0
If results are returned and the "nodev", "nosuid", or "noexec" options
are missing, this is a finding.
Verify "/dev/shm" is mounted with the "nodev", "nosuid", and "noexec"
options: mount | grep /dev/shm
tmpfs on /dev/shm type tmpfs (rw,nodev,nosuid,noexec,seclabel)
If /dev/shm is mounted without secure options "nodev", "nosuid", and
"noexec", this is a finding.
Fix Text: Configure the system so that /dev/shm is mounted with the
"nodev", "nosuid", and "noexec" options by adding /modifying
the /etc/fstab with the following line:
tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0
noexec
is only meant for media filesystem like those from cds and usb-sticks. – Sep 24 '21 at 06:05/dev/shm
qualifies as an untrusted file system then you’ve got bigger fish to fry than worrying aboutnoexec
. The STIG rule only mentions executing binaries, but that’s not the main purpose ofexec
on/dev/shm
. – Stephen Kitt Sep 30 '21 at 21:18