CIS Ubuntu Linux 18.04 LTS Benchmark v2.2.0
CIS Ubuntu Linux 18.04 LTS Benchmark v2.2.0
04
LTS Benchmark
v2.2.0 - 03-27-2024
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
In the end, the CIS Benchmarks are designed as a key component of a comprehensive
cybersecurity program.
Intended Audience
This benchmark is intended for system and application administrators, security
specialists, auditors, help desk, and platform deployment personnel who plan to
develop, deploy, assess, or secure solutions that incorporate Ubuntu Linux 18.04 LTS
on the x64 platform.
Page 10
Page 11
Convention Meaning
Page 12
Title
Concise description for the recommendation's intended configuration.
Assessment Status
An assessment status is included for every recommendation. The assessment status
indicates whether the given recommendation can be automated or requires manual
steps to implement. Both statuses are equally important and are determined and
supported as defined below:
Automated
Represents recommendations for which assessment of a technical control can be fully
automated and validated to a pass/fail state. Recommendations will include the
necessary information to implement automation.
Manual
Represents recommendations for which assessment of a technical control cannot be
fully automated and requires all or some manual steps to validate that the configured
state is set as expected. The expected state can vary depending on the environment.
Profile
A collection of recommendations for securing a technology or a supporting platform.
Most benchmarks include at least a Level 1 and Level 2 Profile. Level 2 extends Level 1
recommendations and is not a standalone profile. The Profile Definitions section in the
benchmark provides the definitions as they pertain to the recommendations included for
the technology.
Description
Detailed information pertaining to the setting with which the recommendation is
concerned. In some cases, the description will include the recommended value.
Rationale Statement
Detailed reasoning for the recommendation to provide the user a clear and concise
understanding on the importance of the recommendation.
Page 13
Audit Procedure
Systematic instructions for determining if the target system complies with the
recommendation.
Remediation Procedure
Systematic instructions for applying recommendations to the target system to bring it
into compliance according to the recommendation.
Default Value
Default value for the given setting in this recommendation, if known. If not known, either
not configured or not defined will be applied.
References
Additional documentation relative to the recommendation.
Additional Information
Supplementary information that does not correspond to any other field but may be
useful to the user.
Page 14
• Level 1 - Server
• Level 2 - Server
This profile extends the "Level 1 - Server" profile. Items in this profile exhibit one
or more of the following characteristics:
• Level 1 - Workstation
• Level 2 - Workstation
This profile extends the "Level 1 - Workstation" profile. Items in this profile exhibit
one or more of the following characteristics:
Page 15
Page 16
Editor
Jonathan Lewis Christopherson
Eric Pinnell
Page 17
Directories that are used for system-wide functions can be further protected by placing
them on separate partitions. This provides protection for resource exhaustion and
enables the use of mounting options that are applicable to the directory's intended use.
Users' data can be stored on separate partitions and have stricter mount options. A user
partition is a filesystem that has been established for use by the users and does not
contain software for system operations.
The recommendations in this section are easier to perform during initial system
installation. If the system is already installed, it is recommended that a full backup be
performed before repartitioning the system.
Note: If you are repartitioning a system that has already been installed (This may
require the system to be in single-user mode):
• Mount the new partition to a temporary mountpoint e.g. mount /dev/sda2 /mnt
• Copy data from the original partition to the new partition. e.g. cp /var/tmp/*
/mnt
• Verify that all data is present on the new partition. e.g. ls -la /mnt
• Unmount the new partition. e.g. umount /mnt
• Remove the data from the original directory that was in the old partition. e.g. rm -
Rf /var/tmp/* Otherwise it will still consume space in the old partition that will be
masked when the new filesystem is mounted.
• Mount the new partition to the desired mountpoint. e.g. mount /dev/sda2
/var/tmp
• Update /etc/fstab with the new mountpoint. e.g. /dev/sda2 /var/tmp xfs
defaults,rw,nosuid,nodev,noexec,relatime 0 0
Page 18
A number of uncommon filesystem types are supported under Linux. Removing support
for unneeded filesystem types reduces the local attack surface of the system. If a
filesystem type is not needed it should be disabled. Native Linux file systems are
designed to ensure that built-in security controls function as expected. Non-native
filesystems can lead to unexpected consequences to both the security and functionality
of the system and should be used with caution. Many filesystems are created for niche
use cases and are not maintained and supported as the operating systems are updated
and patched. Users of non-native filesystems should ensure that there is attention and
ongoing support for them, especially in light of frequent operating system changes.
Standard network connectivity and Internet access to cloud storage may make the use
of non-standard filesystem formats to directly attach heterogeneous devices much less
attractive.
Note: This should not be considered a comprehensive list of filesystems. You may wish
to consider additions to those listed here for your environment. For the current available
file system modules on the system see /usr/lib/modules/$(uname -r)/kernel/fs
Start up scripts
Kernel modules loaded directly via insmod will ignore what is configured in the relevant
/etc/modprobe.d/*.conf files. If modules are still being loaded after a reboot whilst
having the correctly configured blacklist and install command, check for insmod
entries in start up scripts such as .bashrc.
You may also want to check /lib/modprobe.d/. Please note that this directory should
not be used for user defined module loading. Ensure that all such entries resides in
/etc/modprobe.d/*.conf files.
Return values
By using /bin/false as the command in disabling a particular module serves two
purposes; to convey the meaning of the entry to the user and cause a non-zero return
value. The latter can be tested for in scripts. Please note that insmod will ignore what is
configured in the relevant /etc/modprobe.d/*.conf files. The preferred way to load
modules is with modprobe.
Page 19
• Level 1 - Server
• Level 1 - Workstation
Description:
The cramfs filesystem type is a compressed read-only Linux filesystem embedded in
small footprint systems. A cramfs image can be used without having to first decompress
the image.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the cramfs module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 20
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="cramfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Remediation:
Run the following script to disable the cramfs module:
If the module is available in the running kernel:
Page 21
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 22
{
l_mname="cramfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 23
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 24
• Level 1 - Server
• Level 1 - Workstation
Description:
The freevxfs filesystem type is a free version of the Veritas type filesystem. This is the
primary filesystem type for HP-UX operating systems.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the freevxfs module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 25
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="freevxfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Remediation:
Run the following script to disable the freevxfs module:
If the module is available in the running kernel:
Page 26
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 27
{
l_mname="freevxfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 28
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 29
• Level 1 - Server
• Level 1 - Workstation
Description:
The jffs2 (journaling flash filesystem 2) filesystem type is a log-structured filesystem
used in flash memory devices.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the jffs2 module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 30
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="jffs2" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 31
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 32
{
l_mname="jffs2" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 33
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 34
• Level 1 - Server
• Level 1 - Workstation
Description:
The hfs filesystem type is a hierarchical filesystem that allows you to mount Mac OS
filesystems.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the hfs module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 35
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="hfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 36
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 37
{
l_mname="hfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 38
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 39
• Level 1 - Server
• Level 1 - Workstation
Description:
The hfsplus filesystem type is a hierarchical filesystem designed to replace hfs that
allows you to mount Mac OS filesystems.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the hfsplus module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 40
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="hfsplus" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 41
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 42
{
l_mname="hfsplus" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 43
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 44
• Level 2 - Server
• Level 2 - Workstation
Description:
The squashfs filesystem type is a compressed read-only Linux filesystem embedded in
small footprint systems. A squashfs image can be used without having to first
decompress the image.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Impact:
As Snap packages utilizes squashfs as a compressed filesystem, disabling squashfs
will cause Snap packages to fail.
Snap application packages of software are self-contained and work across a range of
Linux distributions. This is unlike traditional Linux package management approaches,
like APT or RPM, which require specifically adapted packages per Linux distribution on
an application update and delay therefore application deployment from developers to
their software's end-user. Snaps themselves have no dependency on any external store
("App store"), can be obtained from any source and can be therefore used for upstream
software deployment.
Audit:
Run the following script to verify the squashfs module is disabled:
If the module is available in the running kernel:
Page 45
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="squashfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 46
Remediation:
Run the following script to disable the squashfs module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 47
{
l_mname="squashfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 48
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 49
• Level 2 - Server
• Level 2 - Workstation
Description:
The udf filesystem type is the universal disk format used to implement ISO/IEC 13346
and ECMA-167 specifications. This is an open vendor filesystem type for data storage
on a broad range of media. This filesystem type is necessary to support writing DVDs
and newer optical disc formats.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Impact:
Microsoft Azure requires the usage of udf.
udf should not be disabled on systems run on Microsoft Azure.
Audit:
Run the following script to verify the udf module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 50
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="udf" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 51
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 52
{
l_mname="udf" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 53
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 54
The /tmp directory is a world-writable directory used for temporary storage by all users
and some applications.
Page 55
Description:
The /tmp directory is a world-writable directory used for temporary storage by all users
and some applications.
Rationale:
Making /tmp its own file system allows an administrator to set additional mount options
such as the noexec option on the mount, making /tmp useless for an attacker to install
executable code. It would also prevent an attacker from establishing a hard link to a
system setuid program and wait for it to be updated. Once the program was updated,
the hard link would be broken and the attacker would have his own copy of the program.
If the program happened to have a security vulnerability, the attacker could continue to
exploit the known flaw.
This can be accomplished by either mounting tmpfs to /tmp, or creating a separate
partition for /tmp.
Impact:
Since the /tmp directory is intended to be world-writable, there is a risk of resource
exhaustion if it is not bound to a separate partition.
Running out of /tmp space is a problem regardless of what kind of filesystem lies under
it, but in a configuration where /tmp is not a separate file system it will essentially have
the whole disk available, as the default installation only creates a single / partition. On
the other hand, a RAM-based /tmp (as with tmpfs) will almost certainly be much
smaller, which can lead to applications filling up the filesystem much more easily.
Another alternative is to create a dedicated partition for /tmp from a separate volume or
disk. One of the downsides of a disk-based dedicated partition is that it will be slower
than tmpfs which is RAM-based.
/tmp utilizing tmpfs can be resized using the size={size} parameter in the relevant
entry in /etc/fstab.
Page 56
Example output:
/tmp tmpfs tmpfs rw,nosuid,nodev,noexec
Remediation:
For specific configuration requirements of the /tmp mount for your environment, modify
/etc/fstab or tmp.mount unit file:
Using /etc/fstab:
Configure /etc/fstab as appropriate:
Example:
tmpfs /tmp tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
-OR-
[Unit]
Description=Temporary Directory (/tmp)
Documentation=https://systemd.io/TEMPORARY_DIRECTORIES
Documentation=man:file-hierarchy(7)
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev,noexec
[Install]
WantedBy=local-fs.target
Run the following command to reload the systemd daemon with the updated tmp.mount
unit file:
Page 57
References:
1. https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems/
2. https://www.freedesktop.org/software/systemd/man/systemd-fstab-generator.html
3. NIST SP 800-53 Rev. 5: CM-7
Additional Information:
If an entry for /tmp exists in /etc/fstab it will take precedence over entries in systemd
unit file.
tmpfs can be resized using the size={size} parameter in /etc/fstab or on the Options line
in the tmp.mount file. If we don't specify the size, it will be half the RAM
Example resize entry:
/etc/fstab:
tmpfs /tmp tmpfs rw,noexec,nodev,nosuid,size=2G 0 0
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 58
Techniques / Sub-
Tactics Mitigations
techniques
Page 59
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /tmp filesystem is not intended to support devices, set this option to ensure
that users cannot create block or character special devices in /tmp.
Audit:
Verify that the nodev option is set for the /tmp mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /tmp | grep nodev
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /tmp
partition.
Example:
<device> /tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp
References:
Page 60
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 61
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /tmp filesystem is only intended for temporary file storage, set this option to
ensure that users cannot run executable binaries from /tmp.
Audit:
Verify that the noexec option is set for the /tmp mount.
Run the following command to verify that the noexec mount option is set.
Example:
# findmnt -kn /tmp | grep noexec
Remediation:
Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the
/tmp partition.
Example:
<device> /tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp
References:
Page 62
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 63
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /tmp filesystem is only intended for temporary file storage, set this option to
ensure that users cannot create setuid files in /tmp.
Audit:
Verify that the nosuid option is set for the /tmp mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /tmp | grep nosuid
Remediation:
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the
/tmp partition.
Example:
<device> /tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp
References:
Page 64
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 65
The /var directory is used by daemons and other system services to temporarily store
dynamic data. Some directories created by these processes may be world-writable.
Page 66
• Level 2 - Server
• Level 2 - Workstation
Description:
The /var directory is used by daemons and other system services to temporarily store
dynamic data. Some directories created by these processes may be world-writable.
Rationale:
The reasoning for mounting /var on a separate partition is as follow.
Page 67
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var it is advisable to bring the system to emergency mode (so auditd
is not running), rename the existing directory, mount the new file system, and migrate
the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 68
Techniques / Sub-
Tactics Mitigations
techniques
Page 69
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var filesystem is not intended to support devices, set this option to ensure
that users cannot create block or character special devices in /var.
Audit:
Verify that the nodev option is set for the /var mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /var | grep -v 'nodev'
Remediation:
IF the /var partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /var partition.
Example:
<device> /var <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /var with the configured options:
# mount -o remount /var
References:
Page 70
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 71
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var filesystem is only intended for variable files such as logs, set this option
to ensure that users cannot create setuid files in /var.
Audit:
Verify that the nosuid option is set for the /var mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /var | grep -v 'nosuid'
Remediation:
IF the /var partition exists, edit the /etc/fstab file and add nosuid to the fourth field
(mounting options) for the /var partition.
Example:
<device> /var <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /var with the configured options:
# mount -o remount /var
References:
Page 72
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 73
The /var/tmp directory is a world-writable directory used for temporary storage by all
users and some applications. Temporary files residing in /var/tmp are to be preserved
between reboots.
Page 74
• Level 2 - Server
• Level 2 - Workstation
Description:
The /var/tmp directory is a world-writable directory used for temporary storage by all
users and some applications. Temporary files residing in /var/tmp are to be preserved
between reboots.
Rationale:
The reasoning for mounting /var/tmp on a separate partition is as follows.
Page 75
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var/tmp.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var/tmp it is advisable to bring the system to emergency mode (so
auditd is not running), rename the existing directory, mount the new file system, and
migrate the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 76
Techniques / Sub-
Tactics Mitigations
techniques
Page 77
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var/tmp filesystem is not intended to support devices, set this option to
ensure that users cannot create block or character special devices in /var/tmp.
Audit:
Verify that the nodev option is set for the /var/tmp mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /var/tmp | grep -v 'nodev'
Remediation:
IF the /var/tmp partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /var/tmp partition.
Example:
<device> /var/tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/tmp with the configured options:
# mount -o remount /var/tmp
References:
Page 78
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 79
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /var/tmp filesystem is only intended for temporary file storage, set this option
to ensure that users cannot run executable binaries from /var/tmp.
Audit:
Verify that the noexec option is set for the /var/tmp mount.
Run the following command to verify that the noexec mount option is set.
Example:
# findmnt -kn /var/tmp | grep -v 'noexec'
Remediation:
IF the /var/tmp partition exists, edit the /etc/fstab file and add noexec to the fourth
field (mounting options) for the /var/tmp partition.
Example:
<device> /var/tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/tmp with the configured options:
# mount -o remount /var/tmp
References:
Page 80
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 81
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var/tmp filesystem is only intended for temporary file storage, set this option
to ensure that users cannot create setuid files in /var/tmp.
Audit:
Verify that the nosuid option is set for the /var/tmp mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /var/tmp | grep -v 'nosuid'
Remediation:
IF the /var/tmp partition exists, edit the /etc/fstab file and add nosuid to the fourth
field (mounting options) for the /var/tmp partition.
Example:
<device> /var/tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/tmp with the configured options:
# mount -o remount /var/tmp
References:
Page 82
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 83
Page 84
• Level 2 - Server
• Level 2 - Workstation
Description:
The /var/log directory is used by system services to store log data.
Rationale:
The reasoning for mounting /var/log on a separate partition is as follows.
Page 85
Example output:
/var/log /dev/sdb ext4 rw,relatime,seclabel,data=ordered
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var/log .
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var/log it is advisable to bring the system to emergency mode (so
auditd is not running), rename the existing directory, mount the new file system, and
migrate the data over before returning to multiuser mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 86
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var/log filesystem is not intended to support devices, set this option to
ensure that users cannot create block or character special devices in /var/log.
Audit:
Verify that the nodev option is set for the /var/log mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /var/log | grep -v 'nodev'
Remediation:
IF the /var/log partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /var/log partition.
Example:
<device> /var/log <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log with the configured options:
# mount -o remount /var/log
References:
Page 87
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 88
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /var/log filesystem is only intended for log files, set this option to ensure that
users cannot run executable binaries from /var/log.
Audit:
Verify that the noexec option is set for the /var/log mount.
Run the following command to verify that the noexec mount option is set.
Example:
# findmnt -kn /var/log | grep -v 'noexec'
Remediation:
IF the /var/log partition exists, edit the /etc/fstab file and add noexec to the fourth
field (mounting options) for the /var/log partition.
Example:
<device> /var/log <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log with the configured options:
# mount -o remount /var/log
References:
Page 89
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 90
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var/log filesystem is only intended for log files, set this option to ensure that
users cannot create setuid files in /var/log.
Audit:
Verify that the nosuid option is set for the /var/log mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /var/log | grep -v 'nosuid'
Remediation:
IF the /var/log partition exists, edit the /etc/fstab file and add nosuid to the fourth
field (mounting options) for the /var/log partition.
Example:
<device> /var/log <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log with the configured options:
# mount -o remount /var/log
References:
Page 91
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 92
The auditing daemon, auditd, stores log data in the /var/log/audit directory.
Page 93
• Level 2 - Server
• Level 2 - Workstation
Description:
The auditing daemon, auditd, stores log data in the /var/log/audit directory.
Rationale:
The reasoning for mounting /var/log/audit on a separate partition is as follows.
Page 94
Example output:
/var/log/audit /dev/sdb ext4 rw,relatime,seclabel,data=ordered
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var/log/audit.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var/log/audit it is advisable to bring the system to emergency mode
(so auditd is not running), rename the existing directory, mount the new file system, and
migrate the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 95
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var/log/audit filesystem is not intended to support devices, set this option
to ensure that users cannot create block or character special devices in
/var/log/audit.
Audit:
Verify that the nodev option is set for the /var/log/audit mount.
Run the following command to verify that the nodev mount option is set.
# findmnt -kn /var/log/audit | grep -v 'nodev'
Remediation:
IF the /var/log/audit partition exists, edit the /etc/fstab file and add nodev to the
fourth field (mounting options) for the /var/log/audit partition.
Example:
<device> /var/log/audit <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log/audit with the configured options:
# mount -o remount /var/log/audit
References:
Page 96
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 97
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /var/log/audit filesystem is only intended for audit logs, set this option to
ensure that users cannot run executable binaries from /var/log/audit.
Audit:
Verify that the noexec option is set for the /var/log/audit mount.
Run the following command to verify that the noexec mount option is set.
# findmnt -kn /var/log/audit | grep -v 'noexec'
Remediation:
IF the /var/log/audit partition exists, edit the /etc/fstab file and add noexec to the
fourth field (mounting options) for the /var partition.
Example:
<device> /var/log/audit <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log/audit with the configured options:
# mount -o remount /var/log/audit
References:
Page 98
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 99
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var/log/audit filesystem is only intended for variable files such as logs, set
this option to ensure that users cannot create setuid files in /var/log/audit.
Audit:
Verify that the nosuid option is set for the /var/log/audit mount.
Run the following command to verify that the nosuid mount option is set.
# findmnt -kn /var/log/audit | grep -v 'nosuid'
Remediation:
IF the /var/log/audit partition exists, edit the /etc/fstab file and add nosuid to the
fourth field (mounting options) for the /var/log/audit partition.
Example:
<device> /var/log/audit <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log/audit with the configured options:
# mount -o remount /var/log/audit
References:
Page 100
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 101
Please note that home directories could be mounted anywhere and are not necessarily
restricted to /home nor restricted to a single location, nor is the name restricted in any
way.
Checks can be made by looking in /etc/passwd, looking over the mounted file systems
with mount or querying the relevant database with getent.
Page 102
• Level 2 - Server
• Level 2 - Workstation
Description:
The /home directory is used to support disk storage needs of local users.
Rationale:
The reasoning for mounting /home on a separate partition is as follows.
Page 103
Example output:
/home /dev/sdb ext4 rw,relatime,seclabel
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /home.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /home it is advisable to bring the system to emergency mode (so auditd
is not running), rename the existing directory, mount the new file system, and migrate
the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 104
Techniques / Sub-
Tactics Mitigations
techniques
Page 105
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /home filesystem is not intended to support devices, set this option to ensure
that users cannot create block or character special devices in /home.
Audit:
Verify that the nodev option is set for the /home mount.
Run the following command to verify that the nodev mount option is set.
# findmnt -kn /home | grep -v 'nodev'
Remediation:
IF the /home partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /home partition.
Example:
<device> /home <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /home with the configured options:
# mount -o remount /home
References:
Page 106
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 107
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /home filesystem is only intended for user file storage, set this option to ensure
that users cannot create setuid files in /home.
Audit:
Verify that the nosuid option is set for the /home mount.
Run the following command to verify that the nosuid mount option is set.
# findmnt -kn /home | grep -v 'nosuid'
Remediation:
IF the /home partition exists, edit the /etc/fstab file and add nosuid to the fourth field
(mounting options) for the /home partition.
Example:
<device> /home <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /home with the configured options:
# mount -o remount /home
References:
Page 108
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 109
Page 110
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /dev/shm filesystem is not intended to support devices, set this option to
ensure that users cannot attempt to create special devices in /dev/shm partitions.
Audit:
Verify that the nodev option is set for the /dev/shm mount.
Run the following command to verify that the nodev mount option is set.
# findmnt -kn /dev/shm | grep -v 'nodev'
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the
/dev/shm partition. See the fstab(5) manual page for more information.
Example:
tmpfs /dev/shm tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /dev/shm with the configured options:
# mount -o remount /dev/shm
Additional Information:
Some distributions mount /dev/shm through other means and require /dev/shm to be
added to /etc/fstab even though it is already being mounted on boot. Others may
configure /dev/shm in other locations and may override /etc/fstab configuration.
Consult the documentation appropriate for your distribution.
Page 111
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 112
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Setting this option on a file system prevents users from executing programs from shared
memory. This deters users from introducing potentially malicious software on the
system.
Audit:
Verify that the noexec option is set for the /dev/shm mount.
Run the following command to verify that the noexec mount option is set.
# findmnt -kn /dev/shm | grep -v 'noexec'
Remediation:
Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the
/dev/shm partition.
Example:
tmpfs /dev/shm tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /dev/shm with the configured options:
# mount -o remount /dev/shm
Page 113
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 114
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Setting this option on a file system prevents users from introducing privileged programs
onto the system and allowing non-root users to execute them.
Audit:
Verify that the nosuid option is set for the /dev/shm mount.
Run the following command to verify that the nosuid mount option is set.
# findmnt -kn /dev/shm | grep -v 'nosuid'
Remediation:
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the
/dev/shm partition. See the fstab(5) manual page for more information.
Example:
tmpfs /dev/shm tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /dev/shm with the configured options:
# mount -o remount /dev/shm
Additional Information:
Some distributions mount /dev/shm through other means and require /dev/shm to be
added to /etc/fstab even though it is already being mounted on boot. Others may
configure /dev/shm in other locations and may override /etc/fstab configuration.
Consult the documentation appropriate for your distribution.
Page 115
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 116
• Level 1 - Server
• Level 2 - Workstation
Description:
autofs allows automatic mounting of devices, typically including CD/DVDs and USB
drives.
Rationale:
With automounting enabled anyone with physical access could attach a USB drive or
disc and have its contents available in the filesystem even if they lacked permissions to
mount it themselves.
Impact:
The use of portable hard drives is very common for workstation users. If your
organization allows the use of portable storage or media on workstations and physical
access controls to workstations are considered adequate there is little value add in
turning off automounting.
Audit:
As a preference autofs should not be installed unless other packages depend on it.
Run the following command to verify autofs is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' autofs
Page 117
References:
Additional Information:
This control should align with the tolerance of the use of portable drives and optical
media in the organization. On a server, requiring an admin to manually mount media
can be part of defense-in-depth to reduce the risk of unapproved software or information
being introduced or proprietary software or information being exfiltrated. If admins
commonly use flash drives and Server access has sufficient physical controls, requiring
manual mounting may not increase security.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 118
• Level 1 - Server
• Level 2 - Workstation
Description:
USB storage provides a means to transfer and store files insuring persistence and
availability of the files independent of network connection status. Its popularity and utility
has led to USB-based malware being a simple and common means for network
infiltration and a first step to establishing a persistent threat within a networked
environment.
Rationale:
Restricting USB access on the system will decrease the physical attack surface for a
device and diminish the possible vectors to introduce malware.
Impact:
Disabling the usb-storage module will disable any usage of USB storage devices.
If requirements and local site policy allow the use of such devices, other solutions
should be configured accordingly instead. One example of a commonly used solution is
USBGuard.
Audit:
Run the following script to verify the usb-storage module is disabled:
If the module is available in the running kernel:
Page 119
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="usb-storage" # set module name
l_mtype="drivers" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 120
• No remediation is necessary
Page 121
{
l_mname="usb-storage" # set module name
l_mtype="drivers" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 122
Additional Information:
An alternative solution to disabling the usb-storage module may be found in USBGuard.
Use of USBGuard and construction of USB device policies should be done in alignment
with site policy.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 123
AIDE is a file integrity checking tool, similar in nature to Tripwire. While it cannot prevent
intrusions, it can detect unauthorized changes to configuration files by alerting when the
files are changed. When setting up AIDE, decide internally what the site policy will be
concerning integrity checking. Review the AIDE quick start guide and AIDE
documentation before proceeding.
Page 124
• Level 1 - Server
• Level 1 - Workstation
Description:
AIDE takes a snapshot of filesystem state including modification times, permissions,
and file hashes which can then be used to compare against the current state of the
filesystem to detect modifications to the system.
Rationale:
By monitoring the filesystem state compromised files can be detected to prevent or limit
the exposure of accidental or malicious misconfigurations or modified binaries.
Audit:
Run the following command to verify aide is installed:
# dpkg-query -s aide &>/dev/null && echo "aide is installed"
aide is installed
aide-common is installed
Remediation:
Run the following command to install aide and aide-common:
# apt install aide aide-common
References:
Additional Information:
The prelinking feature can interfere with AIDE because it alters binaries to speed up
their start up times. Run prelink -ua to restore the binaries to their prelinked state, thus
avoiding false positives from AIDE.
Page 125
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 126
• Level 1 - Server
• Level 1 - Workstation
Description:
Periodic checking of the filesystem integrity is needed to detect changes to the
filesystem.
Rationale:
Periodic file checking allows the system administrator to determine on a regular basis if
critical files have been changed in an unauthorized fashion.
Audit:
Run the following commands to verify a cron job scheduled to run the aide check.
# grep -Prs '^([^#\n\r]+\h+)?(\/usr\/s?bin\/|^\h*)aide(\.wrapper)?\h+(--check|([^#\n\r]+\h+)?\$AIDEARGS)\b'
/etc/cron.* /etc/crontab /var/spool/cron/
Page 127
[Service]
Type=simple
ExecStart=/usr/bin/aide.wrapper --config /etc/aide/aide.conf --check
[Install]
WantedBy=multi-user.target
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
References:
1. https://github.com/konstruktoid/hardening/blob/master/config/aidecheck.service
2. https://github.com/konstruktoid/hardening/blob/master/config/aidecheck.timer
3. NIST SP 800-53 Rev. 5: AU-2
Page 128
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1036, T1036.002,
T1036.003, T1036.004,
TA0040 M1022
T1036.005, T1565,
T1565.001
Page 129
Outdated software is vulnerable to cyber criminals and hackers. Software updates help
reduce the risk to your organization. The release of software update notes often reveal
the patched exploitable entry points to the public. Public knowledge of these exploits
cans your organization more vulnerable to malicious actors attempting to gain entry to
your system's data.
Software updates often offer new and improved features and speed enhancements
Page 130
• Level 1 - Server
• Level 1 - Workstation
Description:
Periodically patches are released for included software either due to security flaws or to
include additional functionality.
Rationale:
Newer patches may contain security enhancements that would not be available through
the latest full update. As a result, it is recommended that the latest software patches be
used to take advantage of the latest functionality. As with any software installation,
organizations need to determine if a given update meets their requirements and verify
the compatibility and supportability of any additional software against the update
revision that is selected.
Audit:
Verify there are no updates or patches to install:
# apt -s upgrade
Remediation:
Run the following command to update all packages following local site policy guidance
on applying updates and patches:
# apt upgrade
OR
# apt dist-upgrade
References:
Page 131
• upgrade - is used to install the newest versions of all packages currently installed
on the system from the sources enumerated in /etc/apt/sources.list. Packages
currently installed with new versions available are retrieved and upgraded; under
no circumstances are currently installed packages removed, or packages not
already installed retrieved and installed. New versions of currently installed
packages that cannot be upgraded without changing the install status of another
package will be left at their current version. An update must be performed first so
that apt knows that new versions of packages are available.
• dist-upgrade - in addition to performing the function of upgrade, also intelligently
handles changing dependencies with new versions of packages; apt has a
"smart" conflict resolution system, and it will attempt to upgrade the most
important packages at the expense of less important ones if necessary. So, dist-
upgrade command may remove some packages. The /etc/apt/sources.list file
contains a list of locations from which to retrieve desired package files. See also
apt_preferences(5) for a mechanism for overriding the general settings for
individual packages.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 132
Techniques / Sub-
Tactics Mitigations
techniques
Page 133
• Level 1 - Server
• Level 1 - Workstation
Description:
Systems need to have package manager repositories configured to ensure they receive
the latest patches and updates.
Rationale:
If a system's package repositories are misconfigured important patches may not be
identified or a rogue repository could introduce compromised software.
Audit:
Run the following command and verify package repositories are configured correctly:
# apt-cache policy
Remediation:
Configure your package manager repositories according to site policy.
References:
Page 134
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 135
• Level 1 - Server
• Level 1 - Workstation
Description:
Most packages managers implement GPG key signing to verify package integrity during
installation.
Rationale:
It is important to ensure that updates are obtained from a valid source to protect against
spoofing that could lead to the inadvertent installation of malware on the system.
Audit:
Verify GPG keys are configured correctly for your package manager:
# apt-key list
Remediation:
Update your package manager GPG keys in accordance with site policy.
References:
Page 136
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1195, T1195.001,
TA0001 M1051
T1195.002
Page 137
The recommendations in this section focus on securing the bootloader and settings
involved in the boot process directly.
Page 138
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting the boot loader password will require that anyone rebooting the system must
enter a password before being able to set command line boot parameters
Rationale:
Requiring a boot password upon execution of the boot loader will prevent an
unauthorized user from entering boot parameters or changing the boot partition. This
prevents users from weakening security (e.g. turning off AppArmor at boot time).
Impact:
If password protection is enabled, only the designated superuser can edit a GRUB 2
menu item by pressing "e" or access the GRUB 2 command line by pressing "c"
If GRUB 2 is set up to boot automatically to a password-protected menu entry the user
has no option to back out of the password prompt to select another menu entry. Holding
the SHIFT key will not display the menu in this case. The user must enter the correct
username and password. If unable to do so, the configuration files will have to be edited
via a LiveCD or other means to fix the problem
You can add --unrestricted to the menu entries to allow the system to boot without
entering a password. A password will still be required to edit menu items.
More Information: https://help.ubuntu.com/community/Grub2/Passwords
Audit:
Run the following commands and verify output matches:
# grep "^set superusers" /boot/grub/grub.cfg
set superusers="<username>"
# grep "^password" /boot/grub/grub.cfg
Page 139
Default Value:
This recommendation is designed around the grub bootloader, if LILO or another
bootloader is in use in your environment enact equivalent settings.
Replace /boot/grub/grub.cfg with the appropriate grub configuration file for your
environment.
References:
Additional Information:
Changes to /etc/grub.d/10_linux may be overwritten during updates to the grub-
common package. You should review any changes to this file before rebooting otherwise
the system may unexpectedly prompt for a password on the next boot.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 140
Techniques / Sub-
Tactics Mitigations
techniques
Page 141
• Level 1 - Server
• Level 1 - Workstation
Description:
The grub configuration file contains information on boot settings and passwords for
unlocking boot options.
Rationale:
Setting the permissions to read and write for root only prevents non-root users from
seeing the boot parameters or changing them. Non-root users who read the boot
parameters may be able to identify weaknesses in security upon boot and be able to
exploit them.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access is 0600
or more restrictive.
# stat /boot/grub/grub.cfg
Remediation:
Run the following commands to set permissions on your grub configuration:
# chown root:root /boot/grub/grub.cfg
# chmod u-x,go-rwx /boot/grub/grub.cfg
References:
Additional Information:
This recommendation is designed around the grub bootloader, if LILO or another
bootloader is in use in your environment enact equivalent settings.
Replace /boot/grub/grub.cfg with the appropriate grub configuration file for your
environment
Page 142
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 143
• Level 1 - Server
• Level 1 - Workstation
Description:
Single user mode is used for recovery when the system detects an issue during boot or
by manual selection from the bootloader.
Rationale:
Requiring authentication in single user mode prevents an unauthorized user from
rebooting the system into single user to gain root privileges without credentials.
Audit:
Perform the following to determine if a password is set for the root user:
# grep -Eq '^root:\$[0-9]' /etc/shadow || echo "root is locked"
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 144
Techniques / Sub-
Tactics Mitigations
techniques
Page 145
Page 146
• Level 1 - Server
• Level 1 - Workstation
Description:
The ptrace() system call provides a means by which one process (the "tracer") may
observe and control the execution of another process (the "tracee"), and examine and
change the tracee's memory and registers.
Rationale:
If one application is compromised, it would be possible for an attacker to attach to other
running processes (e.g. Bash, Firefox, SSH sessions, GPG agent, etc) to extract
additional credentials and continue to expand the scope of their attack.
Enabling restricted mode will limit the ability of a compromised process to
PTRACE_ATTACH on other processes running under the same user. With restricted
mode, ptrace will continue to work with root user.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
kernel.yama.ptrace_scope is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 147
{
l_output="" l_output2=""
a_parlist=("kernel.yama.ptrace_scope=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 148
Page 149
•
kernel.yama.ptrace_scope = 1
Example:
# printf '%s\n' "kernel.yama.ptrace_scope = 1" >> /etc/sysctl.d/60-kernel_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
kernel.yama.ptrace_scope=1
References:
1. https://www.kernel.org/doc/Documentation/security/Yama.txt
2. https://github.com/raj3shp/termspy
Additional Information:
Ptrace is very rarely used by regular applications and is mostly used by debuggers such
as gdb and strace.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 150
Techniques / Sub-
Tactics Mitigations
techniques
T1055.008
Page 151
• Level 1 - Server
• Level 1 - Workstation
Description:
A core dump is the memory of an executable program. It is generally used to determine
why a program aborted. It can also be used to glean confidential information from a core
file. The system provides the ability to set a soft limit for core dumps, but this can be
overridden by the user.
Rationale:
Setting a hard limit on core dumps prevents users from overriding the soft variable. If
core dumps are required, consider setting limits for user groups (see limits.conf(5) ).
In addition, setting the fs.suid_dumpable variable to 0 will prevent setuid programs from
dumping core.
Audit:
Run the following command and verify output matches:
# grep -Es '^(\*|\s).*hard.*core.*(\s+#.*)?$' /etc/security/limits.conf /etc/security/limits.d/*
* hard core 0
•
fs.suid_dumpable is set to 0
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 152
{
l_output="" l_output2=""
a_parlist=("fs.suid_dumpable=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 153
Page 154
•
fs.suid_dumpable = 0
Example:
# printf '%s\n' "fs.suid_dumpable = 0" >> /etc/sysctl.d/60-fs_sysctl.conf
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
-IF- systemd-coredump is installed:
edit /etc/systemd/coredump.conf and add/modify the following lines:
Storage=none
ProcessSizeMax=0
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 155
• Level 1 - Server
• Level 1 - Workstation
Description:
Address space layout randomization (ASLR) is an exploit mitigation technique which
randomly arranges the address space of key data areas of a process.
Rationale:
Randomly placing virtual memory regions will make it difficult to write memory page
exploits as the memory placement will be consistently shifting.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
kernel.randomize_va_space is set to 2
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 156
{
l_output="" l_output2=""
a_parlist=(kernel.randomize_va_space=2)
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 157
Page 158
•
kernel.randomize_va_space = 2
Example:
# printf '%s\n' "kernel.randomize_va_space = 2" >> /etc/sysctl.d/60-kernel_sysctl.conf
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
kernel.randomize_va_space = 2
References:
1. http://manpages.ubuntu.com/manpages/focal/man5/sysctl.d.5.html
2. CCI-000366: The organization implements the security configuration settings
3. NIST SP 800-53 Rev. 5: CM-6
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 159
Techniques / Sub-
Tactics Mitigations
techniques
Page 160
• Level 1 - Server
• Level 1 - Workstation
Description:
prelink is a program that modifies ELF shared libraries and ELF dynamically linked
binaries in such a way that the time needed for the dynamic linker to perform relocations
at startup significantly decreases.
Rationale:
The prelinking feature can interfere with the operation of AIDE, because it changes
binaries. Prelinking can also increase the vulnerability of the system if a malicious user
is able to compromise a common library such as libc.
Audit:
Verify prelink is not installed:
# dpkg-query -s prelink &>/dev/null && echo "prelink is installed"
References:
Page 161
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 162
• Level 1 - Server
• Level 1 - Workstation
Description:
The Apport Error Reporting Service automatically generates crash reports for
debugging
Rationale:
Apport collects potentially sensitive data, such as core dumps, stack traces, and log
files. They can contain passwords, credit card numbers, serial numbers, and other
private material.
Audit:
Run the following command to verify that the Apport Error Reporting Service is not
enabled:
# dpkg-query -s apport > /dev/null 2>&1 && grep -Psi -- '^\h*enabled\h*=\h*[^0]\b' /etc/default/apport
Run the following commands to stop and disable the apport service
# systemctl stop apport.service
# systemctl --now disable apport.service
-- OR --
Run the following command to remove the apport package:
# apt purge apport
Default Value:
enabled=1
Page 163
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 164
AppArmor provides a Mandatory Access Control (MAC) system that greatly augments
the default Discretionary Access Control (DAC) model. Under AppArmor MAC rules are
applied by file paths instead of by security contexts as in other MAC systems. As such it
does not require support in the filesystem and can be applied to network mounted
filesystems for example. AppArmor security policies define what system resources
applications can access and what privileges they can do so with. This automatically
limits the damage that the software can do to files accessible by the calling user. The
user does not need to take any action to gain this benefit. For an action to occur, both
the traditional DAC permissions must be satisfied as well as the AppArmor MAC rules.
The action will not be allowed if either one of these models does not permit the action.
In this way, AppArmor rules can only make a system's permissions more restrictive and
secure.
References:
Page 165
• Level 1 - Server
• Level 1 - Workstation
Description:
AppArmor provides Mandatory Access Controls.
Rationale:
Without a Mandatory Access Control system installed only the default Discretionary
Access Control system will be available.
Audit:
Run the follow command to verify that apparmor is installed:
# dpkg-query -s apparmor &>/dev/null && echo "apparmor is installed"
apparmor is installed
apparmor-utils is installed
Remediation:
Install apparmor
# apt install apparmor apparmor-utils
References:
Page 166
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 167
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure AppArmor to be enabled at boot time and verify that it has not been
overwritten by the bootloader boot parameters.
Note: This recommendation is designed around the grub bootloader, if LILO or another
bootloader is in use in your environment enact equivalent settings.
Rationale:
AppArmor must be enabled at boot time in your bootloader configuration to ensure that
the controls it provides are not overridden.
Audit:
Run the following commands to verify that all linux lines have the apparmor=1 and
security=apparmor parameters set:
# grep "^\s*linux" /boot/grub/grub.cfg | grep -v "apparmor=1"
Remediation:
Edit /etc/default/grub and add the apparmor=1 and security=apparmor parameters to
the GRUB_CMDLINE_LINUX= line
GRUB_CMDLINE_LINUX="apparmor=1 security=apparmor"
References:
Page 168
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 169
• Level 1 - Server
• Level 1 - Workstation
Description:
AppArmor profiles define what resources applications are able to access.
Rationale:
Security configuration requirements vary from site to site. Some sites may mandate a
policy that is stricter than the default policy, which is perfectly acceptable. This item is
intended to ensure that any policies that exist on the system are activated.
Audit:
Run the following command and verify that profiles are loaded, and are in either enforce
or complain mode:
# apparmor_status | grep profiles
Review output and ensure that profiles are loaded, and in either enforce or complain
mode:
37 profiles are loaded.
35 profiles are in enforce mode.
2 profiles are in complain mode.
4 processes have profiles defined.
Page 170
OR
Run the following command to set all profiles to complain mode:
# aa-complain /etc/apparmor.d/*
Note: Any unconfined processes may need to have a profile created or activated for
them and then be restarted
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1497 TA0005
Page 171
• Level 2 - Server
• Level 2 - Workstation
Description:
AppArmor profiles define what resources applications are able to access.
Rationale:
Security configuration requirements vary from site to site. Some sites may mandate a
policy that is stricter than the default policy, which is perfectly acceptable. This item is
intended to ensure that any policies that exist on the system are activated.
Audit:
Run the following commands and verify that profiles are loaded and are not in complain
mode:
# apparmor_status | grep profiles
Review output and ensure that profiles are loaded, and in enforce mode:
34 profiles are loaded.
34 profiles are in enforce mode.
0 profiles are in complain mode.
2 processes have profiles defined.
Run the following command and verify that no processes are unconfined:
apparmor_status | grep processes
Remediation:
Run the following command to set all profiles to enforce mode:
# aa-enforce /etc/apparmor.d/*
Note: Any unconfined processes may need to have a profile created or activated for
them and then be restarted
References:
Page 172
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 173
Presenting a warning message prior to the normal user login may assist in the
prosecution of trespassers on the computer system. Changing some of these login
banners also has the side effect of hiding OS version information and other detailed
system information from attackers attempting to target specific exploits at a system. The
/etc/motd, /etc/issue, and /etc/issue.net files govern warning banners for standard
command line logins for both local and remote users.
Guidelines published by the US Department of Defense require that warning messages
include at least the name of the organization that owns the system, the fact that the
system is subject to monitoring and that such monitoring is in compliance with local
statutes, and that use of the system implies consent to such monitoring. It is important
that the organization's legal counsel review the content of all messages before any
system modifications are made, as these warning messages are inherently site-specific.
More information (including citations of relevant case law) can be found at
http://www.justice.gov/criminal/cybercrime/
The /etc/motd, /etc/issue, and /etc/issue.net files govern warning banners for
standard command line logins for both local and remote users.
Note: The text provided in the remediation actions for these items is intended as an
example only. Please edit to include the specific text for your organization as approved
by your legal department
Page 174
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/motd file are displayed to users after login and function as a
message of the day for authenticated users.
Unix-based systems have typically displayed information about the OS release and
patch level upon logging in to the system. This information can be useful to developers
who are developing software for a particular OS platform. If mingetty(8) supports the
following options, they display operating system information: \m - machine architecture
\r - operating system release \s - operating system name \v - operating system version
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place. Displaying OS and patch level
information in login banners also has the side effect of providing detailed system
information to attackers attempting to target specific exploits of a system. Authorized
users can easily get this information by running the " uname -a " command once they
have logged in.
Audit:
Run the following command and verify no results are returned:
# grep -Eis "(\\\v|\\\r|\\\m|\\\s|$(grep '^ID=' /etc/os-release | cut -d= -f2 | sed -e 's/"//g'))" /etc/motd
Page 175
-- OR --
If the motd is not used, this file can be removed.
Run the following command to remove the motd file:
# rm /etc/motd
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 176
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue file are displayed to users prior to login for local
terminals.
Unix-based systems have typically displayed information about the OS release and
patch level upon logging in to the system. This information can be useful to developers
who are developing software for a particular OS platform. If mingetty(8) supports the
following options, they display operating system information: \m - machine architecture
\r - operating system release \s - operating system name \v - operating system version
- or the operating system's name
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place. Displaying OS and patch level
information in login banners also has the side effect of providing detailed system
information to attackers attempting to target specific exploits of a system. Authorized
users can easily get this information by running the " uname -a " command once they
have logged in.
Audit:
Run the following command and verify that the contents match site policy:
# cat /etc/issue
Page 177
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 178
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue.net file are displayed to users prior to login for remote
connections from configured services.
Unix-based systems have typically displayed information about the OS release and
patch level upon logging in to the system. This information can be useful to developers
who are developing software for a particular OS platform. If mingetty(8) supports the
following options, they display operating system information: \m - machine architecture
\r - operating system release \s - operating system name \v - operating system version
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place. Displaying OS and patch level
information in login banners also has the side effect of providing detailed system
information to attackers attempting to target specific exploits of a system. Authorized
users can easily get this information by running the " uname -a " command once they
have logged in.
Audit:
Run the following command and verify that the contents match site policy:
# cat /etc/issue.net
Page 179
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 180
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/motd file are displayed to users after login and function as a
message of the day for authenticated users.
Rationale:
If the /etc/motd file does not have the correct ownership it could be modified by
unauthorized users with incorrect or misleading information.
Audit:
Run the following command and verify that if /etc/motd exists, Access is 644 or more
restrictive, Uid and Gid are both 0/root:
# [ -e /etc/motd ] && stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/ %G)' /etc/motd
Remediation:
Run the following commands to set permissions on /etc/motd :
# chown root:root $(readlink -e /etc/motd)
# chmod u-x,go-wx $(readlink -e /etc/motd)
-- OR --
Run the following command to remove the /etc/motd file:
# rm /etc/motd
Default Value:
File doesn't exist
References:
Additional Information:
If Message of the day is not needed, this file can be removed.
Page 181
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 182
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue file are displayed to users prior to login for local
terminals.
Rationale:
If the /etc/issue file does not have the correct ownership it could be modified by
unauthorized users with incorrect or misleading information.
Audit:
Run the following command and verify Access is 644 or more restrictive and Uid and Gid
are both 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/ %G)' /etc/issue
Remediation:
Run the following commands to set permissions on /etc/issue:
# chown root:root $(readlink -e /etc/issue)
# chmod u-x,go-wx $(readlink -e /etc/issue)
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 183
Techniques / Sub-
Tactics Mitigations
techniques
Page 184
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue.net file are displayed to users prior to login for remote
connections from configured services.
Rationale:
If the /etc/issue.net file does not have the correct ownership it could be modified by
unauthorized users with incorrect or misleading information.
Audit:
Run the following command and verify Access is 644 or more restrictive and Uid and Gid
are both 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/ %G)' /etc/issue.net
Remediation:
Run the following commands to set permissions on /etc/issue.net:
# chown root:root $(readlink -e /etc/issue.net)
# chmod u-x,go-wx $(readlink -e /etc/issue.net)
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 185
Techniques / Sub-
Tactics Mitigations
techniques
Page 186
The GNOME Display Manager (GDM) is a program that manages graphical display
servers and handles graphical user logins.
Note: If GDM is not installed on the system, this section can be skipped
Page 187
• Level 2 - Server
Description:
The GNOME Display Manager (GDM) is a program that manages graphical display
servers and handles graphical user logins.
Rationale:
If a Graphical User Interface (GUI) is not required, it should be removed to reduce the
attack surface of the system.
Impact:
Removing the GNOME Display manager will remove the Graphical User Interface (GUI)
from the system.
Audit:
Run the following command and verify gdm3 is not installed:
# dpkg-query -s gdm3 &>/dev/null && echo "gdm3 is installed"
References:
Page 188
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 189
• Level 1 - Server
• Level 1 - Workstation
Description:
GDM is the GNOME Display Manager which handles graphical login for GNOME based
systems.
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place.
Audit:
Run the following script to verify that the text banner on the login screen is enabled and
set:
Page 190
{
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
if [ -n "$l_pkgoutput" ]; then
l_output="" l_output2=""
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_gdmfile="$(grep -Prils '^\h*banner-message-enable\b' /etc/dconf/db/*.d)"
if [ -n "$l_gdmfile" ]; then
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
l_gdmprofile="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_gdmfile")"
# Check if banner message is enabled
if grep -Pisq '^\h*banner-message-enable=true\b' "$l_gdmfile"; then
l_output="$l_output\n - The \"banner-message-enable\" option is enabled in \"$l_gdmfile\""
else
l_output2="$l_output2\n - The \"banner-message-enable\" option is not enabled"
fi
l_lsbt="$(grep -Pios '^\h*banner-message-text=.*$' "$l_gdmfile")"
if [ -n "$l_lsbt" ]; then
l_output="$l_output\n - The \"banner-message-text\" option is set in \"$l_gdmfile\"\n - banner-
message-text is set to:\n - \"$l_lsbt\""
else
l_output2="$l_output2\n - The \"banner-message-text\" option is not set"
fi
if grep -Pq "^\h*system-db:$l_gdmprofile" /etc/dconf/profile/"$l_gdmprofile"; then
l_output="$l_output\n - The \"$l_gdmprofile\" profile exists"
else
l_output2="$l_output2\n - The \"$l_gdmprofile\" profile doesn't exist"
fi
if [ -f "/etc/dconf/db/$l_gdmprofile" ]; then
l_output="$l_output\n - The \"$l_gdmprofile\" profile exists in the dconf database"
else
l_output2="$l_output2\n - The \"$l_gdmprofile\" profile doesn't exist in the dconf database"
fi
else
l_output2="$l_output2\n - The \"banner-message-enable\" option isn't configured"
fi
else
echo -e "\n\n - GNOME Desktop Manager isn't installed\n - Recommendation is Not Applicable\n- Audit
result:\n *** PASS ***\n"
fi
# Report results. If no failures output in l_output2, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 191
{
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
if [ -n "$l_pkgoutput" ]; then
l_gdmprofile="gdm" # Set this to desired profile name IaW Local site policy
l_bmessage="'Authorized uses only. All activity may be monitored and reported'" # Set to desired banner
message
if [ ! -f "/etc/dconf/profile/$l_gdmprofile" ]; then
echo "Creating profile \"$l_gdmprofile\""
echo -e "user-db:user\nsystem-db:$l_gdmprofile\nfile-db:/usr/share/$l_gdmprofile/greeter-dconf-
defaults" > /etc/dconf/profile/$l_gdmprofile
fi
if [ ! -d "/etc/dconf/db/$l_gdmprofile.d/" ]; then
echo "Creating dconf database directory \"/etc/dconf/db/$l_gdmprofile.d/\""
mkdir /etc/dconf/db/$l_gdmprofile.d/
fi
if ! grep -Piq '^\h*banner-message-enable\h*=\h*true\b' /etc/dconf/db/$l_gdmprofile.d/*; then
echo "creating gdm keyfile for machine-wide settings"
if ! grep -Piq -- '^\h*banner-message-enable\h*=\h*' /etc/dconf/db/$l_gdmprofile.d/*; then
l_kfile="/etc/dconf/db/$l_gdmprofile.d/01-banner-message"
echo -e "\n[org/gnome/login-screen]\nbanner-message-enable=true" >> "$l_kfile"
else
l_kfile="$(grep -Pil -- '^\h*banner-message-enable\h*=\h*' /etc/dconf/db/$l_gdmprofile.d/*)"
! grep -Pq '^\h*\[org\/gnome\/login-screen\]' "$l_kfile" && sed -ri '/^\s*banner-message-enable/
i\[org/gnome/login-screen]' "$l_kfile"
! grep -Pq '^\h*banner-message-enable\h*=\h*true\b' "$l_kfile" && sed -ri 's/^\s*(banner-message-
enable\s*=\s*)(\S+)(\s*.*$)/\1true \3//' "$l_kfile"
# sed -ri '/^\s*\[org\/gnome\/login-screen\]/ a\\nbanner-message-enable=true' "$l_kfile"
fi
fi
if ! grep -Piq "^\h*banner-message-text=[\'\"]+\S+" "$l_kfile"; then
sed -ri "/^\s*banner-message-enable/ a\banner-message-text=$l_bmessage" "$l_kfile"
fi
dconf update
else
echo -e "\n\n - GNOME Desktop Manager isn't installed\n - Recommendation is Not Applicable\n - No
remediation required\n"
fi
}
Page 192
Default Value:
disabled
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/login-banner.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Additional Information:
Additional options and sections may appear in the /etc/dconf/db/gdm.d/01-banner-
message file.
If a different GUI login service is in use, consult your documentation and apply an
equivalent banner.
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
TA0007 M1028
T1087, T1087.001,
T1087.002
Page 193
• Level 1 - Server
• Level 1 - Workstation
Description:
GDM is the GNOME Display Manager which handles graphical login for GNOME based
systems.
The disable-user-list option controls if a list of users is displayed on the login screen
Rationale:
Displaying the user list eliminates half of the Userid/Password equation that an
unauthorized person would need to log on.
Audit:
Run the following script and to verify that the disable-user-list option is enabled or
GNOME isn't installed:
Page 194
{
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
if [ -n "$l_pkgoutput" ]; then
output="" output2=""
l_gdmfile="$(grep -Pril '^\h*disable-user-list\h*=\h*true\b' /etc/dconf/db)"
if [ -n "$l_gdmfile" ]; then
output="$output\n - The \"disable-user-list\" option is enabled in \"$l_gdmfile\""
l_gdmprofile="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_gdmfile")"
if grep -Pq "^\h*system-db:$l_gdmprofile" /etc/dconf/profile/"$l_gdmprofile"; then
output="$output\n - The \"$l_gdmprofile\" exists"
else
output2="$output2\n - The \"$l_gdmprofile\" doesn't exist"
fi
if [ -f "/etc/dconf/db/$l_gdmprofile" ]; then
output="$output\n - The \"$l_gdmprofile\" profile exists in the dconf database"
else
output2="$output2\n - The \"$l_gdmprofile\" profile doesn't exist in the dconf database"
fi
else
output2="$output2\n - The \"disable-user-list\" option is not enabled"
fi
if [ -z "$output2" ]; then
echo -e "$l_pkgoutput\n- Audit result:\n *** PASS: ***\n$output\n"
else
echo -e "$l_pkgoutput\n- Audit Result:\n *** FAIL: ***\n$output2\n"
[ -n "$output" ] && echo -e "$output\n"
fi
else
echo -e "\n\n - GNOME Desktop Manager isn't installed\n - Recommendation is Not Applicable\n- Audit
result:\n *** PASS ***\n"
fi
}
Page 195
{
l_gdmprofile="gdm"
if [ ! -f "/etc/dconf/profile/$l_gdmprofile" ]; then
echo "Creating profile \"$l_gdmprofile\""
echo -e "user-db:user\nsystem-db:$l_gdmprofile\nfile-db:/usr/share/$l_gdmprofile/greeter-dconf-defaults"
> /etc/dconf/profile/$l_gdmprofile
fi
if [ ! -d "/etc/dconf/db/$l_gdmprofile.d/" ]; then
echo "Creating dconf database directory \"/etc/dconf/db/$l_gdmprofile.d/\""
mkdir /etc/dconf/db/$l_gdmprofile.d/
fi
if ! grep -Piq '^\h*disable-user-list\h*=\h*true\b' /etc/dconf/db/$l_gdmprofile.d/*; then
echo "creating gdm keyfile for machine-wide settings"
if ! grep -Piq -- '^\h*\[org\/gnome\/login-screen\]' /etc/dconf/db/$l_gdmprofile.d/*; then
echo -e "\n[org/gnome/login-screen]\n# Do not show the user list\ndisable-user-list=true" >>
/etc/dconf/db/$l_gdmprofile.d/00-login-screen
else
sed -ri '/^\s*\[org\/gnome\/login-screen\]/ a\# Do not show the user list\ndisable-user-list=true'
$(grep -Pil -- '^\h*\[org\/gnome\/login-screen\]' /etc/dconf/db/$l_gdmprofile.d/*)
fi
fi
dconf update
}
Note: When the user profile is created or changed, the user will need to log out and log
in again before the changes will be applied.
OR
Run the following command to remove the GNOME package:
# apt purge gdm3
Default Value:
false
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/login-userlist-
disable.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Additional Information:
If a different GUI login service is in use and required on the system, consult your
documentation to disable displaying the user list
Page 196
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
TA0007 M1028
T1087, T1087.001,
T1087.002
Page 197
• Level 1 - Server
• Level 1 - Workstation
Description:
GNOME Desktop Manager can make the screen lock automatically whenever the user
is idle for some amount of time.
# Number of seconds after the screen is blank before locking the screen
lock-delay=uint32 5
Rationale:
Setting a lock-out value reduces the window of opportunity for unauthorized user access
to another user's session that has been left unattended.
Audit:
Run the following script to verify that the screen locks when the user is idle:
Page 198
{
# Check if GNMOE Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
l_output="" l_output2=""
l_idmv="900" # Set for max value for idle-delay in seconds
l_ldmv="5" # Set for max value for lock-delay in seconds
# Look for idle-delay to determine profile in use, needed for remaining tests
l_kfile="$(grep -Psril '^\h*idle-delay\h*=\h*uint32\h+\d+\b' /etc/dconf/db/*/)" # Determine file
containing idle-delay key
if [ -n "$l_kfile" ]; then
# set profile name (This is the name of a dconf database)
l_profile="$(awk -F'/' '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile")" #Set the key profile name
l_pdbdir="/etc/dconf/db/$l_profile.d" # Set the key file dconf db directory
# Confirm that idle-delay exists, includes unit32, and value is between 1 and max value for idle-delay
l_idv="$(awk -F 'uint32' '/idle-delay/{print $2}' "$l_kfile" | xargs)"
if [ -n "$l_idv" ]; then
[ "$l_idv" -gt "0" -a "$l_idv" -le "$l_idmv" ] && l_output="$l_output\n - The \"idle-delay\" option
is set to \"$l_idv\" seconds in \"$l_kfile\""
[ "$l_idv" = "0" ] && l_output2="$l_output2\n - The \"idle-delay\" option is set to \"$l_idv\"
(disabled) in \"$l_kfile\""
[ "$l_idv" -gt "$l_idmv" ] && l_output2="$l_output2\n - The \"idle-delay\" option is set to
\"$l_idv\" seconds (greater than $l_idmv) in \"$l_kfile\""
else
l_output2="$l_output2\n - The \"idle-delay\" option is not set in \"$l_kfile\""
fi
# Confirm that lock-delay exists, includes unit32, and value is between 0 and max value for lock-delay
l_ldv="$(awk -F 'uint32' '/lock-delay/{print $2}' "$l_kfile" | xargs)"
if [ -n "$l_ldv" ]; then
[ "$l_ldv" -ge "0" -a "$l_ldv" -le "$l_ldmv" ] && l_output="$l_output\n - The \"lock-delay\" option
is set to \"$l_ldv\" seconds in \"$l_kfile\""
[ "$l_ldv" -gt "$l_ldmv" ] && l_output2="$l_output2\n - The \"lock-delay\" option is set to
\"$l_ldv\" seconds (greater than $l_ldmv) in \"$l_kfile\""
else
l_output2="$l_output2\n - The \"lock-delay\" option is not set in \"$l_kfile\""
fi
# Confirm that dconf profile exists
if grep -Psq "^\h*system-db:$l_profile" /etc/dconf/profile/*; then
l_output="$l_output\n - The \"$l_profile\" profile exists"
else
l_output2="$l_output2\n - The \"$l_profile\" doesn't exist"
fi
# Confirm that dconf profile database file exists
if [ -f "/etc/dconf/db/$l_profile" ]; then
l_output="$l_output\n - The \"$l_profile\" profile exists in the dconf database"
else
l_output2="$l_output2\n - The \"$l_profile\" profile doesn't exist in the dconf database"
fi
else
l_output2="$l_output2\n - The \"idle-delay\" option doesn't exist, remaining tests skipped"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation
is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
[ -n "$l_pkgoutput" ] && echo -e "\n$l_pkgoutput"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 199
•
idle-delay=uint32 Should be 900 seconds (15 minutes) or less, not 0 (disabled)
and follow local site policy
•
lock-delay=uint32 should be 5 seconds or less and follow local site policy
Page 200
{
l_key_file="/etc/dconf/db/local.d/00-screensaver"
l_idmv="900" # Set max value for idle-delay in seconds (between 1 and 900)
l_ldmv="5" # Set max value for lock-delay in seconds (between 0 and 5)
{
echo '# Specify the dconf path'
echo '[org/gnome/desktop/session]'
echo ''
echo '# Number of seconds of inactivity before the screen goes blank'
echo '# Set to 0 seconds if you want to deactivate the screensaver.'
echo "idle-delay=uint32 $l_idmv"
echo ''
echo '# Specify the dconf path'
echo '[org/gnome/desktop/screensaver]'
echo ''
echo '# Number of seconds after the screen is blank before locking the screen'
echo "lock-delay=uint32 $l_ldmv"
} > "$l_key_file"
}
Note: You must include the uint32 along with the integer key values as shown.
Run the following command to update the system databases:
# dconf update
Note: Users must log out and back in again before the system-wide settings take effect.
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/desktop-
lockscreen.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Page 201
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 202
• Level 1 - Server
• Level 1 - Workstation
Description:
GNOME Desktop Manager can make the screen lock automatically whenever the user
is idle for some amount of time.
By using the lockdown mode in dconf, you can prevent users from changing specific
settings.
To lock down a dconf key or subpath, create a locks subdirectory in the keyfile directory.
The files inside this directory contain a list of keys or subpaths to lock. Just as with the
keyfiles, you may add any number of files to this directory.
Example Lock File:
# Lock desktop screensaver settings
/org/gnome/desktop/session/idle-delay
/org/gnome/desktop/screensaver/lock-delay
Rationale:
Setting a lock-out value reduces the window of opportunity for unauthorized user access
to another user's session that has been left unattended.
Without locking down the system settings, user settings take precedence over the
system settings.
Audit:
Run the following script to verify that the screen lock cannot be overridden:
Page 203
{
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
l_output="" l_output2=""
# Look for idle-delay to determine profile in use, needed for remaining tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*idle-delay\h*=\h*uint32\h+\d+\b' /etc/dconf/db/*/ | awk -F'/'
'{split($(NF-1),a,".");print a[1]}').d" #set directory of key file to be locked
l_kfd2="/etc/dconf/db/$(grep -Psril '^\h*lock-delay\h*=\h*uint32\h+\d+\b' /etc/dconf/db/*/ | awk -F'/'
'{split($(NF-1),a,".");print a[1]}').d" #set directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Prilq '\/org\/gnome\/desktop\/session\/idle-delay\b' "$l_kfd"; then
l_output="$l_output\n - \"idle-delay\" is locked in \"$(grep -Pril
'\/org\/gnome\/desktop\/session\/idle-delay\b' "$l_kfd")\""
else
l_output2="$l_output2\n - \"idle-delay\" is not locked"
fi
else
l_output2="$l_output2\n - \"idle-delay\" is not set so it can not be locked"
fi
if [ -d "$l_kfd2" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Prilq '\/org\/gnome\/desktop\/screensaver\/lock-delay\b' "$l_kfd2"; then
l_output="$l_output\n - \"lock-delay\" is locked in \"$(grep -Pril
'\/org\/gnome\/desktop\/screensaver\/lock-delay\b' "$l_kfd2")\""
else
l_output2="$l_output2\n - \"lock-delay\" is not locked"
fi
else
l_output2="$l_output2\n - \"lock-delay\" is not set so it can not be locked"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation
is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
[ -n "$l_pkgoutput" ] && echo -e "\n$l_pkgoutput"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 204
{
# Check if GNMOE Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="y" && echo -e "\n - Package: \"$l_pn\" exists on the
system\n - remediating configuration if needed"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
# Look for idle-delay to determine profile in use, needed for remaining tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*idle-delay\h*=\h*uint32\h+\d+\b' /etc/dconf/db/*/ | awk -F'/'
'{split($(NF-1),a,".");print a[1]}').d" #set directory of key file to be locked
# Look for lock-delay to determine profile in use, needed for remaining tests
l_kfd2="/etc/dconf/db/$(grep -Psril '^\h*lock-delay\h*=\h*uint32\h+\d+\b' /etc/dconf/db/*/ | awk -F'/'
'{split($(NF-1),a,".");print a[1]}').d" #set directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Prilq '^\h*\/org\/gnome\/desktop\/session\/idle-delay\b' "$l_kfd"; then
echo " - \"idle-delay\" is locked in \"$(grep -Pril '^\h*\/org\/gnome\/desktop\/session\/idle-
delay\b' "$l_kfd")\""
else
echo "creating entry to lock \"idle-delay\""
[ ! -d "$l_kfd"/locks ] && echo "creating directory $l_kfd/locks" && mkdir "$l_kfd"/locks
{
echo -e '\n# Lock desktop screensaver idle-delay setting'
echo '/org/gnome/desktop/session/idle-delay'
} >> "$l_kfd"/locks/00-screensaver
fi
else
echo -e " - \"idle-delay\" is not set so it can not be locked\n - Please follow Recommendation
\"Ensure GDM screen locks when the user is idle\" and follow this Recommendation again"
fi
if [ -d "$l_kfd2" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Prilq '^\h*\/org\/gnome\/desktop\/screensaver\/lock-delay\b' "$l_kfd2"; then
echo " - \"lock-delay\" is locked in \"$(grep -Pril '^\h*\/org\/gnome\/desktop\/screensaver\/lock-
delay\b' "$l_kfd2")\""
else
echo "creating entry to lock \"lock-delay\""
[ ! -d "$l_kfd2"/locks ] && echo "creating directory $l_kfd2/locks" && mkdir "$l_kfd2"/locks
{
echo -e '\n# Lock desktop screensaver lock-delay setting'
echo '/org/gnome/desktop/screensaver/lock-delay'
} >> "$l_kfd2"/locks/00-screensaver
fi
else
echo -e " - \"lock-delay\" is not set so it can not be locked\n - Please follow Recommendation
\"Ensure GDM screen locks when the user is idle\" and follow this Recommendation again"
fi
else
echo -e " - GNOME Desktop Manager package is not installed on the system\n - Recommendation is not
applicable"
fi
}
Note: Users must log out and back in again before the system-wide settings take effect.
Page 205
1. https://help.gnome.org/admin/system-admin-guide/stable/desktop-
lockscreen.html.en
2. https://help.gnome.org/admin/system-admin-guide/stable/dconf-lockdown.html.en
3. NIST SP 800-53 Rev. 5: CM-11
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 206
• Level 1 - Server
• Level 2 - Workstation
Description:
By default GNOME automatically mounts removable media when inserted as a
convenience to the user.
Rationale:
With automounting enabled anyone with physical access could attach a USB drive or
disc and have its contents available in system even if they lacked permissions to mount
it themselves.
Impact:
The use of portable hard drives is very common for workstation users. If your
organization allows the use of portable storage or media on workstations and physical
access controls to workstations is considered adequate there is little value add in
turning off automounting.
Audit:
Run the following script to verify automatic mounting is disabled:
Page 207
{
l_pkgoutput="" l_output="" l_output2=""
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_kfile="$(grep -Prils -- '^\h*automount\b' /etc/dconf/db/*.d)"
l_kfile2="$(grep -Prils -- '^\h*automount-open\b' /etc/dconf/db/*.d)"
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
if [ -f "$l_kfile" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile")"
elif [ -f "$l_kfile2" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile2")"
fi
# If the profile name exist, continue checks
if [ -n "$l_gpname" ]; then
l_gpdir="/etc/dconf/db/$l_gpname.d"
# Check if profile file exists
if grep -Pq -- "^\h*system-db:$l_gpname\b" /etc/dconf/profile/*; then
l_output="$l_output\n - dconf database profile file \"$(grep -Pl -- "^\h*system-db:$l_gpname\b"
/etc/dconf/profile/*)\" exists"
else
l_output2="$l_output2\n - dconf database profile isn't set"
fi
# Check if the dconf database file exists
if [ -f "/etc/dconf/db/$l_gpname" ]; then
l_output="$l_output\n - The dconf database \"$l_gpname\" exists"
else
l_output2="$l_output2\n - The dconf database \"$l_gpname\" doesn't exist"
fi
# check if the dconf database directory exists
if [ -d "$l_gpdir" ]; then
l_output="$l_output\n - The dconf directory \"$l_gpdir\" exitst"
else
l_output2="$l_output2\n - The dconf directory \"$l_gpdir\" doesn't exist"
fi
# check automount setting
if grep -Pqrs -- '^\h*automount\h*=\h*false\b' "$l_kfile"; then
l_output="$l_output\n - \"automount\" is set to false in: \"$l_kfile\""
else
l_output2="$l_output2\n - \"automount\" is not set correctly"
fi
# check automount-open setting
if grep -Pqs -- '^\h*automount-open\h*=\h*false\b' "$l_kfile2"; then
l_output="$l_output\n - \"automount-open\" is set to false in: \"$l_kfile2\""
else
l_output2="$l_output2\n - \"automount-open\" is not set correctly"
fi
else
# Setings don't exist. Nothing further to check
l_output2="$l_output2\n - neither \"automount\" or \"automount-open\" is set"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation
is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 208
Page 209
{
l_pkgoutput="" l_output="" l_output2=""
l_gpname="local" # Set to desired dconf profile name (defaule is local)
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
echo -e "$l_packageout"
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_kfile="$(grep -Prils -- '^\h*automount\b' /etc/dconf/db/*.d)"
l_kfile2="$(grep -Prils -- '^\h*automount-open\b' /etc/dconf/db/*.d)"
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
if [ -f "$l_kfile" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile")"
echo " - updating dconf profile name to \"$l_gpname\""
elif [ -f "$l_kfile2" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile2")"
echo " - updating dconf profile name to \"$l_gpname\""
fi
# check for consistency (Clean up configuration if needed)
if [ -f "$l_kfile" ] && [ "$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile")" != "$l_gpname"
]; then
sed -ri "/^\s*automount\s*=/s/^/# /" "$l_kfile"
l_kfile="/etc/dconf/db/$l_gpname.d/00-media-automount"
fi
if [ -f "$l_kfile2" ] && [ "$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile2")" !=
"$l_gpname" ]; then
sed -ri "/^\s*automount-open\s*=/s/^/# /" "$l_kfile2"
fi
[ -z "$l_kfile" ] && l_kfile="/etc/dconf/db/$l_gpname.d/00-media-automount"
# Check if profile file exists
if grep -Pq -- "^\h*system-db:$l_gpname\b" /etc/dconf/profile/*; then
echo -e "\n - dconf database profile exists in: \"$(grep -Pl -- "^\h*system-db:$l_gpname\b"
/etc/dconf/profile/*)\""
else
[ ! -f "/etc/dconf/profile/user" ] && l_gpfile="/etc/dconf/profile/user" ||
l_gpfile="/etc/dconf/profile/user2"
echo -e " - creating dconf database profile"
{
echo -e "\nuser-db:user"
echo "system-db:$l_gpname"
} >> "$l_gpfile"
fi
# create dconf directory if it doesn't exists
l_gpdir="/etc/dconf/db/$l_gpname.d"
if [ -d "$l_gpdir" ]; then
echo " - The dconf database directory \"$l_gpdir\" exists"
else
echo " - creating dconf database directory \"$l_gpdir\""
mkdir "$l_gpdir"
fi
# check automount-open setting
if grep -Pqs -- '^\h*automount-open\h*=\h*false\b' "$l_kfile"; then
echo " - \"automount-open\" is set to false in: \"$l_kfile\""
else
echo " - creating \"automount-open\" entry in \"$l_kfile\""
! grep -Psq -- '\^\h*\[org\/gnome\/desktop\/media-handling\]\b' "$l_kfile" && echo
'[org/gnome/desktop/media-handling]' >> "$l_kfile"
sed -ri '/^\s*\[org\/gnome\/desktop\/media-handling\]/a \\nautomount-open=false' "$l_kfile"
fi
# check automount setting
if grep -Pqs -- '^\h*automount\h*=\h*false\b' "$l_kfile"; then
echo " - \"automount\" is set to false in: \"$l_kfile\""
else
echo " - creating \"automount\" entry in \"$l_kfile\""
! grep -Psq -- '\^\h*\[org\/gnome\/desktop\/media-handling\]\b' "$l_kfile" && echo
Page 210
OR
Run the following command to uninstall the GNOME desktop Manager package:
# apt purge gdm3
References:
1. https://access.redhat.com/solutions/20107
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 211
• Level 1 - Server
• Level 2 - Workstation
Description:
By default GNOME automatically mounts removable media when inserted as a
convenience to the user
By using the lockdown mode in dconf, you can prevent users from changing specific
settings.
To lock down a dconf key or subpath, create a locks subdirectory in the keyfile directory.
The files inside this directory contain a list of keys or subpaths to lock. Just as with the
keyfiles, you may add any number of files to this directory.
Example Lock File:
# Lock desktop screensaver settings
/org/gnome/desktop/media-handling/automount
/org/gnome/desktop/media-handling/automount-open
Rationale:
With automounting enabled anyone with physical access could attach a USB drive or
disc and have its contents available in system even if they lacked permissions to mount
it themselves.
Impact:
The use of portable hard drives is very common for workstation users
Audit:
Run the following script to verify disable automatic mounting is locked:
Page 212
{
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
l_output="" l_output2=""
# Look for idle-delay to determine profile in use, needed for remaining tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*automount\b' /etc/dconf/db/*/ | awk -F'/' '{split($(NF-
1),a,".");print a[1]}').d" #set directory of key file to be locked
l_kfd2="/etc/dconf/db/$(grep -Psril '^\h*automount-open\b' /etc/dconf/db/*/ | awk -F'/' '{split($(NF-
1),a,".");print a[1]}').d" #set directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Piq '^\h*\/org/gnome\/desktop\/media-handling\/automount\b' "$l_kfd"; then
l_output="$l_output\n - \"automount\" is locked in \"$(grep -Pil '^\h*\/org/gnome\/desktop\/media-
handling\/automount\b' "$l_kfd")\""
else
l_output2="$l_output2\n - \"automount\" is not locked"
fi
else
l_output2="$l_output2\n - \"automount\" is not set so it can not be locked"
fi
if [ -d "$l_kfd2" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Piq '^\h*\/org/gnome\/desktop\/media-handling\/automount-open\b' "$l_kfd2"; then
l_output="$l_output\n - \"lautomount-open\" is locked in \"$(grep -Pril
'^\h*\/org/gnome\/desktop\/media-handling\/automount-open\b' "$l_kfd2")\""
else
l_output2="$l_output2\n - \"automount-open\" is not locked"
fi
else
l_output2="$l_output2\n - \"automount-open\" is not set so it can not be locked"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation
is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
[ -n "$l_pkgoutput" ] && echo -e "\n$l_pkgoutput"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 213
{
# Check if GNMOE Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space seporated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="y" && echo -e "\n - Package: \"$l_pn\" exists on the
system\n - remediating configuration if needed"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
# Look for automount to determine profile in use, needed for remaining tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*automount\b' /etc/dconf/db/*/ | awk -F'/' '{split($(NF-
1),a,".");print a[1]}').d" #set directory of key file to be locked
# Look for automount-open to determine profile in use, needed for remaining tests
l_kfd2="/etc/dconf/db/$(grep -Psril '^\h*automount-open\b' /etc/dconf/db/*/ | awk -F'/' '{split($(NF-
1),a,".");print a[1]}').d" #set directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Priq '^\h*\/org/gnome\/desktop\/media-handling\/automount\b' "$l_kfd"; then
echo " - \"automount\" is locked in \"$(grep -Pril '^\h*\/org/gnome\/desktop\/media-
handling\/automount\b' "$l_kfd")\""
else
echo " - creating entry to lock \"automount\""
[ ! -d "$l_kfd"/locks ] && echo "creating directory $l_kfd/locks" && mkdir "$l_kfd"/locks
{
echo -e '\n# Lock desktop media-handling automount setting'
echo '/org/gnome/desktop/media-handling/automount'
} >> "$l_kfd"/locks/00-media-automount
fi
else
echo -e " - \"automount\" is not set so it can not be locked\n - Please follow Recommendation \"Ensure
GDM automatic mounting of removable media is disabled\" and follow this Recommendation again"
fi
if [ -d "$l_kfd2" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Priq '^\h*\/org/gnome\/desktop\/media-handling\/automount-open\b' "$l_kfd2"; then
echo " - \"automount-open\" is locked in \"$(grep -Pril '^\h*\/org/gnome\/desktop\/media-
handling\/automount-open\b' "$l_kfd2")\""
else
echo " - creating entry to lock \"automount-open\""
[ ! -d "$l_kfd2"/locks ] && echo "creating directory $l_kfd2/locks" && mkdir "$l_kfd2"/locks
{
echo -e '\n# Lock desktop media-handling automount-open setting'
echo '/org/gnome/desktop/media-handling/automount-open'
} >> "$l_kfd2"/locks/00-media-automount
fi
else
echo -e " - \"automount-open\" is not set so it can not be locked\n - Please follow Recommendation
\"Ensure GDM automatic mounting of removable media is disabled\" and follow this Recommendation again"
fi
# update dconf database
dconf update
else
echo -e " - GNOME Desktop Manager package is not installed on the system\n - Recommendation is not
applicable"
fi
}
Page 214
1. https://help.gnome.org/admin/system-admin-guide/stable/dconf-lockdown.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Techniques / Sub-
Tactics Mitigations
techniques
Page 215
• Level 1 - Server
• Level 1 - Workstation
Description:
The autorun-never setting allows the GNOME Desktop Display Manager to disable
autorun through GDM.
Rationale:
Malware on removable media may taking advantage of Autorun features when the
media is inserted into a system and execute.
Audit:
Run the following script to verify that autorun-never is set to true for GDM:
Page 216
{
l_pkgoutput="" l_output="" l_output2=""
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space separated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
echo -e "$l_pkgoutput"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_kfile="$(grep -Prils -- '^\h*autorun-never\b' /etc/dconf/db/*.d)"
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
if [ -f "$l_kfile" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile")"
fi
# If the profile name exist, continue checks
if [ -n "$l_gpname" ]; then
l_gpdir="/etc/dconf/db/$l_gpname.d"
# Check if profile file exists
if grep -Pq -- "^\h*system-db:$l_gpname\b" /etc/dconf/profile/*; then
l_output="$l_output\n - dconf database profile file \"$(grep -Pl -- "^\h*system-db:$l_gpname\b"
/etc/dconf/profile/*)\" exists"
else
l_output2="$l_output2\n - dconf database profile isn't set"
fi
# Check if the dconf database file exists
if [ -f "/etc/dconf/db/$l_gpname" ]; then
l_output="$l_output\n - The dconf database \"$l_gpname\" exists"
else
l_output2="$l_output2\n - The dconf database \"$l_gpname\" doesn't exist"
fi
# check if the dconf database directory exists
if [ -d "$l_gpdir" ]; then
l_output="$l_output\n - The dconf directory \"$l_gpdir\" exitst"
else
l_output2="$l_output2\n - The dconf directory \"$l_gpdir\" doesn't exist"
fi
# check autorun-never setting
if grep -Pqrs -- '^\h*autorun-never\h*=\h*true\b' "$l_kfile"; then
l_output="$l_output\n - \"autorun-never\" is set to true in: \"$l_kfile\""
else
l_output2="$l_output2\n - \"autorun-never\" is not set correctly"
fi
else
# Settings don't exist. Nothing further to check
l_output2="$l_output2\n - \"autorun-never\" is not set"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation
is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 217
{
l_pkgoutput="" l_output="" l_output2=""
l_gpname="local" # Set to desired dconf profile name (default is local)
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space separated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
echo -e "$l_pkgoutput"
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_kfile="$(grep -Prils -- '^\h*autorun-never\b' /etc/dconf/db/*.d)"
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
if [ -f "$l_kfile" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_kfile")"
echo " - updating dconf profile name to \"$l_gpname\""
fi
[ ! -f "$l_kfile" ] && l_kfile="/etc/dconf/db/$l_gpname.d/00-media-autorun"
# Check if profile file exists
if grep -Pq -- "^\h*system-db:$l_gpname\b" /etc/dconf/profile/*; then
echo -e "\n - dconf database profile exists in: \"$(grep -Pl -- "^\h*system-db:$l_gpname\b"
/etc/dconf/profile/*)\""
else
[ ! -f "/etc/dconf/profile/user" ] && l_gpfile="/etc/dconf/profile/user" ||
l_gpfile="/etc/dconf/profile/user2"
echo -e " - creating dconf database profile"
{
echo -e "\nuser-db:user"
echo "system-db:$l_gpname"
} >> "$l_gpfile"
fi
# create dconf directory if it doesn't exists
l_gpdir="/etc/dconf/db/$l_gpname.d"
if [ -d "$l_gpdir" ]; then
echo " - The dconf database directory \"$l_gpdir\" exists"
else
echo " - creating dconf database directory \"$l_gpdir\""
mkdir "$l_gpdir"
fi
# check autorun-never setting
if grep -Pqs -- '^\h*autorun-never\h*=\h*true\b' "$l_kfile"; then
echo " - \"autorun-never\" is set to true in: \"$l_kfile\""
else
echo " - creating or updating \"autorun-never\" entry in \"$l_kfile\""
if grep -Psq -- '^\h*autorun-never' "$l_kfile"; then
sed -ri 's/(^\s*autorun-never\s*=\s*)(\S+)(\s*.*)$/\1true \3/' "$l_kfile"
else
! grep -Psq -- '\^\h*\[org\/gnome\/desktop\/media-handling\]\b' "$l_kfile" && echo
'[org/gnome/desktop/media-handling]' >> "$l_kfile"
sed -ri '/^\s*\[org\/gnome\/desktop\/media-handling\]/a \\nautorun-never=true' "$l_kfile"
fi
fi
else
echo -e "\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation is not
applicable"
fi
# update dconf database
dconf update
}
Page 218
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 219
• Level 1 - Server
• Level 1 - Workstation
Description:
The autorun-never setting allows the GNOME Desktop Display Manager to disable
autorun through GDM.
By using the lockdown mode in dconf, you can prevent users from changing specific
settings.
To lock down a dconf key or subpath, create a locks subdirectory in the keyfile directory.
The files inside this directory contain a list of keys or subpaths to lock. Just as with the
keyfiles, you may add any number of files to this directory.
Example Lock File:
# Lock desktop media-handling settings
/org/gnome/desktop/media-handling/autorun-never
Rationale:
Malware on removable media may taking advantage of Autorun features when the
media is inserted into a system and execute.
Page 220
{
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space separated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="$l_pkgoutput\n - Package: \"$l_pn\" exists on the system\n
- checking configuration"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
l_output="" l_output2=""
# Look for idle-delay to determine profile in use, needed for remaining tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*autorun-never\b' /etc/dconf/db/*/ | awk -F'/' '{split($(NF-
1),a,".");print a[1]}').d" #set directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Prisq '^\h*\/org/gnome\/desktop\/media-handling\/autorun-never\b' "$l_kfd"; then
l_output="$l_output\n - \"autorun-never\" is locked in \"$(grep -Pril
'^\h*\/org/gnome\/desktop\/media-handling\/autorun-never\b' "$l_kfd")\""
else
l_output2="$l_output2\n - \"autorun-never\" is not locked"
fi
else
l_output2="$l_output2\n - \"autorun-never\" is not set so it can not be locked"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation
is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
[ -n "$l_pkgoutput" ] && echo -e "\n$l_pkgoutput"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 221
{
# Check if GNOME Desktop Manager is installed. If package isn't installed, recommendation is Not
Applicable\n
# determine system's package manager
l_pkgoutput=""
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -s"
elif command -v rpm > /dev/null 2>&1; then
l_pq="rpm -q"
fi
# Check if GDM is installed
l_pcl="gdm gdm3" # Space separated list of packages to check
for l_pn in $l_pcl; do
$l_pq "$l_pn" > /dev/null 2>&1 && l_pkgoutput="y" && echo -e "\n - Package: \"$l_pn\" exists on the
system\n - remediating configuration if needed"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
# Look for autorun to determine profile in use, needed for remaining tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*autorun-never\b' /etc/dconf/db/*/ | awk -F'/' '{split($(NF-
1),a,".");print a[1]}').d" #set directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options can't be locked
if grep -Prisq '^\h*\/org/gnome\/desktop\/media-handling\/autorun-never\b' "$l_kfd"; then
echo " - \"autorun-never\" is locked in \"$(grep -Pril '^\h*\/org/gnome\/desktop\/media-
handling\/autorun-never\b' "$l_kfd")\""
else
echo " - creating entry to lock \"autorun-never\""
[ ! -d "$l_kfd"/locks ] && echo "creating directory $l_kfd/locks" && mkdir "$l_kfd"/locks
{
echo -e '\n# Lock desktop media-handling autorun-never setting'
echo '/org/gnome/desktop/media-handling/autorun-never'
} >> "$l_kfd"/locks/00-media-autorun
fi
else
echo -e " - \"autorun-never\" is not set so it can not be locked\n - Please follow Recommendation
\"Ensure GDM autorun-never is enabled\" and follow this Recommendation again"
fi
# update dconf database
dconf update
else
echo -e " - GNOME Desktop Manager package is not installed on the system\n - Recommendation is not
applicable"
fi
}
Page 222
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 223
• Level 1 - Server
• Level 1 - Workstation
Description:
X Display Manager Control Protocol (XDMCP) is designed to provide authenticated
access to display management services for remote displays
Rationale:
XDMCP is inherently insecure.
Audit:
Run the following command and verify the output:
# grep -Eis '^\s*Enable\s*=\s*true' /etc/gdm3/custom.conf
Remediation:
Edit the file /etc/gdm3/custom.conf and remove the line:
Enable=true
Default Value:
false (This is denoted by no Enabled= entry in the file /etc/gdm3/custom.conf in the
[xdmcp] section
References:
Page 224
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 225
Page 226
It is recommended that physical systems and virtual guests lacking direct access to the
physical host's clock be configured to synchronize their time using a service such as
systemd-timesyncd, chrony, or ntp.
Note:
Page 227
It is recommended that physical systems and virtual guests lacking direct access to the
physical host's clock be configured to synchronize their time using a service such as
systemd-timesyncd, chrony, or ntp.
Page 228
• Level 1 - Server
• Level 1 - Workstation
Description:
System time should be synchronized between all systems in an environment. This is
typically done by establishing an authoritative time server or set of servers and having
all systems synchronize their clocks to them.
Note:
Rationale:
Time synchronization is important to support time sensitive security mechanisms and
ensures log files have consistent time records across the enterprise, which aids in
forensic investigations.
Page 229
{
output="" l_tsd="" l_sdtd="" chrony="" l_ntp=""
dpkg-query -W chrony > /dev/null 2>&1 && l_chrony="y"
dpkg-query -W ntp > /dev/null 2>&1 && l_ntp="y" || l_ntp=""
systemctl list-units --all --type=service | grep -q 'systemd-timesyncd.service' && systemctl is-enabled
systemd-timesyncd.service | grep -q 'enabled' && l_sdtd="y"
if [[ "$l_chrony" = "y" && "$l_ntp" != "y" && "$l_sdtd" != "y" ]]; then
l_tsd="chrony"
output="$output\n- chrony is in use on the system"
elif [[ "$l_chrony" != "y" && "$l_ntp" = "y" && "$l_sdtd" != "y" ]]; then
l_tsd="ntp"
output="$output\n- ntp is in use on the system"
elif [[ "$l_chrony" != "y" && "$l_ntp" != "y" ]]; then
if systemctl list-units --all --type=service | grep -q 'systemd-timesyncd.service' && systemctl is-
enabled systemd-timesyncd.service | grep -Eq '(enabled|disabled|masked)'; then
l_tsd="sdtd"
output="$output\n- systemd-timesyncd is in use on the system"
fi
else
[[ "$l_chrony" = "y" && "$l_ntp" = "y" ]] && output="$output\n- both chrony and ntp are in use on the
system"
[[ "$l_chrony" = "y" && "$l_sdtd" = "y" ]] && output="$output\n- both chrony and systemd-timesyncd are in
use on the system"
[[ "$l_ntp" = "y" && "$l_sdtd" = "y" ]] && output="$output\n- both ntp and systemd-timesyncd are in use
on the system"
fi
if [ -n "$l_tsd" ]; then
echo -e "\n- PASS:\n$output\n"
else
echo -e "\n- FAIL:\n$output\n"
fi
}
Note: Follow the guidance in the subsection for the time synchronization daemon
available on the system and skip the other two time synchronization daemon
subsections.
Page 230
1.
chrony
Run the following commands to stop and mask the systemd-timesyncd daemon:
# systemctl stop systemd-timesyncd.service
Note:
2.
systemd-timesyncd
Note:
Page 231
Run the following commands to stop and mask the systemd-timesyncd daemon:
# systemctl stop systemd-timesyncd.service
Note:
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 232
chrony is a daemon which implements the Network Time Protocol (NTP) and is
designed to synchronize system clocks across a variety of systems and use a source
that is highly accurate.
chrony can be configured to be a client and/or a server.
More information on chrony can be found at: http://chrony.tuxfamily.org/.
Note:
• If ntp or systemd-timesyncd are used, chrony should be removed and this section
skipped
• Only one time synchronization method should be in use on the system
Page 233
• Level 1 - Server
• Level 1 - Workstation
Description:
• server
o The server directive specifies an NTP server which can be used as a time
source. The client-server relationship is strictly hierarchical: a client might
synchronize its system time to that of the server, but the server’s system
time will never be influenced by that of a client.
o This directive can be used multiple times to specify multiple servers.
o The directive is immediately followed by either the name of the server, or
its IP address.
• pool
o The syntax of this directive is similar to that for the server directive, except
that it is used to specify a pool of NTP servers rather than a single NTP
server. The pool name is expected to resolve to multiple addresses which
might change over time.
o This directive can be used multiple times to specify multiple pools.
o All options valid in the server directive can be used in this directive too.
Rationale:
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Page 234
Verify that at least one pool line and/or at least three server lines are returned, and the
timeserver on the returned lines follows local site policy
Output examples:
pool directive:
pool time.nist.gov iburst maxsources 4 #The maxsources option is unique to the pool directive
server directive:
server time-a-g.nist.gov iburst
server 132.163.97.3 iburst
server time-d-b.nist.gov iburst
Remediation:
Edit /etc/chrony/chrony.conf or a file ending in .sources in /etc/chrony/sources.d/
and add or edit server or pool lines as appropriate according to local site policy:
<[server|pool]> <[remote-server|remote-pool]>
Examples:
pool directive:
pool time.nist.gov iburst maxsources 4 #The maxsources option is unique to the pool directive
server directive:
server time-a-g.nist.gov iburst
server 132.163.97.3 iburst
server time-d-b.nist.gov iburst
Run one of the following commands to load the updated time sources into chronyd
running config:
# systemctl restart chronyd
OR
If another time synchronization service is in use on the system, run the following
command to remove chrony from the system:
# apt purge chrony
Page 235
Additional Information:
If pool and/or server directive(s) are set in a sources file in /etc/chrony/sources.d, the
line:
sourcedir /etc/chrony/sources.d
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 236
• Level 1 - Server
• Level 1 - Workstation
Description:
The chrony package is installed with a dedicated user account _chrony. This account is
granted the access required by the chronyd service
Rationale:
The chronyd service should run with only the required privlidges
Audit:
IF chrony is in use on the system, run the following command to verify the chronyd
service is being run as the _chrony user:
# ps -ef | awk '(/[c]hronyd/ && $1!="_chrony") { print $1 }'
OR
If another time synchronization service is in use on the system, run the following
command to remove chrony from the system:
# apt purge chrony
Default Value:
user _chrony
Page 237
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 238
• Level 1 - Server
• Level 1 - Workstation
Description:
chrony is a daemon for synchronizing the system clock across the network
Rationale:
chrony needs to be enabled and running in order to synchronize the system to a
timeserver.
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Audit:
IF chrony is in use on the system, run the following commands:
Run the following command to verify that the chrony service is enabled:
# systemctl is-enabled chrony.service
enabled
Run the following command to verify that the chrony service is active:
# systemctl is-active chrony.service
active
Page 239
OR
If another time synchronization service is in use on the system, run the following
command to remove chrony:
# apt purge chrony
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 240
systemd-timesyncd is a daemon that has been added for synchronizing the system
clock across the network. It implements an SNTP client. In contrast to NTP
implementations such as chrony or the NTP reference server this only implements a
client side, and does not bother with the full NTP complexity, focusing only on querying
time from one remote server and synchronizing the local clock to it. The daemon runs
with minimal privileges, and has been hooked up with networkd to only operate when
network connectivity is available. The daemon saves the current clock to disk every time
a new NTP sync has been acquired, and uses this to possibly correct the system clock
early at bootup, in order to accommodate for systems that lack an RTC such as the
Raspberry Pi and embedded devices, and make sure that time monotonically
progresses on these systems, even if it is not always correct. To make use of this
daemon a new system user and group "systemd-timesync" needs to be created on
installation of systemd.
The default configuration is set during compilation, so configuration is only needed
when it is necessary to deviate from those defaults. Initially, the main configuration file
in /etc/systemd/ contains commented out entries showing the defaults as a guide to the
administrator. Local overrides can be created by editing this file or by creating drop-ins,
as described below. Using drop-ins for local configuration is recommended over
modifications to the main configuration file.
In addition to the "main" configuration file, drop-in configuration snippets are read from
/usr/lib/systemd/*.conf.d/, /usr/local/lib/systemd/*.conf.d/, and
/etc/systemd/*.conf.d/. Those drop-ins have higher precedence and override the
main configuration file. Files in the *.conf.d/ configuration subdirectories are sorted by
their filename in lexicographic order, regardless of in which of the subdirectories they
reside. When multiple files specify the same option, for options which accept just a
single value, the entry in the file sorted last takes precedence, and for options which
accept a list of values, entries are collected as they occur in the sorted files.
When packages need to customize the configuration, they can install drop-ins under
/usr/. Files in /etc/ are reserved for the local administrator, who may use this logic to
override the configuration files installed by vendor packages. Drop-ins have to be used
to override package drop-ins, since the main configuration file has lower precedence. It
is recommended to prefix all filenames in those subdirectories with a two-digit number
and a dash, to simplify the ordering of the files.
To disable a configuration file supplied by the vendor, the recommended way is to place
a symlink to /dev/null in the configuration directory in /etc/, with the same filename as
the vendor configuration file.
Page 241
Page 242
• Level 1 - Server
• Level 1 - Workstation
Description:
NTP=
FallbackNTP=
Rationale:
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Page 243
Example Output:
/etc/systemd/timesyncd.conf:NTP=time.nist.gov
/etc/systemd/timesyncd.conf:FallbackNTP=time-a-g.nist.gov time-b-g.nist.gov time-c-g.nist.gov
Remediation:
Edit /etc/systemd/timesyncd.conf and add the NTP= and/or FallbackNTP= lines to the
[Time] section:
Example:
[Time]
NTP=time.nist.gov # Uses the generic name for NIST's time servers
-AND/OR-
FallbackNTP=time-a-g.nist.gov time-b-g.nist.gov time-c-g.nist.gov # Space separated list of NIST time servers
Note: Servers added to these line(s) should follow local site policy. NIST servers are for
example.
Example script:
The following example script will add the example NIST time servers to
/etc/systemd/timesyncd.conf
#!/usr/bin/env bash
{
l_ntp_ts="time.nist.gov"
l_ntp_fb="time-a-g.nist.gov time-b-g.nist.gov time-c-g.nist.gov"
l_conf_file="/etc/systemd/timesyncd.conf"
if ! grep -Ph '^\h*NTP=\H+' "$l_conf_file"; then
! grep -Pqs '^\h*\[Time\]' "$l_conf_file" && echo "[Time]" >> "$l_conf_file"
echo "NTP=$l_ntp_ts" >> "$l_conf_file"
fi
if ! grep -Ph '^\h*FallbackNTP=\H+' "$l_conf_file"; then
! grep -Pqs '^\h*\[Time\]' "$l_conf_file" && echo "[Time]" >> "$l_conf_file"
echo "FallbackNTP=$l_ntp_fb" >> "$l_conf_file"
fi
}
-OR-
If another time synchronization service is in use on the system, run the following
command to stop and mask systemd-timesyncd:
# systemctl --now mask systemd-timesyncd
Page 244
1. https://www.freedesktop.org/software/systemd/man/timesyncd.conf.html
2. https://tf.nist.gov/tf-cgi/servers.cgi
3. NIST SP 800-53 Rev. 5: AU-7, AU-8
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 245
• Level 1 - Server
• Level 1 - Workstation
Description:
systemd-timesyncd is a daemon that has been added for synchronizing the system
clock across the network
Rationale:
systemd-timesyncd needs to be enabled and running in order to synchronize the system
to a timeserver.
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Audit:
IF systemd-timesyncd is in use on the system, run the following commands:
Run the following command to verify that the systemd-timesyncd service is enabled:
# systemctl is-enabled systemd-timesyncd.service
enabled
Run the following command to verify that the systemd-timesyncd service is active:
# systemctl is-active systemd-timesyncd.service
active
Page 246
OR
If another time synchronization service is in use on the system, run the following
command to stop and mask systemd-timesyncd:
# systemctl --now mask systemd-timesyncd.service
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 247
ntp is a daemon which implements the Network Time Protocol (NTP). It is designed to
synchronize system clocks across a variety of systems and use a source that is highly
accurate. More information on NTP can be found at http://www.ntp.org. ntp can be
configured to be a client and/or a server.
Note:
Page 248
• Level 1 - Server
• Level 1 - Workstation
Description:
ntp Access Control Commands:
restrict address [mask mask] [ippeerlimit int] [flag ...]
Page 249
• kod - If this flag is set when an access violation occurs, a kiss-o'-death (KoD)
packet is sent. KoD packets are rate limited to no more than one per second. If
another KoD packet occurs within one second after the last one, the packet is
dropped.
• limited - Deny service if the packet spacing violates the lower limits specified in
the discard command. A history of clients is kept using the monitoring capability
of ntpd. Thus, monitoring is always active as long as there is a restriction entry
with the limited flag.
• lowpriotrap - Declare traps set by matching hosts to be low priority. The number
of traps a server can maintain is limited (the current limit is 3). Traps are usually
assigned on a first come, first served basis, with later trap requestors being
denied service. This flag modifies the assignment algorithm by allowing low
priority traps to be overridden by later requests for normal priority traps.
• noepeer - Deny ephemeral peer requests, even if they come from an
authenticated source. Note that the ability to use a symmetric key for
authentication may be restricted to one or more IPs or subnets via the third field
of the ntp.keys file. This restriction is not enabled by default, to maintain
backward compatibility. Expect noepeer to become the default in ntp-4.4.
• nomodify - Deny ntpq and ntpdc queries which attempt to modify the state of the
server (i.e., run time reconfiguration). Queries which return information are
permitted.
• noquery - Deny ntpq and ntpdc queries. Time service is not affected.
• nopeer - Deny unauthenticated packets which would result in mobilizing a new
association. This includes broadcast and symmetric active packets when a
configured association does not exist. It also includes pool associations, so if you
want to use servers from a pool directive and also want to use nopeer by default,
you'll want a restrict source ... line as well that does not include the nopeer
directive.
• noserve - Deny all packets except ntpq and ntpdc queries.
• notrap - Decline to provide mode 6 control message trap service to matching
hosts. The trap service is a subsystem of the ntpq control message protocol
which is intended for use by remote event logging programs.
• notrust - Deny service unless the packet is cryptographically authenticated.
• ntpport - This is actually a match algorithm modifier, rather than a restriction
flag. Its presence causes the restriction entry to be matched only if the source
port in the packet is the standard NTP UDP port (123). Both ntpport and non-
ntpport may be specified. The ntpport is considered more specific and is sorted
later in the list.
Rationale:
If ntp is in use on the system, proper configuration is vital to ensuring time
synchronization is accurate.
Page 250
Verify that the output includes two lines, and both lines include: default, kod, nomodify,
notrap, nopeer and noquery.
Note: The -4 in the first line is optional, options after default may appear in any order,
and additional options may exist.
Remediation:
Add or edit restrict lines in /etc/ntp.conf to match the following:
restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp from the system:
# apt purge ntp
Default Value:
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
Page 251
1. http://www.ntp.org/
2. ntp.conf(5)
3. ntpd(8)
4. NIST SP 800-53 Rev. 5: AU-8
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 252
• Level 1 - Server
• Level 1 - Workstation
Description:
The various modes are determined by the command keyword and the type of the
required IP address. Addresses are classed by type as (s) a remote server or peer
(IPv4 class A, B and C), (b) the broadcast address of a local interface, (m) a multicast
address (IPv4 class D), or (r) a reference clock address (127.127.x.x).
Note: That only those options applicable to each command are listed below. Use of
options not listed may not be caught as an error, but may result in some weird and even
destructive behavior.
If the Basic Socket Interface Extensions for IPv6 (RFC-2553) is detected, support for
the IPv6 address family is generated in addition to the default support of the IPv4
address family. In a few cases, including the reslist billboard generated by ntpq or
ntpdc, IPv6 addresses are automatically generated. IPv6 addresses can be identified by
the presence of colons “:” in the address field. IPv6 addresses can be used almost
everywhere where IPv4 addresses can be used, with the exception of reference clock
addresses, which are always IPv4.
Note: In contexts where a host name is expected, a -4 qualifier preceding the host
name forces DNS resolution to the IPv4 namespace, while a -6 qualifier forces DNS
resolution to the IPv6 namespace. See IPv6 references for the equivalent classes for
that address family.
• pool - For type s addresses, this command mobilizes a persistent client mode
association with a number of remote servers. In this mode the local clock can
synchronized to the remote server, but the remote server can never be
synchronized to the local clock.
• server - For type s and r addresses, this command mobilizes a persistent client
mode association with the specified remote server or local radio clock. In this
mode the local clock can synchronized to the remote server, but the remote
server can never be synchronized to the local clock. This command should not
be used for type b or m addresses.
Rationale:
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Page 253
Verify that at least one pool line and/or at least three server lines are returned, and the
timeserver on the returned lines follows local site policy
Output examples:
pool mode:
pool time.nist.gov iburst maxsources 4 #The maxsources option is unique to the pool directive
server mode:
server time-a-g.nist.gov iburst
server 132.163.97.3 iburst
server time-d-b.nist.gov iburst
Remediation:
Edit /etc/ntp.conf and add or edit server or pool lines as appropriate according to local
site policy:
<[server|pool]> <[remote-server|remote-pool]>
Examples:
pool mode:
pool time.nist.gov iburst
server mode:
server time-a-g.nist.gov iburst
server 132.163.97.3 iburst
server time-d-b.nist.gov iburst
Run the following command to load the updated time sources into ntp running config:
# systemctl restart ntp
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp from the system:
# apt purge ntp
References:
1. http://www.ntp.org/
2. https://tf.nist.gov/tf-cgi/servers.cgi
3. ntp.conf(5)
4. ntpd(8)
5. NIST SP 800-53 Rev. 5: AU-8
Page 254
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 255
• Level 1 - Server
• Level 1 - Workstation
Description:
The ntp package is installed with a dedicated user account ntp. This account is granted
the access required by the ntpd daemon
Note:
• If chrony or systemd-timesyncd are used, ntp should be removed and this section
skipped
• This recommendation only applies if ntp is in use on the system
• Only one time synchronization method should be in use on the system
Rationale:
The ntpd daemon should run with only the required privlidge
Audit:
IF ntp is in use on the system run the following command to verify the ntpd daemon is
being run as the user ntp:
# ps -ef | awk '(/[n]tpd/ && $1!="ntp") { print $1 }'
Run the following command to verify the RUNASUSER= is set to ntp in /usr/lib/ntp/ntp-
systemd-wrapper:
# grep -P -- '^\h*RUNASUSER=' /usr/lib/ntp/ntp-systemd-wrapper
RUNASUSER=ntp
Page 256
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp from the system:
# apt purge ntp
Default Value:
user ntp
References:
1. http://www.ntp.org/
2. NIST SP 800-53 Rev. 5: AU-8
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 257
• Level 1 - Server
• Level 1 - Workstation
Description:
ntp is a daemon for synchronizing the system clock across the network
Rationale:
ntp needs to be enabled and running in order to synchronize the system to a timeserver.
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Audit:
IF ntp is in use on the system, run the following commands:
Run the following command to verify that the ntp service is enabled:
# systemctl is-enabled ntp.service
enabled
Run the following command to verify that the ntp service is active:
# systemctl is-active ntp.service
active
Remediation:
IF ntp is in use on the system, run the following commands:
Run the following command to unmask ntp.service:
# systemctl unmask ntp.service
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp:
# apt purge ntp
Page 258
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 259
This section describes services that are installed on systems that specifically need to
run these services. If any of these services are not required, it is recommended that the
package be removed, or the service be masked to reduce the potential attack surface.
Note: This should not be considered a comprehensive list of services not required for
normal system operation. You may wish to consider additions to those listed here for
your environment
The following commands can be used to stop and mask the service:
# systemctl stop <service_name>
# systemctl mask <service_name>
Page 260
• Level 2 - Server
Description:
The X Window System provides a Graphical User Interface (GUI) where users can have
multiple windows in which to run programs and various add on. The X Windows system
is typically used on workstations where users login, but not on servers where users
typically do not login.
Rationale:
Unless your organization specifically requires graphical login access via X Windows,
remove it to reduce the potential attack surface.
Impact:
Many Linux systems run applications which require a Java runtime. Some Linux Java
packages have a dependency on specific X Windows xorg-x11-fonts. One workaround
to avoid this dependency is to use the "headless" Java packages for your specific Java
runtime, if provided by your distribution.
Audit:
Verify X Windows System is not installed:
dpkg-query -s xserver-xorg &>/dev/null && echo "xserver-xorg* is installed"
References:
Page 261
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 262
• Level 1 - Server
• Level 1 - Workstation
Description:
Avahi is a free zeroconf implementation, including a system for multicast DNS/DNS-SD
service discovery. Avahi allows programs to publish and discover services and hosts
running on a local network with no specific configuration. For example, a user can plug
a computer into a network and Avahi automatically finds printers to print to, files to look
at and people to talk to, as well as network services running on the machine.
Rationale:
Automatic discovery of network services is not normally required for system
functionality. It is recommended to remove this package to reduce the potential attack
surface.
Audit:
Run the following command to verify avahi-daemon is not installed:
# dpkg-query -s avahi-daemon &>/dev/null && echo "avahi-daemon is installed"
Page 263
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 264
• Level 1 - Server
• Level 2 - Workstation
Description:
The Common Unix Print System (CUPS) provides the ability to print to both local and
network printers. A system running CUPS can also accept print jobs from remote
systems and print them to local printers. It also provides a web based remote
administration capability.
Rationale:
If the system does not need to print jobs or accept print jobs from other systems, it is
recommended that CUPS be removed to reduce the potential attack surface.
Impact:
Removing CUPS will prevent printing from the system, a common task for workstation
systems.
Audit:
Run the following command to verify cups is not Installed:
# dpkg-query -s cups &>/dev/null && echo "cups is installed"
References:
Page 265
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 266
• Level 1 - Server
• Level 1 - Workstation
Description:
The Dynamic Host Configuration Protocol (DHCP) is a service that allows machines to
be dynamically assigned IP addresses.
Rationale:
Unless a system is specifically set up to act as a DHCP server, it is recommended that
this package be removed to reduce the potential attack surface.
Audit:
Run the following commands to verify isc-dhcp-server is not installed:
# dpkg-query -s isc-dhcp-server &>/dev/null && echo "isc-dhcp-server is installed"
References:
Page 267
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 268
• Level 1 - Server
• Level 1 - Workstation
Description:
The Lightweight Directory Access Protocol (LDAP) was introduced as a replacement for
NIS/YP. It is a service that provides a method for looking up information from a central
database.
Rationale:
If the system will not need to act as an LDAP server, it is recommended that the
software be removed to reduce the potential attack surface.
Audit:
Run the following command to verify slapd is not installed:
# dpkg-query -s slapd &>/dev/null && echo "slapd is installed"
References:
Page 269
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 270
• Level 1 - Server
• Level 1 - Workstation
Description:
The Network File System (NFS) is one of the first and most widely distributed file
systems in the UNIX environment. It provides the ability for systems to mount file
systems of other servers through the network.
Rationale:
If the system does not export NFS shares, it is recommended that the nfs-kernel-
server package be removed to reduce the remote attack surface.
Audit:
Run the following command to verify nfs is not installed:
# dpkg-query -s nfs-kernel-server &>/dev/null && echo "nfs-kernel-server is installed"
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 271
Techniques / Sub-
Tactics Mitigations
techniques
Page 272
• Level 1 - Server
• Level 1 - Workstation
Description:
The Domain Name System (DNS) is a hierarchical naming system that maps names to
IP addresses for computers, services and other resources connected to a network.
Rationale:
Unless a system is specifically designated to act as a DNS server, it is recommended
that the package be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify DNS server is not installed:
# dpkg-query -s bind9 &>/dev/null && echo "bind9 is installed"
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 273
Techniques / Sub-
Tactics Mitigations
techniques
Page 274
• Level 1 - Server
• Level 1 - Workstation
Description:
The File Transfer Protocol (FTP) provides networked computers with the ability to
transfer files.
Rationale:
FTP does not protect the confidentiality of data or authentication credentials. It is
recommended SFTP be used if file transfer is required. Unless there is a need to run
the system as a FTP server (for example, to allow anonymous downloads), it is
recommended that the package be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify vsftpd is not installed:
# dpkg-query -s vsftpd &>/dev/null && echo "vsftpd is installed"
References:
Additional Information:
Additional FTP servers also exist and should be audited.
Page 275
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 276
• Level 1 - Server
• Level 1 - Workstation
Description:
HTTP or web servers provide the ability to host web site content.
Rationale:
Unless there is a need to run the system as a web server, it is recommended that the
package be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify apache2 is not installed:
# dpkg-query -s apache2 &>/dev/null && echo "apache2 is installed"
References:
Additional Information:
Several httpd servers exist and can use other service names. apache2 and nginx are
example services that provide an HTTP server. These and other services should also
be audited
Page 277
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 278
• Level 1 - Server
• Level 1 - Workstation
Description:
dovecot-imapdand dovecot-pop3d are an open source IMAP and POP3 server for Linux
based systems.
Rationale:
Unless POP3 and/or IMAP servers are to be provided by this system, it is
recommended that the package be removed to reduce the potential attack surface.
Audit:
Run the following command to verify dovecot-imapdis not installed:
# dpkg-query -s dovecot-imapd &>/dev/null && echo "dovecot-imapd is installed"
References:
Additional Information:
Several IMAP/POP3 servers exist and can use other service names. courier-imap and
cyrus-imap are example services that provide a mail server. These and other services
should also be audited.
Page 279
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 280
• Level 1 - Server
• Level 1 - Workstation
Description:
The Samba daemon allows system administrators to configure their Linux systems to
share file systems and directories with Windows desktops. Samba will advertise the file
systems and directories via the Server Message Block (SMB) protocol. Windows
desktop users will be able to mount these directories and file systems as letter drives on
their systems.
Rationale:
If there is no need to mount directories and file systems to Windows systems, then this
service should be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify samba is not installed:
# dpkg-query -s samba &>/dev/null && echo "samba is installed"
References:
Page 281
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 282
• Level 1 - Server
• Level 1 - Workstation
Description:
Squid is a standard proxy server used in many distributions and environments.
Rationale:
If there is no need for a proxy server, it is recommended that the squid proxy be deleted
to reduce the potential attack surface.
Audit:
Run the following command to verify squid is not installed:
# dpkg-query -s squid &>/dev/null && echo "squid is installed"
References:
Additional Information:
Several HTTP proxy servers exist. These and other services should be checked
Page 283
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 284
• Level 1 - Server
• Level 1 - Workstation
Description:
Simple Network Management Protocol (SNMP) is a widely used protocol for monitoring
the health and welfare of network equipment, computer equipment and devices like
UPSs.
Net-SNMP is a suite of applications used to implement SNMPv1 (RFC 1157), SNMPv2
(RFCs 1901-1908), and SNMPv3 (RFCs 3411-3418) using both IPv4 and IPv6.
Support for SNMPv2 classic (a.k.a. "SNMPv2 historic" - RFCs 1441-1452) was dropped
with the 4.0 release of the UCD-snmp package.
The Simple Network Management Protocol (SNMP) server is used to listen for SNMP
commands from an SNMP management system, execute the commands or collect the
information and then send results back to the requesting system.
Rationale:
The SNMP server can communicate using SNMPv1, which transmits data in the clear and
does not require authentication to execute commands. SNMPv3 replaces the simple/clear
text password sharing used in SNMPv2 with more securely encoded parameters. If the
the SNMP service is not required, the snmpd package should be removed to reduce the
attack surface of the system.
Note: If SNMP is required:
• The server should be configured for SNMP v3 only. User Authentication and
Message Encryption should be configured.
• If SNMP v2 is absolutely necessary, modify the community strings' values.
Audit:
Run the following command to verify snmpd is not installed:
# dpkg-query -s snmpd &>/dev/null && echo "snmpd is installed"
Page 285
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 286
• Level 1 - Server
• Level 1 - Workstation
Description:
The Network Information Service (NIS) (formally known as Yellow Pages) is a client-
server directory service protocol for distributing system configuration files. The NIS
server is a collection of programs that allow for the distribution of configuration files.
Rationale:
The NIS service is inherently an insecure system that has been vulnerable to DOS
attacks, buffer overflows and has poor authentication for querying NIS maps. NIS
generally has been replaced by such protocols as Lightweight Directory Access
Protocol (LDAP). It is recommended that the service be removed and other, more
secure services be used
Audit:
Run the following command to verify nis is not installed:
# dpkg-query -s nis &>/dev/null && echo "nis is installed"
References:
Page 287
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 288
• Level 1 - Server
• Level 1 - Workstation
Description:
dnsmasqis a lightweight tool that provides DNS caching, DNS forwarding and DHCP
(Dynamic Host Configuration Protocol) services.
Rationale:
Unless a system is specifically designated to act as a DNS caching, DNS forwarding
and/or DHCP server, it is recommended that the package be removed to reduce the
potential attack surface.
Audit:
Run one of the following commands to verify dnsmasq is not installed:
# dpkg-query -s dnsmasq &>/dev/null && echo "dnsmasq is installed"
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 289
Techniques / Sub-
Tactics Mitigations
techniques
Page 290
• Level 1 - Server
• Level 1 - Workstation
Description:
Mail Transfer Agents (MTA), such as sendmail and Postfix, are used to listen for
incoming mail and transfer the messages to the appropriate user or mail server. If the
system is not intended to be a mail server, it is recommended that the MTA be
configured to only process local mail.
Rationale:
The software for all Mail Transfer Agents is complex and most have a long history of
security issues. While it is important to ensure that the system can process local mail
messages, it is not necessary to have the MTA's daemon listening on a port unless the
server is intended to be a mail server that receives and processes mail from other
systems.
Audit:
Run the following script to verify that the MTA is not listening on any non-loopback
address ( 127.0.0.1 or ::1
Page 291
{
l_output=""
l_output2=""
a_port_list=("25" "465" "587")
unset a_port_list
Remediation:
Edit /etc/postfix/main.cf and add the following line to the RECEIVING MAIL section.
If the line already exists, change it to look like the line below:
inet_interfaces = loopback-only
Note:
References:
Page 292
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 293
• Level 1 - Server
• Level 1 - Workstation
Description:
The rsync service can be used to synchronize files between systems over network
links.
Rationale:
The rsync service presents a security risk as the rsync protocol is unencrypted. The
rsync package should be removed or if required for dependencies, the rsync service
should be stopped and masked to reduce the attack area of the system.
Audit:
Run the following command to verify rsync is not installed:
# dpkg-query -s rsync &>/dev/null && echo "rsync is installed"
inactive
masked
Remediation:
Run the following command to remove rsync:
# apt purge rsync
-- OR --
Run the following commands to stop and mask rsync:
# systemctl stop rsync
References:
Page 294
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 295
A number of insecure services exist. While disabling the servers prevents a local attack
against these services, it is advised to remove their clients unless they are required.
Note: This should not be considered a comprehensive list of insecure service clients.
You may wish to consider additions to those listed here for your environment.
Page 296
• Level 1 - Server
• Level 1 - Workstation
Description:
The Network Information Service (NIS), formerly known as Yellow Pages, is a client-
server directory service protocol used to distribute system configuration files. The NIS
client was used to bind a machine to an NIS server and receive the distributed
configuration files.
Rationale:
The NIS service is inherently an insecure system that has been vulnerable to DOS
attacks, buffer overflows and has poor authentication for querying NIS maps. NIS
generally has been replaced by such protocols as Lightweight Directory Access
Protocol (LDAP). It is recommended that the service be removed.
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify nis is not installed. Use the following command to provide the needed
information:
# dpkg-query -s nis &>/dev/null && echo "nis is installed"
References:
Page 297
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 298
• Level 1 - Server
• Level 1 - Workstation
Description:
The rsh-client package contains the client commands for the rsh services.
Rationale:
These legacy clients contain numerous security exposures and have been replaced with
the more secure SSH package. Even if the server is removed, it is best to ensure the
clients are also removed to prevent users from inadvertently attempting to use these
commands and therefore exposing their credentials. Note that removing the rsh-client
package removes the clients for rsh , rcp and rlogin .
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify rsh-client is not installed. Use the following command to provide the needed
information:
# dpkg-query -s rsh-client &>/dev/null && echo "rsh-client is installed"
References:
Page 299
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 300
• Level 1 - Server
• Level 1 - Workstation
Description:
The talk software makes it possible for users to send and receive messages across
systems through a terminal session. The talk client, which allows initialization of talk
sessions, is installed by default.
Rationale:
The software presents a security risk as it uses unencrypted protocols for
communication.
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify talk is not installed. The following command may provide the needed
information:
# dpkg-query -s talk &>/dev/null && echo "talk is installed"
References:
Page 301
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 302
• Level 1 - Server
• Level 1 - Workstation
Description:
The telnet package contains the telnet client, which allows users to start connections
to other systems via the telnet protocol.
Rationale:
The telnet protocol is insecure and unencrypted. The use of an unencrypted
transmission medium could allow an unauthorized user to steal credentials. The ssh
package provides an encrypted session and stronger security and is included in most
Linux distributions.
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify telnet is not installed. Use the following command to provide the needed
information:
# dpkg-query -s telnet &>/dev/null && echo "telnet is installed"
References:
Page 303
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 304
• Level 1 - Server
• Level 1 - Workstation
Description:
The Lightweight Directory Access Protocol (LDAP) was introduced as a replacement for
NIS/YP. It is a service that provides a method for looking up information from a central
database.
Rationale:
If the system will not need to act as an LDAP client, it is recommended that the software
be removed to reduce the potential attack surface.
Impact:
Removing the LDAP client will prevent or inhibit using LDAP for authentication in your
environment.
Audit:
Verify that ldap-utils is not installed. Use the following command to provide the
needed information:
# dpkg-query -s ldap-utils &>/dev/null && echo "ldap-utils is installed"
References:
Page 305
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 306
• Level 1 - Server
• Level 1 - Workstation
Description:
Remote Procedure Call (RPC) is a method for creating low level client server
applications across different system architectures. It requires an RPC compliant client
listening on a network port. The supporting package is rpcbind."
Rationale:
If RPC is not required, it is recommended that this services be removed to reduce the
remote attack surface.
Audit:
Run the following command to verify rpcbind is not installed:
# dpkg-query -s rpcbind &>/dev/null && echo "rpcbind is installed"
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 307
Techniques / Sub-
Tactics Mitigations
techniques
Page 308
• Level 1 - Server
• Level 1 - Workstation
Description:
A network port is identified by its number, the associated IP address, and the type of the
communication protocol such as TCP or UDP.
A listening port is a network port on which an application or process listens on, acting as
a communication endpoint.
Each listening port can be open or closed (filtered) using a firewall. In general terms, an
open port is a network port that accepts incoming packets from remote locations.
Rationale:
Services listening on the system pose a potential risk as an attack vector. These
services should be reviewed, and if not required, the service should be stopped, and the
package containing the service should be removed. If required packages have a
dependency, the service should be stopped and masked to reduce the attack surface of
the system.
Audit:
Run the following command:
# ss -plntu
Review the output to ensure that all services listed are required on the system. If a listed
service is not required, remove the package containing the service. If the package
containing the service is required, stop and mask the service
Page 309
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 310
Page 311
Page 312
• Level 1 - Server
• Level 1 - Workstation
Description:
Internet Protocol Version 6 (IPv6) is the most recent version of Internet Protocol (IP). It's
designed to supply IP addressing and additional security to support the predicted
growth of connected devices. IPv6 is based on 128-bit addressing and can support 340
undecillion, which is 340 trillion3 addresses.
Features of IPv6
Rationale:
IETF RFC 4038 recommends that applications are built with an assumption of dual
stack. It is recommended that IPv6 be enabled and configured in accordance with
Benchmark recommendations.
-IF- dual stack and IPv6 are not used in your environment, IPv6 may be disabled to
reduce the attack surface of the system, and recommendations pertaining to IPv6 can
be skipped.
Note: It is recommended that IPv6 be enabled and configured unless this is against
local site policy
Impact:
IETF RFC 4038 recommends that applications are built with an assumption of dual
stack.
When enabled, IPv6 will require additional configuration to reduce risk to the system.
Audit:
Run the following to identify if IPv6 is enabled on the system:
# grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && echo -e "\n - IPv6 is enabled\n" || echo -e "\n -
IPv6 is not enabled\n"
Remediation:
Enable or disable IPv6 in accordance with system requirements and local site policy
Page 313
Additional Information:
Having more addresses has grown in importance with the expansion of smart devices
and connectivity. IPv6 provides more than enough globally unique IP addresses for
every networked device currently on the planet, helping ensure providers can keep pace
with the expected proliferation of IP-based devices.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 314
• Level 1 - Server
Description:
Wireless networking is used when wired networks are unavailable.
Rationale:
-IF- wireless is not to be used, wireless devices can be disabled to reduce the potential
attack surface.
Impact:
Many if not all laptop workstations and some desktop workstations will connect via
wireless requiring these interfaces be enabled.
Audit:
Run the following script to verify no wireless interfaces are active on the system:
Page 315
{
l_output="" l_output2=""
module_chk()
{
# Check how module will be loaded
l_loadable="$(modprobe -n -v "$l_mname")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
# Check is the module currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
# Check if the module is deny listed
if modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mname\b"; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pl --
"^\h*blacklist\h+$l_mname\b" /etc/modprobe.d/*)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
if [ -n "$(find /sys/class/net/*/ -type d -name wireless)" ]; then
l_dname=$(for driverdir in $(find /sys/class/net/*/ -type d -name wireless | xargs -0 dirname); do
basename "$(readlink -f "$driverdir"/device/driver/module)";done | sort -u)
for l_mname in $l_dname; do
module_chk
done
fi
# Report results. If no failures output in l_output2, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **"
if [ -z "$l_output" ]; then
echo -e "\n - System has no wireless NICs installed"
else
echo -e "\n$l_output\n"
fi
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 316
{
module_fix()
{
if ! modprobe -n -v "$l_mname" | grep -P -- '^\h*install \/bin\/(true|false)'; then
echo -e " - setting module: \"$l_mname\" to be un-loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mname".conf
fi
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e " - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
if ! grep -Pq -- "^\h*blacklist\h+$l_mname\b" /etc/modprobe.d/*; then
echo -e " - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mname".conf
fi
}
if [ -n "$(find /sys/class/net/*/ -type d -name wireless)" ]; then
l_dname=$(for driverdir in $(find /sys/class/net/*/ -type d -name wireless | xargs -0 dirname); do
basename "$(readlink -f "$driverdir"/device/driver/module)";done | sort -u)
for l_mname in $l_dname; do
module_fix
done
fi
}
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 317
Techniques / Sub-
Tactics Mitigations
techniques
Page 318
• Level 1 - Server
• Level 2 - Workstation
Description:
Bluetooth is a short-range wireless technology standard that is used for exchanging
data between devices over short distances. It employs UHF radio waves in the ISM
bands, from 2.402 GHz to 2.48 GHz. It is mainly used as an alternative to wire
connections.
Rationale:
An attacker may be able to find a way to access or corrupt your data. One example of
this type of activity is bluesnarfing, which refers to attackers using a Bluetooth
connection to steal information off of your Bluetooth device. Also, viruses or other
malicious code can take advantage of Bluetooth technology to infect other devices. If
you are infected, your data may be corrupted, compromised, stolen, or lost.
Impact:
Many personal electronic devices (PEDs) use Bluetooth technology. For example, you
may be able to operate your computer with a wireless keyboard. Disabling Bluetooth will
prevent these devices from connecting to the system.
There may be packages that are dependent on the bluez package. If the bluez package
is removed, these dependent packages will be removed as well. Before removing the
bluez package, review any dependent packages to determine if they are required on the
system.
-IF- a dependent package is required: stop and mask bluetooth.service leaving the
bluez package installed.
Page 319
-OR-
-IF- the bluez package is required as a dependency:
Run the following command to verify bluetooth.service is not enabled:
# systemctl is-enabled bluetooth.service 2>/dev/null | grep 'enabled'
Remediation:
Run the following commands to stop bluetooth.service, and remove the bluez
package:
# systemctl stop bluetooth.service
# apt purge bluez
# apt autoremove bluez
-OR-
-IF- the bluez package is required as a dependency:
Run the following commands to stop and mask bluetooth.service:
# systemctl stop bluetooth.service
# systemctl mask bluetooth.service
1. https://www.cisa.gov/tips/st05-015
2. NIST SP 800-53 Rev. 5: CM-7
Page 320
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 321
The Linux kernel modules support several network protocols that are not commonly
used. If these protocols are not needed, it is recommended that they be disabled in the
kernel.
Note: This should not be considered a comprehensive list of uncommon network
protocols, you may wish to consider additions to those listed here for your environment.
Page 322
• Level 2 - Server
• Level 2 - Workstation
Description:
The Datagram Congestion Control Protocol (DCCP) is a transport layer protocol that
supports streaming media and telephony. DCCP provides a way to gain access to
congestion control, without having to do it at the application layer, but does not provide
in-sequence delivery.
Rationale:
-IF- the protocol is not required, it is recommended that the drivers not be installed to
reduce the potential attack surface.
Audit:
Run the following script to verify the dccp module is disabled:
-IF- the module is available in the running kernel:
-IF- the kernel module is not available on the system, or pre-compiled into the kernel:
Page 323
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="dccp" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 324
-IF- the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 325
{
l_mname="dccp" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 326
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 327
• Level 2 - Server
• Level 2 - Workstation
Description:
The Transparent Inter-Process Communication (TIPC) protocol is designed to provide
communication between cluster nodes.
Rationale:
-IF- the protocol is not being used, it is recommended that kernel module not be loaded,
disabling the service to reduce the potential attack surface.
Audit:
Run the following script to verify the tipc module is disabled:
-IF- the module is available in the running kernel:
-IF- the kernel module is not available on the system, or pre-compiled into the kernel:
Page 328
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="tipc" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 329
-IF- the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 330
{
l_mname="tipc" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 331
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 332
• Level 2 - Server
• Level 2 - Workstation
Description:
The Reliable Datagram Sockets (RDS) protocol is a transport layer protocol designed to
provide low-latency, high-bandwidth communications between cluster nodes. It was
developed by the Oracle Corporation.
Rationale:
-IF- the protocol is not being used, it is recommended that kernel module not be loaded,
disabling the service to reduce the potential attack surface.
Audit:
Run the following script to verify the rds module is disabled:
-IF- the module is available in the running kernel:
-IF- the kernel module is not available on the system, or pre-compiled into the kernel:
Page 333
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="rds" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 334
-IF- the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 335
{
l_mname="rds" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 336
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 337
• Level 2 - Server
• Level 2 - Workstation
Description:
The Stream Control Transmission Protocol (SCTP) is a transport layer protocol used to
support message oriented communication, with several streams of messages in one
connection. It serves a similar function as TCP and UDP, incorporating features of both.
It is message-oriented like UDP, and ensures reliable in-sequence transport of
messages with congestion control like TCP.
Rationale:
-IF- the protocol is not being used, it is recommended that kernel module not be loaded,
disabling the service to reduce the potential attack surface.
Audit:
Run the following script to verify the sctp module is disabled:
-IF- the module is available in the running kernel:
-IF- the kernel module is not available on the system, or pre-compiled into the kernel:
Page 338
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="sctp" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 339
-IF- the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 340
{
l_mname="sctp" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P -- "(^\h*install|\b$l_mname)\b" <<<
"$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 341
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 342
The following network parameters are intended for use on both host only and router
systems. A system acts as a router if it has at least two interfaces and is configured to
perform routing functions.
Note:
Page 343
• Level 1 - Server
• Level 1 - Workstation
Description:
The net.ipv4.ip_forward and net.ipv6.conf.all.forwarding flags are used to tell the
system whether it can forward packets or not.
Rationale:
Setting net.ipv4.ip_forward and net.ipv6.conf.all.forwarding to 0 ensures that a
system with multiple interfaces (for example, a hard proxy), will never be able to forward
packets, and therefore, never serve as a router.
Impact:
IP forwarding is required on systems configured to act as a router. If these parameters
are disabled, the system will not be able to perform as a router.
Many Cloud Service Provider (CSP) hosted systems require IP forwarding to be
enabled. If the system is running on a CSP platform, this requirement should be
reviewed before disabling IP forwarding.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.ip_forward is set to 0
•
net.ipv6.conf.all.forwarding is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
canonically later file, that "correct" setting will be ignored both by the script and
by the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 344
{
l_output="" l_output2=""
a_parlist=("net.ipv4.ip_forward=0" "net.ipv6.conf.all.forwarding=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 345
Page 346
•
net.ipv4.ip_forward = 0
Example:
# printf '%s\n' "net.ipv4.ip_forward = 0" >> /etc/sysctl.d/60-netipv4_sysctl.conf
•
net.ipv6.conf.all.forwarding = 0
Example:
# printf '%s\n' "net.ipv6.conf.all.forwarding = 0" >> /etc/sysctl.d/60-netipv6_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.ip_forward = 0
net.ipv6.conf.all.forwarding = 0
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 347
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 348
• Level 1 - Server
• Level 1 - Workstation
Description:
ICMP Redirects are used to send routing information to other hosts. As a host itself
does not act as a router (in a host only configuration), there is no need to send
redirects.
Rationale:
An attacker could use a compromised host to send invalid ICMP redirects to other
router devices in an attempt to corrupt routing and have users access a system set up
by the attacker as opposed to a valid system.
Impact:
IP forwarding is required on systems configured to act as a router. If these parameters
are disabled, the system will not be able to perform as a router.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.conf.all.send_redirects is set to 0
•
net.ipv4.conf.default.send_redirects is set to 0
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 349
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.send_redirects=0" "net.ipv4.conf.default.send_redirects=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 350
Page 351
•
net.ipv4.conf.all.send_redirects = 0
•
net.ipv4.conf.default.send_redirects = 0
Example:
# printf '%s\n' "net.ipv4.conf.all.send_redirects = 0" "net.ipv4.conf.default.send_redirects = 0" >>
/etc/sysctl.d/60-netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.send_redirects = 1
net.ipv4.conf.default.send_redirects = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 352
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 353
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting net.ipv4.icmp_ignore_bogus_error_responses to 1 prevents the kernel from
logging bogus responses (RFC-1122 non-compliant) from broadcast reframes, keeping
file systems from filling up with useless log messages.
Rationale:
Some routers (and some attackers) will send responses that violate RFC-1122 and
attempt to fill up a log file system with many useless error messages.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.icmp_ignore_bogus_error_responses is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 354
{
l_output="" l_output2=""
a_parlist=("net.ipv4.icmp_ignore_bogus_error_responses=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 355
Page 356
•
net.ipv4.icmp_ignore_bogus_error_responses = 1
Example:
# printf '%s\n' "net.ipv4.icmp_ignore_bogus_error_responses = 1" >> /etc/sysctl.d/60-netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.icmp_ignore_bogus_error_responses = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 357
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 358
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting net.ipv4.icmp_echo_ignore_broadcasts to 1 will cause the system to ignore all
ICMP echo and timestamp requests to broadcast and multicast addresses.
Rationale:
Accepting ICMP echo and timestamp requests with broadcast or multicast destinations
for your network could be used to trick your host into starting (or participating) in a
Smurf attack. A Smurf attack relies on an attacker sending large amounts of ICMP
broadcast messages with a spoofed source address. All hosts receiving this message
and responding would send echo-reply messages back to the spoofed address, which is
probably not routable. If many hosts respond to the packets, the amount of traffic on the
network could be significantly multiplied.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.icmp_echo_ignore_broadcasts is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 359
{
l_output="" l_output2=""
a_parlist=("net.ipv4.icmp_echo_ignore_broadcasts=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 360
Page 361
•
net.ipv4.icmp_echo_ignore_broadcasts = 1
Example:
# printf '%s\n' "net.ipv4.icmp_echo_ignore_broadcasts = 1" >> /etc/sysctl.d/60-netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.default.log_martians = 0
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 362
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 363
• Level 1 - Server
• Level 1 - Workstation
Description:
ICMP redirect messages are packets that convey routing information and tell your host
(acting as a router) to send packets via an alternate path. It is a way of allowing an
outside routing device to update your system routing tables.
Rationale:
ICMP redirect messages are packets that convey routing information and tell your host
(acting as a router) to send packets via an alternate path. It is a way of allowing an
outside routing device to update your system routing tables. By setting
net.ipv4.conf.all.accept_redirects, net.ipv4.conf.default.accept_redirects,
net.ipv6.conf.all.accept_redirects, and net.ipv6.conf.default.accept_redirects
to 0, the system will not accept any ICMP redirect messages, and therefore, won't allow
outsiders to update the system's routing tables.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.conf.all.accept_redirects is set to 0
•
net.ipv4.conf.default.accept_redirects is set to 0
•
net.ipv6.conf.all.accept_redirects is set to 0
•
net.ipv6.conf.default.accept_redirects is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
canonically later file, that "correct" setting will be ignored both by the script and
by the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 364
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.accept_redirects=0" "net.ipv4.conf.default.accept_redirects=0"
"net.ipv6.conf.all.accept_redirects=0" "net.ipv6.conf.default.accept_redirects=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
Page 365
Page 366
•
net.ipv4.conf.all.accept_redirects = 0
•
net.ipv4.conf.default.accept_redirects = 0
Example:
# printf '%s\n' "net.ipv4.conf.all.accept_redirects = 0" "net.ipv4.conf.default.accept_redirects = 0" >>
/etc/sysctl.d/60-netipv4_sysctl.conf
•
net.ipv6.conf.all.accept_redirects = 0
•
net.ipv6.conf.default.accept_redirects = 0
Example:
# printf '%s\n' "net.ipv6.conf.all.accept_redirects = 0" "net.ipv6.conf.default.accept_redirects = 0" >>
/etc/sysctl.d/60-netipv6_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.accept_redirects = 1
net.ipv4.conf.default.accept_redirects = 1
net.ipv6.conf.all.accept_redirects = 1
net.ipv6.conf.default.accept_redirects = 1
Page 367
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 368
• Level 1 - Server
• Level 1 - Workstation
Description:
Secure ICMP redirects are the same as ICMP redirects, except they come from
gateways listed on the default gateway list. It is assumed that these gateways are
known to your system, and that they are likely to be secure.
Rationale:
It is still possible for even known gateways to be compromised. Setting
net.ipv4.conf.all.secure_redirects and net.ipv4.conf.default.secure_redirects
to 0 protects the system from routing table updates by possibly compromised known
gateways.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.conf.all.secure_redirects is set to 0
•
net.ipv4.conf.default.secure_redirects is set to 0
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 369
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.secure_redirects=0" "net.ipv4.conf.default.secure_redirects=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 370
Page 371
•
net.ipv4.conf.all.secure_redirects = 0
•
net.ipv4.conf.default.secure_redirects = 0
Example:
# printf '%s\n' "net.ipv4.conf.all.secure_redirects = 0" "net.ipv4.conf.default.secure_redirects = 0" >>
/etc/sysctl.d/60-netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.secure_redirects = 1
net.ipv4.conf.default.secure_redirects = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 372
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 373
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting net.ipv4.conf.all.rp_filter and net.ipv4.conf.default.rp_filter to 1
forces the Linux kernel to utilize reverse path filtering on a received packet to determine
if the packet was valid. Essentially, with reverse path filtering, if the return packet does
not go out the same interface that the corresponding source packet came from, the
packet is dropped (and logged if log_martians is set).
Rationale:
Setting net.ipv4.conf.all.rp_filter and net.ipv4.conf.default.rp_filter to 1 is a
good way to deter attackers from sending your system bogus packets that cannot be
responded to. One instance where this feature beaks down is if asymmetrical routing is
employed. This would occur when using dynamic routing protocols (bgp, ospf, etc) on
your system. If you are using asymmetrical routing on your system, you will not be able
to enable this feature without breaking the routing.
Impact:
If you are using asymmetrical routing on your system, you will not be able to enable this
feature without breaking the routing.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.conf.all.rp_filter is set to 1
•
net.ipv4.conf.default.rp_filter is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 374
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.rp_filter=1" "net.ipv4.conf.default.rp_filter=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 375
Page 376
•
net.ipv4.conf.all.rp_filter = 1
•
net.ipv4.conf.default.rp_filter = 1
Example:
# printf '%s\n' "net.ipv4.conf.all.rp_filter = 1" "net.ipv4.conf.default.rp_filter = 1" >> /etc/sysctl.d/60-
netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 377
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 378
• Level 1 - Server
• Level 1 - Workstation
Description:
In networking, source routing allows a sender to partially or fully specify the route
packets take through a network. In contrast, non-source routed packets travel a path
determined by routers in the network. In some cases, systems may not be routable or
reachable from some locations (e.g. private addresses vs. Internet routable), and so
source routed packets would need to be used.
Rationale:
Setting net.ipv4.conf.all.accept_source_route,
net.ipv4.conf.default.accept_source_route,
net.ipv6.conf.all.accept_source_route and
net.ipv6.conf.default.accept_source_route to 0 disables the system from accepting
source routed packets. Assume this system was capable of routing packets to Internet
routable addresses on one interface and private addresses on another interface.
Assume that the private addresses were not routable to the Internet routable addresses
and vice versa. Under normal routing circumstances, an attacker from the Internet
routable addresses could not use the system as a way to reach the private address
systems. If, however, source routed packets were allowed, they could be used to gain
access to the private address systems as the route could be specified, rather than rely
on routing protocols that did not allow this routing.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.conf.all.accept_source_route is set to 0
•
net.ipv4.conf.default.accept_source_route is set to 0
•
net.ipv6.conf.all.accept_source_route is set to 0
•
net.ipv6.conf.default.accept_source_route is set to 0
Page 379
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
canonically later file, that "correct" setting will be ignored both by the script and
by the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 380
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.accept_source_route=0" "net.ipv4.conf.default.accept_source_route=0"
"net.ipv6.conf.all.accept_source_route=0" "net.ipv6.conf.default.accept_source_route=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
Page 381
Page 382
•
net.ipv4.conf.all.accept_source_route = 0
•
net.ipv4.conf.default.accept_source_route = 0
Example:
# printf '%s\n' "net.ipv4.conf.all.accept_source_route = 0" "net.ipv4.conf.default.accept_source_route = 0" >>
/etc/sysctl.d/60-netipv4_sysctl.conf
•
net.ipv6.conf.all.accept_source_route = 0
•
net.ipv6.conf.default.accept_source_route = 0
Example:
# printf '%s\n' "net.ipv6.conf.all.accept_source_route = 0" "net.ipv6.conf.default.accept_source_route = 0" >>
/etc/sysctl.d/60-netipv6_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
Page 383
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 384
• Level 1 - Server
• Level 1 - Workstation
Description:
When enabled, this feature logs packets with un-routable source addresses to the
kernel log.
Rationale:
Setting net.ipv4.conf.all.log_martians and net.ipv4.conf.default.log_martians
to 1` enables this feature. Logging these packets allows an administrator to investigate
the possibility that an attacker is sending spoofed packets to their system.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.conf.all.log_martians is set to 1
•
net.ipv4.conf.default.log_martians is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 385
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.log_martians=1" "net.ipv4.conf.default.log_martians=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 386
Page 387
•
net.ipv4.conf.all.log_martians = 1
•
net.ipv4.conf.default.log_martians = 1
Example:
# printf '%s\n' "net.ipv4.conf.all.log_martians = 1" "net.ipv4.conf.default.log_martians = 1" >>
/etc/sysctl.d/60-netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.log_martians = 0
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 388
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 389
• Level 1 - Server
• Level 1 - Workstation
Description:
When tcp_syncookies is set, the kernel will handle TCP SYN packets normally until the
half-open connection queue is full, at which time, the SYN cookie functionality kicks in.
SYN cookies work by not using the SYN queue at all. Instead, the kernel simply replies
to the SYN with a SYN|ACK, but will include a specially crafted TCP sequence number
that encodes the source and destination IP address and port number and the time the
packet was sent. A legitimate connection would send the ACK packet of the three way
handshake with the specially crafted sequence number. This allows the system to verify
that it has received a valid response to a SYN cookie and allow the connection, even
though there is no corresponding SYN in the queue.
Rationale:
Attackers use SYN flood attacks to perform a denial of service attacked on a system by
sending many SYN packets without completing the three way handshake. This will
quickly use up slots in the kernel's half-open connection queue and prevent legitimate
connections from succeeding. Setting net.ipv4.tcp_syncookies to 1 enables SYN
cookies, allowing the system to keep accepting valid connections, even if under a denial
of service attack.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv4.tcp_syncookies is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a canonically later
file, that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 390
{
l_output="" l_output2=""
a_parlist=("net.ipv4.tcp_syncookies=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 391
Page 392
•
net.ipv4.tcp_syncookies = 1
Example:
# printf '%s\n' "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.d/60-netipv4_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.tcp_syncookies = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 393
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 394
• Level 1 - Server
• Level 1 - Workstation
Description:
This setting disables the system's ability to accept IPv6 router advertisements.
Rationale:
It is recommended that systems do not accept router advertisements as they could be
tricked into routing traffic to compromised machines. Setting hard routes within the
system (usually a single default route to a trusted router) protects the system from bad
routes. Setting net.ipv6.conf.all.accept_ra and net.ipv6.conf.default.accept_ra
to 0 disables the system's ability to accept IPv6 router advertisements.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
•
net.ipv6.conf.all.accept_ra is set to 0
•
net.ipv6.conf.default.accept_ra is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
canonically later file, that "correct" setting will be ignored both by the script and
by the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 395
{
l_output="" l_output2=""
a_parlist=("net.ipv6.conf.all.accept_ra=0" "net.ipv6.conf.default.accept_ra=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)"
a_searchpath=("/run/sysctl.d/" "/etc/sysctl.d/" "/usr/local/lib/sysctl.d/" "/usr/lib/sysctl.d/"
"/lib/sysctl.d/")
unset A_files
declare -A A_files # Array of "valid" files
A_files+=(["sysctl.conf"]="/etc/sysctl.conf")
for l_searchpath in "${a_searchpath[@]}"; do
if [ -d "$l_searchpath" ]; then
while IFS= read -r -d $'\0' l_filename; do
if [ -f "$l_filename" ]; then
l_basename="$(basename "$l_filename")"
if [ -z "${A_files["$l_basename"]}" ]; then
A_files+=(["$l_basename"]="$l_filename")
fi
fi
done < <(find "$l_searchpath" -type f -name '*.conf' -print0)
fi
done
a_sorted=()
while IFS= read -rd '' l_key; do
a_sorted+=( "$l_key" )
done < <(printf '%s\0' "${!A_files[@]}" | sort -rz)
kernel_parameter_chk()
{
l_var="" l_var2=""
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running configuration
and should have a value of: \"$l_kpvalue\""
fi
if [ -n "$l_ufwscf" ]; then # Check UFW kernel parameter file first
if grep -Pqs -- "^\h*$l_kpname\b" "$l_$l_ufwscf"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "$l_$l_ufwscf" | tail -n 1)"
fi
fi
if grep -Pqs -- "^\h*$l_kpname\b" /etc/sysctl.conf; then # Check /etc/sysctl.conf parameter file next
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" /etc/sysctl.conf | tail -n 1)"
fi
if [ -z "$l_var" ]; then # If non found yet, now we loop find actual conf file parameter setting based on
presence
for l_keyname in "${a_sorted[@]}";do
if grep -Pqs -- "^\h*$l_kpname\b" "${A_files["$l_keyname"]}"; then
l_var="$(grep -PHo -- "^\h*$l_kpname\h*=\h*\H+\b" "${A_files["$l_keyname"]}" | tail -n 1)"
break
fi
done
fi
if [ -n "$l_var" ]; then
while IFS=":" read -r l_conf_file l_var2; do
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$l_conf_file\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$l_conf_file\" and should have a value of: \"$l_kpvalue\"\n"
fi
done <<< "$l_var2"
done <<< "$l_var"
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note: \"$l_kpname\" May
be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<< "$l_kpname";
then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
Page 396
Page 397
•
net.ipv6.conf.all.accept_ra = 0
•
net.ipv6.conf.default.accept_ra = 0
Example:
# printf '%s\n' "net.ipv6.conf.all.accept_ra = 0" "net.ipv6.conf.default.accept_ra = 0" >> /etc/sysctl.d/60-
netipv6_sysctl.conf
Note: If these settings appear in a canonically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.default.accept_ra = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 398
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 399
A firewall is a set of rules. When a data packet moves into or out of a protected network
space, its contents (in particular, information about its origin, target, and the protocol it
plans to use) are tested against the firewall rules to see if it should be allowed through
To provide a Host Based Firewall, the Linux kernel includes support for:
• Netfilter - A set of hooks inside the Linux kernel that allows kernel modules to
register callback functions with the network stack. A registered callback function
is then called back for every packet that traverses the respective hook within the
network stack. Includes the ip_tables, ip6_tables, arp_tables, and ebtables kernel
modules. These modules are some of the significant parts of the Netfilter hook
system.
• nftables - A subsystem of the Linux kernel providing filtering and classification of
network packets/datagrams/frames. nftables is supposed to replace certain parts
of Netfilter, while keeping and reusing most of it. nftables utilizes the building
blocks of the Netfilter infrastructure, such as the existing hooks into the
networking stack, connection tracking system, userspace queueing component,
and logging subsystem. Is available in Linux kernels 3.13 and newer.
In order to configure firewall rules for Netfilter or nftables, a firewall utility needs to be
installed. Guidance has been included for the following firewall utilities:
Note:
• Only one method should be used to configure a firewall on the system. Use of
more than one method could produce unexpected results
• This section is intended only to ensure the resulting firewall rules are in place, not
how they are configured
Page 400
If nftables or iptables are being used in your environment, please follow the
guidance in their respective section and pass-over the guidance in this section.
Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to
be easy to use.
Note:
Page 401
• Level 1 - Server
• Level 1 - Workstation
Description:
The Uncomplicated Firewall (ufw) is a frontend for iptables and is particularly well-suited
for host-based firewalls. ufw provides a framework for managing netfilter, as well as a
command-line interface for manipulating the firewall
Rationale:
A firewall utility is required to configure the Linux kernel's netfilter framework via the
iptables or nftables back-end.
The Linux kernel's netfilter framework host-based firewall can protect against threats
originating from within a corporate network to include malicious mobile code and poorly
configured software on a host.
Note: Only one firewall utility should be installed and configured. UFW is dependent on
the iptables package
Audit:
Run the following command to verify that Uncomplicated Firewall (UFW) is installed:
# dpkg-query -s ufw &>/dev/null && echo "ufw is installed"
ufw is installed
Remediation:
Run the following command to install Uncomplicated Firewall (UFW):
apt install ufw
References:
Page 402
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 403
• Level 1 - Server
• Level 1 - Workstation
Description:
The iptables-persistent is a boot-time loader for netfilter rules, iptables plugin
Rationale:
Running both ufw and the services included in the iptables-persistent package may lead
to conflict
Audit:
Run the following command to verify that the iptables-persistent package is not
installed:
dpkg-query -s iptables-persistent
Remediation:
Run the following command to remove the iptables-persistent package:
# apt purge iptables-persistent
References:
Page 404
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 405
• Level 1 - Server
• Level 1 - Workstation
Description:
UncomplicatedFirewall (ufw) is a frontend for iptables. ufw provides a framework for
managing netfilter, as well as a command-line and available graphical user interface for
manipulating the firewall.
Note:
• When running ufw enable or starting ufw via its initscript, ufw will flush its chains.
This is required so ufw can maintain a consistent state, but it may drop existing
connections (eg ssh). ufw does support adding rules before enabling the firewall.
• Run the following command before running ufw enable.
• The rules will still be flushed, but the ssh port will be open after enabling the
firewall. Please note that once ufw is 'enabled', ufw will not flush the chains when
adding or removing rules (but will when modifying a rule or changing the default
policy)
• By default, ufw will prompt when enabling the firewall while running under ssh.
This can be disabled by using ufw --force enable
Rationale:
The ufw service must be enabled and running in order for ufw to protect the system
Impact:
Changing firewall settings while connected over network can result in being locked out
of the system.
Page 406
enabled
Run the following command to verify that the ufw daemon is active:
# systemctl is-active ufw
active
Status: active
Remediation:
Run the following command to unmask the ufw daemon:
# systemctl unmask ufw.service
Run the following command to enable and start the ufw daemon:
# systemctl --now enable ufw.service
active
References:
1. http://manpages.ubuntu.com/manpages/precise/en/man8/ufw.8.html
2. NIST SP 800-53 Rev. 5: SC-7
Page 407
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 408
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network (127.0.0.0/8 for IPv4 and ::1/128 for IPv6).
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
(127.0.0.0/8 for IPv4 and ::1/128 for IPv6) traffic should be seen, all other interfaces
should ignore traffic on this network as an anti-spoofing measure.
Audit:
Run the following commands and verify output includes the listed rules in order:
# ufw status verbose
To Action From
-- ------ ----
Anywhere on lo ALLOW IN Anywhere
Anywhere DENY IN 127.0.0.0/8
Anywhere (v6) on lo ALLOW IN Anywhere (v6)
Anywhere (v6) DENY IN ::1
Remediation:
Run the following commands to implement the loopback rules:
# ufw allow in on lo
# ufw allow out on lo
# ufw deny in from 127.0.0.0/8
# ufw deny in from ::1
References:
Page 409
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 410
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound connections.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system.
• Unlike iptables, when a new outbound rule is added, ufw automatically takes care
of associated established connections, so no rules for the latter kind are required.
Rationale:
If rules are not in place for new outbound connections all packets will be dropped by the
default policy preventing network usage.
Audit:
Run the following command and verify all rules for new outbound connections match
site policy:
# ufw status numbered
Remediation:
Configure ufw in accordance with site policy. The following commands will implement a
policy to allow all outbound connections on all interfaces:
# ufw allow out on all
References:
Page 411
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 412
• Level 1 - Server
• Level 1 - Workstation
Description:
Services and ports can be accepted or explicitly rejected.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• The remediation command opens up the port to traffic from all sources. Consult
ufw documentation and set any restrictions in compliance with site policy
Rationale:
To reduce the attack surface of a system, all services and ports should be blocked
unless required.
• Any ports that have been opened on non-loopback addresses need firewall rules
to govern traffic.
• Without a firewall rule configured for open ports, the default firewall policy will
drop all packets to these ports.
• Required ports should have a firewall rule created to allow approved connections
in accordance with local site policy.
• Unapproved ports should have an explicit deny rule created.
Page 413
{
unset a_ufwout;unset a_openports
while read -r l_ufwport; do
[ -n "$l_ufwport" ] && a_ufwout+=("$l_ufwport")
done < <(ufw status verbose | grep -Po '^\h*\d+\b' | sort -u)
while read -r l_openport; do
[ -n "$l_openport" ] && a_openports+=("$l_openport")
done < <(ss -tuln | awk '($5!~/%lo:/ && $5!~/127.0.0.1:/ && $5!~/\[?::1\]?:/) {split($5, a, ":"); print
a[2]}' | sort -u)
a_diff=("$(printf '%s\n' "${a_openports[@]}" "${a_ufwout[@]}" "${a_ufwout[@]}" | sort | uniq -u)")
if [[ -n "${a_diff[*]}" ]]; then
echo -e "\n- Audit Result:\n ** FAIL **\n- The following port(s) don't have a rule in UFW: $(printf
'%s\n' \\n"${a_diff[*]}")\n- End List"
else
echo -e "\n - Audit Passed -\n- All open ports have a rule in UFW\n"
fi
}
Remediation:
For each port identified in the audit which does not have a firewall rule, evaluate the
service listening on the port and add a rule for accepting or denying inbound
connections in accordance with local site policy:
Examples:
# ufw allow in <port>/<tcp or udp protocol>
Note: Examples create rules for from any, to any. More specific rules should be
concentered when allowing inbound traffic e.g only traffic from this network.
Example to allow traffic on port 443 using the tcp protocol from the 192.168.1.0 network:
ufw allow from 192.168.1.0/24 to any proto tcp port 443
Page 414
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 415
• Level 1 - Server
• Level 1 - Workstation
Description:
A default deny policy on connections ensures that any unconfigured network usage will
be rejected.
Note: Any port or protocol without a explicit allow before the default deny will be
blocked
Rationale:
With a default accept policy the firewall will accept any packet that is not configured to
be denied. It is easier to allow list acceptable usage than to deny list unacceptable
usage.
Impact:
Any port and protocol not explicitly allowed will be blocked. The following rules should
be considered before applying the default deny.
ufw allow git
ufw allow in http
ufw allow out http <- required for apt to connect to repository
ufw allow in https
ufw allow out https
ufw allow out 53
ufw logging on
Audit:
Run the following command and verify that the default policy for incoming , outgoing ,
and routed directions is deny , reject , or disabled:
# ufw status verbose | grep Default:
Example output:
Default: deny (incoming), deny (outgoing), disabled (routed)
Remediation:
Run the following commands to implement a default deny policy:
# ufw default deny incoming
# ufw default deny outgoing
# ufw default deny routed
Page 416
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 417
• This section broadly assumes starting with an empty nftables firewall ruleset
(established by flushing the rules with nft flush ruleset).
• Remediation steps included only affect the live system, you will also need to
configure your default firewall configuration to apply on boot.
• Configuration of a live systems firewall directly over a remote connection will
often result in being locked out. It is advised to have a known good firewall
configuration set to run on boot and to configure an entire firewall structure in a
script that is then run and tested before saving to boot.
The following will implement the firewall rules of this section and open ICMP, IGMP, and
port 22(ssh) from anywhere. Opening the ports for ICMP, IGMP, and port 22(ssh) needs
to be updated in accordance with local site policy. Allow port 22(ssh) needs to be
updated to only allow systems requiring ssh connectivity to connect, as per site
policy.
Save the script bellow as /etc/nftables.rules
Page 418
# Base chain for hook forward named forward (Filters forwarded network packets)
chain forward {
type filter hook forward priority 0; policy drop;
}
# Base chain for hook output named output (Filters outbount network packets)
chain output {
type filter hook output priority 0; policy drop;
# Ensure outbound and established connections are configured
ip protocol tcp ct state established,related,new accept
ip protocol udp ct state established,related,new accept
ip protocol icmp ct state established,related,new accept
}
}
Page 419
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables provides a new in-kernel packet classification framework that is based on a
network-specific Virtual Machine (VM) and a new nft userspace command line tool.
nftables reuses the existing Netfilter subsystems such as the existing hook
infrastructure, the connection tracking system, NAT, userspace queuing and logging
subsystem.
Notes:
Rationale:
nftables is a subsystem of the Linux kernel that can protect against threats originating
from within a corporate network to include malicious mobile code and poorly configured
software on a host.
Audit:
Run the following command to verify that nftables is installed:
# dpkg-query -s nftables | grep 'Status: install ok installed'
Remediation:
Run the following command to install nftables:
# apt install nftables
References:
Page 420
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 421
• Level 1 - Server
• Level 1 - Workstation
Description:
Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to
be easy to use.
Rationale:
Running both the nftables service and ufw may lead to conflict and unexpected results.
Audit:
Run the following commands to verify that ufw is either not installed or inactive. Only
one of the following needs to pass.
Run the following command to verify that ufw is not installed:
# dpkg-query -s -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' ufw
-OR-
Run the following commands to verify ufw is disabled and ufw.service is not enabled:
# ufw status
Status: inactive
# systemctl is-enabled ufw.service
masked
Remediation:
Run one of the following to either remove ufw or disable ufw and mask ufw.service:
Run the following command to remove ufw:
# apt purge ufw
-OR-
Run the following commands to disable ufw and mask ufw.service:
# ufw disable
# systemctl stop ufw.service
# systemctl mask ufw.service
Note: ufw disable needs to be run before systemctl mask ufw.service in order to
correctly disable UFW
Page 422
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 423
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables is a replacement for iptables, ip6tables, ebtables and arptables
Rationale:
It is possible to mix iptables and nftables. However, this increases complexity and also
the chance to introduce errors. For simplicity flush out all iptables rules, and ensure it is
not loaded
Audit:
Run the following commands to ensure no iptables rules exist
For iptables:
# iptables -L
For ip6tables:
# ip6tables -F
References:
Page 424
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 425
• Level 1 - Server
• Level 1 - Workstation
Description:
Tables hold chains. Each table only has one address family and only applies to packets
of this family. Tables can have one of five families.
Rationale:
nftables doesn't have any default tables. Without a table being build, nftables will not
filter network traffic.
Impact:
Adding rules to a running nftables can cause loss of connectivity to the system
Audit:
Run the following command to verify that a nftables table exists:
# nft list tables
Remediation:
Run the following command to create a table in nftables
# nft create table inet <table name>
Example:
# nft create table inet filter
References:
Page 426
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 427
• Level 1 - Server
• Level 1 - Workstation
Description:
Chains are containers for rules. They exist in two kinds, base chains and regular chains.
A base chain is an entry point for packets from the networking stack, a regular chain
may be used as jump target and is used for better rule organization.
Rationale:
If a base chain doesn't exist with a hook for input, forward, and delete, packets that
would flow through those chains will not be touched by nftables.
Impact:
If configuring nftables over ssh, creating a base chain with a policy of drop will cause
loss of connectivity.
Ensure that a rule allowing ssh has been added to the base chain prior to setting the
base chain's policy to drop
Audit:
Run the following commands and verify that base chains exist for INPUT.
# nft list ruleset | grep 'hook input'
Run the following commands and verify that base chains exist for FORWARD.
# nft list ruleset | grep 'hook forward'
Run the following commands and verify that base chains exist for OUTPUT.
# nft list ruleset | grep 'hook output'
Page 428
Example:
# nft create chain inet filter input { type filter hook input priority 0 \; }
# nft create chain inet filter forward { type filter hook forward priority 0 \; }
# nft create chain inet filter output { type filter hook output priority 0 \; }
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 429
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
traffic should be seen, all other interfaces should ignore traffic on this network as an
anti-spoofing measure.
Audit:
Run the following commands to verify that the loopback interface is configured:
Run the following command to verify the loopback interface is configured to accept
network traffic:
# nft list ruleset | awk '/hook input/,/}/' | grep 'iif "lo" accept'
Example output:
iif "lo" accept
Run the following command to verify network traffic from an iPv4 loopback interface is
configured to drop:
# nft list ruleset | awk '/hook input/,/}/' | grep 'ip saddr'
Example output:
ip saddr 127.0.0.0/8 counter packets 0 bytes 0 drop
Example output:
ip6 saddr ::1 counter packets 0 bytes 0 drop
Page 430
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 431
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound, and established connections
Rationale:
If rules are not in place for new outbound, and established connections all packets will
be dropped by the default policy preventing network usage.
Audit:
Run the following commands and verify all rules for established incoming connections
match site policy: site policy:
# nft list ruleset | awk '/hook input/,/}/' | grep -E 'ip protocol (tcp|udp|icmp) ct state'
Run the folllowing command and verify all rules for new and established outbound
connections match site policy
# nft list ruleset | awk '/hook output/,/}/' | grep -E 'ip protocol (tcp|udp|icmp) ct state'
Page 432
# nft add rule inet filter input ip protocol udp ct state established accept
# nft add rule inet filter input ip protocol icmp ct state established accept
# nft add rule inet filter output ip protocol tcp ct state new,related,established accept
# nft add rule inet filter output ip protocol udp ct state new,related,established accept
# nft add rule inet filter output ip protocol icmp ct state new,related,established accept
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 433
• Level 1 - Server
• Level 1 - Workstation
Description:
Base chain policy is the default verdict that will be applied to packets reaching the end
of the chain.
Rationale:
There are two policies: accept (Default) and drop. If the policy is set to accept, the
firewall will accept any packet that is not configured to be denied and the packet will
continue transversing the network stack.
It is easier to allow list acceptable usage than to deny list unacceptable usage.
Note: Changing firewall settings while connected over network can result in being
locked out of the system.
Impact:
If configuring nftables over ssh, creating a base chain with a policy of drop will cause
loss of connectivity.
Ensure that a rule allowing ssh has been added to the base chain prior to setting the
base chain's policy to drop
Audit:
Run the following commands and verify that base chains contain a policy of DROP.
# nft list ruleset | grep 'hook input'
Page 434
Example:
# nft chain inet filter input { policy drop \; }
Default Value:
accept
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 435
• Level 1 - Server
• Level 1 - Workstation
Description:
The nftables service allows for the loading of nftables rulesets during boot, or starting on
the nftables service
Rationale:
The nftables service restores the nftables rules from the rules files referenced in the
/etc/nftables.conf file during boot or the starting of the nftables service
Audit:
Run the following command and verify that the nftables service is enabled:
# systemctl is-enabled nftables
enabled
Remediation:
Run the following command to enable the nftables service:
# systemctl enable nftables
References:
Page 436
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 437
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables is a subsystem of the Linux kernel providing filtering and classification of
network packets/datagrams/frames.
The nftables service reads the /etc/nftables.conf file for a nftables file or files to
include in the nftables ruleset.
A nftables ruleset containing the input, forward, and output base chains allow network
traffic to be filtered.
Rationale:
Changes made to nftables ruleset only affect the live system, you will also need to
configure the nftables ruleset to apply on boot
Page 438
Review the input base chain to ensure that it follows local site policy
Run the following command to verify the forward base chain:
# [ -n "$(grep -E '^\s*include' /etc/nftables.conf)" ] && awk '/hook forward/,/}/' $(awk '$1 ~ /^\s*include/ {
gsub("\"","",$2);print $2 }' /etc/nftables.conf)
Review the forward base chain to ensure that it follows local site policy.
Run the following command to verify the forward base chain:
# [ -n "$(grep -E '^\s*include' /etc/nftables.conf)" ] && awk '/hook output/,/}/' $(awk '$1 ~ /^\s*include/ {
gsub("\"","",$2);print $2 }' /etc/nftables.conf)
Review the output base chain to ensure that it follows local site policy.
Page 439
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 440
Page 441
Page 442
• Level 1 - Server
• Level 1 - Workstation
Description:
iptables is a utility program that allows a system administrator to configure the tables
provided by the Linux kernel firewall, implemented as different Netfilter modules, and
the chains and rules it stores. Different kernel modules and programs are used for
different protocols; iptables applies to IPv4, ip6tables to IPv6, arptables to ARP, and
ebtables to Ethernet frames.
Rationale:
A method of configuring and maintaining firewall rules is necessary to configure a Host
Based Firewall.
Audit:
Run the following command to verify that iptables is installed:
# dpkg-query -s iptables &>/dev/null && echo "iptables is installed"
iptables is installed
iptables-persistent is installed
Remediation:
Run the following command to install iptables and iptables-persistent
# apt install iptables iptables-persistent
References:
Page 443
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 444
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables is a subsystem of the Linux kernel providing filtering and classification of
network packets/datagrams/frames and is the successor to iptables.
Rationale:
Running both iptables and nftables may lead to conflict.
Audit:
Run the following commend to verify that nftables is not installed:
# dpkg-query -s nftables &>/dev/null && echo "nftables is installed"
References:
Page 445
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 446
• Level 1 - Server
• Level 1 - Workstation
Description:
Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to
be easy to use.
Rationale:
Running iptables.persistent with ufw enabled may lead to conflict and unexpected
results.
Audit:
Run the following commands to verify that ufw is either not installed or disabled. Only
one of the following needs to pass.
Run the following command to verify that ufw is not installed:
# dpkg-query -s ufw &>/dev/null && echo "ufw is installed"
Status: inactive
Run the following commands to verify that the ufw service is masked:
# systemctl is-enabled ufw
masked
Page 447
-OR-
Run the following commands to disable ufw:
# ufw disable
# systemctl stop ufw
# systemctl mask ufw
Note: ufw disable needs to be run before systemctl mask ufw in order to correctly
disable UFW
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 448
Page 449
• Level 1 - Server
• Level 1 - Workstation
Description:
A default deny all policy on connections ensures that any unconfigured network usage
will be rejected.
Notes:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
With a default accept policy the firewall will accept any packet that is not configured to
be denied. It is easier to allow list acceptable usage than to deny list unacceptable
usage.
Audit:
Run the following command and verify that the policy for the INPUT , OUTPUT , and
FORWARD chains is DROP or REJECT :
# iptables -L -n
Remediation:
Run the following commands to implement a default DROP policy:
# iptables -P INPUT DROP
# iptables -P OUTPUT DROP
# iptables -P FORWARD DROP
References:
Page 450
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 451
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network (127.0.0.0/8).
Notes:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
(127.0.0.0/8) traffic should be seen, all other interfaces should ignore traffic on this
network as an anti-spoofing measure.
Audit:
Run the following commands and verify output includes the listed rules in order (packet
and byte counts may differ):
# iptables -L INPUT -v -n
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 127.0.0.0/8 0.0.0.0/0
# iptables -L OUTPUT -v -n
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
Remediation:
Run the following commands to implement the loopback rules:
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A OUTPUT -o lo -j ACCEPT
# iptables -A INPUT -s 127.0.0.0/8 -j DROP
References:
Page 452
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 453
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound, and established connections.
Notes:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
If rules are not in place for new outbound, and established connections all packets will
be dropped by the default policy preventing network usage.
Audit:
Run the following command and verify all rules for new outbound, and established
connections match site policy:
# iptables -L -v -n
Remediation:
Configure iptables in accordance with site policy. The following commands will
implement a policy to allow all outbound connections and all established connections:
# iptables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -p icmp -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
# iptables -A INPUT -p udp -m state --state ESTABLISHED -j ACCEPT
# iptables -A INPUT -p icmp -m state --state ESTABLISHED -j ACCEPT
References:
Page 454
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 455
• Level 1 - Server
• Level 1 - Workstation
Description:
Any ports that have been opened on non-loopback addresses need firewall rules to
govern traffic.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
• The remediation command opens up the port to traffic from all sources. Consult
iptables documentation and set any restrictions in compliance with site policy
Rationale:
Without a firewall rule configured for open ports default firewall policy will drop all
packets to these ports.
Audit:
Run the following command to determine open ports:
# ss -4tuln
Verify all open ports listening on non-localhost addresses have at least one firewall rule.
The last line identified by the "tcp dpt:22 state NEW" identifies it as a firewall rule for
new connections on tcp port 22.
Page 456
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 457
Page 458
• Level 1 - Server
• Level 1 - Workstation
Description:
A default deny all policy on connections ensures that any unconfigured network usage
will be rejected.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
With a default accept policy the firewall will accept any packet that is not configured to
be denied. It is easier to allow list acceptable usage than to deny list unacceptable
usage.
Audit:
Run the following command and verify that the policy for the INPUT, OUTPUT, and
FORWARD chains is DROP or REJECT:
# ip6tables -L -n
-OR-
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Page 459
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 460
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network (::1).
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
(::1) traffic should be seen, all other interfaces should ignore traffic on this network as
an anti-spoofing measure.
Page 461
# ip6tables -L OUTPUT -v -n
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all * lo ::/0 ::/0
-OR-
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Remediation:
Run the following commands to implement the loopback rules:
# ip6tables -A INPUT -i lo -j ACCEPT
# ip6tables -A OUTPUT -o lo -j ACCEPT
# ip6tables -A INPUT -s ::1 -j DROP
References:
Page 462
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 463
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound, and established IPv6 connections.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
If rules are not in place for new outbound, and established connections all packets will
be dropped by the default policy preventing network usage.
Audit:
Run the following command and verify all rules for new outbound, and established
connections match site policy:
# ip6tables -L -v -n
-OR-
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Page 464
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 465
• Level 1 - Server
• Level 1 - Workstation
Description:
Any ports that have been opened on non-loopback addresses need firewall rules to
govern traffic.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
• The remediation command opens up the port to traffic from all sources. Consult
iptables documentation and set any restrictions in compliance with site policy
Rationale:
Without a firewall rule configured for open ports default firewall policy will drop all
packets to these ports.
Page 466
Verify all open ports listening on non-localhost addresses have at least one firewall rule.
The last line identified by the "tcp dpt:22 state NEW" identifies it as a firewall rule for
new connections on tcp port 22.
-OR-
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Remediation:
For each port identified in the audit which does not have a firewall rule establish a
proper rule for accepting inbound connections:
# ip6tables -A INPUT -p <protocol> --dport <port> -m state --state NEW -j ACCEPT
References:
Page 467
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 468
cron is a time-based job scheduler used to schedule jobs, commands or shell scripts, to
run periodically at fixed times, dates, or intervals.
atprovides the ability to execute a command or shell script at a specified date and
hour, or after a given interval of time.
Notes:
• Other methods exist for scheduling jobs, such as systemd timers. If another
method is used, it should be secured in accordance with local site policy
• systemd timers are systemd unit files whose name ends in .timer that control
.service files or events
o Timers can be used as an alternative to cron and at
o Timers have built-in support for calendar time events, monotonic time
events, and can be run asynchronously
• If cron and at are not installed, this section can be skipped
Page 469
• Level 1 - Server
• Level 1 - Workstation
Description:
The cron daemon is used to execute batch jobs on the system.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
While there may not be user jobs that need to be run on the system, the system does
have maintenance jobs that may include security monitoring that have to run, and cron
is used to execute them.
Audit:
Run the following command to verify cron is enabled:
# systemctl is-enabled cron
enabled
active
Remediation:
Run the following command to enable and start cron:
# systemctl unmask cron
# systemctl --now enable cron
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 470
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/crontab file is used by cron to control its own jobs. The commands in this
item make sure that root is the user and group owner of the file and that only the owner
can access the file.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
This file contains information on what system jobs are run by cron. Write access to
these files could provide unprivileged users with the ability to elevate their privileges.
Read access to these files could provide users with the ability to gain insight on system
jobs that run on the system and could provide them a way to gain unauthorized
privileged access.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other :
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/crontab
Remediation:
Run the following commands to set ownership and permissions on /etc/crontab :
# chown root:root /etc/crontab
# chmod og-rwx /etc/crontab
Default Value:
Access: (644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 471
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 472
• Level 1 - Server
• Level 1 - Workstation
Description:
This directory contains system cron jobs that need to run on an hourly basis. The files in
this directory cannot be manipulated by the crontab command, but are instead edited
by system administrators using a text editor. The commands below restrict read/write
and search access to user and group root, preventing regular users from accessing this
directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.hourly/
Remediation:
Run the following commands to set ownership and permissions on the
/etc/cron.hourly directory:
# chown root:root /etc/cron.hourly/
# chmod og-rwx /etc/cron.hourly/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 473
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 474
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.daily directory contains system cron jobs that need to run on a daily
basis. The files in this directory cannot be manipulated by the crontab command, but
are instead edited by system administrators using a text editor. The commands below
restrict read/write and search access to user and group root, preventing regular users
from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.daily/
Remediation:
Run the following commands to set ownership and permissions on the /etc/cron.daily
directory:
# chown root:root /etc/cron.daily/
# chmod og-rwx /etc/cron.daily/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 475
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 476
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.weekly directory contains system cron jobs that need to run on a weekly
basis. The files in this directory cannot be manipulated by the crontab command, but
are instead edited by system administrators using a text editor. The commands below
restrict read/write and search access to user and group root, preventing regular users
from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.weekly/
Remediation:
Run the following commands to set ownership and permissions on the
/etc/cron.weekly directory:
# chown root:root /etc/cron.weekly/
# chmod og-rwx /etc/cron.weekly/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 477
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 478
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.monthly directory contains system cron jobs that need to run on a
monthly basis. The files in this directory cannot be manipulated by the crontab
command, but are instead edited by system administrators using a text editor. The
commands below restrict read/write and search access to user and group root,
preventing regular users from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.monthly/
Remediation:
Run the following commands to set ownership and permissions on the
/etc/cron.monthly directory:
# chown root:root /etc/cron.monthly/
# chmod og-rwx /etc/cron.monthly/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 479
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 480
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.d directory contains system cron jobs that need to run in a similar
manner to the hourly, daily weekly and monthly jobs from /etc/crontab, but require
more granular control as to when they run. The files in this directory cannot be
manipulated by the crontab command, but are instead edited by system administrators
using a text editor. The commands below restrict read/write and search access to user
and group root, preventing regular users from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.d/
Remediation:
Run the following commands to set ownership and permissions on the /etc/cron.d
directory:
# chown root:root /etc/cron.d/
# chmod og-rwx /etc/cron.d/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Page 481
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 482
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure /etc/cron.allow to allow specific users to use this service. If
/etc/cron.allow does not exist, then /etc/cron.deny is checked. Any user not
specifically defined in this file is allowed to use cron. By removing the file, only users in
/etc/cron.allow are allowed to use cron.
Note:
• Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be
secured in accordance with local site policy
• Even though a given user is not listed in cron.allow, cron jobs can still be run as
that user
• The cron.allow file only controls administrative access to the crontab command
for scheduling and modifying cron jobs
Rationale:
On many systems, only the system administrator is authorized to schedule cron jobs.
Using the cron.allow file to control who can run cron jobs enforces this policy. It is
easier to manage an allow list than a deny list. In a deny list, you could potentially add a
user ID to the system and forget to add it to the deny files.
Page 483
•
/etc/cron.deny does not exist
•
/etc/cron.allow does exist
•
/etc/cron.allow is mode 0640 or more restrictive
•
/etc/cron.allow is owned by the user root
•
/etc/cron.allow is group owned by the group crontab
-OR-
•
cron is not installed on the system
#!/usr/bin/env bash
{
l_output="" l_output2=""
if dpkg-query -W cron > /dev/null 2>&1; then
l_file="/etc/cron.allow"
[ -e /etc/cron.deny ] && l_output2="$l_output2\n - cron.deny exists"
if [ ! -e /etc/cron.allow ]; then
l_output2="$l_output2\n - cron.allow doesn't exist"
else
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_output2="$l_output2\n - \"$l_file\" is mode: \"$l_mode\" (should be mode: \"$l_maxperm\" or
more restrictive)"
else
l_output="$l_output\n - \"$l_file\" is correctly set to mode: \"$l_mode\""
fi
if [ "$l_fown" != "root" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by user \"$l_fown\" (should be owned by
\"root\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by user: \"$l_fown\""
fi
if [ "$l_fgroup" != "crontab" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by group: \"$l_fgroup\" (should be owned by
group: \"crontab\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by group: \"$l_fgroup\""
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
fi
else
l_output="$l_output\n - cron is not installed on the system"
fi
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:$l_output2\n"
fi
}
Page 484
#!/usr/bin/env bash
{
if dpkg-query -W cron > /dev/null 2>&1; then
l_file="/etc/cron.allow"
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ -e /etc/cron.deny ]; then
echo -e " - Removing \"/etc/cron.deny\""
rm -f /etc/cron.deny
fi
if [ ! -e /etc/cron.allow ]; then
echo -e " - creating \"$l_file\""
touch "$l_file"
fi
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
echo -e " - Removing excessive permissions from \"$l_file\""
chmod u-x,g-wx,o-rwx "$l_file"
fi
if [ "$l_fown" != "root" ]; then
echo -e " - Changing owner on \"$l_file\" from: \"$l_fown\" to: \"root\""
chown root "$l_file"
fi
if [ "$l_fgroup" != "crontab" ]; then
echo -e " - Changing group owner on \"$l_file\" from: \"$l_fgroup\" to: \"crontab\""
chgrp crontab "$l_file"
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
else
echo -e "- cron is not installed on the system, no remediation required\n"
fi
}
Page 485
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 486
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure /etc/at.allow to allow specific users to use this service. If /etc/at.allow
does not exist, then /etc/at.deny is checked. Any user not specifically defined in this
file is allowed to use at. By removing the file, only users in /etc/at.allow are allowed
to use at.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, at should be removed, and the alternate method should be secured in
accordance with local site policy
Rationale:
On many systems, only the system administrator is authorized to schedule at jobs.
Using the at.allow file to control who can run at jobs enforces this policy. It is easier to
manage an allow list than a deny list. In a deny list, you could potentially add a user ID
to the system and forget to add it to the deny files.
Page 487
•
/etc/at.deny does not exist
•
/etc/at.allow does exist
•
/etc/at.allow is mode 0640 or more restrictive
•
/etc/at.allow is owned by the user root
•
/etc/at.allow is group owned by the group root
-OR-
•
at is not installed on the system
#!/usr/bin/env bash
{
l_output="" l_output2=""
if dpkg-query -W at > /dev/null 2>&1; then
l_file="/etc/at.allow"
[ -e /etc/at.deny ] && l_output2="$l_output2\n - at.deny exists"
if [ ! -e /etc/at.allow ]; then
l_output2="$l_output2\n - at.allow doesn't exist"
else
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_output2="$l_output2\n - \"$l_file\" is mode: \"$l_mode\" (should be mode: \"$l_maxperm\" or
more restrictive)"
else
l_output="$l_output\n - \"$l_file\" is correctly set to mode: \"$l_mode\""
fi
if [ "$l_fown" != "root" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by user \"$l_fown\" (should be owned by
\"root\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by user: \"$l_fown\""
fi
if [ "$l_fgroup" != "root" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by group: \"$l_fgroup\" (should be owned by
group: \"root\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by group: \"$l_fgroup\""
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
fi
else
l_output="$l_output\n - at is not installed on the system"
fi
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:$l_output2\n"
fi
}
Page 488
#!/usr/bin/env bash
{
if dpkg-query -W at > /dev/null 2>&1; then
l_file="/etc/at.allow"
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ -e /etc/at.deny ]; then
echo -e " - Removing \"/etc/at.deny\""
rm -f /etc/at.deny
fi
if [ ! -e /etc/at.allow ]; then
echo -e " - creating \"$l_file\""
touch "$l_file"
fi
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
echo -e " - Removing excessive permissions from \"$l_file\""
chmod u-x,g-wx,o-rwx "$l_file"
fi
if [ "$l_fown" != "root" ]; then
echo -e " - Changing owner on \"$l_file\" from: \"$l_fown\" to: \"root\""
chown root "$l_file"
fi
if [ "$l_fgroup" != "root" ]; then
echo -e " - Changing group owner on \"$l_file\" from: \"$l_fgroup\" to: \"root\""
chgrp root "$l_file"
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
else
echo -e "- cron is not installed on the system, no remediation required\n"
fi
}
References:
Page 489
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 490
SSH is a secure, encrypted replacement for common login services such as telnet,
ftp, rlogin, rsh, and rcp. It is strongly recommended that sites abandon older clear-
text login protocols and use SSH to prevent session hijacking and sniffing of sensitive
data off the network.
Note:
• The recommendations in this section only apply if the SSH daemon is installed
on the system, if remote access is not required the SSH daemon can be
removed and this section skipped.
• The openSSH daemon configuration option Match, may cause the audits in this
section's recommendations to report incorrectly. It is recommended that this
option only be used if it's needed and fully understood. If this option is configured
in accordance with local site policy, it should be accounted for when following the
recommendations in this section.
• The audits of the configuration in this section are run in the context of the root
user, the local host name, and the local host's IP address. If a Match block exists
that matches one of these criteria, the output of the audit will be from the match
block. The respective matched criteria should be replaced with a non-matching
substitution.
• Once all configuration changes have been made to /etc/ssh/sshd_config the
sshd configuration must be reloaded
• Match:
o Introduces a conditional block.
o If all of the criteria on the Match line are satisfied, the keywords on the
following lines override those set in the global section of the config file,
until either another Match line or the end of the file.
o If a keyword appears in multiple Match blocks that are satisfied, only the
first instance of the keyword is applied.
o The arguments to Match are one or more criteria-pattern pairs or the
single token All which matches all criteria. The available criteria are User,
Group, Host, LocalAddress, LocalPort, RDomain, and Address (with
RDomain representing the rdomain(4) on which the connection was
received).
o The match patterns may consist of single entries or comma-separated lists
and may use the wildcard and negation operators described in the
PATTERNS section of ssh_config(5).
o The patterns in an Address criteria may additionally contain addresses to
match in CIDR address/masklen format, such as 192.0.2.0/24 or
2001:db8::/32. Note that the mask length provided must be consistent with
the address - it is an error to specify a mask length that is too long for the
address or one with bits set in this host portion of the address. For
example, 192.0.2.0/33 and 192.0.2.0/8, respectively.
Page 491
Page 492
• Level 1 - Server
• Level 1 - Workstation
Description:
The file /etc/ssh/sshd_config, and files ending in .conf in the /etc/ssh/sshd_config.d
directory, contain configuration specifications for sshd.
Rationale:
configuration specifications for sshd need to be protected from unauthorized changes by
non-privileged users.
Page 493
#!/usr/bin/env bash
{
l_output="" l_output2=""
perm_mask='0177' && maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
SSHD_FILES_CHK()
{
while IFS=: read -r l_mode l_user l_group; do
l_out2=""
[ $(( $l_mode & $perm_mask )) -gt 0 ] && l_out2="$l_out2\n - Is mode: \"$l_mode\" should be:
\"$maxperm\" or more restrictive"
[ "$l_user" != "root" ] && l_out2="$l_out2\n - Is owned by \"$l_user\" should be owned by \"root\""
[ "$l_group" != "root" ] && l_out2="$l_out2\n - Is group owned by \"$l_user\" should be group owned
by \"root\""
if [ -n "$l_out2" ]; then
l_output2="$l_output2\n - File: \"$l_file\":$l_out2"
else
l_output="$l_output\n - File: \"$l_file\":\n - Correct: mode ($l_mode), owner ($l_user), and group
owner ($l_group) configured"
fi
done < <(stat -Lc '%#a:%U:%G' "$l_file")
}
[ -e "/etc/ssh/sshd_config" ] && l_file="/etc/ssh/sshd_config" && SSHD_FILES_CHK
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && SSHD_FILES_CHK
done < <(find -L /etc/ssh/sshd_config.d -type f \( -perm /077 -o ! -user root -o ! -group root \) -print0
2>/dev/null)
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n *** PASS ***\n- * Correctly set * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2\n"
[ -n "$l_output" ] && echo -e " - * Correctly set * :\n$l_output\n"
fi
}
Page 494
{
chmod u-x,og-rwx /etc/ssh/sshd_config
chown root:root /etc/ssh/sshd_config
while IFS= read -r -d $'\0' l_file; do
if [ -e "$l_file" ]; then
chmod u-x,og-rwx "$l_file"
chown root:root "$l_file"
fi
done < <(find /etc/ssh/sshd_config.d -type f -print0 2>/dev/null)
}
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 495
• Level 1 - Server
• Level 1 - Workstation
Description:
Two files are used in SSH public key authentication. In this authentication method:
• The possession of the private key is proof of identity. Only a private key that
corresponds to a public key will be able to authenticate successfully. The private
keys need to be stored and handled carefully, and no copies of the private key
should be distributed.
• A public key is a key that can be used for verifying digital signatures generated
using a corresponding private key. Only a public key that corresponds to a
private key will be able to authenticate successfully.
Rationale:
If a public host key file is modified by an unauthorized user, the SSH service may be
compromised. If an unauthorized user obtains the private SSH host key file, the host
could be impersonated.
Impact:
Incorrectly configured access to the SSH key files may prevent the ssh daemon from
starting, preventing remote access to the system.
Page 496
Page 497
{
l_output="" l_output2="" l_count="0"
if command -v ssh-keygen &>/dev/null; then
if [ -d /etc/ssh ]; then
l_ssh_key_group_name="$(grep -Po -- '^(ssh_keys|_?ssh)\b' /etc/group)" # Group designated to own
openSSH keys
f_key_chk()
{
l_out2=""
while IFS=: read -r l_mode l_owner l_group; do
if [ "$l_key_type" = "public" ]; then
l_pmask="0133"
l_auth_group="root"
else
[ "$l_ssh_key_group_name" = "$l_group" ] && l_pmask="0137" || l_pmask="0177"
[ -n "$l_ssh_key_group_name" ] && l_auth_group="(root|$l_ssh_key_group_name)" ||
l_auth_group="root"
fi
l_maxperm="$( printf '%o' $(( 0777 & ~$l_pmask )) )"
if [ $(( $l_mode & $l_pmask )) -gt 0 ]; then
l_out2="$l_out2\n - Mode: \"$l_mode\" should be mode: \"$l_maxperm\" or more restrictive"
fi
if [ "$l_owner" != "root" ]; then
l_out2="$l_out2\n - Owned by: \"$l_owner\" should be owned by \"root\""
fi
if [[ ! "$l_group" =~ $l_auth_group ]]; then
l_out2="$l_out2\n - Owned by group \"$l_group\" should be group owned by: \"
${l_auth_group//|/ or } \""
fi
if [ -n "$l_out2" ]; then
l_output2="$l_output2\n - $l_key_type key file: \"$l_file\"$l_out2"
else
l_output="$l_output\n - $l_key_type key file: \"$l_file\"\n - Correct: mode ($l_mode), owner
($l_owner), and group owner ($l_group) configured"
fi
done < <(stat -Lc '%#a:%U:%G' "$l_file")
}
while IFS= read -r -d $'\0' l_file; do # Loop to populate array
if ssh-keygen -l -f "$l_file" &>/dev/null; then
(( l_count++ ))
if grep -Pq -- '\.pub$' <<< "$l_file"; then
l_key_type="public"
else
l_key_type="private"
fi
f_key_chk
fi
done < <(find /etc/ssh -xdev -type f -print0)
[ "$l_count" = "0" ] && l_output=" - No ssh keys found in \"/etc/ssh\""
else
l_output=" - ssh directory: \"/etc/ssh\" not found on the system"
fi
else
l_output2=" - ssh-keygen command not found\n - manual check may be required"
fi
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n *** PASS ***\n- * Correctly set * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2\n"
[ -n "$l_output" ] && echo -e " - * Correctly set * :\n$l_output\n"
fi
}
Page 498
{
l_output="" l_output2="" l_count="0"
if command -v ssh-keygen &>/dev/null; then
if [ -d /etc/ssh ]; then
l_ssh_key_group_name="$(grep -Po -- '^(ssh_keys|_?ssh)\b' /etc/group)" # Group designated to own
openSSH keys
f_key_fix()
{
while IFS=: read -r l_mode l_owner l_group; do
if [ "$l_key_type" = "public" ]; then
l_pmask="0133" && l_mode_fix="u-x,go-wx"
l_auth_group="root" && l_group_fix="root"
else
if [ "$l_ssh_key_group_name" = "$l_group" ]; then
l_pmask="0137" && l_mode_fix="u-x,g-wx,o-rwx"
else
l_pmask="0177" && l_mode_fix="u-x,go-rwx"
fi
if [ -n "$l_ssh_key_group_name" ]; then
l_auth_group="(root|$l_ssh_key_group_name)" && l_group_fix="$l_ssh_key_group_name"
else
l_auth_group="root" && l_group_fix="root"
fi
fi
if [ "$l_owner" != "root" ]; then
echo -e "\n - $l_key_type key file: \"$l_file\" - Owned by: \"$l_owner\" changing owner to:
\"root\""
chown root "$l_file"
fi
if [[ ! "$l_group" =~ $l_auth_group ]]; then
echo -e "\n - $l_key_type key file: \"$l_file\"\n - Owned by group \"$l_group\" changing
group owner to: \"$l_group_fix\""
chgrp "$l_group_fix" "$l_file"
fi
l_maxperm="$( printf '%o' $(( 0777 & ~$l_pmask )) )"
if [ $(( $l_mode & $l_pmask )) -gt 0 ]; then
echo -e "\n - $l_key_type key file: \"$l_file\"\n - Mode: \"$l_mode\" removing excessive
permissions"
chmod "$l_mode_fix" "$l_file"
fi
done < <(stat -Lc '%#a:%U:%G' "$l_file")
}
while IFS= read -r -d $'\0' l_file; do # Loop to populate array
if ssh-keygen -l -f "$l_file" &>/dev/null; then
(( l_count++ ))
if grep -Pq -- '\.pub$' <<< "$l_file"; then
l_key_type="public"
else
l_key_type="private"
fi
f_key_fix
fi
done < <(find /etc/ssh -xdev -type f -print0)
[ "$l_count" = "0" ] && echo " - No ssh keys found in \"/etc/ssh\""
else
echo " - ssh directory: \"/etc/ssh\" not found on the system"
fi
else
echo -e " - ssh-keygen command not found\n - manual remediation may be required"
fi
}
Page 499
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 500
• Level 1 - Server
• Level 1 - Workstation
Description:
There are several options available to limit which users and group can access the
system via SSH. It is recommended that at least one of the following options be
leveraged:
• AllowUsers:
o The AllowUsers variable gives the system administrator the option of
allowing specific users to ssh into the system. The list consists of space
separated user names. Numeric user IDs are not recognized with this
variable. If a system administrator wants to restrict user access further by
only allowing the allowed users to log in from a particular host, the entry
can be specified in the form of user@host.
• AllowGroups:
o The AllowGroups variable gives the system administrator the option of
allowing specific groups of users to ssh into the system. The list consists
of space separated group names. Numeric group IDs are not recognized
with this variable.
• DenyUsers:
o The DenyUsers variable gives the system administrator the option of
denying specific users to ssh into the system. The list consists of space
separated user names. Numeric user IDs are not recognized with this
variable. If a system administrator wants to restrict user access further by
specifically denying a user's access from a particular host, the entry can
be specified in the form of user@host.
• DenyGroups:
o The DenyGroups variable gives the system administrator the option of
denying specific groups of users to ssh into the system. The list consists of
space separated group names. Numeric group IDs are not recognized
with this variable.
Rationale:
Restricting which users can remotely access the system via SSH will help ensure that
only authorized users access the system.
Page 501
Verify that the output matches at least one of the following lines:
allowusers <userlist>
-OR-
allowgroups <grouplist>
-OR-
denyusers <userlist>
-OR-
denygroups <grouplist>
Review the list(s) to ensure included users and/or groups follow local site policy
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep -Pi '^\h*allow(users|groups)\h+\H+'
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain).
Remediation:
Edit /etc/ssh/sshd_config and set one or more of the parameters above any Match set
statements as follows:
AllowUsers <userlist>
-OR-
AllowGroups <grouplist>
-OR-
DenyUsers <userlist>
-OR-
DenyGroups <grouplist>
Default Value:
None
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: AC-3. MP-2
Page 502
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 503
• Level 1 - Server
• Level 1 - Workstation
Description:
The Banner parameter specifies a file whose contents must be sent to the remote user
before authentication is permitted. By default, no banner is displayed.
Rationale:
Banners are used to warn connecting users of the particular site's policy regarding
connection. Presenting a warning message prior to the normal user login may assist the
prosecution of trespassers on the computer system.
Audit:
Run the following command to verify Banner is set:
# sshd -T | grep -Pi -- '^banner\h+\/\H+'
Example:
banner /etc/issue.net
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep -Pi -- '^banner\h+\/\H+'
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain).
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Match entries as
follows:
Banner /etc/issue.net
Page 504
Techniques / Sub-
Tactics Mitigations
techniques
Page 505
• Level 1 - Server
• Level 1 - Workstation
Description:
This variable limits the ciphers that SSH can use during communication.
Notes:
Rationale:
Weak ciphers that are used for authentication to the cryptographic module cannot be
relied upon to provide confidentiality or integrity, and system data may be compromised.
• The Triple DES ciphers, as used in SSH, have a birthday bound of approximately
four billion blocks, which makes it easier for remote attackers to obtain clear text
data via a birthday attack against a long-duration encrypted session, aka a
"Sweet32" attack.
• Error handling in the SSH protocol; Client and Server, when using a block cipher
algorithm in Cipher Block Chaining (CBC) mode, makes it easier for remote
attackers to recover certain plain text data from an arbitrary block of cipher text in
an SSH session via unknown vectors.
Page 506
- IF - a line is returned, review the list of ciphers. If the line includes chacha20-
[email protected], review CVE-2023-48795 and verify the system has been patched.
No ciphers in the list below should be returned as they're considered "weak":
3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
arcfour
arcfour128
arcfour256
blowfish-cbc
cast128-cbc
[email protected]
Remediation:
Edit the /etc/ssh/sshd_config file and add/modify the Ciphers line to contain a comma
separated list of the site unapproved (weak) Ciphers preceded with a -:
Example:
Ciphers -3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,[email protected]
- IF - CVE-2023-48795 has been addressed, and it meets local site policy, chacha20-
[email protected] may be removed from the list of excluded ciphers.
1. https://nvd.nist.gov/vuln/detail/CVE-2016-2183
2. https://www.openssh.com/txt/cbc.adv
3. https://nvd.nist.gov/vuln/detail/CVE-2008-5161
4. https://www.openssh.com/txt/cbc.adv
5. SSHD_CONFIG(5)
6. NIST SP 800-53 Rev. 5: SC-8
7. https://nvd.nist.gov/vuln/detail/CVE-2023-48795
8. SSHD(8)
Page 507
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 508
• Level 1 - Server
• Level 1 - Workstation
Description:
Note: To clarify, the two settings described below are only meant for idle connections
from a protocol perspective and are not meant to check if the user is active or not. An
idle user does not mean an idle connection. SSH does not and never had, intentionally,
the capability to drop idle users. In SSH versions before 8.2p1 there was a bug that
caused these values to behave in such a manner that they were abused to disconnect
idle users. This bug has been resolved in 8.2p1 and thus it can no longer be abused
disconnect idle users.
The two options ClientAliveInterval and ClientAliveCountMax control the timeout of
SSH sessions. Taken directly from man 5 sshd_config:
Page 509
Example Output:
clientaliveinterval 15
clientalivecountmax 3
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep -Pi -- 'clientalive(interval|countmax)'
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain).
Remediation:
Edit the /etc/ssh/sshd_config file to set the ClientAliveInterval and
ClientAliveCountMax parameters above any Match entries according to site policy.
Example:
ClientAliveInterval 15
ClientAliveCountMax 3
Page 510
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Additional Information:
https://bugzilla.redhat.com/show_bug.cgi?id=1873547
https://github.com/openssh/openssh-portable/blob/V_8_9/serverloop.c#L137
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1026
T1078.002, T1078.003
Page 511
• Level 1 - Workstation
• Level 2 - Server
Description:
The DisableForwarding parameter disables all forwarding features, including X11, ssh-
agent(1), TCP and StreamLocal. This option overrides all other forwarding-related
options and may simplify restricted configurations.
• X11Forwarding provides the ability to tunnel X11 traffic through the connection to
enable remote graphic connections.
• ssh-agent is a program to hold private keys used for public key authentication.
Through use of environment variables the agent can be located and
automatically used for authentication when logging in to other machines using
ssh.
• SSH port forwarding is a mechanism in SSH for tunneling application ports from
the client to the server, or servers to clients. It can be used for adding encryption
to legacy applications, going through firewalls, and some system administrators
and IT professionals use it for opening backdoors into the internal network from
their home machines.
Rationale:
Disable X11 forwarding unless there is an operational requirement to use X11
applications directly. There is a small risk that the remote X11 servers of users who are
logged in via SSH with X11 forwarding could be compromised by other users on the
X11 server. Note that even if X11 forwarding is disabled, users can always install their
own forwarders.
anyone with root privilege on the the intermediate server can make free use of ssh-
agent to authenticate them to other servers
Leaving port forwarding enabled can expose the organization to security risks and
backdoors. SSH connections are protected with strong encryption. This makes their
contents invisible to most deployed network monitoring and traffic filtering solutions.
This invisibility carries considerable risk potential if it is used for malicious purposes
such as data exfiltration. Cybercriminals or malware could exploit SSH to hide their
unauthorized communications, or to exfiltrate stolen data from the target network.
Page 512
disableforwarding yes
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep -i -- 'disableforwarding'
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the DisableForwarding parameter to yes
above any Match entries as follows:
DisableForwarding yes
1. sshd_config(5)
2. NIST SP 800-53 Rev. 5: CM-7
3. SSHD(8)
Page 513
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 514
• Level 1 - Workstation
• Level 2 - Server
Description:
The GSSAPIAuthentication parameter specifies whether user authentication based on
GSSAPI is allowed
Rationale:
Allowing GSSAPI authentication through SSH exposes the system's GSSAPI to remote
hosts, and should be disabled to reduce the attack surface of the system
Audit:
Run the following command to verify GSSAPIAuthentication is set to no:
# sshd -T | grep gssapiauthentication
gssapiauthentication no
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep gssapiauthentication
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the GSSAPIAuthentication parameter to no
above any Match entries as follows:
GSSAPIAuthentication no
Page 515
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1042
T1078.003
Page 516
• Level 1 - Server
• Level 1 - Workstation
Description:
The HostbasedAuthentication parameter specifies if authentication is allowed through
trusted hosts via the user of .rhosts, or /etc/hosts.equiv, along with successful public
key client host authentication.
Rationale:
Even though the .rhosts files are ineffective if support is disabled in /etc/pam.conf,
disabling the ability to use .rhosts files in SSH provides an additional layer of
protection.
Audit:
Run the following command to verify HostbasedAuthentication is set to no:
# sshd -T | grep hostbasedauthentication
hostbasedauthentication no
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep hostbasedauthentication
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the HostbasedAuthentication parameter to no
above any Match entries as follows:
HostbasedAuthentication no
Page 517
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1042
T1078.003
Page 518
• Level 1 - Server
• Level 1 - Workstation
Description:
The IgnoreRhosts parameter specifies that .rhosts and .shosts files will not be used in
RhostsRSAAuthentication or HostbasedAuthentication.
Rationale:
Setting this parameter forces users to enter a password when authenticating with SSH.
Audit:
Run the following command to verify IgnoreRhosts is set to yes:
# sshd -T | grep ignorerhosts
ignorerhosts yes
Remediation:
Edit the /etc/ssh/sshd_config file to set the IgnoreRhosts parameter to yes as follows:
IgnoreRhosts yes
Default Value:
IgnoreRhosts yes
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Page 519
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1027
T1078.003
Page 520
• Level 1 - Server
• Level 1 - Workstation
Description:
Key exchange is any method in cryptography by which cryptographic keys are
exchanged between two parties, allowing use of a cryptographic algorithm. If the sender
and receiver wish to exchange encrypted messages, each must be equipped to encrypt
messages to be sent and decrypt messages received
Notes:
• Kex algorithms have a higher preference the earlier they appear in the list
• Some organizations may have stricter requirements for approved Key exchange
algorithms
• Ensure that Key exchange algorithms used are in compliance with site policy
• The only Key Exchange Algorithms currently FIPS 140 approved are:
o ecdh-sha2-nistp256
o ecdh-sha2-nistp384
o ecdh-sha2-nistp521
o diffie-hellman-group-exchange-sha256
o diffie-hellman-group16-sha512
o diffie-hellman-group18-sha512
o diffie-hellman-group14-sha256
Rationale:
Key exchange methods that are considered weak should be removed. A key exchange
method may be weak because too few bits are used, or the hashing algorithm is
considered too weak. Using weak algorithms could expose connections to man-in-the-
middle attacks
Page 521
The following are considered "weak" Key Exchange Algorithms, and should not be
used:
diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group-exchange-sha1
Remediation:
Edit the /etc/ssh/sshd_config file and add/modify the KexAlgorithms line to contain a
comma separated list of the site unapproved (weak) Ciphers preceded with a -
Example:
KexAlgorithms -diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
Page 522
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 523
• Level 1 - Server
• Level 1 - Workstation
Description:
The LoginGraceTime parameter specifies the time allowed for successful authentication
to the SSH server. The longer the Grace period is the more open unauthenticated
connections can exist. Like other session controls in this session the Grace Period
should be limited to appropriate organizational limits to ensure the service is available
for needed access.
Rationale:
Setting the LoginGraceTime parameter to a low number will minimize the risk of
successful brute force attacks to the SSH server. It will also limit the number of
concurrent unauthenticated connections While the recommended setting is 60 seconds
(1 Minute), set the number based on site policy.
Audit:
Run the following command and verify that output LoginGraceTime is between 1 and 60
seconds:
# sshd -T | grep logingracetime
logingracetime 60
Remediation:
Edit the /etc/ssh/sshd_config file to set the LoginGraceTime parameter to a value of 60
seconds (1m) or less:
Example:
LoginGraceTime 60
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-6
3. SSHD(8)
Page 524
Techniques / Sub-
Tactics Mitigations
techniques
T1110, T1110.001,
TA0006 M1036
T1110.003, T1110.004
Page 525
• Level 1 - Server
• Level 1 - Workstation
Description:
LogLevel gives the verbosity level that is used when logging messages from sshd. The
possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and
DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each
specify higher levels of debugging output.
Note: Logging with a DEBUG level violates the privacy of users and is not
recommended.
Rationale:
SSH provides several logging levels with varying amounts of verbosity. The DEBUG
options are specifically not recommended other than strictly for debugging SSH
communications. These levels provide so much data that it is difficult to identify
important security information, and may violate the privacy of users.
The INFO level is the basic level that only records login activity of SSH users. In many
situations, such as Incident Response, it is important to determine when a particular
user was active on a system. The logout record can eliminate those users who
disconnected, which helps narrow the field.
The VERBOSE level specifies that login and logout activity as well as the key fingerprint for
any SSH key used for login will be logged. This information is important for SSH key
management, especially in legacy environments.
Page 526
loglevel VERBOSE
- OR -
loglevel INFO
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep ignorerhosts
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the LogLevel parameter above any Match
entries as follows:
LogLevel VERBOSE
- OR -
LogLevel INFO
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: AU-3, AU-12, SI-5
3. SSHD(8)
Page 527
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 528
• Level 1 - Server
• Level 1 - Workstation
Description:
This variable limits the types of MAC algorithms that SSH can use during
communication.
Note:
Rationale:
MD5 and 96-bit MAC algorithms are considered weak and have been shown to increase
exploitability in SSH downgrade attacks. Weak algorithms continue to have a great deal
of attention as a weak spot that can be exploited with expanded computing power. An
attacker that breaks the algorithm could take advantage of a MiTM position to decrypt
the SSH tunnel and capture credentials and information.
Page 529
The following are considered "weak" MACs, and should not be used:
hmac-md5
hmac-md5-96
hmac-ripemd160
hmac-sha1-96
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
IMPORTANT: Review CVE-2023-48795 and verify the system has been patched. If the
system has not been patched, review the use of the Encrypt Then Mac (etm) MACs.
Run the following command to determine if the the Encrypt Then Mac (etm) MACs are
in use:
# sshd -T | grep -Pi -- 'macs\h+([^#\n\r]+,)?([email protected]|[email protected]|hmac-
[email protected])\b'
Remediation:
Edit the /etc/ssh/sshd_config file and add/modify the MACs line to contain a comma
separated list of the site unapproved (weak) MACs preceded with a - above any
Include entries:
Example:
MACs -hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-sha1-96,[email protected],[email protected],hmac-md5-
[email protected],[email protected],[email protected],[email protected],umac-
[email protected],[email protected],[email protected],[email protected]
- IF - CVE-2023-48795 has been reviewed and addressed, the following etm MACs may
be dropped from the exclude list: [email protected],hmac-sha2-256-
[email protected],[email protected]
Note: First occurrence of an option takes precedence.
Default Value:
MACs [email protected],[email protected],hmac-sha2-256-
[email protected],[email protected],hmac-sha1-
[email protected],[email protected],[email protected],hmac-sha2-
256,hmac-sha2-512,hmac-sha1,[email protected]
Page 530
Additional Information:
The supported MACs are:
hmac-md5
hmac-md5-96
hmac-ripemd160
hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 531
Techniques / Sub-
Tactics Mitigations
techniques
Page 532
• Level 1 - Server
• Level 1 - Workstation
Description:
The MaxAuthTries parameter specifies the maximum number of authentication attempts
permitted per connection. When the login failure count reaches half the number, error
messages will be written to the syslog file detailing the login failure.
Rationale:
Setting the MaxAuthTries parameter to a low number will minimize the risk of successful
brute force attacks to the SSH server. While the recommended setting is 4, set the
number based on site policy.
Audit:
Run the following command and verify that MaxAuthTries is 4 or less:
# sshd -T | grep maxauthtries
maxauthtries 4
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep maxauthtries
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the MaxAuthTries parameter to 4 or less above
any Match entries as follows:
MaxAuthTries 4
Page 533
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: AU-3
3. SSHD(8)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1110, T1110.001,
TA0006 M1036
T1110.003
Page 534
• Level 1 - Server
• Level 1 - Workstation
Description:
The MaxSessions parameter specifies the maximum number of open sessions permitted
from a given connection.
Rationale:
To protect a system from denial of service due to a large number of concurrent
sessions, use the rate limiting function of MaxSessions to protect availability of sshd
logins and prevent overwhelming the daemon.
Audit:
Run the following command and verify that MaxSessions is 10 or less:
# sshd -T | grep -i maxsessions
maxsessions 10
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep maxsessions
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the MaxSessions parameter to 10 or less above
any Match entries as follows:
MaxSessions 10
Page 535
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Techniques / Sub-
Tactics Mitigations
techniques
Page 536
• Level 1 - Server
• Level 1 - Workstation
Description:
The MaxStartups parameter specifies the maximum number of concurrent
unauthenticated connections to the SSH daemon.
Rationale:
To protect a system from denial of service due to a large number of pending
authentication connection attempts, use the rate limiting function of MaxStartups to
protect availability of sshd logins and prevent overwhelming the daemon.
Audit:
Run the following command to verify MaxStartups is 10:30:60 or more restrictive:
# sshd -T | grep -i maxstartups
maxstartups 10:30:60
Remediation:
Edit the /etc/ssh/sshd_config file to set the MaxStartups parameter to 10:30:60 or
more restrictive:
MaxStartups 10:30:60
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Page 537
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 538
• Level 1 - Server
• Level 1 - Workstation
Description:
The PermitEmptyPasswords parameter specifies if the SSH server allows login to
accounts with empty password strings.
Rationale:
Disallowing remote shell access to accounts that have an empty password reduces the
probability of unauthorized access to the system.
Audit:
Run the following command to verify PermitEmptyPasswords is set to no:
# sshd -T | grep permitemptypasswords
permitemptypasswords no
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep permitemptypasswords
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit /etc/ssh/sshd_config and set the PermitEmptyPasswords parameter to no above
any Match entries:
PermitEmptyPasswords no
Page 539
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 540
• Level 1 - Server
• Level 1 - Workstation
Description:
The PermitRootLogin parameter specifies if the root user can log in using SSH. The
default is prohibit-password.
Rationale:
Disallowing root logins over SSH requires system admins to authenticate using their
own individual account, then escalating to root. This limits opportunity for non-
repudiation and provides a clear audit trail in the event of a security incident.
Audit:
Run the following command to verify PermitRootLogin is set to no:
# sshd -T | grep permitrootlogin
permitrootlogin no
- IF - Match set statements are used in your environment, specify the connection
parameters to use for the -T extended test mode and run the audit to verify the setting is
not incorrectly configured in a match block
Example additional audit needed for a match block for the user sshuser:
# sshd -T -C user=sshuser | grep permitrootlogin
Note: If provided, any Match directives in the configuration file that would apply are
applied before the configuration is written to standard output. The connection
parameters are supplied as keyword=value pairs and may be supplied in any order,
either with multiple -C options or as a comma-separated list. The keywords are addr
(source address), user (user), host (resolved source host name), laddr (local address),
lport (local port number), and rdomain (routing domain)
Remediation:
Edit the /etc/ssh/sshd_config file to set the PermitRootLogin parameter to no above
any Match entries as follows:
PermitRootLogin no
Page 541
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5:AC-6
3. SSHD(8)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 542
• Level 1 - Server
• Level 1 - Workstation
Description:
The PermitUserEnvironment option allows users to present environment options to the
SSH daemon.
Rationale:
Permitting users the ability to set environment variables through the SSH daemon could
potentially allow users to bypass security controls (e.g. setting an execution path that
has SSH executing trojan'd programs)
Audit:
Run the following command to verify PermitUserEnviroment is set to no:
# sshd -T | grep permituserenvironment
permituserenvironment no
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter PermitUserEnvironment to no:
PermitUserEnvironment no
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Page 543
Techniques / Sub-
Tactics Mitigations
techniques
Page 544
• Level 1 - Server
• Level 1 - Workstation
Description:
The UsePAM directive enables the Pluggable Authentication Module (PAM) interface. If
set to yes this will enable PAM authentication using ChallengeResponseAuthentication
and PasswordAuthentication directives in addition to PAM account and session module
processing for all authentication types.
Rationale:
When usePAM is set to yes, PAM runs through account and session types properly. This
is important if you want to restrict access to services based off of IP, time or other
factors of the account. Additionally, you can make sure users inherit certain
environment variables on login or disallow access to the server
Audit:
Run the following command to verify UsePAM is set to yes:
# sshd -T | grep -i usepam
usepam yes
Remediation:
Edit the /etc/ssh/sshd_config file to set the UsePAM parameter to yes:
UsePAM yes
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
3. SSHD(8)
Page 545
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 546
There are various tools which allows a permitted user to execute a command as the
superuser or another user, as specified by the security policy.
sudo
sudo documentation
The invoking user's real (not effective) user ID is used to determine the user name with
which to query the security policy.
sudo supports a plug-in architecture for security policies and input/output logging. Third
parties can develop and distribute their own policy and I/O logging plug-ins to work
seamlessly with the sudo front end. The default security policy is sudoers, which is
configured via the file /etc/sudoers and any entries in /etc/sudoers.d.
pkexec
pkexec documentation
pkexec allows an authorized user to execute PROGRAM as another user. If username
is not specified, then the program will be executed as the administrative super user,
root.
Page 547
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo allows a permitted user to execute a command as the superuser or another user,
as specified by the security policy. The invoking user's real (not effective) user ID is
used to determine the user name with which to query the security policy.
Rationale:
sudo supports a plug-in architecture for security policies and input/output logging. Third
parties can develop and distribute their own policy and I/O logging plug-ins to work
seamlessly with the sudo front end. The default security policy is sudoers, which is
configured via the file /etc/sudoers and any entries in /etc/sudoers.d.
The security policy determines what privileges, if any, a user has to run sudo. The policy
may require that users authenticate themselves with a password or another
authentication mechanism. If authentication is required, sudo will exit if the user's
password is not entered within a configurable time limit. This limit is policy-specific.
Audit:
Run the following command to verify that either sudo or sudo-ldap is installed:
# dpkg-query -W sudo sudo-ldap > /dev/null 2>&1 && dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-
Status}\n' sudo sudo-ldap | awk '($4=="installed" && $NF=="installed") {print "\n""PASS:""\n""Package
""\""$1"\""" is installed""\n"}' || echo -e "\nFAIL:\nneither \"sudo\" or \"sudo-ldap\" package is installed\n"
Remediation:
First determine is LDAP functionality is required. If so, then install sudo-ldap, else install
sudo.
Example:
# apt install sudo
References:
1. SUDO(8)
2. NIST SP 800-53 Rev. 5: AC-2, AC-6
Page 548
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 549
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo can be configured to run only from a pseudo terminal (pseudo-pty).
Rationale:
Attackers can run a malicious program using sudo which would fork a background
process that remains even when the main program has finished executing.
Impact:
WARNING: Editing the sudo configuration incorrectly can cause sudo to stop
functioning. Always use visudo to modify sudo configuration files.
Audit:
Verify that sudo can only run other commands from a pseudo terminal.
Run the following command:
# grep -rPi '^\h*Defaults\h+([^#\n\r]+,)?use_pty(,\h*\h+\h*)*\h*(#.*)?$' /etc/sudoers*
Remediation:
Edit the file /etc/sudoers with visudo or a file in /etc/sudoers.d/ with visudo -f <PATH
TO FILE> and add the following line:
Defaults use_pty
Note:
• sudo will read each file in /etc/sudoers.d, skipping file names that end in ~ or
contain a . character to avoid causing problems with package manager or editor
temporary/backup files.
• Files are parsed in sorted lexical order. That is, /etc/sudoers.d/01_first will be
parsed before /etc/sudoers.d/10_second.
• Be aware that because the sorting is lexical, not numeric,
/etc/sudoers.d/1_whoops would be loaded after /etc/sudoers.d/10_second.
• Using a consistent number of leading zeroes in the file names can be used to
avoid such problems.
Page 550
1. SUDO(8)
2. VISUDO(8)
3. sudoers(5)
4. NIST SP 800-53 Rev. 5: AC-6
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 551
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo can use a custom log file
Rationale:
A sudo log file simplifies auditing of sudo commands
Impact:
WARNING: Editing the sudo configuration incorrectly can cause sudo to stop
functioning. Always use visudo to modify sudo configuration files.
Audit:
Run the following command to verify that sudo has a custom log file configured:
# grep -rPsi "^\h*Defaults\h+([^#]+,\h*)?logfile\h*=\h*(\"|\')?\H+(\"|\')?(,\h*\H+\h*)*\h*(#.*)?$"
/etc/sudoers*
Remediation:
Edit the file /etc/sudoers or a file in /etc/sudoers.d/ with visudo or visudo -f <PATH
TO FILE> and add the following line:
Example:
Defaults logfile="/var/log/sudo.log"
Note:
• sudo will read each file in /etc/sudoers.d, skipping file names that end in ~ or
contain a . character to avoid causing problems with package manager or editor
temporary/backup files.
• Files are parsed in sorted lexical order. That is, /etc/sudoers.d/01_first will be
parsed before /etc/sudoers.d/10_second.
• Be aware that because the sorting is lexical, not numeric,
/etc/sudoers.d/1_whoops would be loaded after /etc/sudoers.d/10_second.
• Using a consistent number of leading zeroes in the file names can be used to
avoid such problems.
Page 552
1. SUDO(8)
2. VISUDO(8)
3. sudoers(5)
4. NIST SP 800-53 Rev. 5: AU-3, AU-12
Additional Information:
visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the
sudoers file against multiple simultaneous edits, provides basic sanity checks, and
checks for parse errors. If the sudoers file is currently being edited you will receive a
message to try again later.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 553
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must be configured so that users must provide a password for
privilege escalation.
Rationale:
Without (re-)authentication, users may access resources or perform tasks for which they
do not have authorization.
When operating systems provide the capability to escalate a functional capability, it is
critical the user (re-)authenticate.
Impact:
This will prevent automated processes from being able to elevate privileges.
Audit:
Note: If passwords are not being used for authentication, this is not applicable.
Verify the operating system requires users to supply a password for privilege escalation.
Check the configuration of the /etc/sudoers and /etc/sudoers.d/* files with the
following command:
# grep -r "^[^#].*NOPASSWD" /etc/sudoers*
References:
Page 554
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 555
• Level 1 - Server
• Level 1 - Workstation
Description:
The operating system must be configured so that users must re-authenticate for
privilege escalation.
Rationale:
Without re-authentication, users may access resources or perform tasks for which they
do not have authorization.
When operating systems provide the capability to escalate a functional capability, it is
critical the user re-authenticate.
Audit:
Verify the operating system requires users to re-authenticate for privilege escalation.
Check the configuration of the /etc/sudoers and /etc/sudoers.d/* files with the
following command:
# grep -r "^[^#].*\!authenticate" /etc/sudoers*
If any line is found with a !authenticate tag, refer to the remediation procedure below.
Remediation:
Configure the operating system to require users to reauthenticate for privilege
escalation.
Based on the outcome of the audit procedure, use visudo -f <PATH TO FILE> to edit
the relevant sudoers file.
Remove any occurrences of !authenticate tags in the file(s).
References:
Page 556
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 557
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo caches used credentials for a default of 15 minutes. This is for ease of use when
there are multiple administrative tasks to perform. The timeout can be modified to suit
local security policies.
This default is distribution specific. See audit section for further information.
Rationale:
Setting a timeout value reduces the window of opportunity for unauthorized privileged
access to another user.
Audit:
Ensure that the caching timeout is no more than 15 minutes.
Example:
# grep -roP "timestamp_timeout=\K[0-9]*" /etc/sudoers*
Page 558
1. https://www.sudo.ws/man/1.9.0/sudoers.man.html
2. NIST SP 800-53 Rev. 5: AC-6
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 559
• Level 1 - Server
• Level 1 - Workstation
Description:
The su command allows a user to run a command or shell as another user. The
program has been superseded by sudo, which allows for more granular control over
privileged access. Normally, the su command can be executed by any user. By
uncommenting the pam_wheel.so statement in /etc/pam.d/su, the su command will only
allow users in a specific groups to execute su. This group should be empty to reinforce
the use of sudo for privileged access.
Rationale:
Restricting the use of su , and using sudo in its place, provides system administrators
better control of the escalation of user privileges to execute privileged commands. The
sudo utility also provides a better logging and audit mechanism, as it can log each
command executed via sudo , whereas su can only record that a user executed the su
program.
Audit:
Run the following command:
# grep -Pi
'^\h*auth\h+(?:required|requisite)\h+pam_wheel\.so\h+(?:[^#\n\r]+\h+)?((?!\2)(use_uid\b|group=\H+\b))\h+(?:[^#\
n\r]+\h+)?((?!\1)(use_uid\b|group=\H+\b))(\h+.*)?$' /etc/pam.d/su
Run the following command and verify that the group specified in <group_name> contains
no users:
# grep <group_name> /etc/group
Verify the output does not contain any users in the relevant group:
<group_name>:x:<GID>:
Page 560
Add the following line to the /etc/pam.d/su file, specifying the empty group:
auth required pam_wheel.so use_uid group=sugroup
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 561
• As of this writing, the management of PAM via pam-auth-update does not offer all
the required functionality implemented by the benchmark. As such, the usage of
pam-auth-update is not recommended at present.
Page 562
• Level 1 - Server
• Level 1 - Workstation
Description:
The pam_pwquality.so module checks the strength of passwords. It performs checks
such as making sure a password is not a dictionary word, it is a certain length, contains
a mix of characters (e.g. alphabet, numeric, other) and more.
The following options are set in the /etc/security/pwquality.conf file:
• Password Length:
o - password must be 14 characters or more
minlen = 14
• Password complexity:
o minclass = 4 - The minimum number of required classes of characters for
the new password (digits, uppercase, lowercase, others)
OR
Rationale:
Strong passwords protect systems from being hacked through brute force methods.
Page 563
Password complexity
Option 1
Run the following command:
# grep '^\s*minclass\s*' /etc/security/pwquality.conf
Option 2
Run the following command:
# grep -E '^\s*[duol]credit\s*' /etc/security/pwquality.conf
pam_pwquality.so enabled
Example output:
password requisite pam_pwquality.so retry=3
Page 564
Edit the file /etc/security/pwquality.conf and add or modify the following line for
password length to conform to site policy:
minlen = 14
Edit the file /etc/security/pwquality.conf and add or modify the following line for
password complexity to conform to site policy:
Option 1
minclass = 4
Option 2
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
References:
Additional Information:
Additional module options may be set, recommendation requirements only cover
including try_first_pass and minlen set to 14 or more.
NOTE: As of this writing it is not possible to customize the maximum number of retries
for the creation of a password within recommended methods. The command pam-auth-
update is used to manage certain PAM configurations via profiles, such as
/etc/pam.d/common-password. Making a manual change to this file will cause pam-auth-
update to overwrite it on the next run and is thus against recommendations.
Alternatively, pam_pwquality (via /etc/security/pwquality.conf) fully supports the
configuration of the maximum number of retries for a password change with the
configuration entry retry = XXX. The issue is that the template /usr/share/pam-
configs/pwquality contains retry=3 which will override any retry setting in
/etc/security/pwquality.conf as PAM entries takes precedence. This template file
should not be modified as any package update will overwrite the change. Thus it is not
possible, in any recommended way, to modify password retries.
Page 565
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003
Page 566
• Level 1 - Server
• Level 1 - Workstation
Description:
Lock out users after n unsuccessful consecutive login attempts. The first sets of
changes are made to the PAM configuration files. The second set of changes are
applied to the program specific PAM configuration file. The second set of changes must
be applied to each program that will lock out users. Check the documentation for each
secondary program for instructions on how to configure them to work with PAM.
• deny=n - n represents the number of failed attempts before the account is locked
• unlock_time=n - n represents the number of seconds before the account is
unlocked
• audit - Will log the user name into the system log if the user is not found.
• silent - Don't print informative messages. Set the lockout number and unlock time
in accordance with local site policy.
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute
force password attacks against your systems.
Page 567
Example output:
auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900
Run the following command to verify the pam_deny.so module and pam_tally2.so
modules are included in /etc/pam.d/common-account:
# grep -E 'pam_(tally2|deny)\.so' /etc/pam.d/common-account
Remediation:
Edit the /etc/pam.d/common-auth file and add the auth line below:
auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900
Edit the /etc/pam.d/common-account file and add the account lines bellow:
account requisite pam_deny.so
account required pam_tally2.so
References:
Additional Information:
• Add pam_tally2 to the account section account required pam_tally2.so for the
counter to reset to 0 when using sudo
• Use of the "audit" keyword may log credentials in the case of user error during
authentication. This risk should be evaluated in the context of the site policies of
your organization.
• If a user has been locked out because they have reached the maximum
consecutive failure count defined by deny= in the pam_tally2.so module, the user
can be unlocked by issuing the command /sbin/pam_tally2 -u <username> --
reset. This command sets the failed count to 0, effectively unlocking the user.
Page 568
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1110, T1110.001,
TA0006 M1027
T1110.003
Page 569
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/security/opasswd file stores the users' old passwords and can be checked to
ensure that users are not recycling recent passwords.
Rationale:
Forcing users not to reuse their past 5 passwords make it less likely that an attacker will
be able to guess the password.
Audit:
Run the following command to verify the following in /etc/pam.d/common-password:
Remediation:
NOTE: Pay special attention to the configuration. Incorrect configuration can cause
system lock outs or unexpected behavior. This is example configuration. You
configuration may differ based on previous changes to the files.
Edit the /etc/pam.d/common-password file to include:
•
password required pam_pwhistory.so remember=5
•
use_authtok on the pam_unix.so line
Example:
password required pam_pwhistory.so remember=5
password [success=1 default=ignore] pam_unix.so obscure sha512 use_authtok
Page 570
1. https://manpages.ubuntu.com/manpages/focal/man8/pam_pwhistory.8.html
2. https://bugs.launchpad.net/ubuntu/+source/pam/+bug/1989731
3. NIST SP 800-53 Rev. 5: AC-2, IA-5
Additional Information:
Changes only apply to accounts configured on the local system.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
TA0005 M1028
T1078.004, T1110,
T1110.004
Page 571
• Level 1 - Server
• Level 1 - Workstation
Description:
Hash functions behave as one-way functions by using mathematical operations that are
extremely difficult and cumbersome to revert
When a user is created, the password is run through a one-way hashing algorithm
before being stored. When the user logs in, the password sent is run through the same
one-way hashing algorithm and compared to the hash connected with the provided
username. If the hashed password and the stored hash match, the login is valid.
Rationale:
The SHA512 hashing algorithm provides stronger hashing than previous available
algorithms like MD5, thus providing additional protection to the system by increasing the
level of effort for an attacker to successfully determine passwords.
Audit:
Run the following command to verify that pam_unix.so includes sha512 in
/etc/pam.d/common-password:
# grep -Pi -- '^\h*password\h+[^#\n\r]+\h+pam_unix.so([^#\n\r]+\h+)?(sha512|yescrypt)\b' /etc/pam.d/common-
password
Example Output
password [success=1 default=ignore] pam_unix.so obscure sha512 use_authtok
Page 572
Edit the /etc/pam.d/common-password file and ensure that sha512 is included and the
pam_unix.so success line:
Example:
password [success=1 default=ignore] pam_unix.so obscure sha512 use_authtok
Default Value:
sha512
References:
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
yescrypt has been included in the audit commands. This hashing algorithm is not
currently supported, but it will be acceptable as an alternative to sha512 if future updates
enable its support.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 573
Techniques / Sub-
Tactics Mitigations
techniques
Page 574
• Level 1 - Server
• Level 1 - Workstation
Description:
Currently used passwords with out of date hashing algorithms may pose a security risk
to the system.
Rationale:
In use passwords should always match the configured hashing algorithm for the system.
Impact:
If the administrator forces a password change, this could cause a large spike in CPU
usage if a large number of users change their password during the same time.
Audit:
Run the following script to get a list of users that are not using the currently configured
hashing algorithm:
#!/usr/bin/env bash
{
declare -A HASH_MAP=( ["y"]="yescrypt" ["1"]="md5" ["2"]="blowfish" ["5"]="SHA256" ["6"]="SHA512"
["g"]="gost-yescrypt" )
Page 575
{
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
awk -F: -v UID_MIN="${UID_MIN}" '( $3 >= UID_MIN && $1 != "nfsnobody" ) { print $1 }' /etc/passwd | xargs -n
1 chage -d 0
}
NOTE: This could cause significant temporary CPU load on the system if a large
number of users reset their passwords at the same time.
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 576
This section provides guidance on setting up secure defaults for system and user
accounts and their environment.
Page 577
While a majority of the password control parameters have been moved to PAM, some
parameters are still available through the shadow password suite. Any changes made to
/etc/login.defs will only be applied if the usermod command is used. If user IDs are
added a different way, use the chage command to effect changes to individual user IDs.
Page 578
• Level 1 - Server
• Level 1 - Workstation
Description:
The PASS_MIN_DAYS parameter in /etc/login.defs allows an administrator to prevent
users from changing their password until a minimum number of days have passed since
the last time the user changed their password. It is recommended that PASS_MIN_DAYS
parameter be set to 1 or more days.
Rationale:
By restricting the frequency of password changes, an administrator can prevent users
from repeatedly changing their password in an attempt to circumvent password reuse
controls.
Audit:
Run the following command and verify PASS_MIN_DAYS conforms to site policy (no less
than 1 day):
# grep PASS_MIN_DAYS /etc/login.defs
PASS_MIN_DAYS 1
Run the following command and Review list of users and PAS_MIN_DAYS to Verify that
all users' PAS_MIN_DAYS conforms to site policy (no less than 1 day):
# awk -F : '(/^[^:]+:[^!*]/ && $4 < 1){print $1 " " $4}' /etc/shadow
Remediation:
Set the PASS_MIN_DAYS parameter to 1 in /etc/login.defs:
PASS_MIN_DAYS 1
Modify user parameters for all users with a password set to match:
# chage --mindays 1 <user>
Default Value:
PASS_MIN_DAYS 0
References:
Page 579
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 580
• Level 1 - Server
• Level 1 - Workstation
Description:
The PASS_MAX_DAYS parameter in /etc/login.defs allows an administrator to force
passwords to expire once they reach a defined age.
Rationale:
The window of opportunity for an attacker to leverage compromised credentials or
successfully compromise credentials via an online brute force attack is limited by the
age of the password. Therefore, reducing the maximum age of a password also reduces
an attacker's window of opportunity. It is recommended that the PASS_MAX_DAYS
parameter does not exceed 365 days and is greater than the value of PASS_MIN_DAYS.
Audit:
Run the following command and verify PASS_MAX_DAYS conforms to site policy, does not
exceed 365 days, and is greater than PASS_MIN_DAYS:
# grep PASS_MAX_DAYS /etc/login.defs
PASS_MAX_DAYS 365
Run the following command and Review list of users and PASS_MAX_DAYS to verify that all
users' PASS_MAX_DAYS conforms to site policy, does not exceed 365 days, and is no less
than PASS_MIN_DAYS
# awk -F: '(/^[^:]+:[^!*]/ && ($5>365 || $5~/([0-1]|-1|\s*)/)){print $1 " " $5}' /etc/shadow
Remediation:
Set the PASS_MAX_DAYS parameter to conform to site policy in /etc/login.defs :
PASS_MAX_DAYS 365
Modify user parameters for all users with a password set to match:
# chage --maxdays 365 <user>
Default Value:
PASS_MAX_DAYS 99999
Page 581
1. https://www.cisecurity.org/white-papers/cis-password-policy-guide/
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Additional Information:
A value of -1 will disable password expiration
The password expiration must be greater than the minimum days between
password changes or users will be unable to change their password
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 582
• Level 1 - Server
• Level 1 - Workstation
Description:
The PASS_WARN_AGE parameter in /etc/login.defs allows an administrator to notify
users that their password will expire in a defined number of days. It is recommended
that the PASS_WARN_AGE parameter be set to 7 or more days.
Rationale:
Providing an advance warning that a password will be expiring gives users time to think
of a secure password. Users caught unaware may choose a simple password or write it
down where it may be discovered.
Audit:
Run the following command and verify PASS_WARN_AGE conforms to site policy (No less
than 7 days):
# grep PASS_WARN_AGE /etc/login.defs
PASS_WARN_AGE 7
Verify all users with a password have their number of days of warning before password
expires set to 7 or more:
Run the following command and Review list of users and PASS_WARN_AGE to verify that all
users' PASS_WARN_AGE conforms to site policy (No less than 7 days):
# awk -F: '(/^[^:]+:[^!*]/ && $6<7){print $1 " " $6}' /etc/shadow
Remediation:
Set the PASS_WARN_AGE parameter to 7 in /etc/login.defs:
PASS_WARN_AGE 7
Modify user parameters for all users with a password set to match:
# chage --warndays 7 <user>
Default Value:
PASS_WARN_AGE 7
Page 583
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 584
• Level 1 - Server
• Level 1 - Workstation
Description:
User accounts that have been inactive for over a given period of time can be
automatically disabled. It is recommended that accounts that are inactive for 30 days
after password expiration be disabled.
Rationale:
Inactive accounts pose a threat to system security since the users are not logging in to
notice failed login attempts or other anomalies.
Audit:
Run the following command and verify INACTIVE conforms to site policy (no more than
30 days):
# useradd -D | grep INACTIVE
INACTIVE=30
Verify all users with a password have Password inactive no more than 30 days after
password expires:
Run the following command and Review list of users and INACTIVE to verify that all
users' INACTIVE conforms to site policy (no more than 30 days):
# awk -F: '(/^[^:]+:[^!*]/ && ($7~/(\s*|-1)/ || $7>30)){print $1 " " $7}' /etc/shadow
Remediation:
Run the following command to set the default password inactivity period to 30 days:
# useradd -D -f 30
Modify user parameters for all users with a password set to match:
# chage --inactive 30 <user>
Default Value:
INACTIVE=-1
References:
Page 585
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.002,
TA0001 M1027
T1078.003
Page 586
• Level 1 - Server
• Level 1 - Workstation
Description:
All users should have a password change date in the past.
Rationale:
If a users recorded password change date is in the future then they could bypass any
set password expiration.
Audit:
Run the following script to verify all users last password change was in the past:
#!/usr/bin/env bash
{
l_output2=""
while read -r l_user; do
l_change="$(chage --list $l_user | awk -F: '($1 ~ /^\s*Last\s+password\s+change/ && $2 !~ /never/){print
$2}' | xargs)"
if [[ "$(date -d "$l_change" +%s)" -gt "$(date +%s)" ]]; then
l_output2="$l_output2\n - User: \"$l_user\" last password change is in the future \"$l_change\""
fi
done < <(awk -F: '($2 ~ /^[^*!xX\n\r][^\n\r]+/){print $1}' /etc/shadow)
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - All user password changes are in the past \n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :$l_output2\n"
fi
}
Remediation:
Investigate any users with a password change date in the future and correct them.
Locking the account, expiring the password, or resetting the password manually may be
appropriate.
References:
Page 587
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 588
• Level 1 - Server
• Level 1 - Workstation
Description:
The pwquality difok option sets the number of characters in a password that must not
be present in the old password.
Rationale:
Use of a complex password helps to increase the time and resources required to
compromise the password. Password complexity, or strength, is a measure of the
effectiveness of a password in resisting attempts at guessing and brute-force attacks.
Password complexity is one factor of several that determines how long it takes to crack
a password. The more complex the password, the greater the number of possible
combinations that need to be tested before the password is compromised.
Audit:
Run the following command to verify that the difok option in
/etc/security/pwquality.conf is set to 2 or more:
# grep -P '^\h*difok\h*=\h*([2-9]|[1-9][0-9]+)\b' /etc/security/pwquality.conf
difok = 2
Remediation:
Edit or add the following line in /etc/security/pwquality.conf to a value of 2 or more:
difok = 2
Default Value:
difok = 1
References:
Page 589
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 590
• Level 1 - Server
• Level 1 - Workstation
Description:
The pwquality dictcheck option sets whether to check for the words from the cracklib
dictionary.
Rationale:
If the operating system allows the user to select passwords based on dictionary words,
this increases the chances of password compromise by increasing the opportunity for
successful guesses, and brute-force attacks.
Audit:
Run the following command to verify that the dictcheck option in
/etc/security/pwquality.conf is not set to 0:
# grep -Pi -- '^\h*dictcheck\h*=\h*0\b' /etc/security/pwquality.conf
Remediation:
Edit or add the following line in /etc/security/pwquality.conf to a value of 1:
dictcheck = 1
Default Value:
dictcheck = 1
References:
Page 591
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 592
• Level 1 - Server
• Level 1 - Workstation
Description:
There are a number of accounts provided with most distributions that are used to
manage applications and are not intended to provide an interactive shell.
Rationale:
It is important to make sure that accounts that are not being used by regular users are
prevented from being used to provide an interactive shell. By default, most distributions
set the password field for these accounts to an invalid string, but it is also recommended
that the shell field in the password file be set to the nologin shell. This prevents the
account from potentially being used to run any commands.
Page 593
{
l_output="" l_output2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\\\/,g;p}' |
paste -s -d '|' - ))$"
a_users=(); a_ulock=() # initialize arrays
while read -r l_user; do # Populate array with system accounts that have a valid login shell
a_users+=("$l_user")
done < <(awk -v pat="$l_valid_shells" -F: '($1!~/(root|sync|shutdown|halt|^\+)/ && $3<'"$(awk
'/^\s*UID_MIN/{print $2}' /etc/login.defs)"' && $(NF) ~ pat) { print $1 }' /etc/passwd)
while read -r l_ulock; do # Populate array with system accounts that aren't locked
a_ulock+=("$l_ulock")
done < <(awk -v pat="$l_valid_shells" -F: '($1!~/(root|^\+)/ && $2!~/LK?/ && $3<'"$(awk '/^\s*UID_MIN/{print
$2}' /etc/login.defs)"' && $(NF) ~ pat) { print $1 }' /etc/passwd)
if ! (( ${#a_users[@]} > 0 )); then
l_output="$l_output\n - local system accounts login is disabled"
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_users[@]}")\" system accounts with login
enabled\n - List of accounts:\n$(printf '%s\n' "${a_users[@]:0:$l_limit}")\n - end of list\n"
fi
if ! (( ${#a_ulock[@]} > 0 )); then
l_output="$l_output\n - local system accounts are locked"
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_ulock[@]}")\" system accounts that are not
locked\n - List of accounts:\n$(printf '%s\n' "${a_ulock[@]:0:$l_limit}")\n - end of list\n"
fi
unset a_users; unset a_ulock # Remove arrays
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "- * Correctly configured * :\n$l_output\n"
fi
}
Note:
• The root, sync, shutdown, and halt users are exempted from requiring a non-
login shell
•
root is exempt from being locked
Page 594
• Set the shell for any accounts returned by the audit to nologin
• Lock any non root system accounts returned by the audit:
#!/usr/bin/env bash
{
l_output="" l_output2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\\\/,g;p}' |
paste -s -d '|' - ))$"
a_users=(); a_ulock=() # initialize arrays
while read -r l_user; do # change system accounts that have a valid login shell to nolog shell
echo -e " - System account \"$l_user\" has a valid logon shell, changing shell to \"$(which nologin)\""
usermod -s "$(which nologin)" "$l_user"
done < <(awk -v pat="$l_valid_shells" -F: '($1!~/(root|sync|shutdown|halt|^\+)/ && $3<'"$(awk
'/^\s*UID_MIN/{print $2}' /etc/login.defs)"' && $(NF) ~ pat) { print $1 }' /etc/passwd)
while read -r l_ulock; do # Lock system accounts that aren't locked
echo -e " - System account \"$l_ulock\" is not locked, locking account"
usermod -L "$l_ulock"
done < <(awk -v pat="$l_valid_shells" -F: '($1!~/(root|^\+)/ && $2!~/LK?/ && $3<'"$(awk '/^\s*UID_MIN/{print
$2}' /etc/login.defs)"' && $(NF) ~ pat) { print $1 }' /etc/passwd)
}
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 595
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1026
T1078.003
Page 596
• Level 1 - Server
• Level 1 - Workstation
Description:
The usermod command can be used to specify which group the root user belongs to.
This affects permissions of files that are created by the root user.
Rationale:
Using GID 0 for the root account helps prevent root -owned files from accidentally
becoming accessible to non-privileged users.
Audit:
Run the following command and verify the result is 0 :
# grep "^root:" /etc/passwd | cut -f4 -d:
0
Remediation:
Run the following command to set the root user default group to GID 0 :
# usermod -g 0 root
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 597
Techniques / Sub-
Tactics Mitigations
techniques
Page 598
• Level 1 - Server
• Level 1 - Workstation
Description:
The user file-creation mode mask (umask) is use to determine the file permission for
newly created directories and files. In Linux, the default permissions for any newly
created directory is 0777 (rwxrwxrwx), and for any newly created file it is 0666 (rw-rw-
rw-). The umask modifies the default Linux permissions by restricting (masking) these
permissions. The umask is not simply subtracted, but is processed bitwise. Bits set in the
umask are cleared in the resulting file mode.
• Octal (Numeric) Value - Represented by either three or four digits. ie umask 0027
or umask 027. If a four digit umask is used, the first digit is ignored. The remaining
three digits effect the resulting permissions for user, group, and world/other
respectively.
• Symbolic Value - Represented by a comma separated list for User u, group g,
and world/other o. The permissions listed are not masked by umask. ie a umask
set by umask u=rwx,g=rx,o= is the Symbolic equivalent of the Octal umask 027.
This umask would set a newly created directory with file mode drwxr-x--- and a
newly created file with file mode rw-r-----.
• pam_umask module:
o will set the umask according to the system default in /etc/login.defs and
user settings, solving the problem of different umask settings with different
shells, display managers, remote sessions etc.
o umask=<mask> value in the /etc/login.defs file is interpreted as Octal
o Setting USERGROUPS_ENAB to yes in /etc/login.defs (default):
▪ will enable setting of the umask group bits to be the same as owner
bits. (examples: 022 -> 002, 077 -> 007) for non-root users, if the
uid is the same as gid, and username is the same as the primary
group name
▪ userdel will remove the user's group if it contains no more
members, and useradd will create by default a group with the name
of the user
• System Wide Shell Configuration File:
Page 599
Rationale:
Setting a very secure default value for umask ensures that users make a conscious
choice about their file permissions. A default umask setting of 077 causes files and
directories created by users to not be readable by any other user on the system. A
umask of 027 would make files and directories readable by users in the same Unix group,
while a umask of 022 would make files readable by every user on the system.
Impact:
Setting USERGROUPS_ENAB no in /etc/login.defs may change the expected behavior of
useradd and userdel.
Page 600
Run the following script to verify that a default user umask is set enforcing a newly
created directories's permissions to be 750 (drwxr-x---), and a newly created file's
permissions be 640 (rw-r-----), or more restrictive:
#!/bin/bash
passing=""
grep -Eiq '^\s*UMASK\s+(0[0-7][2-7]7|[0-7][2-7]7)\b' /etc/login.defs && grep -Eqi
'^\s*USERGROUPS_ENAB\s*"?no"?\b' /etc/login.defs && grep -Eq
'^\s*session\s+(optional|requisite|required)\s+pam_umask\.so\b' /etc/pam.d/common-session && passing=true
grep -REiq '^\s*UMASK\s+\s*(0[0-7][2-7]7|[0-7][2-7]7|u=(r?|w?|x?)(r?|w?|x?)(r?|w?|x?),g=(r?x?|x?r?),o=)\b'
/etc/profile* /etc/bash.bashrc* && passing=true
[ "$passing" = true ] && echo "Default user umask is set"
Page 601
Follow one of the following methods to set the default user umask:
Edit /etc/login.defs and edit the UMASK and USERGROUPS_ENAB lines as follows:
UMASK 027
USERGROUPS_ENAB no
OR
Configure umask in one of the following files:
Example: /etc/profile.d/set_umask.sh
umask 027
Note: this method only applies to bash and shell. If other shells are supported on the
system, it is recommended that their configuration files also are checked.
Default Value:
UMASK 022
References:
1. pam_umask(8)
2. NIST SP 800-53 Rev. 5: AC-3, MP-2
Page 602
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 603
• Level 1 - Server
• Level 1 - Workstation
Description:
TMOUT is an environmental setting that determines the timeout of a shell in seconds.
Rationale:
Setting a timeout value reduces the window of opportunity for unauthorized user access
to another user's shell session that has been left unattended. It also ends the inactive
session and releases the resources associated with that session.
Page 604
{
l_output="" l_output2=""
l_tmv_max="900"
l_searchloc="/etc/bashrc /etc/bash.bashrc /etc/profile /etc/profile.d/*.sh"
a_tmofile=()
while read -r l_file; do
[ -e "$l_file" ] && a_tmofile+=("$(readlink -f $l_file)")
done < <(grep -PRils '^\h*([^#\n\r]+\h+)?TMOUT=\d+\b' $l_searchloc)
if ! (( ${#a_tmofile[@]} > 0 )); then
l_output2="$l_output2\n - TMOUT is not set"
elif (( ${#a_tmofile[@]} > 1 )); then
l_output2="$l_output2\n - TMOUT is set in multiple locations.\n - List of files where TMOUT is
set:\n$(printf '%s\n' "${a_tmofile[@]}")\n - end of list\n"
else
for l_file in ${a_tmofile[@]}; do
if (( "$(grep -Pci '^\h*([^#\n\r]+\h+)?TMOUT=\d+' "$l_file")" > 1 )); then
l_output2="$l_output2\n - TMOUT is set multiple times in \"$l_file\""
else
l_tmv="$(grep -Pi '^\h*([^#\n\r]+\h+)?TMOUT=\d+' "$l_file" | grep -Po '\d+')"
if (( "$l_tmv" > "$l_tmv_max" )); then
l_output2="$l_output\n - TMOUT is \"$l_tmv\" in \"$l_file\"\n - Should be \"$l_tmv_max\" or
less and not \"0\""
else
l_output="$l_output\n- TMOUT is correctly set to \"$l_tmv\" in \"$l_file\""
if grep -Piq '^\h*([^#\n\r]+\h+)?readonly\h+TMOUT\b' "$l_file"; then
l_output="$l_output\n- TMOUT is correctly set to \"readonly\" in \"$l_file\""
else
l_output2="$l_output2\n- TMOUT is not set to \"readonly\""
fi
if grep -Piq '^(\h*|\h*[^#\n\r]+\h*;\h*)export\h+TMOUT\b' "$l_file"; then
l_output="$l_output\n- TMOUT is correctly set to \"export\" in \"$l_file\""
else
l_output2="$l_output2\n- TMOUT is not set to \"export\""
fi
fi
fi
done
fi
unset a_tmofile # Remove array
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "- * Correctly configured * :\n$l_output\n"
fi
}
Page 605
• Be configured once, as multiple lines, or a single line, in one and only one of the
following locations:
o A file in the /etc/profile.d/ directory ending in .sh
o
/etc/profile
o
/etc/bash.bashrc
• Not exceed 900
• Not be equal to 0
References:
Additional Information:
The audit and remediation in this recommendation apply to bash and shell. If other
shells are supported on the system, it is recommended that their configuration files are
also checked
Other methods of setting a timeout exist not covered here
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 606
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1026
T1078.002, T1078.003
Page 607
• Level 2 - Server
• Level 2 - Workstation
Description:
/etc/shells is a text file which contains the full pathnames of valid login shells. This file
is consulted by chsh and available to be queried by other programs.
Be aware that there are programs which consult this file to find out if a user is a normal
user; for example, FTP daemons traditionally disallow access to users with shells not
included in this file.
Rationale:
A user can use chsh to change their configured shell.
If a user has a shell configured that isn't in in /etc/shells, then the system assumes
that they're somehow restricted. In the case of chsh it means that the user cannot
change that value.
Other programs might query that list and apply similar restrictions.
By putting nologin in /etc/shells, any user that has nologin as its shell is considered
a full, unrestricted user. This is not the expected behavior for nologin.
Audit:
Run the following command to verify that nologin is not listed in the /etc/shells file:
# grep '/nologin\b' /etc/shells
References:
1. shells(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Page 608
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1026
T1078.003
Page 609
• Level 1 - Server
• Level 1 - Workstation
Description:
The pwquality maxrepeat option sets the maximum number of allowed same
consecutive characters in a new password.
Rationale:
Use of a complex password helps to increase the time and resources required to
compromise the password. Password complexity, or strength, is a measure of the
effectiveness of a password in resisting attempts at guessing and brute-force attacks.
Password complexity is one factor of several that determines how long it takes to crack
a password. The more complex the password, the greater the number of possible
combinations that need to be tested before the password is compromised.
Audit:
Run the following command to verify that the maxrepeat option in
/etc/security/pwquality.conf is set to 3 or less, and not 0:
# grep -Pi '^\h*maxrepeat\h*=\h*[1-3]\b' /etc/security/pwquality.conf
maxrepeat = 3
Default Value:
maxrepeat = 0
References:
Page 610
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 611
Page 612
• Ensure transport layer security is implemented between the client and the log
server.
• Ensure that logs are rotated as per the environment requirements.
• Ensure all locally generated logs have the appropriate permissions.
• Ensure all security logs are sent to a remote log server.
• Ensure the required events are logged.
What is covered
This section will cover the minimum best practices for the usage of either rsyslog or
journald. The recommendations are written such that each is wholly independent of
each other and only one is implemented.
Page 613
Page 614
Page 615
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald (via systemd-journal-remote) supports the ability to send log events it gathers
to a remote log host or to receive messages from remote hosts, thus enabling
centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker
gains root access on the local system, they could tamper with or remove log data that is
stored on the local system.
Audit:
Run the following command to verify systemd-journal-remote is installed.
Run the following command:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' systemd-journal-remote
Remediation:
Run the following command to install systemd-journal-remote:
# apt install systemd-journal-remote
References:
Page 616
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 617
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald (via systemd-journal-remote) supports the ability to send log events it gathers
to a remote log host or to receive messages from remote hosts, thus enabling
centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker
gains root access on the local system, they could tamper with or remove log data that is
stored on the local system.
Audit:
Verify systemd-journal-remote is configured.
Run the following command:
# grep -P "^ *URL=|^ *ServerKeyFile=|^ *ServerCertificateFile=|^ *TrustedCertificateFile="
/etc/systemd/journal-upload.conf
Verify the output matches per your environments certificate locations and the URL of
the log server. Example:
URL=192.168.50.42
ServerKeyFile=/etc/ssl/private/journal-upload.pem
ServerCertificateFile=/etc/ssl/certs/journal-upload.pem
TrustedCertificateFile=/etc/ssl/ca/trusted.pem
Remediation:
Edit the /etc/systemd/journal-upload.conf file and ensure the following lines are set
per your environment:
URL=192.168.50.42
ServerKeyFile=/etc/ssl/private/journal-upload.pem
ServerCertificateFile=/etc/ssl/certs/journal-upload.pem
TrustedCertificateFile=/etc/ssl/ca/trusted.pem
References:
Page 618
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 619
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald (via systemd-journal-remote) supports the ability to send log events it gathers
to a remote log host or to receive messages from remote hosts, thus enabling
centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker
gains root access on the local system, they could tamper with or remove log data that is
stored on the local system.
Audit:
Verify systemd-journal-remote is enabled.
Run the following command:
# systemctl is-enabled systemd-journal-upload.service
Remediation:
Run the following command to enable systemd-journal-remote:
# systemctl --now enable systemd-journal-upload.service
References:
Page 620
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 621
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald supports the ability to receive messages from remote hosts, thus acting as a
log server. Clients should not receive data from other hosts.
Note:
Rationale:
If a client is configured to also receive data, thus turning it into a server, the client
system is acting outside it's operational boundary.
Audit:
Run the following command to verify systemd-journal-remote.socket is not enabled:
# systemctl is-enabled systemd-journal-remote.socket
Remediation:
Run the following command to disable systemd-journal-remote.socket:
# systemctl --now disable systemd-journal-remote.socket
References:
Page 622
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 623
• Level 1 - Server
• Level 1 - Workstation
Description:
Ensure that the systemd-journald service is enabled to allow capturing of logging
events.
Rationale:
If the systemd-journald service is not enabled to start on boot, the system will not
capture logging events.
Audit:
Run the following command to verify systemd-journald is enabled:
# systemctl is-enabled systemd-journald.service
Remediation:
By default the systemd-journald service does not have an [Install] section and thus
cannot be enabled / disabled. It is meant to be referenced as Requires or Wants by other
unit files. As such, if the status of systemd-journald is not static, investigate why.
References:
Page 624
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 625
• Level 1 - Server
• Level 1 - Workstation
Description:
The journald system includes the capability of compressing overly large files to avoid
filling up the system with logs or making the logs unmanageably large.
Rationale:
Uncompressed large files may unexpectedly fill a filesystem leading to resource
unavailability. Compressing logs prior to write can prevent sudden, unexpected
filesystem impacts.
Audit:
Run the following command to verify that large files will be compressed:
# grep -Psi '^\h*Compress\h*=\h*yes\b' /etc/systemd/journald.conf /etc/systemd/journald.conf.d/*
Remediation:
Edit the /etc/systemd/journald.conf file or a file ending in .conf in
/etc/systemd/journald.conf.d/ and add the following line:
Compress=yes
References:
Additional Information:
The main configuration file /etc/systemd/journald.conf is read before any of the
custom *.conf files. If there are custom configs present, they override the main
configuration parameters.
It is possible to change the default threshold of 512 bytes per object before compression
is used.
Page 626
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 627
• Level 1 - Server
• Level 1 - Workstation
Description:
Data from journald may be stored in volatile memory or persisted locally on the server.
Logs in memory will be lost upon a system reboot. By persisting logs to local disk on the
server they are protected from loss due to a reboot.
Rationale:
Writing log data to disk will provide the ability to forensically reconstruct events which
may have impacted the operations or security of a system even after a system crash or
reboot.
Audit:
Run the following command to verify that logs are persisted to disk:
# grep -Psi '^\h*Storage\h*=\h*persistent\b' /etc/systemd/journald.conf /etc/systemd/journald.conf.d/*
Remediation:
Edit the /etc/systemd/journald.conf file or a file ending in .conf in
/etc/systemd/journald.conf.d/ and add the following line:
Storage=persistent
References:
Page 628
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 629
• Level 1 - Server
• Level 1 - Workstation
Description:
Data from journald should be kept in the confines of the service and not forwarded on
to other services.
Rationale:
IF journald is the method for capturing logs, all logs of the system should be handled by
journald and not forwarded to other logging mechanisms.
Audit:
IF journald is the method for capturing logs
Run the following command to verify that logs are not forwarded to rsyslog:
# grep -Psi '^\h*ForwardToSyslog\h*=\h*yes\b` /etc/systemd/journald.conf /etc/systemd/journald.conf.d/*
References:
Page 630
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 631
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald includes the capability of rotating log files regularly to avoid filling up the
system with logs or making the logs unmanageably large. The file
/etc/systemd/journald.conf is the configuration file used to specify how logs
generated by Journald should be rotated.
Rationale:
By keeping the log files smaller and more manageable, a system administrator can
easily archive these files to another system and spend less time looking through
inordinately large log files.
Audit:
Review /etc/systemd/journald.conf, and files in /etc/systemd/journald.conf.d/, and
verify logs are rotated according to site policy. The specific parameters for log rotation
are:
SystemMaxUse=
SystemKeepFree=
RuntimeMaxUse=
RuntimeKeepFree=
MaxFileSec=
Remediation:
Review /etc/systemd/journald.conf and verify logs are rotated according to site
policy. The settings should be carefully understood as there are specific edge cases
and prioritisation of parameters.
The specific parameters for log rotation are:
SystemMaxUse=
SystemKeepFree=
RuntimeMaxUse=
RuntimeKeepFree=
MaxFileSec=
References:
Page 632
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 633
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald will create logfiles that do not already exist on the system. This setting controls
what permissions will be applied to these newly created files.
Rationale:
It is important to ensure that log files have the correct permissions to ensure that
sensitive data is archived and protected.
Audit:
First see if there is an override file /etc/tmpfiles.d/systemd.conf. If so, this file will
override all default settings as defined in /usr/lib/tmpfiles.d/systemd.conf and
should be inspected.
If there is no override file, inspect the default /usr/lib/tmpfiles.d/systemd.conf
against the site specific requirements.
Ensure that file permissions are 0640.
Should a site policy dictate less restrictive permissions, ensure to follow said policy.
NOTE: More restrictive permissions such as 0600 is implicitly sufficient.
Remediation:
If the default configuration is not appropriate for the site specific requirements, copy
/usr/lib/tmpfiles.d/systemd.conf to /etc/tmpfiles.d/systemd.conf and modify as
required. Requirements is either 0640 or site policy if that is less restrictive.
References:
Additional Information:
See man 5 tmpfiles.d for detailed information on the permission sets for the relevant
log files. Further information with examples can be found at
https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
Page 634
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 635
The rsyslog software package may be used instead of the default journald logging
mechanism.
Note: This section only applies if rsyslog is the chosen method for client side logging.
Do not apply this section if journald is used.
Page 636
• Level 1 - Server
• Level 1 - Workstation
Description:
The rsyslog software is recommended in environments where journald does not meet
operation requirements.
Rationale:
The security enhancements of rsyslog such as connection-oriented (i.e. TCP)
transmission of logs, the option to log to database formats, and the encryption of log
data en route to a central logging server) justify installing and configuring the package.
Audit:
Run the following command to verify rsyslog is installed:
# dpkg-query -s rsyslog &>/dev/null && echo "rsyslog is installed"
rsyslog is installed
Remediation:
Run the following command to install rsyslog:
# apt install rsyslog
References:
Page 637
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 638
• Level 1 - Server
• Level 1 - Workstation
Description:
Once the rsyslog package is installed, ensure that the service is enabled.
Rationale:
If the rsyslog service is not enabled to start on boot, the system will not capture logging
events.
Audit:
Run the following command to verify rsyslog is enabled:
# systemctl is-enabled rsyslog
Remediation:
Run the following command to enable rsyslog:
# systemctl --now enable rsyslog
References:
Page 639
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 640
• Level 1 - Server
• Level 1 - Workstation
Description:
Data from journald may be stored in volatile memory or persisted locally on the server.
Utilities exist to accept remote export of journald logs, however, use of the RSyslog
service provides a consistent means of log collection and export.
Rationale:
IF RSyslog is the preferred method for capturing logs, all logs of the system should be
sent to it for further processing.
Audit:
IF RSyslog is the preferred method for capturing logs
Review /etc/systemd/journald.conf and verify that logs are forwarded to rsyslog.
# grep ^\s*ForwardToSyslog /etc/systemd/journald.conf
Remediation:
Edit the /etc/systemd/journald.conf file and add the following line:
ForwardToSyslog=yes
References:
Page 641
Controls
Control IG 1 IG 2 IG 3
Version
Page 642
Techniques / Sub-
Tactics Mitigations
techniques
Page 643
• Level 1 - Server
• Level 1 - Workstation
Description:
RSyslog will create logfiles that do not already exist on the system. This setting controls
what permissions will be applied to these newly created files.
Rationale:
It is important to ensure that log files have the correct permissions to ensure that
sensitive data is archived and protected.
Impact:
The systems global umask could override, but only making the file permissions stricter,
what is configured in RSyslog with the FileCreateMode directive. RSyslog also has it's
own $umask directive that can alter the intended file creation mode. In addition,
consideration should be given to how FileCreateMode is used.
Thus it is critical to ensure that the intended file creation mode is not overridden with
less restrictive settings in /etc/rsyslog.conf, /etc/rsyslog.d/*conf files and that
FileCreateMode is set before any file is created.
Audit:
Run the following command:
# grep ^\$FileCreateMode /etc/rsyslog.conf /etc/rsyslog.d/*.conf
Should a site policy dictate less restrictive permissions, ensure to follow said policy.
NOTE: More restrictive permissions such as 0600 is implicitly sufficient.
Page 644
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 645
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files specifies rules for logging and
which files are to be used to log certain classes of messages.
Rationale:
A great deal of important security-related information is sent via rsyslog (e.g.,
successful and failed su attempts, failed login attempts, root login attempts, etc.).
Audit:
Review the contents of /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files to ensure
appropriate logging is set. In addition, run the following command and verify that the log
files are logging information as expected:
# ls -l /var/log/
Remediation:
Edit the following lines in the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files as
appropriate for your environment.
NOTE: The below configuration is shown for example purposes only. Due care should
be given to how the organization wish to store log data.
*.emerg :omusrmsg:*
auth,authpriv.* /var/log/secure
mail.* -/var/log/mail
mail.info -/var/log/mail.info
mail.warning -/var/log/mail.warn
mail.err /var/log/mail.err
cron.* /var/log/cron
*.=warning;*.=err -/var/log/warn
*.crit /var/log/warn
*.*;mail.none;news.none -/var/log/messages
local0,local1.* -/var/log/localmessages
local2,local3.* -/var/log/localmessages
local4,local5.* -/var/log/localmessages
local6,local7.* -/var/log/localmessages
References:
Page 646
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 647
• Level 1 - Server
• Level 1 - Workstation
Description:
RSyslog supports the ability to send log events it gathers to a remote log host or to
receive messages from remote hosts, thus enabling centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker
gains root access on the local system, they could tamper with or remove log data that is
stored on the local system.
Audit:
Review the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and verify that logs are
sent to a central host (where loghost.example.com is the name of your central log host):
Old format
New format
Page 648
References:
Additional Information:
In addition, see the RSyslog documentation for implementation details of TLS.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 649
• Level 1 - Server
• Level 1 - Workstation
Description:
RSyslog supports the ability to receive messages from remote hosts, thus acting as a
log server. Clients should not receive data from other hosts.
Rationale:
If a client is configured to also receive data, thus turning it into a server, the client
system is acting outside it's operational boundary.
Audit:
Review the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and verify that the
system is not configured to accept incoming logs.
Old format
No output expected.
New format
No output expected.
Page 650
Old format
$ModLoad imtcp
$InputTCPServerRun
New format
module(load="imtcp")
input(type="imtcp" port="514")
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 651
Techniques / Sub-
Tactics Mitigations
techniques
Page 652
• Level 1 - Server
• Level 1 - Workstation
Description:
Log files stored in /var/log/ contain logged information from many services on the
system and potentially from other logged hosts as well.
Rationale:
It is important that log files have the correct permissions to ensure that sensitive data is
protected and that only the appropriate users / groups have access to them.
Audit:
Run the following script to verify that files in /var/log/ have appropriate permissions
and ownership:
Page 653
{
l_op2="" l_output2=""
l_uidmin="$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)"
file_test_chk()
{
l_op2=""
if [ $(( $l_mode & $perm_mask )) -gt 0 ]; then
l_op2="$l_op2\n - Mode: \"$l_mode\" should be \"$maxperm\" or more restrictive"
fi
if [[ ! "$l_user" =~ $l_auser ]]; then
l_op2="$l_op2\n - Owned by: \"$l_user\" and should be owned by \"${l_auser//|/ or }\""
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_op2="$l_op2\n - Group owned by: \"$l_group\" and should be group owned by \"${l_agroup//|/ or }\""
fi
[ -n "$l_op2" ] && l_output2="$l_output2\n - File: \"$l_fname\" is:$l_op2\n"
}
unset a_file && a_file=() # clear and initialize array
# Loop to create array with stat of files that could possibly fail one of the audits
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_file+=("$(stat -Lc '%n^%#a^%U^%u^%G^%g' "$l_file")")
done < <(find -L /var/log -type f \( -perm /0137 -o ! -user root -o ! -group root \) -print0)
while IFS="^" read -r l_fname l_mode l_user l_uid l_group l_gid; do
l_bname="$(basename "$l_fname")"
case "$l_bname" in
lastlog | lastlog.* | wtmp | wtmp.* | wtmp-* | btmp | btmp.* | btmp-* | README)
perm_mask='0113'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|utmp)"
file_test_chk
;;
secure | auth.log | syslog | messages)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
file_test_chk
;;
SSSD | sssd)
perm_mask='0117'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="(root|SSSD)"
l_agroup="(root|SSSD)"
file_test_chk
;;
gdm | gdm3)
perm_mask='0117'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|gdm|gdm3)"
file_test_chk
;;
*.journal | *.journal~)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|systemd-journal)"
file_test_chk
;;
*)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
if [ "$l_uid" -lt "$l_uidmin" ] && [ -z "$(awk -v grp="$l_group" -F: '$1==grp {print $4}'
/etc/group)" ]; then
if [[ ! "$l_user" =~ $l_auser ]]; then
l_auser="(root|syslog|$l_user)"
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_tst=""
while l_out3="" read -r l_duid; do
[ "$l_duid" -ge "$l_uidmin" ] && l_tst=failed
done <<< "$(awk -F: '$4=='"$l_gid"' {print $3}' /etc/passwd)"
[ "$l_tst" != "failed" ] && l_agroup="(root|adm|$l_group)"
fi
fi
file_test_chk
Page 654
Page 655
Page 656
{
l_op2="" l_output2=""
l_uidmin="$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)"
file_test_fix()
{
l_op2=""
l_fuser="root"
l_fgroup="root"
if [ $(( $l_mode & $perm_mask )) -gt 0 ]; then
l_op2="$l_op2\n - Mode: \"$l_mode\" should be \"$maxperm\" or more restrictive\n - Removing excess
permissions"
chmod "$l_rperms" "$l_fname"
fi
if [[ ! "$l_user" =~ $l_auser ]]; then
l_op2="$l_op2\n - Owned by: \"$l_user\" and should be owned by \"${l_auser//|/ or }\"\n - Changing
ownership to: \"$l_fuser\""
chown "$l_fuser" "$l_fname"
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_op2="$l_op2\n - Group owned by: \"$l_group\" and should be group owned by \"${l_agroup//|/ or }\"\n
- Changing group ownership to: \"$l_fgroup\""
chgrp "$l_fgroup" "$l_fname"
fi
[ -n "$l_op2" ] && l_output2="$l_output2\n - File: \"$l_fname\" is:$l_op2\n"
}
unset a_file && a_file=() # clear and initialize array
# Loop to create array with stat of files that could possibly fail one of the audits
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_file+=("$(stat -Lc '%n^%#a^%U^%u^%G^%g' "$l_file")")
done < <(find -L /var/log -type f \( -perm /0137 -o ! -user root -o ! -group root \) -print0)
while IFS="^" read -r l_fname l_mode l_user l_uid l_group l_gid; do
l_bname="$(basename "$l_fname")"
case "$l_bname" in
lastlog | lastlog.* | wtmp | wtmp.* | wtmp-* | btmp | btmp.* | btmp-* | README)
perm_mask='0113'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="ug-x,o-wx"
l_auser="root"
l_agroup="(root|utmp)"
file_test_fix
;;
secure | auth.log | syslog | messages)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="u-x,g-wx,o-rwx"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
file_test_fix
;;
SSSD | sssd)
perm_mask='0117'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="ug-x,o-rwx"
l_auser="(root|SSSD)"
l_agroup="(root|SSSD)"
file_test_fix
;;
gdm | gdm3)
perm_mask='0117'
l_rperms="ug-x,o-rwx"
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|gdm|gdm3)"
file_test_fix
;;
*.journal | *.journal~)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="u-x,g-wx,o-rwx"
l_auser="root"
l_agroup="(root|systemd-journal)"
file_test_fix
;;
*)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="u-x,g-wx,o-rwx"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
Page 657
Note: You may also need to change the configuration for your logging software or
services for any logs that had incorrect permissions.
If there are services that log to other locations, ensure that those log files have the
appropriate access configured.
Page 658
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 659
The Linux Auditing System operates on a set of rules that collects certain types of
system activity to facilitate incident investigation, detect unauthorized access or
modification of data. By default events will be logged to /var/log/audit/audit.log,
which can be configured in /etc/audit/auditd.conf.
The following types of audit rules can be specified:
• On the command line using the auditctl utility. These rules are not persistent
across reboots.
• In /etc/audit/audit.rules. These rules have to be merged and loaded before
they are active.
Notes:
• For 64 bit systems that have arch as a rule parameter, you will need two rules:
one for 64 bit and one for 32 bit systems calls. For 32 bit systems, only one rule
is needed.
• If the auditing system is configured to be locked (-e 2), a system reboot will be
required in order to load any changes.
• Key names are optional on the rules and will not be used as a compliance
auditing. The usage of key names is highly recommended as it facilitates
organisation and searching, as such, all remediation steps will have key names
supplied.
• It is best practice to store the rules, in number prepended files, in
/etc/audit/rules.d/. Rules must end in a .rules suffix. This then requires the
use of augenrules to merge all the rules into /etc/audit/audit.rules based on
their their alphabetical (lexical) sort order. All benchmark recommendations
follow this best practice for remediation, specifically using the prefix of 50 which is
centre weighed if all rule sets make use of the number prepending naming
convention.
• Your system may have been customized to change the default UID_MIN. All
samples output uses 1000, but this value will not be used in compliance auditing.
To confirm the UID_MIN for your system, run the following command: awk
'/^\s*UID_MIN/{print $2}' /etc/login.defs
Page 660
• With regards to users whose login UID is not set, the values -1 / unset /
4294967295 are equivalent and normalized to -1.
• When comparing field types and both sides of the comparison is valid fields
types, such aseuid!=uid, then the auditing system may normalize such that the
output is uid!=euid.
• Some parts of the rule may be rearranged whilst others are dependant on
previous syntax. For example, the following two statements are the same:
-a always,exit -F arch=b64 -S execve -C uid!=euid -F auid!=-1 -F key=user_emulation
and
-a always,exit -F arch=b64 -C euid!=uid -F auid!=unset -S execve -k user_emulation
Capacity planning
The recommendations in this section implement auditing policies that not only produces
large quantities of logged data, but may also negatively impact system performance.
Capacity planning is critical in order not to adversely impact production environments.
Page 661
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Page 662
• Level 2 - Server
• Level 2 - Workstation
Description:
auditd is the userspace component to the Linux Auditing System. It's responsible for
writing audit records to the disk
Rationale:
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Audit:
Run the following command and verify auditd and audispd-plugins are installed:
# dpkg-query -s auditd &>/dev/null && echo "auditd is installed"
auditd is installed
Remediation:
Run the following command to Install auditd
# apt install auditd
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 663
Techniques / Sub-
Tactics Mitigations
techniques
Page 664
• Level 2 - Server
• Level 2 - Workstation
Description:
Turn on the auditd daemon to record system events.
Rationale:
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Audit:
Run the following command to verify auditd is enabled:
# systemctl is-enabled auditd
enabled
active
References:
Page 665
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 666
• Level 2 - Server
• Level 2 - Workstation
Description:
Configure grub2 so that processes that are capable of being audited can be audited
even if they start up prior to auditd startup.
Rationale:
Audit events need to be captured on processes that start up prior to auditd , so that
potential malicious activity cannot go undetected.
Audit:
Run the following command:
# find -L /boot -type f -name 'grub.cfg' -exec grep -Ph -- '^\h*linux\b' {} + | grep -v 'audit=1'
References:
Additional Information:
This recommendation is designed around the grub2 bootloader, if another bootloader is
in use in your environment enact equivalent settings.
Page 667
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 668
• Level 2 - Server
• Level 2 - Workstation
Description:
In the kernel-level audit subsystem, a socket buffer queue is used to hold audit events.
Whenever a new audit event is received, it is logged and prepared to be added to this
queue.
The kernel boot parameter audit_backlog_limit=N, with N representing the amount of
messages, will ensure that a queue cannot grow beyond a certain size. If an audit event
is logged which would grow the queue beyond this limit, then a failure occurs and is
handled according to the system configuration
Rationale:
If an audit event is logged which would grow the queue beyond the
audit_backlog_limit, then a failure occurs, auditd records will be lost, and potential
malicious activity could go undetected.
Audit:
Run the following command and verify the audit_backlog_limit= parameter is set:
# find -L /boot -type f -name 'grub.cfg' -exec grep -Ph -- '^\h*linux\b' {} + | grep -Pv
'audit_backlog_limit=\d+\b'
Default Value:
if audit_backlog_limit is not set, the system defaults to audit_backlog_limit=64
References:
Page 669
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 670
When auditing, it is important to carefully configure the storage requirements for audit
logs. By default, auditd will max out the log files at 5MB and retain only 4 copies of
them. Older versions will be deleted. It is possible on a system that the 20 MBs of audit
logs may fill up the system causing loss of audit data. While the recommendations here
provide guidance, check your site policy for audit storage requirements.
Page 671
• Level 2 - Server
• Level 2 - Workstation
Description:
Configure the maximum size of the audit log file. Once the log reaches the maximum
size, it will be rotated and a new log file will be started.
Rationale:
It is important that an appropriate size is determined for log files so that they do not
impact the system and audit data is not lost.
Audit:
Run the following command and ensure output is in compliance with site policy:
# grep -Po -- '^\h*max_log_file\h*=\h*\d+\b' /etc/audit/auditd.conf
max_log_file = <MB>
Remediation:
Set the following parameter in /etc/audit/auditd.conf in accordance with site policy:
max_log_file = <MB>
Default Value:
max_log_file = 8
References:
Additional Information:
The max_log_file parameter is measured in megabytes.
Other methods of log rotation may be appropriate based on site policy. One example is
time-based rotation strategies which don't have native support in auditd configurations.
Manual audit of custom configurations should be evaluated for effectiveness and
completeness.
Page 672
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 673
• Level 2 - Server
• Level 2 - Workstation
Description:
The max_log_file_action setting determines how to handle the audit log file reaching
the max file size. A value of keep_logs will rotate the logs but never delete old logs.
Rationale:
In high security contexts, the benefits of maintaining a long audit history exceed the cost
of storing the audit history.
Audit:
Run the following command and verify output matches:
# grep max_log_file_action /etc/audit/auditd.conf
max_log_file_action = keep_logs
Remediation:
Set the following parameter in /etc/audit/auditd.conf:
max_log_file_action = keep_logs
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 674
Techniques / Sub-
Tactics Mitigations
techniques
Page 675
• Level 2 - Server
• Level 2 - Workstation
Description:
The auditd daemon can be configured to halt the system when the audit logs are full.
The admin_space_left_action parameter tells the system what action to take when the
system has detected that it is low on disk space. Valid values are ignore, syslog,
suspend, single, and halt.
Rationale:
In high security contexts, the risk of detecting unauthorized access or nonrepudiation
exceeds the benefit of the system's availability.
Impact:
If the admin_space_left_action parameter is set to halt the audit daemon will
shutdown the system when the disk partition containing the audit logs becomes full.
Audit:
Run the following commands and verify output matches:
# grep space_left_action /etc/audit/auditd.conf
space_left_action = email
# grep action_mail_acct /etc/audit/auditd.conf
action_mail_acct = root
Run the following command and verify the output is either halt or single:
# grep -E 'admin_space_left_action\s*=\s*(halt|single)' /etc/audit/auditd.conf
admin_space_left_action = <halt|single>
Page 676
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 677
The Audit system operates on a set of rules that define what is to be captured in the log
files.
The following types of Audit rules can be specified:
• Control rules: Allow the Audit system's behavior and some of its configuration to
be modified.
• File system rules: Allow the auditing of access to a particular file or a directory.
(Also known as file watches)
• System call rules: Allow logging of system calls that any specified program
makes.
• on the command line using the auditctl utility. Note that these rules are not
persistent across reboots.
• in a file ending in .rules in the /etc/audit/audit.d/ directory.
Page 678
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor scope changes for system administrators. If the system has been properly
configured to force system administrators to log in as themselves first and then use the
sudo command to execute privileged commands, it is possible to monitor changes in
scope. The file /etc/sudoers, or files in /etc/sudoers.d, will be written to when the
file(s) or related attributes have changed. The audit records will be tagged with the
identifier "scope".
Rationale:
Changes in the /etc/sudoers and /etc/sudoers.d files can indicate that an
unauthorized change has been made to the scope of system administrator activity.
Page 679
On disk configuration
Running configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor scope changes for system administrators.
Example:
# printf "
-w /etc/sudoers -p wa -k scope
-w /etc/sudoers.d -p wa -k scope
" >> /etc/audit/rules.d/50-scope.rules
References:
Additional Information:
Page 680
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 681
• Level 2 - Server
• Level 2 - Workstation
Description:
sudo provides users with temporary elevated privileges to perform operations, either as
the superuser or another user.
Rationale:
Creating an audit log of users with temporary elevated privileges and the operation(s)
they performed is essential to reporting. Administrators will want to correlate the events
written to the audit trail with the records written to sudo's logfile to verify if unauthorized
commands have been executed.
Page 682
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&(/ -C *euid!=uid/||/ -C *uid!=euid/) \
&&/ -S *execve/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Running configuration
Run the following command to check loaded rules:
# auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&(/ -C *euid!=uid/||/ -C *uid!=euid/) \
&&/ -S *execve/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 683
Example:
# printf "
-a always,exit -F arch=b64 -C euid!=uid -F auid!=unset -S execve -k user_emulation
-a always,exit -F arch=b32 -C euid!=uid -F auid!=unset -S execve -k user_emulation
" >> /etc/audit/rules.d/50-user_emulation.rules
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 684
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 685
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the sudo log file. If the system has been properly configured to disable the use
of the su command and force all administrators to have to log in first and then use sudo
to execute privileged commands, then all administrator commands will be logged to
/var/log/sudo.log . Any time a command is executed, an audit event will be triggered
as the /var/log/sudo.log file will be opened for write and the executed administration
command will be written to the log.
Rationale:
Changes in /var/log/sudo.log indicate that an administrator has executed a command
or the log file itself has been tampered with. Administrators will want to correlate the
events written to the audit trail with the records written to /var/log/sudo.log to verify if
unauthorized commands have been executed.
Page 686
On disk configuration
Running configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor events that modify the sudo log file.
Example:
# {
SUDO_LOG_FILE=$(grep -r logfile /etc/sudoers* | sed -e 's/.*logfile=//;s/,? .*//' -e 's/"//g')
[ -n "${SUDO_LOG_FILE}" ] && printf "
-w ${SUDO_LOG_FILE} -p wa -k sudo_log_file
" >> /etc/audit/rules.d/50-sudo.rules || printf "ERROR: Variable 'SUDO_LOG_FILE_ESCAPED' is unset.\n"
}
Page 687
Additional Information:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 688
• Level 2 - Server
• Level 2 - Workstation
Description:
Capture events where the system date and/or time has been modified. The parameters
in this section are set to determine if the;
system calls have been executed. Further, ensure to write an audit record to the
configured audit log file upon exit, tagging the records with a unique identifier such as
"time-change".
Rationale:
Unexpected changes in system date and/or time could be a sign of malicious activity on
the system.
Page 689
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&/ -S/ \
&&(/adjtimex/ \
||/settimeofday/ \
||/clock_settime/ ) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Running configuration
Run the following command to check loaded rules:
# {
auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&/ -S/ \
&&(/adjtimex/ \
||/settimeofday/ \
||/clock_settime/ ) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
In addition, also audit for the stime system call rule. For example:
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime,stime -k time-change
Page 690
Example:
# printf "
-a always,exit -F arch=b64 -S adjtimex,settimeofday,clock_settime -k time-change
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime -k time-change
-w /etc/localtime -p wa -k time-change
" >> /etc/audit/rules.d/50-time-change.rules
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64. In
addition, add stime to the system call audit. Example:
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime,stime -k time-change
References:
Additional Information:
Page 691
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 692
• Level 2 - Server
• Level 2 - Workstation
Description:
Record changes to network environment files or system calls. The below parameters
monitors the following system calls, and write an audit event on system call exit:
Rationale:
Monitoring sethostname and setdomainname will identify potential unauthorized changes
to host and domainname of a system. The changing of these names could potentially
break security parameters that are set based on those names. The /etc/hosts file is
monitored for changes that can indicate an unauthorized intruder is trying to change
machine associations with IP addresses and trick users and processes into connecting
to unintended machines. Monitoring /etc/issue and /etc/issue.net is important, as
intruders could put disinformation into those files and trick users into providing
information to the intruder. Monitoring /etc/network is important as it can show if
network interfaces or scripts are being modified in a way that can lead to the machine
becoming unavailable or compromised. All audit records should have a relevant tag
associated with them.
Page 693
64 Bit systems
On disk configuration
Run the following commands to check the on disk rules:
# awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&/ -S/ \
&&(/sethostname/ \
||/setdomainname/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Running configuration
Run the following command to check loaded rules:
# auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&/ -S/ \
&&(/sethostname/ \
||/setdomainname/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64
Page 694
Example:
# printf "
-a always,exit -F arch=b64 -S sethostname,setdomainname -k system-locale
-a always,exit -F arch=b32 -S sethostname,setdomainname -k system-locale
-w /etc/issue -p wa -k system-locale
-w /etc/issue.net -p wa -k system-locale
-w /etc/hosts -p wa -k system-locale
-w /etc/networks -p wa -k system-locale
-w /etc/network/ -p wa -k system-locale
" >> /etc/audit/rules.d/50-system_locale.rules
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 695
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 696
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor privileged programs, those that have the setuid and/or setgid bit set on
execution, to determine if unprivileged users are running these commands.
Rationale:
Execution of privileged commands by non-privileged users could be an indication of
someone trying to gain unauthorized access to the system.
Impact:
Both the audit and remediation section of this recommendation will traverse all mounted
file systems that is not mounted with either noexec or nosuid mount options. If there are
large file systems without these mount options, such traversal will be significantly
detrimental to the performance of the system.
Before running either the audit or remediation section, inspect the output of the following
command to determine exactly which file systems will be traversed:
# findmnt -n -l -k -it $(awk '/nodev/ { print $2 }' /proc/filesystems | paste -sd,) | grep -Pv "noexec|nosuid"
To exclude a particular file system due to adverse performance impacts, update the
audit and remediation sections by adding a sufficiently unique string to the grep
statement. The above command can be used to test the modified exclusions.
Page 697
On disk configuration
Running configuration
If there are any special mount points that are not visible by default from findmnt as per
the above audit, said file systems would have to be manually audited.
Page 698
If there are any special mount points that are not visible by default from just scanning /,
change the PARTITION variable to the appropriate partition and re-run the remediation.
References:
Additional Information:
Page 699
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 700
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor for unsuccessful attempts to access files. The following parameters are
associated with system calls that control files:
• creation - creat
• opening - open , openat
• truncation - truncate , ftruncate
An audit log record will only be written if all of the following criteria is met for the user
when trying to access a file:
Rationale:
Failed attempts to open, create or truncate files could be an indication that an individual
or process is trying to gain unauthorized access to the system.
Page 701
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&(/ -F *exit=-EACCES/||/ -F *exit=-EPERM/) \
&&/ -S/ \
&&/creat/ \
&&/open/ \
&&/truncate/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&(/ -F *exit=-EACCES/||/ -F *exit=-EPERM/) \
&&/ -S/ \
&&/creat/ \
&&/open/ \
&&/truncate/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 702
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S creat,open,openat,truncate,ftruncate -F exit=-EACCES -F auid>=${UID_MIN} -F
auid!=unset -k access
-a always,exit -F arch=b64 -S creat,open,openat,truncate,ftruncate -F exit=-EPERM -F auid>=${UID_MIN} -F
auid!=unset -k access
-a always,exit -F arch=b32 -S creat,open,openat,truncate,ftruncate -F exit=-EACCES -F auid>=${UID_MIN} -F
auid!=unset -k access
-a always,exit -F arch=b32 -S creat,open,openat,truncate,ftruncate -F exit=-EPERM -F auid>=${UID_MIN} -F
auid!=unset -k access
" >> /etc/audit/rules.d/50-access.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 703
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 704
• Level 2 - Server
• Level 2 - Workstation
Description:
Record events affecting the modification of user or group information, including that of
passwords and old passwords if in use.
The parameters in this section will watch the files to see if they have been opened for
write or have had attribute changes (e.g. permissions) and tag them with the identifier
"identity" in the audit log file.
Rationale:
Unexpected changes to these files could be an indication that the system has been
compromised and that an unauthorized user is attempting to hide their activities or
compromise additional accounts.
Page 705
On disk configuration
Running configuration
Page 706
References:
Additional Information:
Controls
Control IG 1 IG 2 IG 3
Version
Page 707
Techniques / Sub-
Tactics Mitigations
techniques
Page 708
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor changes to file permissions, attributes, ownership and group. The parameters in
this section track changes for system calls that affect file permissions and attributes.
The following commands and system calls effect the permissions, ownership and
various attributes of files.
• chmod
• fchmod
• fchmodat
• chown
• fchown
• fchownat
• lchown
• setxattr
• lsetxattr
• fsetxattr
• removexattr
• lremovexattr
• fremovexattr
In all cases, an audit record will only be written for non-system user ids and will ignore
Daemon events. All audit records will be tagged with the identifier "perm_mod."
Rationale:
Monitoring for changes in file attributes could alert a system administrator to activity that
could indicate intruder activity or policy violation.
Page 709
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -S/ \
&&/ -F *auid>=${UID_MIN}/ \
&&(/chmod/||/fchmod/||/fchmodat/ \
||/chown/||/fchown/||/fchownat/||/lchown/ \
||/setxattr/||/lsetxattr/||/fsetxattr/ \
||/removexattr/||/lremovexattr/||/fremovexattr/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -S/ \
&&/ -F *auid>=${UID_MIN}/ \
&&(/chmod/||/fchmod/||/fchmodat/ \
||/chown/||/fchown/||/fchownat/||/lchown/ \
||/setxattr/||/lsetxattr/||/fsetxattr/ \
||/removexattr/||/lremovexattr/||/fremovexattr/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 710
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat -F auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b64 -S chown,fchown,lchown,fchownat -F auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b64 -S setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
" >> /etc/audit/rules.d/50-perm_mod.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 711
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 712
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the use of the mount system call. The mount (and umount ) system call controls
the mounting and unmounting of file systems. The parameters below configure the
system to create an audit record when the mount system call is used by a non-
privileged user
Rationale:
It is highly unusual for a non privileged user to mount file systems to the system. While
tracking mount commands gives the system administrator evidence that external media
may have been mounted (based on a review of the source of the mount and confirming
it's an external media type), it does not conclusively indicate that data was exported to
the media. System administrators who wish to determine if data were exported, would
also have to track successful open, creat and truncate system calls requiring write
access to a file under the mount point of the external media file system. This could give
a fair indication that a write occurred. The only way to truly prove it, would be to track
successful writes to the external media. Tracking write system calls could quickly fill up
the audit log and is not recommended. Recommendations on configuration options to
track data export to media is beyond the scope of this document.
Page 713
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&/mount/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&/mount/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 714
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b32 -S mount -F auid>=$UID_MIN -F auid!=unset -k mounts
-a always,exit -F arch=b64 -S mount -F auid>=$UID_MIN -F auid!=unset -k mounts
" >> /etc/audit/rules.d/50-mounts.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 715
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 716
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor session initiation events. The parameters in this section track changes to the
files associated with session events.
Page 717
On disk configuration
Running configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor session initiation information.
Example:
# printf "
-w /var/run/utmp -p wa -k session
-w /var/log/wtmp -p wa -k session
-w /var/log/btmp -p wa -k session
" >> /etc/audit/rules.d/50-session.rules
Page 718
Additional Information:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 719
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor login and logout events. The parameters below track changes to files
associated with login/logout events.
Rationale:
Monitoring login/logout events could provide a system administrator with information
associated with brute force attacks against user logins.
Page 720
On disk configuration
Running configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor login and logout events.
Example:
# printf "
-w /var/log/lastlog -p wa -k logins
-w /var/run/faillock -p wa -k logins
" >> /etc/audit/rules.d/50-login.rules
Page 721
Additional Information:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 722
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the use of system calls associated with the deletion or renaming of files and file
attributes. This configuration statement sets up monitoring for:
Rationale:
Monitoring these calls from non-privileged users could provide a system administrator
with evidence that inappropriate removal of files and file attributes associated with
protected files is occurring. While this audit option will look at all events, system
administrators will want to look for specific privileged files that are being deleted or
altered.
Page 723
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&(/unlink/||/rename/||/unlinkat/||/renameat/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&(/unlink/||/rename/||/unlinkat/||/renameat/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 724
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S rename,unlink,unlinkat,renameat -F auid>=${UID_MIN} -F auid!=unset -F key=delete
-a always,exit -F arch=b32 -S rename,unlink,unlinkat,renameat -F auid>=${UID_MIN} -F auid!=unset -F key=delete
" >> /etc/audit/rules.d/50-delete.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 725
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 726
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor AppArmor, an implementation of mandatory access controls. The parameters
below monitor any write access (potential additional, deletion or modification of files in
the directory) or attribute changes to the /etc/apparmor/ and /etc/apparmor.d/
directories.
Note: If a different Mandatory Access Control method is used, changes to the
corresponding directories should be audited.
Rationale:
Changes to files in the /etc/apparmor/ and /etc/apparmor.d/ directories could indicate
that an unauthorized user is attempting to modify access controls and change security
contexts, leading to a compromise of the system.
Page 727
On disk configuration
Running configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor events that modify the system's Mandatory Access
Controls.
Example:
# printf "
-w /etc/apparmor/ -p wa -k MAC-policy
-w /etc/apparmor.d/ -p wa -k MAC-policy
" >> /etc/audit/rules.d/50-MAC-policy.rules
References:
Page 728
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 729
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the chcon command.
Rationale:
The chcon command is used to change file security context. Without generating audit
records that are specific to the security and mission needs of the organization, it would
be difficult to establish, correlate, and investigate the events relating to an incident or
identify those responsible for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 730
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chcon/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chcon/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 731
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/bin/chcon -F perm=x -F auid>=${UID_MIN} -F auid!=unset -k perm_chng
" >> /etc/audit/rules.d/50-perm_chng.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 732
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 733
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the setfacl command
Rationale:
This utility sets Access Control Lists (ACLs) of files and directories. Without generating
audit records that are specific to the security and mission needs of the organization, it
would be difficult to establish, correlate, and investigate the events relating to an
incident or identify those responsible for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 734
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/setfacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules || printf "ERROR: Variable 'UID_MIN' is
unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/setfacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 735
64 Bit systems
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/bin/setfacl -F perm=x -F auid>=${UID_MIN} -F auid!=unset -k perm_chng
" >> /etc/audit/rules.d/50-perm_chng.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 736
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 737
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the chacl command.
chacl is an IRIX-compatibility command, and is maintained for those users who are
familiar with its use from either XFS or IRIX.
Rationale:
chacl changes the ACL(s) for a file or directory. Without generating audit records that
are specific to the security and mission needs of the organization, it would be difficult to
establish, correlate, and investigate the events relating to an incident or identify those
responsible for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 738
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 739
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/bin/chacl -F perm=x -F auid>=${UID_MIN} -F auid!=unset -k perm_chng
" >> /etc/audit/rules.d/50-perm_chng.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 740
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 741
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the usermod command.
Rationale:
The usermod command modifies the system account files to reflect the changes that are
specified on the command line. Without generating audit records that are specific to the
security and mission needs of the organization, it would be difficult to establish,
correlate, and investigate the events relating to an incident or identify those responsible
for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 742
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/sbin\/usermod/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/sbin\/usermod/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 743
64 Bit systems
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/sbin/usermod -F perm=x -F auid>=${UID_MIN} -F auid!=unset -k usermod
" >> /etc/audit/rules.d/50-usermod.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Page 744
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 745
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the loading and unloading of kernel modules. All the loading / listing /
dependency checking of modules is done by kmod via symbolic links.
The following system calls control loading and unloading of modules:
Any execution of the loading and unloading module programs and system calls will
trigger an audit record with an identifier of modules.
Rationale:
Monitoring the use of all the various ways to manipulate kernel modules could provide
system administrators with evidence that an unauthorized change was made to a kernel
module, possibly compromising the security of the system.
Page 746
64 Bit systems
On disk configuration
Run the following commands to check the on disk rules:
# {
awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F auid!=unset/||/ -F auid!=-1/||/ -F auid!=4294967295/) \
&&/ -S/ \
&&(/init_module/ \
||/finit_module/ \
||/delete_module/ \
||/create_module/ \
||/query_module/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Running configuration
Run the following command to check loaded rules:
# {
auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&(/ -F auid!=unset/||/ -F auid!=-1/||/ -F auid!=4294967295/) \
&&/ -S/ \
&&(/init_module/ \
||/finit_module/ \
||/delete_module/ \
||/create_module/ \
||/query_module/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
Page 747
Verify the output states OK. If there is a symlink pointing to a different location it should
be investigated.
Remediation:
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S init_module,finit_module,delete_module,create_module,query_module -F
auid>=${UID_MIN} -F auid!=unset -k kernel_modules
-a always,exit -F path=/usr/bin/kmod -F perm=x -F auid>=${UID_MIN} -F auid!=unset -k kernel_modules
" >> /etc/audit/rules.d/50-kernel_modules.rules || printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Page 748
Additional Information:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 749
• Level 2 - Server
• Level 2 - Workstation
Description:
Set system audit so that audit rules cannot be modified with auditctl . Setting the flag
"-e 2" forces audit to be put in immutable mode. Audit changes can only be made on
system reboot.
Note: This setting will require the system to be rebooted to update the active auditd
configuration settings.
Rationale:
In immutable mode, unauthorized users cannot execute changes to the audit system to
potentially hide malicious activity and then put the audit rules back. Users would most
likely notice a system reboot and that could alert administrators of an attempt to make
unauthorized audit changes.
Audit:
Run the following command and verify output matches:
# grep -Ph -- '^\h*-e\h+2\b' /etc/audit/rules.d/*.rules | tail -1
-e 2
Remediation:
Edit or create the file /etc/audit/rules.d/99-finalize.rules and add the line -e 2 at
the end of the file:
Example:
# printf -- "-e 2
" >> /etc/audit/rules.d/99-finalize.rules
References:
Page 750
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 751
• Level 2 - Server
• Level 2 - Workstation
Description:
The Audit system have both on disk and running configuration. It is possible for these
configuration settings to differ.
Note: Due to the limitations of augenrules and auditctl, it is not absolutely guaranteed
that loading the rule sets via augenrules --load will result in all rules being loaded or
even that the user will be informed if there was a problem loading the rules.
Rationale:
Configuration differences between what is currently running and what is on disk could
cause unexpected problems or may give a false impression of compliance
requirements.
Audit:
/usr/sbin/augenrules: No change
Should there be any drift, run augenrules --load to merge and load all rules.
Remediation:
If the rules are not aligned across all three () areas, run the following command to
merge and load all rules:
# augenrules --load
References:
Page 752
Controls
Control IG 1 IG 2 IG 3
Version
Page 753
Without the capability to restrict which roles and individuals can select which events are
audited, unauthorized personnel may be able to prevent the auditing of critical events.
Page 754
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit log files contain information about the system and system activity.
Rationale:
Access to audit records can reveal system and configuration data to attackers,
potentially compromising its confidentiality.
Audit:
Run the following command to verify audit log files have mode 0640 or less permissive:
# [ -f /etc/audit/auditd.conf ] && find "$(dirname $(awk -F "=" '/^\s*log_file/ {print $2}'
/etc/audit/auditd.conf | xargs))" -type f -perm /0137 -exec stat -Lc "%n %#a" {} +
References:
Page 755
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 756
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit log files contain information about the system and system activity.
Rationale:
Access to audit records can reveal system and configuration data to attackers,
potentially compromising its confidentiality.
Audit:
Run the following command to verify audit log files are owned by the root user:
# [ -f /etc/audit/auditd.conf ] && find "$(dirname $(awk -F "=" '/^\s*log_file/ {print $2}'
/etc/audit/auditd.conf | xargs))" -type f ! -user root -exec stat -Lc "%n %U" {} +
References:
Page 757
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 758
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit log files contain information about the system and system activity.
Rationale:
Access to audit records can reveal system and configuration data to attackers,
potentially compromising its confidentiality.
Audit:
Run the following command to verify log_group parameter is set to either adm or root in
/etc/audit/auditd.conf:
# grep -Piws -- '^\h*log_group\h*=\h*\H+\b' /etc/audit/auditd.conf | grep -Pvi -- '(adm)'
{
if [ -e /etc/audit/auditd.conf ]; then
l_fpath="$(dirname "$(awk -F "=" '/^\s*log_file/ {print $2}' /etc/audit/auditd.conf | xargs)")"
find -L "$l_fpath" -not -path "$l_fpath"/lost+found -type f \( ! -group root -a ! -group adm \) -exec ls
-l {} +
fi
}
Page 759
Run the following command to set the log_group parameter in the audit configuration
file to log_group = adm:
# sed -ri 's/^\s*#?\s*log_group\s*=\s*\S+(\s*#.*)?.*$/log_group = adm\1/' /etc/audit/auditd.conf
Run the following command to restart the audit daemon to reload the configuration file:
# systemctl restart auditd
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 760
• Level 2 - Server
• Level 2 - Workstation
Description:
The audit log directory contains audit log files.
Rationale:
Audit information includes all information including: audit records, audit settings and
audit reports. This information is needed to successfully audit system activity. This
information must be protected from unauthorized modification or deletion. If this
information were to be compromised, forensic analysis and discovery of the true source
of potentially malicious system activity is impossible to achieve.
Audit:
Run the following command to verify that the audit log directory has a mode of 0750 or
less permissive:
# stat -Lc "%n %a" "$(dirname $( awk -F"=" '/^\s*log_file/ {print $2}' /etc/audit/auditd.conf))" | grep -Pv --
'^\h*\H+\h+([0,5,7][0,5]0)'
Default Value:
750
References:
Page 761
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 762
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit configuration files control auditd and what events are audited.
Rationale:
Access to the audit configuration files could allow unauthorized personnel to prevent the
auditing of critical events.
Misconfigured audit configuration files may prevent the auditing of critical events or
impact the system's performance by overwhelming the audit log. Misconfiguration of the
audit configuration files may also make it more difficult to establish and investigate
events relating to an incident.
Audit:
Run the following command to verify that the audit configuration files have mode 640 or
more restrictive and are owned by the root user and root group:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) -exec stat -Lc "%n %a" {} + | grep -Pv --
'^\h*\H+\h*([0,2,4,6][0,4]0)\h*$'
References:
Page 763
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 764
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit configuration files control auditd and what events are audited.
Rationale:
Access to the audit configuration files could allow unauthorized personnel to prevent the
auditing of critical events.
Misconfigured audit configuration files may prevent the auditing of critical events or
impact the system's performance by overwhelming the audit log. Misconfiguration of the
audit configuration files may also make it more difficult to establish and investigate
events relating to an incident.
Audit:
Run the following command to verify that the audit configuration files have mode 640 or
more restrictive and are owned by the root user and root group:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) ! -user root
References:
Page 765
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 766
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit configuration files control auditd and what events are audited.
Rationale:
Access to the audit configuration files could allow unauthorized personnel to prevent the
auditing of critical events.
Misconfigured audit configuration files may prevent the auditing of critical events or
impact the system's performance by overwhelming the audit log. Misconfiguration of the
audit configuration files may also make it more difficult to establish and investigate
events relating to an incident.
Audit:
Run the following command to verify that the audit configuration files have mode 640 or
more restrictive and are owned by the root user and root group:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) ! -group root
References:
Page 767
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 768
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting audit information includes identifying and protecting the tools used to view
and manipulate log data. Protecting audit tools is necessary to prevent unauthorized
operation on audit information.
Audit:
Run the following command to verify the audit tools have mode 755 or more restrictive,
are owned by the root user and group root:
# stat -c "%n %a" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd /sbin/augenrules |
grep -Pv -- '^\h*\H+\h+([0-7][0,1,4,5][0,1,4,5])\h*$'
References:
Page 769
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 770
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting audit information includes identifying and protecting the tools used to view
and manipulate log data. Protecting audit tools is necessary to prevent unauthorized
operation on audit information.
Audit:
Run the following command to verify the audit tools have mode 755 or more restrictive,
are owned by the root user and group root:
# stat -c "%n %U" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd /sbin/augenrules |
grep -Pv -- '^\h*\H+\h+root\h*$'
References:
Page 771
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 772
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting audit information includes identifying and protecting the tools used to view
and manipulate log data. Protecting audit tools is necessary to prevent unauthorized
operation on audit information.
Audit:
Run the following command to verify the audit tools have mode 755 or more restrictive,
are owned by the root user and group root:
# stat -c "%n %a %U %G" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd
/sbin/augenrules | grep -Pv -- '^\h*\H+\h+([0-7][0,1,4,5][0,1,4,5])\h+root\h+root\h*$'
Run the following command to change owner and group of the audit tools to root user
and group:
# chown root:root /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd /sbin/augenrules
References:
Page 773
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 774
• Level 1 - Server
• Level 1 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting the integrity of the tools used for auditing purposes is a critical step toward
ensuring the integrity of audit information. Audit information includes all information
(e.g., audit records, audit settings, and audit reports) needed to successfully audit
information system activity.
Attackers may replace the audit tools or inject code into the existing tools with the
purpose of providing the capability to hide or erase system activity from the audit logs.
Audit tools should be cryptographically signed in order to provide the capability to
identify when the audit tools have been modified, manipulated, or replaced. An example
is a checksum hash of the file or files.
Audit:
Verify that Advanced Intrusion Detection Environment (AIDE) is properly configured .
Run the following command to verify that AIDE is configured to use cryptographic
mechanisms to protect the integrity of audit tools:
# grep -Ps -- '(\/sbin\/(audit|au)\H*\b)' /etc/aide.conf /etc/aide/aide.conf /etc/aide.conf.d/*.conf
/etc/aide/aide.conf.d/*
Page 775
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 776
Page 777
This section provides guidance on securing aspects of system files and directories.
Page 778
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/passwd file contains user account information that is used by many system
utilities and therefore must be readable for these utilities to operate.
Rationale:
It is critical to ensure that the /etc/passwd file is protected from unauthorized write
access. Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/passwd is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/passwd
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/passwd:
# chmod u-x,go-wx /etc/passwd
# chown root:root /etc/passwd
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 779
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 780
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/passwd- file contains backup user account information.
Rationale:
It is critical to ensure that the /etc/passwd- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/passwd- is mode 644 or more restrictive, Uid
is 0/root and Gid is 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/ %G)' /etc/passwd-
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/passwd-:
# chmod u-x,go-wx /etc/passwd-
# chown root:root /etc/passwd-
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: { 0/ root)
References:
Page 781
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 782
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/group file contains a list of all the valid groups defined in the system. The
command below allows read/write access for root and read access for everyone else.
Rationale:
The /etc/group file needs to be protected from unauthorized changes by non-privileged
users, but needs to be readable as this information is used with many non-privileged
programs.
Audit:
Run the following command to verify /etc/group is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/group
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/group:
# chmod u-x,go-wx /etc/group
# chown root:root /etc/group
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 783
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 784
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/group- file contains a backup list of all the valid groups defined in the system.
Rationale:
It is critical to ensure that the /etc/group- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/group- is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/group-
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/group-:
# chmod u-x,go-wx /etc/group-
# chown root:root /etc/group-
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 785
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 786
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/shadow file is used to store the information about user accounts that is critical
to the security of those accounts, such as the hashed password and other security
information.
Rationale:
If attackers can gain read access to the /etc/shadow file, they can easily run a
password cracking program against the hashed password to break it. Other security
information that is stored in the /etc/shadow file (such as expiration) could also be
useful to subvert the user accounts.
Audit:
Run the following command to verify /etc/shadow is mode 640 or more restrictive, Uid is
0/root and Gid is 0/root or ({GID}/ shadow):
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/shadow
Example:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
Remediation:
Run one of the following commands to set ownership of /etc/shadow to root and group
to either root or shadow:
# chown root:shadow /etc/shadow
-OR-
# chown root:root /etc/shadow
Default Value:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
References:
Page 787
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 788
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/shadow- file is used to store backup information about user accounts that is
critical to the security of those accounts, such as the hashed password and other
security information.
Rationale:
It is critical to ensure that the /etc/shadow- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/shadow- is mode 640 or more restrictive, Uid
is 0/root and Gid is 0/root or {GID}/shadow:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/shadow-
Example:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
Remediation:
Run one of the following commands to set ownership of /etc/shadow- to root and
group to either root or shadow:
# chown root:shadow /etc/shadow-
-OR-
# chown root:root /etc/shadow-
Default Value:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
References:
Page 789
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 790
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/gshadow file is used to store the information about groups that is critical to the
security of those accounts, such as the hashed password and other security
information.
Rationale:
If attackers can gain read access to the /etc/gshadow file, they can easily run a
password cracking program against the hashed password to break it. Other security
information that is stored in the /etc/gshadow file (such as group administrators) could
also be useful to subvert the group.
Audit:
Run the following command to verify /etc/gshadow is mode 640 or more restrictive, Uid
is 0/root and Gid is 0/root or `{GID}/shadow:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/gshadow
Example:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
Remediation:
Run one of the following commands to set ownership of /etc/gshadow to root and
group to either root or shadow:
# chown root:shadow /etc/gshadow
-OR-
# chown root:root /etc/gshadow
Default Value:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
References:
Page 791
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 792
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/gshadow- file is used to store backup information about groups that is critical
to the security of those accounts, such as the hashed password and other security
information.
Rationale:
It is critical to ensure that the /etc/gshadow- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/gshadow- is mode 640 or more restrictive, Uid
is 0/root and Gid is 0/root or {GID}/shadow:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/gshadow-
Example:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
Remediation:
Run one of the following commands to set ownership of /etc/gshadow- to root and
group to either root or shadow:
# chown root:shadow /etc/gshadow-
-OR-
# chown root:root /etc/gshadow-
Default Value:
Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 42/ shadow)
References:
Page 793
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 794
• Level 1 - Server
• Level 1 - Workstation
Description:
/etc/security/opasswd and it's backup /etc/security/opasswd.old hold user's
previous passwords if pam_unix or pam_pwhistory is in use on the system
Rationale:
It is critical to ensure that /etc/security/opasswd is protected from unauthorized
access. Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following commands to verify /etc/security/opasswd and
/etc/security/opasswd.old are mode 600 or more restrictive, Uid is 0/root and Gid is
0/root if they exist:
# [ -e "/etc/security/opasswd" ] && stat -Lc '%n Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)'
/etc/security/opasswd
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/security/opasswd and /etc/security/opasswd.old is they exist:
# [ -e "/etc/security/opasswd" ] && chmod u-x,go-rwx /etc/security/opasswd
# [ -e "/etc/security/opasswd" ] && chown root:root /etc/security/opasswd
# [ -e "/etc/security/opasswd.old" ] && chmod u-x,go-rwx /etc/security/opasswd.old
# [ -e "/etc/security/opasswd.old" ] && chown root:root /etc/security/opasswd.old
Default Value:
/etc/security/opasswd Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 795
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 796
• Level 1 - Server
• Level 1 - Workstation
Description:
World writable files are the least secure. Data in world-writable files can be modified and
compromised by any user on the system. World writable files may also indicate an
incorrectly written script or program that could potentially be the cause of a larger
compromise to the system's integrity. See the chmod(2) man page for more information.
Setting the sticky bit on world writable directories prevents users from deleting or
renaming files in that directory that are not owned by them.
Rationale:
Data in world-writable files can be modified and compromised by any user on the
system. World writable files may also indicate an incorrectly written script or program
that could potentially be the cause of a larger compromise to the system's integrity.
This feature prevents the ability to delete or rename files in world writable directories
(such as /tmp ) that are owned by another user.
Page 797
{
l_output="" l_output2=""
l_smask='01000'
a_file=(); a_dir=() # Initialize arrays
a_path=(! -path "/run/user/*" -a ! -path "/proc/*" -a ! -path "*/containerd/*" -a ! -path "*/kubelet/pods/*"
-a ! -path "*/kubelet/plugins/*" -a ! -path "/sys/*" -a ! -path "/snap/*")
while IFS= read -r l_mount; do
while IFS= read -r -d $'\0' l_file; do
if [ -e "$l_file" ]; then
[ -f "$l_file" ] && a_file+=("$l_file") # Add WR files
if [ -d "$l_file" ]; then # Add directories w/o sticky bit
l_mode="$(stat -Lc '%#a' "$l_file")"
[ ! $(( $l_mode & $l_smask )) -gt 0 ] && a_dir+=("$l_file")
fi
fi
done < <(find "$l_mount" -xdev \( "${a_path[@]}" \) \( -type f -o -type d \) -perm -0002 -print0 2>
/dev/null)
done < <(findmnt -Dkerno fstype,target | awk '($1 !~ /^\s*(nfs|proc|smb|vfat|iso9660|efivarfs|selinuxfs)/ &&
$2 !~ /^(\/run\/user\/|\/tmp|\/var\/tmp)/){print $2}')
if ! (( ${#a_file[@]} > 0 )); then
l_output="$l_output\n - No world writable files exist on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_file[@]}")\" World writable files on the
system.\n - The following is a list of World writable files:\n$(printf '%s\n' "${a_file[@]}")\n - end of
list\n"
fi
if ! (( ${#a_dir[@]} > 0 )); then
l_output="$l_output\n - Sticky bit is set on world writable directories on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_dir[@]}")\" World writable directories without
the sticky bit on the system.\n - The following is a list of World writable directories without the sticky
bit:\n$(printf '%s\n' "${a_dir[@]}")\n - end of list\n"
fi
unset a_path; unset a_arr; unset a_file; unset a_dir # Remove arrays
# If l_output2 is empty, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "- * Correctly configured * :\n$l_output\n"
fi
}
Note: On systems with a large number of files and/or directories, this audit may be a
long running process
Page 798
{
l_smask='01000'
a_file=(); a_dir=() # Initialize arrays
a_path=(! -path "/run/user/*" -a ! -path "/proc/*" -a ! -path "*/containerd/*" -a ! -path "*/kubelet/pods/*"
-a ! -path "*/kubelet/plugins/*" -a ! -path "/sys/*" -a ! -path "/snap/*")
while IFS= read -r l_mount; do
while IFS= read -r -d $'\0' l_file; do
if [ -e "$l_file" ]; then
l_mode="$(stat -Lc '%#a' "$l_file")"
if [ -f "$l_file" ]; then # Remove excess permissions from WW files
echo -e " - File: \"$l_file\" is mode: \"$l_mode\"\n - removing write permission on \"$l_file\"
from \"other\""
chmod o-w "$l_file"
fi
if [ -d "$l_file" ]; then # Add sticky bit
if [ ! $(( $l_mode & $l_smask )) -gt 0 ]; then
echo -e " - Directory: \"$l_file\" is mode: \"$l_mode\" and doesn't have the sticky bit set\n
- Adding the sticky bit"
chmod a+t "$l_file"
fi
fi
fi
done < <(find "$l_mount" -xdev \( "${a_path[@]}" \) \( -type f -o -type d \) -perm -0002 -print0 2>
/dev/null)
done < <(findmnt -Dkerno fstype,target | awk '($1 !~ /^\s*(nfs|proc|smb|vfat|iso9660|efivarfs|selinuxfs)/ &&
$2 !~ /^(\/run\/user\/|\/tmp|\/var\/tmp)/){print $2}')
}
Page 799
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 800
• Level 1 - Server
• Level 1 - Workstation
Description:
Administrators may delete users or groups from the system and neglect to remove all
files and/or directories owned by those users or groups.
Rationale:
A new user or group who is assigned a deleted user's user ID or group ID may then end
up "owning" a deleted user or group's files, and thus have more access on the system
than was intended.
Page 801
{
l_output="" l_output2=""
a_nouser=(); a_nogroup=() # Initialize arrays
a_path=(! -path "/run/user/*" -a ! -path "/proc/*" -a ! -path "*/containerd/*" -a ! -path "*/kubelet/pods/*"
-a ! -path "*/kubelet/plugins/*" -a ! -path "/sys/fs/cgroup/memory/*" -a ! -path "/var/*/private/*")
while IFS= read -r l_mount; do
while IFS= read -r -d $'\0' l_file; do
if [ -e "$l_file" ]; then
while IFS=: read -r l_user l_group; do
[ "$l_user" = "UNKNOWN" ] && a_nouser+=("$l_file")
[ "$l_group" = "UNKNOWN" ] && a_nogroup+=("$l_file")
done < <(stat -Lc '%U:%G' "$l_file")
fi
done < <(find "$l_mount" -xdev \( "${a_path[@]}" \) \( -type f -o -type d \) \( -nouser -o -nogroup \) -
print0 2> /dev/null)
done < <(findmnt -Dkerno fstype,target | awk '($1 !~ /^\s*(nfs|proc|smb|vfat|iso9660|efivarfs|selinuxfs)/ &&
$2 !~ /^\/run\/user\//){print $2}')
if ! (( ${#a_nouser[@]} > 0 )); then
l_output="$l_output\n - No files or directories without a owner exist on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_nouser[@]}")\" unowned files or directories on
the system.\n - The following is a list of unowned files and/or directories:\n$(printf '%s\n'
"${a_nouser[@]}")\n - end of list"
fi
if ! (( ${#a_nogroup[@]} > 0 )); then
l_output="$l_output\n - No files or directories without a group exist on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_nogroup[@]}")\" ungrouped files or directories
on the system.\n - The following is a list of ungrouped files and/or directories:\n$(printf '%s\n'
"${a_nogroup[@]}")\n - end of list"
fi
unset a_path; unset a_arr ; unset a_nouser; unset a_nogroup # Remove arrays
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "\n- * Correctly configured * :\n$l_output\n"
fi
}
Note: On systems with a large number of files and/or directories, this audit may be a
long running process
Page 802
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 803
• Level 1 - Server
• Level 1 - Workstation
Description:
The owner of a file can set the file's permissions to run with the owner's or group's
permissions, even if the user running the program is not the owner or a member of the
group. The most common reason for a SUID or SGID program is to enable users to
perform functions (such as changing their password) that require root privileges.
Rationale:
There are valid reasons for SUID and SGID programs, but it is important to identify and
review such programs to ensure they are legitimate. Review the files returned by the
action in the audit section and check to see if system binaries have a different
checksum than what from the package. This is an indication that the binary may have
been replaced.
Page 804
{
l_output="" l_output2=""
a_suid=(); a_sgid=() # initialize arrays
while IFS= read -r l_mount_point; do
if ! grep -Pqs '^\h*\/run\/usr\b' <<< "$l_mount_point" && ! grep -Pqs -- '\bnoexec\b' <<< "$(findmnt -krn
"$l_mount_point")"; then
while IFS= read -r -d $'\0' l_file; do
if [ -e "$l_file" ]; then
l_mode="$(stat -Lc '%#a' "$l_file")"
[ $(( $l_mode & 04000 )) -gt 0 ] && a_suid+=("$l_file")
[ $(( $l_mode & 02000 )) -gt 0 ] && a_sgid+=("$l_file")
fi
done < <(find "$l_mount_point" -xdev -type f \( -perm -2000 -o -perm -4000 \) -print0 2>/dev/null)
fi
done <<< "$(findmnt -Derno target)"
if ! (( ${#a_suid[@]} > 0 )); then
l_output="$l_output\n - No executable SUID files exist on the system"
else
l_output2="$l_output2\n - List of \"$(printf '%s' "${#a_suid[@]}")\" SUID executable files:\n$(printf
'%s\n' "${a_suid[@]}")\n - end of list -\n"
fi
if ! (( ${#a_sgid[@]} > 0 )); then
l_output="$l_output\n - There are no SGID files exist on the system"
else
l_output2="$l_output2\n - List of \"$(printf '%s' "${#a_sgid[@]}")\" SGID executable files:\n$(printf
'%s\n' "${a_sgid[@]}")\n - end of list -\n"
fi
[ -n "$l_output2" ] && l_output2="$l_output2\n- Review the preceding list(s) of SUID and/or SGID files to\n-
ensure that no rogue programs have been introduced onto the system.\n"
unset a_arr; unset a_suid; unset a_sgid # Remove arrays
# If l_output2 is empty, Nothing to report
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n$l_output\n"
else
echo -e "\n- Audit Result:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "$l_output\n"
fi
}
Note: on systems with a large number of files, this may be a long running process
Page 805
1. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5, AC-3, MP-2
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 806
• Level 1 - Server
• Level 1 - Workstation
Description:
/etc/shells is a text file which contains the full pathnames of valid login shells. This file
is consulted by chsh and available to be queried by other programs.
Rationale:
It is critical to ensure that the /etc/shells file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/shells is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/shells
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/shells:
# chmod u-x,go-wx /etc/shells
# chown root:root /etc/shells
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 807
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 808
This section provides guidance on securing aspects of the local users and groups.
Note: The recommendations in this section check local users and groups. Any users or
groups from other sources such as LDAP will not be audited. In a domain environment
similar checks should be performed against domain users and groups.
Page 809
• Level 1 - Server
• Level 1 - Workstation
Description:
Local accounts can uses shadowed passwords. With shadowed passwords, The
passwords are saved in shadow password file, /etc/shadow, encrypted by a salted one-
way hash. Accounts with a shadowed password have an x in the second field in
/etc/passwd.
Rationale:
The /etc/passwd file also contains information like user ID's and group ID's that are
used by many system programs. Therefore, the /etc/passwd file must remain world
readable. In spite of encoding the password with a randomly-generated one-way hash
function, an attacker could still break the system if they got access to the /etc/passwd
file. This can be mitigated by using shadowed passwords, thus moving the passwords in
the /etc/passwd file to /etc/shadow. The /etc/shadow file is set so only root will be able
to read and write. This helps mitigate the risk of an attacker gaining access to the
encoded passwords with which to perform a dictionary attack.
Note:
• All accounts must have passwords or be locked to prevent the account from
being used by an unauthorized user.
• A user account with an empty second field in /etc/passwd allows the account to
be logged into by providing only the username.
Audit:
Run the following command and verify that no output is returned:
# awk -F: '($2 != "x" ) { print "User: \"" $1 "\" is not set to shadowed passwords "}' /etc/passwd
Remediation:
Run the following command to set accounts to use shadowed passwords and migrate
passwords in /etc/passwd to /etc/shadow:
# pwconv
Investigate to determine if the account is logged in and what it is being used for, to
determine if it needs to be forced off.
Page 810
Additional Information:
The pwconv command creates shadow from passwd and an optionally existing shadow.
• The pwunconv command creates passwd from passwd and shadow and then
removes shadow.
• The grpconv command creates gshadow from group and an optionally existing
gshadow.
• The grpunconv command creates group from group and gshadow and then
removes gshadow.
These four programs all operate on the normal and shadow password and group files:
/etc/passwd, /etc/group, /etc/shadow, and /etc/gshadow.
Each program acquires the necessary locks before conversion. pwconv and grpconv are
similar. First, entries in the shadowed file which don't exist in the main file are removed.
Then, shadowed entries which don't have x' as the password in the main file are
updated. Any missing shadowed entries are added. Finally, passwords in the
main file are replaced with x'. These programs can be used for initial conversion as
well to update the shadowed file if the main file is edited by hand.
pwconv will use the values of PASS_MIN_DAYS, PASS_MAX_DAYS, and PASS_WARN_AGE from
/etc/login.defs when adding new entries to /etc/shadow.
pwunconv and grpunconv are similar. Passwords in the main file are updated from the
shadowed file. Entries which exist in the main file but not in the shadowed file are left
alone. Finally, the shadowed file is removed. Some password aging information is lost
by pwunconv. It will convert what it can.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 811
Techniques / Sub-
Tactics Mitigations
techniques
Page 812
• Level 1 - Server
• Level 1 - Workstation
Description:
An account with an empty password field means that anybody may log in as that user
without providing a password.
Rationale:
All accounts must have passwords or be locked to prevent the account from being used
by an unauthorized user.
Audit:
Run the following command and verify that no output is returned:
# awk -F: '($2 == "" ) { print $1 " does not have a password "}' /etc/shadow
Remediation:
If any accounts in the /etc/shadow file do not have a password, run the following
command to lock the account until it can be determined why it does not have a
password:
# passwd -l <username>
Also, check to see if the account is logged in and investigate what it is being used for to
determine if it needs to be forced off.
References:
Page 813
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0003 M1027
T1078.003
Page 814
• Level 1 - Server
• Level 1 - Workstation
Description:
Over time, system administration errors and changes can lead to groups being defined
in /etc/passwd but not in /etc/group .
Rationale:
Groups defined in the /etc/passwd file but not in the /etc/group file pose a threat to
system security since group permissions are not properly managed.
Audit:
Run the following script to verify all GIDs in /etc/passwd exist in /etc/group:
#!/usr/bin/env bash
{
a_passwd_group_gid=("$(awk -F: '{print $4}' /etc/passwd | sort -u)")
a_group_gid=("$(awk -F: '{print $3}' /etc/group | sort -u)")
a_passwd_group_diff=("$(printf '%s\n' "${a_group_gid[@]}" "${a_passwd_group_gid[@]}" | sort | uniq -u)")
while IFS= read -r l_gid; do
awk -F: '($4 == '"$l_gid"') {print " - User: \"" $1 "\" has GID: \"" $4 "\" which does not exist in
/etc/group" }' /etc/passwd
done < <(printf '%s\n' "${a_passwd_group_gid[@]}" "${a_passwd_group_diff[@]}" | sort | uniq -D | uniq)
unset a_passwd_group_gid; unset a_group_gid; unset a_passwd_group_diff
}
Page 815
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 816
• Level 1 - Server
• Level 1 - Workstation
Description:
The shadow group allows system programs which require access the ability to read the
/etc/shadow file. No users should be assigned to the shadow group.
Rationale:
Any users assigned to the shadow group would be granted read access to the
/etc/shadow file. If attackers can gain read access to the /etc/shadow file, they can
easily run a password cracking program against the hashed passwords to break them.
Other security information that is stored in the /etc/shadow file (such as expiration)
could also be useful to subvert additional user accounts.
Audit:
Run the following commands and verify no results are returned:
# awk -F: '($1=="shadow") {print $NF}' /etc/group
# awk -F: '($4 == '"$(getent group shadow | awk -F: '{print $3}' | xargs)"') {print " - user: \"" $1 "\"
primary group is the shadow group"}' /etc/passwd
Remediation:
Run the following command to remove all users from the shadow group
# sed -ri 's/(^shadow:[^:]*:[^:]*:)([^:]+$)/\1/' /etc/group
Change the primary group of any users with shadow as their primary group.
# usermod -g <primary group> <user>
References:
Page 817
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 818
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the useradd program will not let you create a duplicate User ID (UID), it is
possible for an administrator to manually edit the /etc/passwd file and change the UID
field.
Rationale:
Users must be assigned unique UIDs for accountability and to ensure appropriate
access protections.
Audit:
Run the following script and verify no results are returned:
#!/usr/bin/env bash
{
while read -r l_count l_uid; do
if [ "$l_count" -gt 1 ]; then
echo -e "Duplicate UID: \"$l_uid\" Users: \"$(awk -F: '($3 == n) { print $1 }' n=$l_uid /etc/passwd |
xargs)\""
fi
done < <(cut -f3 -d":" /etc/passwd | sort -n | uniq -c)
}
Remediation:
Based on the results of the audit script, establish unique UIDs and review all files owned
by the shared UIDs to determine which UID they are supposed to belong to.
References:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1027
T1078.003
Page 819
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the groupadd program will not let you create a duplicate Group ID (GID), it is
possible for an administrator to manually edit the /etc/group file and change the GID
field.
Rationale:
User groups must be assigned unique GIDs for accountability and to ensure appropriate
access protections.
Audit:
Run the following script and verify no results are returned:
#!/usr/bin/env bash
{
while read -r l_count l_gid; do
if [ "$l_count" -gt 1 ]; then
echo -e "Duplicate GID: \"$l_gid\" Groups: \"$(awk -F: '($3 == n) { print $1 }' n=$l_gid /etc/group |
xargs)\""
fi
done < <(cut -f3 -d":" /etc/group | sort -n | uniq -c)
}
Remediation:
Based on the results of the audit script, establish unique GIDs and review all files
owned by the shared GID to determine which group they are supposed to belong to.
References:
Additional Information:
You can also use the grpck command to check for other inconsistencies in the
/etc/group file.
Page 820
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1027
T1078.003
Page 821
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the useradd program will not let you create a duplicate user name, it is
possible for an administrator to manually edit the /etc/passwd file and change the user
name.
Rationale:
If a user is assigned a duplicate user name, it will create and have access to files with
the first UID for that username in /etc/passwd . For example, if "test4" has a UID of
1000 and a subsequent "test4" entry has a UID of 2000, logging in as "test4" will use
UID 1000. Effectively, the UID is shared, which is a security problem.
Audit:
Run the following script and verify no results are returned:
#!/usr/bin/env bash
{
while read -r l_count l_user; do
if [ "$l_count" -gt 1 ]; then
echo -e "Duplicate User: \"$l_user\" Users: \"$(awk -F: '($1 == n) { print $1 }' n=$l_user /etc/passwd
| xargs)\""
fi
done < <(cut -f1 -d":" /etc/group | sort -n | uniq -c)
}
Remediation:
Based on the results of the audit script, establish unique user names for the users. File
ownerships will automatically reflect the change as long as the users have unique UIDs.
References:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0004 M1027
T1078.003
Page 822
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the groupadd program will not let you create a duplicate group name, it is
possible for an administrator to manually edit the /etc/group file and change the group
name.
Rationale:
If a group is assigned a duplicate group name, it will create and have access to files
with the first GID for that group in /etc/group . Effectively, the GID is shared, which is a
security problem.
Audit:
Run the following script and verify no results are returned:
#!/usr/bin/env bash
{
while read -r l_count l_group; do
if [ "$l_count" -gt 1 ]; then
echo -e "Duplicate Group: \"$l_group\" Groups: \"$(awk -F: '($1 == n) { print $1 }' n=$l_group
/etc/group | xargs)\""
fi
done < <(cut -f1 -d":" /etc/group | sort -n | uniq -c)
}
Remediation:
Based on the results of the audit script, establish unique names for the user groups. File
group ownerships will automatically reflect the change as long as the groups have
unique GIDs.
References:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0004 M1027
T1078.003
Page 823
• Level 1 - Server
• Level 1 - Workstation
Description:
The user home directory is space defined for the particular user to set local environment
variables and to store personal files. While the system administrator can establish
secure permissions for users' home directories, the users can easily override these.
Users can be defined in /etc/passwd without a home directory or with a home directory
that does not actually exist.
Rationale:
Since the user is accountable for files stored in the user home directory, the user must
be the owner of the directory. Group or world-writable user home directories may enable
malicious users to steal or modify other users' data or to gain another user's system
privileges. If the user's home directory does not exist or is unassigned, the user will be
placed in "/" and will not be able to write any files or have local environment variables
set.
Page 824
{
l_output="" l_output2="" l_heout2="" l_hoout2="" l_haout2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\\\/,g;p}' |
paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }' /etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
[ "$l_asize " -gt "10000" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local interactive users found on
the system\n - This may be a long running check\n"
while read -r l_user l_home; do
if [ -d "$l_home" ]; then
l_mask='0027'
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read -r l_own l_mode; do
[ "$l_user" != "$l_own" ] && l_hoout2="$l_hoout2\n - User: \"$l_user\" Home \"$l_home\" is owned
by: \"$l_own\""
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_haout2="$l_haout2\n - User: \"$l_user\" Home \"$l_home\" is mode: \"$l_mode\" should be mode:
\"$l_max\" or more restrictive"
fi
done <<< "$(stat -Lc '%U %#a' "$l_home")"
else
l_heout2="$l_heout2\n - User: \"$l_user\" Home \"$l_home\" Doesn't exist"
fi
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
[ -z "$l_heout2" ] && l_output="$l_output\n - home directories exist" || l_output2="$l_output2$l_heout2"
[ -z "$l_hoout2" ] && l_output="$l_output\n - own their home directory" || l_output2="$l_output2$l_hoout2"
[ -z "$l_haout2" ] && l_output="$l_output\n - home directories are mode: \"$l_max\" or more restrictive"
|| l_output2="$l_output2$l_haout2"
[ -n "$l_output" ] && l_output=" - All local interactive users:$l_output"
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "\n- * Correctly configured * :\n$l_output"
fi
}
Page 825
{
l_output2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\\\/,g;p}' |
paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }' /etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
[ "$l_asize " -gt "10000" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local interactive users found on
the system\n - This may be a long running process\n"
while read -r l_user l_home; do
if [ -d "$l_home" ]; then
l_mask='0027'
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read -r l_own l_mode; do
if [ "$l_user" != "$l_own" ]; then
l_output2="$l_output2\n - User: \"$l_user\" Home \"$l_home\" is owned by: \"$l_own\"\n -
changing ownership to: \"$l_user\"\n"
chown "$l_user" "$l_home"
fi
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_output2="$l_output2\n - User: \"$l_user\" Home \"$l_home\" is mode: \"$l_mode\" should be
mode: \"$l_max\" or more restrictive\n - removing excess permissions\n"
chmod g-w,o-rwx "$l_home"
fi
done <<< "$(stat -Lc '%U %#a' "$l_home")"
else
l_output2="$l_output2\n - User: \"$l_user\" Home \"$l_home\" Doesn't exist\n - Please create a home
in accordance with local site policy"
fi
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e " - No modification needed to local interactive users home directories"
else
echo -e "\n$l_output2"
fi
}
Page 826
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 827
• Level 1 - Server
• Level 1 - Workstation
Description:
While the system administrator can establish secure permissions for users' "dot" files,
the users can easily override these.
• .forward file specifies an email address to forward the user's mail to.
• .rhost file provides the "remote authentication" database for the rcp, rlogin, and
rsh commands and the rcmd() function. These files bypass the standard
password-based user authentication mechanism. They specify remote hosts and
users that are considered trusted (i.e. are allowed to access the local system
without supplying a password)
• .netrc file contains data for logging into a remote host or passing authentication
to an API.
• .bash_history file keeps track of the user’s commands.
Rationale:
User configuration files with excessive or incorrect access may enable malicious users
to steal or modify other users' data or to gain another user's system privileges.
Audit:
Run the following script to verify local interactive user dot files:
Note: If a .netrc file is required, and follows local site policy, it should be mode 0600 or
more restrictive.
Page 828
{
l_output="" l_output2="" l_output3=""
l_bf="" l_df="" l_nf="" l_hf=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\\\/,g;p}' |
paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
[[ -n "$l_epu" && -n "$l_eph" ]] && a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }' /etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
l_maxsize="1000" # Maximun number of local interactive users before warning (Default 1,000)
[ "$l_asize " -gt "$l_maxsize" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local interactive users found
on the system\n - This may be a long running check\n"
file_access_chk()
{
l_facout2=""
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_facout2="$l_facout2\n - File: \"$l_hdfile\" is mode: \"$l_mode\" and should be mode: \"$l_max\" or
more restrictive"
fi
if [[ ! "$l_owner" =~ ($l_user) ]]; then
l_facout2="$l_facout2\n - File: \"$l_hdfile\" owned by: \"$l_owner\" and should be owned by
\"${l_user//|/ or }\""
fi
if [[ ! "$l_gowner" =~ ($l_group) ]]; then
l_facout2="$l_facout2\n - File: \"$l_hdfile\" group owned by: \"$l_gowner\" and should be group owned
by \"${l_group//|/ or }\""
fi
}
while read -r l_user l_home; do
l_fe="" l_nout2="" l_nout3="" l_dfout2="" l_hdout2="" l_bhout2=""
if [ -d "$l_home" ]; then
l_group="$(id -gn "$l_user" | xargs)"
l_group="${l_group// /|}"
while IFS= read -r -d $'\0' l_hdfile; do
while read -r l_mode l_owner l_gowner; do
case "$(basename "$l_hdfile")" in
.forward | .rhost )
l_fe="Y" && l_bf="Y"
l_dfout2="$l_dfout2\n - File: \"$l_hdfile\" exists" ;;
.netrc )
l_mask='0177'
file_access_chk
if [ -n "$l_facout2" ]; then
l_fe="Y" && l_nf="Y"
l_nout2="$l_facout2"
else
l_nout3=" - File: \"$l_hdfile\" exists"
fi ;;
.bash_history )
l_mask='0177'
file_access_chk
if [ -n "$l_facout2" ]; then
l_fe="Y" && l_hf="Y"
l_bhout2="$l_facout2"
fi ;;
* )
l_mask='0133'
file_access_chk
if [ -n "$l_facout2" ]; then
l_fe="Y" && l_df="Y"
l_hdout2="$l_facout2"
fi ;;
esac
done <<< "$(stat -Lc '%#a %U %G' "$l_hdfile")"
done < <(find "$l_home" -xdev -type f -name '.*' -print0)
fi
if [ "$l_fe" = "Y" ]; then
l_output2="$l_output2\n - User: \"$l_user\" Home Directory: \"$l_home\""
[ -n "$l_dfout2" ] && l_output2="$l_output2$l_dfout2"
[ -n "$l_nout2" ] && l_output2="$l_output2$l_nout2"
[ -n "$l_bhout2" ] && l_output2="$l_output2$l_bhout2"
[ -n "$l_hdout2" ] && l_output2="$l_output2$l_hdout2"
fi
[ -n "$l_nout3" ] && l_output3="$l_output3\n - User: \"$l_user\" Home Directory: \"$l_home\"\n$l_nout3"
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
unset a_uarr # Remove array
[ -n "$l_output3" ] && l_output3=" - ** Warning **\n - \".netrc\" files should be removed unless deemed
Page 829
Page 830
Page 831
{
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn '/^\//{s,/,\\\\/,g;p}' |
paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
[[ -n "$l_epu" && -n "$l_eph" ]] && a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }' /etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
l_maxsize="1000" # Maximum number of local interactive users before warning (Default 1,000)
[ "$l_asize " -gt "$l_maxsize" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local interactive users found
on the system\n - This may be a long running check\n"
file_access_fix()
{
l_facout2=""
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
echo -e " - File: \"$l_hdfile\" is mode: \"$l_mode\" and should be mode: \"$l_max\" or more
restrictive\n - Changing to mode \"$l_max\""
chmod "$l_chp" "$l_hdfile"
fi
if [[ ! "$l_owner" =~ ($l_user) ]]; then
echo -e " - File: \"$l_hdfile\" owned by: \"$l_owner\" and should be owned by \"${l_user//|/ or }\"\n
- Changing ownership to \"$l_user\""
chown "$l_user" "$l_hdfile"
fi
if [[ ! "$l_gowner" =~ ($l_group) ]]; then
echo -e " - File: \"$l_hdfile\" group owned by: \"$l_gowner\" and should be group owned by
\"${l_group//|/ or }\"\n - Changing group ownership to \"$l_group\""
chgrp "$l_group" "$l_hdfile"
fi
}
while read -r l_user l_home; do
if [ -d "$l_home" ]; then
echo -e "\n - Checking user: \"$l_user\" home directory: \"$l_home\""
l_group="$(id -gn "$l_user" | xargs)"
l_group="${l_group// /|}"
while IFS= read -r -d $'\0' l_hdfile; do
while read -r l_mode l_owner l_gowner; do
case "$(basename "$l_hdfile")" in
.forward | .rhost )
echo -e " - File: \"$l_hdfile\" exists\n - Please investigate and manually delete
\"$l_hdfile\""
;;
.netrc )
l_mask='0177'
l_chp="u-x,go-rwx"
file_access_fix ;;
.bash_history )
l_mask='0177'
l_chp="u-x,go-rwx"
file_access_fix ;;
* )
l_mask='0133'
l_chp="u-x,go-wx"
file_access_fix ;;
esac
done <<< "$(stat -Lc '%#a %U %G' "$l_hdfile")"
done < <(find "$l_home" -xdev -type f -name '.*' -print0)
fi
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
unset a_uarr # Remove array
}
Page 832
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1222, T1222.001,
T1222.002, T1552, TA0005 M1022
T1552.003, T1552.004
Page 833
Yes No
1 Initial Setup
Page 834
Yes No
Page 835
Yes No
Page 836
Yes No
Page 837
Yes No
Page 838
Yes No
2 Services
Page 839
Yes No
Page 840
Yes No
3 Network
Page 841
Yes No
3.4.1.6 Ensure ufw firewall rules exist for all open ports
(Automated)
Page 842
Yes No
Page 843
Yes No
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
(Automated)
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
(Automated)
Page 844
Yes No
Page 845
Yes No
Page 846
Yes No
4.5.1.5 Ensure all users last password change date is in the past
(Automated)
Page 847
Yes No
Page 848
Yes No
Page 849
Yes No
5.2.3.3 Ensure events that modify the sudo log file are collected
(Automated)
5.2.3.4 Ensure events that modify date and time information are
collected (Automated)
Page 850
Yes No
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
(Automated)
Page 851
Yes No
6 System Maintenance
Page 852
Yes No
Page 853
Page 854
Page 855
Page 856
Page 857
Page 858
Page 859
Page 860
Page 861
Page 862
Page 863
Page 864
Page 865
Page 866
Page 867
Page 868
Page 869
Page 870
Page 871
Page 872
Page 873
Page 874
Page 875
Page 876
Page 877
Page 878
Page 879
Page 880
Page 881
Page 882
Page 883
Page 884
Page 885
Page 886
Page 887
Page 888
Page 889
Page 890
Page 891
Page 892
Page 893
Page 894
Page 895
Page 896
Page 897
Page 898
Page 899
Page 900
Page 901
Page 902
Page 903
Page 904
Page 905
Page 906
Page 907
Page 908
Page 909
Page 910
Page 911
Page 912
Page 913
Page 914
Page 915
Page 916
Page 917
3/27/2024 2.2.0 ADDED SECTION: 6.2 - Local User and Group Settings
DROPPED RECOMMENDATIONS
Page 918
Page 919
Page 920
Page 921
Page 922
Page 923
MOVED RECOMMENDATIONS
Page 924
Page 925
Page 926
Page 927
Page 928
Page 929
Page 930
Page 931
Page 932
3/27/2024 2.2.0 MOVED SECTION: 2.2 - Special Purpose Services moved from
2.1 in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 2.3 - Service Clients moved from 2.2 in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 3.4 - Firewall Configuration moved from 3.5
in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 3.4.2 - Configure nftables moved from 3.5.2
in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 3.4.3 - Configure iptables moved from 3.5.3
in 2.1.0
Page 933
3/27/2024 2.2.0 MOVED SECTION: 3.4.3.2 - Configure IPv4 iptables moved from
3.5.3.2 in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 4.2 - Configure SSH Server moved from 5.3
in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 4.4 - Configure PAM moved from 5.4 in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 5.1 - Configure Logging moved from 4.2 in
2.1.0
3/27/2024 2.2.0 MOVED SECTION: 5.1.1 - Configure journald moved from 4.2.2
in 2.1.0
3/27/2024 2.2.0 MOVED SECTION: 5.1.2 - Configure rsyslog moved from 4.2.1
in 2.1.0
Page 934
Page 935
Page 936
Page 937
Page 938
Page 939
Page 940
Page 941
Page 942
Page 943
Page 944
Page 945
Page 946
Page 947