#TRUSTED 0ede7d6d394d735c8d68ec4f2adbc1ceabe4682807d44638b10c5acb218f4718e622492d9c362ebc052b089fbfee60053b76768c0565f19be4e76e3ba3f9c88e3cb9e6c7c286f3d81e586447ef84c435b2b62e9cb32d2e7c3da3972c87483b3bd50aa9274b03cfe733f5353d1255b63fb85bd892e7d0588cb098b2224e9305a514b7e422498f7a06fa3b7ee4693ebafa680483fd1361c33d120ef22798dbf6d612432338b7a21e1b55ce32fc889a12353d2576953b3e0333bd3e7e49e157c9c07da0e2df2cef68951684f521ffb82ee0f06e51dde8f7455de07fe5259209242e0e70c60544b19f1bdb8b891207ca77765d974cd8406eb8b3e086dd6536dd046822efa0776a4f8b3209aea5f40bf2bf88f597bcf7beaf3697f771f6fe007d98dc5d606e6da91d6012bc4840cd122363f59bf9ce51942131b3366075605b9ebe6bb6e41930078f9124ce0e5826ad5a7d027264119b84d8ae1884ce3315f5140809d718d3655c202e14611c40532fc0f48b3c6b5d1dcef2f490a9a221584845add95c2dfbc9cd0e37789afd952f284721974605f0b0daaf97ad379f25e9fe1006f314e9285108873892dfcc003ba8855b3c8554e97e30eb99f58854855ea11cf7201460d2240908dd6b751d35d30d4f87f7710a51a02b1f251e01339ae14e21063159606a4f6b1f765d9ebc6f4783f42536bcfbe96b669a3a4f19b49a575b07ee36
#TRUST-RSA-SHA256 483f666f4545a9a2dc87978dc0600efcbf6673ac3f6655e0abc21443ab9c21fe3bdd40664f1b136061f300ed276ce1ad42c33e02b5fa660ed16d1189686dfb403bd7851be757523a30cd86435380d6d6276efa6d22242a40cbc20687f8634bbf45c30db5e4efa6132c5752aeb8bbdabc82712afed39da79a4fca262f36ca2b02316e45452bbc2ca2af3da9eb6614093eb0a3b7904bb8fa8fe37be6c6f59094b6a3d2682841bfdb41b51e139c74b64dc03d62e1b70e7f0e44a82c0c9b4d3a0f68bfe9a1911915a4041dd66bf9295f752373af0b1a2e008bca29dc220f2990fbae9df86819e27613f42fa66b6d4307f2ca0d8ddc2d362758411ac1ff68c83a2c3113117ac68182bcfab2bf55fe846dfe173b232fd07bde126480cfce22e0b033a9fb5476501a9503663ae3b1addf8fe02cba9feefc720a4693ee92aec4dd6c7a9b481384da165d3535d850794d7411c6c056906b918ed8e4c1e40a2132d5f834114517ca467f384b8a29c374e9ddce8177d8c7475260589815e4865877a0249fbc1d005f452fa0d654b4f8059e264e3a3e542d063a044fe7a88acaa44385c6f236475a4674721c4e6143612edbedff77c5eaf6aee0da580d153b7d279f33d1341a778ced6e51d2c3806917a0ca7504818cfd409aa674d8a9826d8dc776b22963a80c1c3a0b017567aac6f56d4a252c9389f5a2a08ff3574adfa4ede85f4cfdd946
#
# This script is Copyright (C) 2004-2023 and is owned by Tenable, Inc. or an Affiliate thereof.
#
# This script is released under the Tenable Subscription License and
# may not be used from within scripts released under another license
# without authorization from Tenable, Inc.
#
# See the following licenses for details:
#
# http://static.tenable.com/prod_docs/Nessus_6_SLA_and_Subscription_Agreement.pdf
#
# @PROFESSIONALFEED@
# $Revision: 1.14 $
# $Date: 2023/08/29 $
#
# Description : This document implements the security configuration as recommended by the CIS Rocky Linux 9 Benchmark v1.0.0
#
#
#CIS Rocky Linux 9 Server L1 v1.0.0
#
# CIS
# Rocky Linux 9 Server L1
# 1.0.0
# https://workbench.cisecurity.org/files/4230
#
#unix,cis,rocky_linux_9,agent,update_20230227
#CCE,CSCv6,CSCv7,CSCv8,LEVEL
#
#
# NTP_SERVER
# 10.0.0.2
# Network Time
# Host address of the NTP server for the target.
# STRING
#
#
# PAM_RETRY_VALUE
# [1-3]
# PAM RETRY Value
# Number of retries the user has to create strong passwords
# STRING
#
#
# PAM_MINLEN_VALUE
# (1[4-9]|[2-9][0-9])
# PAM Minimum Length Value
# Minimum password length config value for PAM Password Quality settings that conform to your site policy.
# STRING
#
#
# JOURNALD_SERVER
# 192.168.50.42
# Journald Remote Server
# Host address of the journald log server for the target to send logs to.
# HOSTNAME_IP_ADDRESS
#
#
# JOURNALD_SERVER_KEY
# /etc/ssl/private/journal-upload.pem
# Journald Remote Server SSL Key
# SSL Key for the journald log server for the target to send logs to.
# UNIX_FILE_PATH
#
#
# JOURNALD_SERVER_CERT
# /etc/ssl/certs/journal-upload.pem
# Journald Remote Server SSL Cert
# SSL Cert for the journald log server for the target to send logs to.
# UNIX_FILE_PATH
#
#
# JOURNALD_TRUSTED_CERT
# /etc/ssl/ca/trusted.pem
# Journald Remote Trusted SSL Cert
# Trusted SSL Cert for the journald log server for the target to send logs to.
# UNIX_FILE_PATH
#
#
# PLATFORM_VERSION
# 9
# Linux Distribution Version
# Linux Distribution Version
# STRING
#
#
# PASSWORD_MINCLASS
# 4
# Password Complexity Value
# Password complexity value found in /etc/security/pwquality.conf
# INTEGER
#
#
# PASSWORD_ENCRYPTION
# (SHA512|YESCRYPT)
# Password encryption method
# Password encryption method found in /etc/login.defs
# STRING
#
#
# PASSWORD_MAX_DAYS
# ([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-5])
# Password expiration
# Password expiration parameter found in /etc/login.defs
# STRING
#
#
# PASSWORD_MIN_DAYS
# ([1-9]|[1-9][0-9]+)
# Password minimum days
# Minimum days between password changes parameter found in /etc/login.defs
# STRING
#
#
# PASSWORD_WARN_AGE
# ([7-9]|[1-9][0-9]+)
# Password expiration warning
# Password expiration warning parameter found in /etc/login.defs
# STRING
#
#
# INACTIVE_PASSWORD_LOCK
# (30|[1-2][0-9]|[1-9])
# Password lock for inactive users
# The given period of time a user can be inactive before account is locked
# STRING
#
#
# LOG_SECURE
# /var/log/secure
# Rsyslog.conf - destination for auth,authpriv.*
# The preferred destination for auth and authpriv messages.
# STRING
#
#
# LOG_MAIL
# /var/log/mail
# Rsyslog.conf - destination for mail.*
# The preferred destination for mail.* messages.
# STRING
#
#
# LOG_MAIL_INFO
# /var/log/mail.info
# Rsyslog.conf - destination for mail.info
# The preferred destination for mail.info messages.
# STRING
#
#
# LOG_MAIL_WARN
# /var/log/mail.warn
# Rsyslog.conf - destination for mail.warning
# The preferred destination for mail.warning messages.
# STRING
#
#
# LOG_MAIL_ERR
# /var/log/mail.err
# Rsyslog.conf - destination for mail.err
# The preferred destination for mail.err messages.
# STRING
#
#
# LOG_CRON
# /var/log/cron
# Rsyslog.conf - destination for cron.*
# The preferred destination for cron.* messages.
# STRING
#
#
# LOG_WARN
# /var/log/warn
# Rsyslog.conf - destination for warning, err, and .crit
# The preferred destination for *.=warning;*.=err, and *.crit messages.
# STRING
#
#
# LOG_MESSAGES
# /var/log/messages
# Rsyslog.conf - destination for catchall, mail.none, news.none
# The preferred destination for *.*;mail.none;news.none messages.
# STRING
#
#
# LOG_LOCALMESSAGES
# /var/log/localmessages
# Rsyslog.conf - destination for local*
# The preferred destination for local0-local7.* messages.
# STRING
#
#
#
type : FILE_CONTENT_CHECK
description : "Rocky Linux 9 is installed"
file : "/etc/system-release"
regex : "^[\\s]*Rocky Linux release 9"
expect : "^[\\s]*Rocky Linux release 9.*"
description : "CIS_Rocky_Linux_9_v1.0.0_L1_Server.audit from CIS Rocky Linux 9 Benchmark v1.0.0"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "1.1.2.1 Ensure /tmp is a separate partition - mount check"
info : "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.
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.
This can be accomplished by either mounting tmpfs to /tmp, or creating a separate partition for /tmp.
Impact:
By design files saved to /tmp should have no expectation of surviving a reboot of the system. tmpfs is ram based and all files stored to tmpfs will be lost when the system is rebooted.
If files need to be persistent through a reboot, they should be saved to /var/tmp not /tmp.
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."
solution : "First ensure that systemd is correctly configured to ensure that /tmp will be mounted at boot time.
# systemctl unmask tmp.mount
For specific configuration requirements of the /tmp mount for your environment, modify /etc/fstab.
Example of using tmpfs with specific mount options:
tmpfs/tmptmpfs defaults,rw,nosuid,nodev,noexec,relatime,size=2G 0 0
Example of using a volume or disk with specific mount options. The source location of the volume or disk will vary depending on your environment.
/tmp defaults,nodev,nosuid,noexec 0 0"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /tmp"
expect : "[\\s]*/tmp[\\s]*"
type : CMD_EXEC
description : "Determine whether systemd or legacy fstab"
cmd : "/usr/bin/systemctl is-enabled tmp.mount"
expect : "(enabled|static|generated)"
system : "Linux"
type : CMD_EXEC
description : "1.1.2.1 Ensure /tmp is a separate partition - config check"
info : "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.
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.
This can be accomplished by either mounting tmpfs to /tmp, or creating a separate partition for /tmp.
Impact:
By design files saved to /tmp should have no expectation of surviving a reboot of the system. tmpfs is ram based and all files stored to tmpfs will be lost when the system is rebooted.
If files need to be persistent through a reboot, they should be saved to /var/tmp not /tmp.
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."
solution : "First ensure that systemd is correctly configured to ensure that /tmp will be mounted at boot time.
# systemctl unmask tmp.mount
For specific configuration requirements of the /tmp mount for your environment, modify /etc/fstab.
Example of using tmpfs with specific mount options:
tmpfs/tmptmpfs defaults,rw,nosuid,nodev,noexec,relatime,size=2G 0 0
Example of using a volume or disk with specific mount options. The source location of the volume or disk will vary depending on your environment.
/tmp defaults,nodev,nosuid,noexec 0 0"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled tmp.mount"
expect : "(enabled|static|generated)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.1.2.1 Ensure /tmp is a separate partition - config check"
info : "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.
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.
This can be accomplished by either mounting tmpfs to /tmp, or creating a separate partition for /tmp.
Impact:
By design files saved to /tmp should have no expectation of surviving a reboot of the system. tmpfs is ram based and all files stored to tmpfs will be lost when the system is rebooted.
If files need to be persistent through a reboot, they should be saved to /var/tmp not /tmp.
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."
solution : "First ensure that systemd is correctly configured to ensure that /tmp will be mounted at boot time.
# systemctl unmask tmp.mount
For specific configuration requirements of the /tmp mount for your environment, modify /etc/fstab.
Example of using tmpfs with specific mount options:
tmpfs/tmptmpfs defaults,rw,nosuid,nodev,noexec,relatime,size=2G 0 0
Example of using a volume or disk with specific mount options. The source location of the volume or disk will vary depending on your environment.
/tmp defaults,nodev,nosuid,noexec 0 0"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/fstab"
regex : "[\\s]+\/tmp[\\s]+"
expect : "^[\\s]*[\\W\\w]+[\\s]+\/tmp[\\s]+.*?$"
system : "Linux"
type : CMD_EXEC
description : "1.1.2.2 Ensure nodev option set on /tmp partition"
info : "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 a block or character special devices in /tmp."
solution : "Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /tmp partition.
Example:
/tmp defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /tmp"
expect : "[\\s]*[,]?nodev"
system : "Linux"
type : CMD_EXEC
description : "1.1.2.3 Ensure noexec option set on /tmp partition"
info : "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."
solution : "Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the /tmp partition.
Example:
/tmp defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /tmp"
expect : "[\\s]*[,]?noexec"
system : "Linux"
type : CMD_EXEC
description : "1.1.2.4 Ensure nosuid option set on /tmp partition"
info : "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."
solution : "Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the /tmp partition.
Example:
/tmp defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /tmp"
expect : "[\\s]*[,]?nosuid"
system : "Linux"
type : CMD_EXEC
description : "1.1.3.2 Ensure nodev option set on /var partition"
info : "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 a block or character special devices in /var."
solution : "Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /var partition.
Example:
/var defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var with the configured options:
# mount -o remount /var"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nodev|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.3.3 Ensure nosuid option set on /var partition"
info : "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."
solution : "Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the /var partition.
Example:
/var defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var with the configured options:
# mount -o remount /var"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nosuid|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.4.2 Ensure noexec option set on /var/tmp partition"
info : "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."
solution : "Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the /var/tmp partition.
Example:
/var/tmp 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/tmp | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?noexec|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.4.3 Ensure nosuid option set on /var/tmp partition"
info : "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."
solution : "Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the /var/tmp partition.
Example:
/var/tmp 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/tmp | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nosuid|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.4.4 Ensure nodev option set on /var/tmp partition"
info : "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 a block or character special devices in /var/tmp."
solution : "Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /var/tmp partition.
Example:
/var/tmp 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/tmp | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nodev|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.5.2 Ensure nodev option set on /var/log partition"
info : "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 a block or character special devices in /var/log."
solution : "Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /var/log partition.
Example:
/var/log 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/log | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nodev|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.5.3 Ensure noexec option set on /var/log partition"
info : "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."
solution : "Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the /var/log partition.
Example:
/var/log 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/log | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?noexec|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.5.4 Ensure nosuid option set on /var/log partition"
info : "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."
solution : "Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the /var/log partition.
Example:
/var/log 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/log | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nosuid|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.6.2 Ensure noexec option set on /var/log/audit partition"
info : "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."
solution : "Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the /var partition.
Example:
/var/log/audit 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/log/audit | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?noexec|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.6.3 Ensure nodev option set on /var/log/audit partition"
info : "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 a block or character special devices in /var/log/audit."
solution : "Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /var/log/audit partition.
Example:
/var/log/audit 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/log/audit | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nodev|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.6.4 Ensure nosuid option set on /var/log/audit partition"
info : "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."
solution : "Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the /var/log/audit partition.
Example:
/var/log/audit 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"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /var/log/audit | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nosuid|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.7.2 Ensure nodev option set on /home partition"
info : "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 a block or character special devices in /var."
solution : "Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /home partition.
Example:
/home defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /home with the configured options:
# mount -o remount /home"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /home | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nodev|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.7.3 Ensure nosuid option set on /home partition"
info : "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."
solution : "Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the /home partition.
Example:
/home defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /home with the configured options:
# mount -o remount /home"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /home | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nosuid|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.8.1 Ensure /dev/shm is a separate partition"
info : "The /dev/shm directory is a world-writable directory that can function as shared memory that facilitates inter process communication (IPC).
Rationale:
Making /dev/shm its own file system allows an administrator to set additional mount options such as the noexec option on the mount, making /dev/shm 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 mounting tmpfs to /dev/shm.
Impact:
Since the /dev/shm directory is intended to be world-writable, there is a risk of resource exhaustion if it is not bound to a separate partition.
/dev/shm utilizing tmpfs can be resized using the size={size} parameter in the relevant entry in /etc/fstab."
solution : "For specific configuration requirements of the /dev/shm mount for your environment, modify /etc/fstab.
Example of using tmpfs with specific mount options:
tmpfs/dev/shmtmpfs defaults,rw,nosuid,nodev,noexec,relatime,size=2G 0 0"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /dev/shm | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*/dev/shm[\\s]*tmpfs|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.8.2 Ensure nodev option set on /dev/shm partition"
info : "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."
solution : "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.
Run the following command to remount /dev/shm using the updated options from /etc/fstab:
# 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.
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /dev/shm | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nodev|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.8.3 Ensure noexec option set on /dev/shm partition"
info : "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."
solution : "Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the /dev/shm partition.
Example:
/dev/shm 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
NOTE It is recommended to use tmpfs as the device/filesystem type as /dev/shm is used as shared memory space by applications."
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /dev/shm | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?noexec|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.8.4 Ensure nosuid option set on /dev/shm partition"
info : "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."
solution : "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.
Run the following command to remount /dev/shm using the updated options from /etc/fstab:
# 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.
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/findmnt --kernel /dev/shm | /usr/bin/awk '{print} END {if (NR == 0) print \"not mounted\"}'"
expect : "([\\s]*[,]?nosuid|not mounted)"
system : "Linux"
type : CMD_EXEC
description : "1.1.9 Disable USB Storage"
info : "USB storage provides a means to transfer and store files ensuring 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."
solution : "Run the following script to disable usb-storage:
#!/usr/bin/env bash
{
l_mname='usb-storage' # set module name
# Check if the module exists on the system
if [ -z '$(modprobe -n -v '$l_mname' 2>&1 | grep -Pi -- '\h*modprobe:\h+FATAL:\h+Module\h+$l_mname\h+not\h+found\h+in\h+directory')' ]; then
# Remediate 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
echo -e ' - setting module: \'$l_mname\' to be not loadable'
echo -e 'install $l_mname /bin/false' >> /etc/modprobe.d/'$l_mname'.conf
fi
# Remediate loaded
if lsmod | grep '$l_mname' > /dev/null 2>&1; then
echo -e ' - unloading module \'$l_mname\''
modprobe -r '$l_mname'
fi
# Remediate deny list
if ! modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+$(tr '-' '_' <<< '$l_mname')\b'; then
echo -e ' - deny listing \'$l_mname\''
echo -e 'blacklist $l_mname' >> /etc/modprobe.d/'$l_mname'.conf
fi
else
echo -e ' - Nothing to remediate\n - Module \'$l_mname\' doesn't exist on the system'
fi
}
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.
NIST SP 800-53 Rev. 5:
SC-18(4)"
reference : "800-171|3.8.7,800-53|MP-7,800-53r5|MP-7,CN-L3|8.5.4.1(c),CSCv7|13.7,CSCv8|10.3,CSF|PR.PT-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.8.3.1,ISO/IEC-27001|A.8.3.3,LEVEL|1A,NESA|T1.4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_output=\"\" l_output2=\"\"
l_mname=\"usb-storage\" # set module name
# Check if the module exists on the system
if [ -z \"$(modprobe -n -v \"$l_mname\" 2>&1 | grep -Pi -- \"\\h*modprobe:\\h+FATAL:\\h+Module\\h+$l_mname\\h+not\\h+found\\h+in\\h+directory\")\" ]; then
# Check how module will be loaded
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
# 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+$(tr '-' '_' <<< \"$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
else
l_output=\"$l_output\\n - Module \\\"$l_mname\\\" doesn't exist on the system\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.2.1 Ensure GPG keys are configured - gpgkey"
info : "The RPM Package Manager implements GPG key signing to verify package integrity during and after 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. To this end, verify that GPG keys are configured correctly for your system.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Update your package manager GPG keys in accordance with site policy.
Additional Information:
Fedora public keys: https://getfedora.org/security/
NIST SP 800-53 Rev. 5:
SI-2"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.14.1,800-53|RA-5,800-53|SI-2,800-53|SI-2(2),800-53r5|RA-5,800-53r5|SI-2,800-53r5|SI-2(2),CN-L3|8.1.4.4(e),CN-L3|8.1.10.5(a),CN-L3|8.1.10.5(b),CN-L3|8.5.4.1(b),CN-L3|8.5.4.1(d),CN-L3|8.5.4.1(e),CSCv7|3.4,CSCv7|3.5,CSCv8|7.3,CSCv8|7.4,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|RA-5,ITSG-33|SI-2,ITSG-33|SI-2(2),LEVEL|1M,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.6.2,NESA|T7.7.1,NIAv2|PR9,PCI-DSSv3.2.1|6.1,PCI-DSSv3.2.1|6.2,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,PCI-DSSv4.0|6.3.3,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "grep -r gpgkey /etc/yum.repos.d/* /etc/dnf/dnf.conf"
expect : "Manual Review Required"
dont_echo_cmd : YES
severity : MEDIUM
system : "Linux"
type : CMD_EXEC
description : "1.2.1 Ensure GPG keys are configured - show rpm keys"
info : "The RPM Package Manager implements GPG key signing to verify package integrity during and after 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. To this end, verify that GPG keys are configured correctly for your system.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Update your package manager GPG keys in accordance with site policy.
Additional Information:
Fedora public keys: https://getfedora.org/security/
NIST SP 800-53 Rev. 5:
SI-2"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.14.1,800-53|RA-5,800-53|SI-2,800-53|SI-2(2),800-53r5|RA-5,800-53r5|SI-2,800-53r5|SI-2(2),CN-L3|8.1.4.4(e),CN-L3|8.1.10.5(a),CN-L3|8.1.10.5(b),CN-L3|8.5.4.1(b),CN-L3|8.5.4.1(d),CN-L3|8.5.4.1(e),CSCv7|3.4,CSCv7|3.5,CSCv8|7.3,CSCv8|7.4,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|RA-5,ITSG-33|SI-2,ITSG-33|SI-2(2),LEVEL|1M,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.6.2,NESA|T7.7.1,NIAv2|PR9,PCI-DSSv3.2.1|6.1,PCI-DSSv3.2.1|6.2,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,PCI-DSSv4.0|6.3.3,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "for RPM_PACKAGE in $(rpm -q gpg-pubkey); do echo \"RPM: ${RPM_PACKAGE}\"; RPM_SUMMARY=$(rpm -q --queryformat \"%{SUMMARY}\" \"${RPM_PACKAGE}\"); RPM_PACKAGER=$(rpm -q --queryformat \"%{PACKAGER}\" \"${RPM_PACKAGE}\"); RPM_DATE=$(date +%Y-%m-%d -d \"1970-1-1+$((0x$(rpm -q --queryformat \"%{RELEASE}\" \"${RPM_PACKAGE}\") ))sec\"); RPM_KEY_ID=$(rpm -q --queryformat \"%{VERSION}\" \"${RPM_PACKAGE}\"); echo \"Packager: ${RPM_PACKAGER}\" && echo \"Summary: ${RPM_SUMMARY}\" && echo \"Creation date: ${RPM_DATE}\" && echo \"Key ID: ${RPM_KEY_ID}\" && echo \"\"; done"
expect : "Manual Review Required"
dont_echo_cmd : YES
severity : MEDIUM
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.2.2 Ensure gpgcheck is globally activated - dnf.conf"
info : "The gpgcheck option, found in the main section of the /etc/dnf/dnf.conf and individual /etc/yum.repos.d/* files, determines if an RPM package's signature is checked prior to its installation.
Rationale:
It is important to ensure that an RPM's package signature is always checked prior to installation to ensure that the software is obtained from a trusted source."
solution : "Edit /etc/dnf/dnf.conf and set gpgcheck=1 in the [main] section.
Example:
# sed -i 's/^gpgcheck\s*=\s*.*/gpgcheck=1/' /etc/dnf/dnf.conf
Edit any failing files in /etc/yum.repos.d/* and set all instances starting with gpgcheck to 1.
Example:
# find /etc/yum.repos.d/ -name '*.repo' -exec echo 'Checking:' {} \; -exec sed -i 's/^gpgcheck\s*=\s*.*/gpgcheck=1/' {} \;
Additional Information:
NIST SP 800-53 Rev. 5:
SI-2"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.14.1,800-53|RA-5,800-53|SI-2,800-53|SI-2(2),800-53r5|RA-5,800-53r5|SI-2,800-53r5|SI-2(2),CN-L3|8.1.4.4(e),CN-L3|8.1.10.5(a),CN-L3|8.1.10.5(b),CN-L3|8.5.4.1(b),CN-L3|8.5.4.1(d),CN-L3|8.5.4.1(e),CSCv7|3.4,CSCv8|7.3,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|RA-5,ITSG-33|SI-2,ITSG-33|SI-2(2),LEVEL|1A,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.6.2,NESA|T7.7.1,NIAv2|PR9,PCI-DSSv3.2.1|6.1,PCI-DSSv3.2.1|6.2,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,PCI-DSSv4.0|6.3.3,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/dnf/dnf.conf"
regex : "^[\\s]*gpgcheck[\\s]*="
expect : "^[\\s]*gpgcheck[\\s]*=[\\s]*1[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "1.2.2 Ensure gpgcheck is globally activated - /etc/yum.repos.d/*"
info : "The gpgcheck option, found in the main section of the /etc/dnf/dnf.conf and individual /etc/yum.repos.d/* files, determines if an RPM package's signature is checked prior to its installation.
Rationale:
It is important to ensure that an RPM's package signature is always checked prior to installation to ensure that the software is obtained from a trusted source."
solution : "Edit /etc/dnf/dnf.conf and set gpgcheck=1 in the [main] section.
Example:
# sed -i 's/^gpgcheck\s*=\s*.*/gpgcheck=1/' /etc/dnf/dnf.conf
Edit any failing files in /etc/yum.repos.d/* and set all instances starting with gpgcheck to 1.
Example:
# find /etc/yum.repos.d/ -name '*.repo' -exec echo 'Checking:' {} \; -exec sed -i 's/^gpgcheck\s*=\s*.*/gpgcheck=1/' {} \;
Additional Information:
NIST SP 800-53 Rev. 5:
SI-2"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.14.1,800-53|RA-5,800-53|SI-2,800-53|SI-2(2),800-53r5|RA-5,800-53r5|SI-2,800-53r5|SI-2(2),CN-L3|8.1.4.4(e),CN-L3|8.1.10.5(a),CN-L3|8.1.10.5(b),CN-L3|8.5.4.1(b),CN-L3|8.5.4.1(d),CN-L3|8.5.4.1(e),CSCv7|3.4,CSCv8|7.3,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|RA-5,ITSG-33|SI-2,ITSG-33|SI-2(2),LEVEL|1A,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.6.2,NESA|T7.7.1,NIAv2|PR9,PCI-DSSv3.2.1|6.1,PCI-DSSv3.2.1|6.2,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,PCI-DSSv4.0|6.3.3,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/yum.repos.d/*"
regex : "^\\h*gpgcheck\\h*=\\h*\\b[^1]\\b.*\\h*$"
expect : "^\\h*gpgcheck\\h*=\\h*\\b[^1]\\b.*\\h*$"
system : "Linux"
type : CMD_EXEC
description : "1.2.3 Ensure package manager repositories are configured"
info : "Systems need to have the respective package manager repositories configured to ensure that the system is able to 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.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Configure your package manager repositories according to site policy.
Additional Information:
For further information about Fedora repositories see: https://docs.fedoraproject.org/en-US/quick-docs/repositories/
NIST SP 800-53 Rev. 5:
SI-2"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.14.1,800-53|RA-5,800-53|SI-2,800-53|SI-2(2),800-53r5|RA-5,800-53r5|SI-2,800-53r5|SI-2(2),CN-L3|8.1.4.4(e),CN-L3|8.1.10.5(a),CN-L3|8.1.10.5(b),CN-L3|8.5.4.1(b),CN-L3|8.5.4.1(d),CN-L3|8.5.4.1(e),CSCv7|3.4,CSCv7|3.5,CSCv8|7.3,CSCv8|7.4,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|RA-5,ITSG-33|SI-2,ITSG-33|SI-2(2),LEVEL|1M,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.6.2,NESA|T7.7.1,NIAv2|PR9,PCI-DSSv3.2.1|6.1,PCI-DSSv3.2.1|6.2,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,PCI-DSSv4.0|6.3.3,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/dnf repolist"
expect : "Manual Review Required"
severity : MEDIUM
system : "Linux"
type : RPM_CHECK
description : "1.3.1 Ensure AIDE is installed"
info : "Advanced Intrusion Detection Environment (AIDE) is a intrusion detection tool that uses predefined rules to check the integrity of files and directories in the Linux operating system. AIDE has its own database to check the integrity of files and directories.
AIDE takes a snapshot of files and directories 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."
solution : "Run the following command to install AIDE:
# dnf install aide
Configure AIDE as appropriate for your environment. Consult the AIDE documentation for options.
Initialize AIDE:
Run the following commands:
# aide --init
# mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "aide-0.0.0-0"
operator : "gt"
required : YES
type : CMD_EXEC
description : "Check for crontab aide"
cmd : "/usr/bin/grep -Prs '^([^#]+\\s+)?(\\/usr\\/s?bin\\/|^\\s*)aide(\\.wrapper)?\\s(--?\\S+\\s)*(--(check|update)|\\$AIDEARGS)\\b' /etc/cron.* /etc/crontab /var/spool/cron/ | /usr/bin/awk '{print} END {if (NR == 0) print \"fail\"; else print \"pass\"}'"
expect : "pass"
system : "Linux"
type : CMD_EXEC
description : "1.3.2 Ensure filesystem integrity is regularly checked - cron"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/grep -Prs '^([^#]+\\s+)?(\\/usr\\/s?bin\\/|^\\s*)aide(\\.wrapper)?\\s(--?\\S+\\s)*(--(check|update)|\\$AIDEARGS)\\b' /etc/cron.* /etc/crontab /var/spool/cron/ | /usr/bin/awk '{print} END {if (NR == 0) print \"fail\"; else print \"pass\"}'"
expect : "pass"
description : "1.3.2 Ensure filesystem integrity is regularly checked - systemctl is-enabled aidecheck.service"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "1.3.2 Ensure filesystem integrity is regularly checked - systemctl is-enabled aidecheck.timer"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "1.3.2 Ensure filesystem integrity is regularly checked - systemctl status aidecheck.timer"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "1.3.2 Ensure filesystem integrity is regularly checked - cron"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "1.3.2 Ensure filesystem integrity is regularly checked - systemctl is-enabled aidecheck.service"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled aidecheck.service | /usr/bin/awk '{print} END {if(NR==0) print \"disabled\" }'"
expect : "enabled"
system : "Linux"
type : CMD_EXEC
description : "1.3.2 Ensure filesystem integrity is regularly checked - systemctl is-enabled aidecheck.timer"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled aidecheck.timer | /usr/bin/awk '{print} END {if(NR==0) print \"disabled\" }'"
expect : "enabled"
system : "Linux"
type : CMD_EXEC
description : "1.3.2 Ensure filesystem integrity is regularly checked - systemctl status aidecheck.timer"
info : "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."
solution : "If cron will be used to schedule and run aide check
Run the following command:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
Description=Aide check every day at 5AM
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
Run the following commands:
# chown root:root /etc/systemd/system/aidecheck.*
# chmod 0644 /etc/systemd/system/aidecheck.*
# systemctl daemon-reload
# systemctl enable aidecheck.service
# systemctl --now enable aidecheck.timer"
reference : "800-171|3.1.7,800-171|3.3.1,800-171|3.3.2,800-53|AC-6(9),800-53|AU-2,800-53|AU-12,800-53r5|AC-6(9),800-53r5|AU-2,800-53r5|AU-12,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.3(a),CN-L3|8.1.10.6(a),CSCv7|14.9,CSCv8|3.14,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.12.4.3,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.5.4,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl status aidecheck.timer | /usr/bin/awk '{print} END {if(NR==0) print \"disabled\" }'"
expect : "^[\\s]*Active:[\\s]*active[\\s]*\\((running|waiting)\\).*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.3.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools - auditctl"
info : "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."
solution : "Add or update the following selection lines for to a file ending in .conf in the /etc/aide.conf.d/ directory or to /etc/aide.conf to protect the integrity of the audit tools:
# Audit Tools
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1070, T1070.002, T1083, T1083.000
TA0007"
reference : "800-53|SI-7,800-53r5|SI-7,CSF|PR.DS-6,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(c)(1),HIPAA|164.312(c)(2),HIPAA|164.312(e)(2)(i),ITSG-33|SI-7,ITSG-33|SI-7a.,LEVEL|1A,NESA|T3.4.1,NESA|T7.3.2,NESA|T7.3.3,PCI-DSSv3.2.1|10.5.5,QCSC-v1|3.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/aide.conf.d/*.conf /etc/aide.conf"
regex : "^[\\s]*/sbin/auditctl[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
expect : "^[\\s]*/sbin/auditctl[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.3.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools - auditd"
info : "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."
solution : "Add or update the following selection lines for to a file ending in .conf in the /etc/aide.conf.d/ directory or to /etc/aide.conf to protect the integrity of the audit tools:
# Audit Tools
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1070, T1070.002, T1083, T1083.000
TA0007"
reference : "800-53|SI-7,800-53r5|SI-7,CSF|PR.DS-6,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(c)(1),HIPAA|164.312(c)(2),HIPAA|164.312(e)(2)(i),ITSG-33|SI-7,ITSG-33|SI-7a.,LEVEL|1A,NESA|T3.4.1,NESA|T7.3.2,NESA|T7.3.3,PCI-DSSv3.2.1|10.5.5,QCSC-v1|3.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/aide.conf.d/*.conf /etc/aide.conf"
regex : "^[\\s]*/sbin/auditd[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
expect : "^[\\s]*/sbin/auditd[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.3.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools - ausearch"
info : "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."
solution : "Add or update the following selection lines for to a file ending in .conf in the /etc/aide.conf.d/ directory or to /etc/aide.conf to protect the integrity of the audit tools:
# Audit Tools
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1070, T1070.002, T1083, T1083.000
TA0007"
reference : "800-53|SI-7,800-53r5|SI-7,CSF|PR.DS-6,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(c)(1),HIPAA|164.312(c)(2),HIPAA|164.312(e)(2)(i),ITSG-33|SI-7,ITSG-33|SI-7a.,LEVEL|1A,NESA|T3.4.1,NESA|T7.3.2,NESA|T7.3.3,PCI-DSSv3.2.1|10.5.5,QCSC-v1|3.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/aide.conf.d/*.conf /etc/aide.conf"
regex : "^[\\s]*/sbin/ausearch[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
expect : "^[\\s]*/sbin/ausearch[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.3.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools - aureport"
info : "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."
solution : "Add or update the following selection lines for to a file ending in .conf in the /etc/aide.conf.d/ directory or to /etc/aide.conf to protect the integrity of the audit tools:
# Audit Tools
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1070, T1070.002, T1083, T1083.000
TA0007"
reference : "800-53|SI-7,800-53r5|SI-7,CSF|PR.DS-6,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(c)(1),HIPAA|164.312(c)(2),HIPAA|164.312(e)(2)(i),ITSG-33|SI-7,ITSG-33|SI-7a.,LEVEL|1A,NESA|T3.4.1,NESA|T7.3.2,NESA|T7.3.3,PCI-DSSv3.2.1|10.5.5,QCSC-v1|3.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/aide.conf.d/*.conf /etc/aide.conf"
regex : "^[\\s]*/sbin/aureport[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
expect : "^[\\s]*/sbin/aureport[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.3.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools - autrace"
info : "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."
solution : "Add or update the following selection lines for to a file ending in .conf in the /etc/aide.conf.d/ directory or to /etc/aide.conf to protect the integrity of the audit tools:
# Audit Tools
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1070, T1070.002, T1083, T1083.000
TA0007"
reference : "800-53|SI-7,800-53r5|SI-7,CSF|PR.DS-6,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(c)(1),HIPAA|164.312(c)(2),HIPAA|164.312(e)(2)(i),ITSG-33|SI-7,ITSG-33|SI-7a.,LEVEL|1A,NESA|T3.4.1,NESA|T7.3.2,NESA|T7.3.3,PCI-DSSv3.2.1|10.5.5,QCSC-v1|3.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/aide.conf.d/*.conf /etc/aide.conf"
regex : "^[\\s]*/sbin/autrace[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
expect : "^[\\s]*/sbin/autrace[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.3.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools - augenrules"
info : "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."
solution : "Add or update the following selection lines for to a file ending in .conf in the /etc/aide.conf.d/ directory or to /etc/aide.conf to protect the integrity of the audit tools:
# Audit Tools
/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1070, T1070.002, T1083, T1083.000
TA0007"
reference : "800-53|SI-7,800-53r5|SI-7,CSF|PR.DS-6,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(c)(1),HIPAA|164.312(c)(2),HIPAA|164.312(e)(2)(i),ITSG-33|SI-7,ITSG-33|SI-7a.,LEVEL|1A,NESA|T3.4.1,NESA|T7.3.2,NESA|T7.3.3,PCI-DSSv3.2.1|10.5.5,QCSC-v1|3.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/aide.conf.d/*.conf /etc/aide.conf"
regex : "^[\\s]*/sbin/augenrules[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
expect : "^[\\s]*/sbin/augenrules[\\s]+p\\+i\\+n\\+u\\+g\\+s\\+b\\+acl\\+xattrs\\+sha512"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.4.1 Ensure bootloader password is set"
info : "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 SELinux 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, the configuration files will have to be edited via the LiveCD or other means to fix the problem"
solution : "Create an encrypted password with grub2-setpassword:
# grub2-setpassword
Enter password:
Confirm password:
Additional Information:
This recommendation is designed around the grub2 bootloader, if LILO or another bootloader is in use in your environment enact equivalent settings.
grub2-setpassword outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user.
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/boot/grub2/user.cfg"
regex : "^[\\s]*GRUB2_PASSWORD"
expect : "^[\\s]*GRUB2_PASSWORD[\\s]*=[^\\s]+$"
system : "Linux"
type : FILE_CHECK
description : "1.4.2 Ensure permissions on bootloader config are configured - grub.cfg"
info : "The grub files contain 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."
solution : "Run the following commands to set ownership and permissions on your grub configuration files:
Run the following command to set ownership and permissions on grub.cfg:
# chown root:root /boot/grub2/grub.cfg
# chmod og-rwx /boot/grub2/grub.cfg
Run the following command to set ownership and permissions on grubenv:
# chown root:root /boot/grub2/grubenv
# chmod u-x,og-rwx /boot/grub2/grubenv
Run the following command to set ownership and permissions on user.cfg:
# chown root:root /boot/grub2/user.cfg
# chmod u-x,og-rwx /boot/grub2/user.cfg
Note: This may require a re-boot to enable the change
Default Value:
/boot/grub2/grub.cfg 0700 0/root 0/root
/boot/grub2/grubenv 0600 0/root 0/root
/boot/grub2/user.cfg 0600 0/root 0/root
Additional Information:
This recommendation is designed around the grub bootloader, if LILO or another bootloader is in use in your environment enact equivalent settings."
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/boot/grub2/grub.cfg"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "1.4.2 Ensure permissions on bootloader config are configured - grubenv"
info : "The grub files contain 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."
solution : "Run the following commands to set ownership and permissions on your grub configuration files:
Run the following command to set ownership and permissions on grub.cfg:
# chown root:root /boot/grub2/grub.cfg
# chmod og-rwx /boot/grub2/grub.cfg
Run the following command to set ownership and permissions on grubenv:
# chown root:root /boot/grub2/grubenv
# chmod u-x,og-rwx /boot/grub2/grubenv
Run the following command to set ownership and permissions on user.cfg:
# chown root:root /boot/grub2/user.cfg
# chmod u-x,og-rwx /boot/grub2/user.cfg
Note: This may require a re-boot to enable the change
Default Value:
/boot/grub2/grub.cfg 0700 0/root 0/root
/boot/grub2/grubenv 0600 0/root 0/root
/boot/grub2/user.cfg 0600 0/root 0/root
Additional Information:
This recommendation is designed around the grub bootloader, if LILO or another bootloader is in use in your environment enact equivalent settings."
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/boot/grub2/grubenv"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "1.4.2 Ensure permissions on bootloader config are configured - user.cfg"
info : "The grub files contain 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."
solution : "Run the following commands to set ownership and permissions on your grub configuration files:
Run the following command to set ownership and permissions on grub.cfg:
# chown root:root /boot/grub2/grub.cfg
# chmod og-rwx /boot/grub2/grub.cfg
Run the following command to set ownership and permissions on grubenv:
# chown root:root /boot/grub2/grubenv
# chmod u-x,og-rwx /boot/grub2/grubenv
Run the following command to set ownership and permissions on user.cfg:
# chown root:root /boot/grub2/user.cfg
# chmod u-x,og-rwx /boot/grub2/user.cfg
Note: This may require a re-boot to enable the change
Default Value:
/boot/grub2/grub.cfg 0700 0/root 0/root
/boot/grub2/grubenv 0600 0/root 0/root
/boot/grub2/user.cfg 0600 0/root 0/root
Additional Information:
This recommendation is designed around the grub bootloader, if LILO or another bootloader is in use in your environment enact equivalent settings."
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/boot/grub2/user.cfg"
owner : "root"
mask : "077"
file_required : NO
group : "root"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.5.1 Ensure core dump storage is disabled"
info : "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.
Rationale:
A core dump includes a memory image taken at the time the operating system terminates an application. The memory image could contain sensitive data and is generally useful only for developers trying to debug problems."
solution : "Edit /etc/systemd/coredump.conf and edit or add the following line:
Storage=none"
reference : "800-171|3.1.7,800-53|AC-6(10),800-53r5|AC-6(10),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ITSG-33|AC-6,LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/systemd/coredump.conf"
regex : "^[\\s]*(?i)Storage(?-i)"
expect : "^[\\s]*(?i)Storage(?-i)[\\s]*=[\\s]*none[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.5.2 Ensure core dump backtraces are disabled"
info : "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.
Rationale:
A core dump includes a memory image taken at the time the operating system terminates an application. The memory image could contain sensitive data and is generally useful only for developers trying to debug problems, increasing the risk to the system."
solution : "Edit or add the following line in /etc/systemd/coredump.conf:
ProcessSizeMax=0
Default Value:
ProcessSizeMax=2G"
reference : "800-171|3.1.7,800-53|AC-6(10),800-53r5|AC-6(10),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ITSG-33|AC-6,LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/systemd/coredump.conf"
regex : "^[\\s]*ProcessSizeMax"
expect : "^[\\s]*ProcessSizeMax[\\s]*=[\\s]*0[\\s]*$"
system : "Linux"
type : CMD_EXEC
description : "1.5.3 Ensure address space layout randomization (ASLR) is enabled"
info : "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."
solution : "Run the following script to set:
kernel.randomize_va_space=2
#!/usr/bin/env bash
{
l_output='' l_output2=''
l_parlist='kernel.randomize_va_space=2'
l_searchloc='/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf $([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)'
l_kpfile='/etc/sysctl.d/60-kernel_sysctl.conf'
KPF()
{
# comment out incorrect parameter(s) in kernel parameter file(s)
l_fafile='$(grep -s -- '^\s*$l_kpname' $l_searchloc | grep -Pv -- '\h*=\h*$l_kpvalue\b\h*' | awk -F: '{print $1}')'
for l_bkpf in $l_fafile; do
echo -e '\n - Commenting out \'$l_kpname\' in \'$l_bkpf\''
sed -ri '/$l_kpname/s/^/# /' '$l_bkpf'
done
# Set correct parameter in a kernel parameter file
if ! grep -Pslq -- '^\h*$l_kpname\h*=\h*$l_kpvalue\b\h*(#.*)?$' $l_searchloc; then
echo -e '\n - Setting \'$l_kpname\' to \'$l_kpvalue\' in \'$l_kpfile\''
echo '$l_kpname = $l_kpvalue' >> '$l_kpfile'
fi
# Set correct parameter in active kernel parameters
l_krp='$(sysctl '$l_kpname' | awk -F= '{print $2}' | xargs)'
if [ '$l_krp' != '$l_kpvalue' ]; then
echo -e '\n - Updating \'$l_kpname\' to \'$l_kpvalue\' in the active kernel parameters'
sysctl -w '$l_kpname=$l_kpvalue'
sysctl -w '$(awk -F'.' '{print $1'.'$2'.route.flush=1'}' <<< '$l_kpname')'
fi
}
for l_kpe in $l_parlist; do
l_kpname='$(awk -F= '{print $1}' <<< '$l_kpe')'
l_kpvalue='$(awk -F= '{print $2}' <<< '$l_kpe')'
KPF
done
}
Default Value:
kernel.randomize_va_space = 2"
reference : "800-53|SI-16,800-53r5|SI-16,CSCv7|8.3,CSCv8|10.5,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|SI-16,LEVEL|1A"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_output=\"\" l_output2=\"\"
l_parlist=\"kernel.randomize_va_space=2\"
l_searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf $([ -f /etc/default/ufw ] && awk -F= '/^\\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)\"
KPC()
{
l_krp=\"$(sysctl \"$l_kpname\" | awk -F= '{print $2}' | xargs)\"
l_pafile=\"$(grep -Psl -- \"^\\h*$l_kpname\\h*=\\h*$l_kpvalue\\b\\h*(#.*)?$\" $l_searchloc)\"
l_fafile=\"$(grep -s -- \"^\\s*$l_kpname\" $l_searchloc | grep -Pv -- \"\\h*=\\h*$l_kpvalue\\b\\h*\" | awk -F: '{print $1}')\"
if [ \"$l_krp\" = \"$l_kpvalue\" ]; then
l_output=\"$l_output\\n - \\\"$l_kpname\\\" is set to \\\"$l_kpvalue\\\" in the running configuration\"
else
l_output2=\"$l_output2\\n - \\\"$l_kpname\\\" is set to \\\"$l_krp\\\" in the running configuration\"
fi
if [ -n \"$l_pafile\" ]; then
l_output=\"$l_output\\n - \\\"$l_kpname\\\" is set to \\\"$l_kpvalue\\\" in \\\"$l_pafile\\\"\"
else
l_output2=\"$l_output2\\n - \\\"$l_kpname = $l_kpvalue\\\" is not set in a kernel parameter configuration file\"
fi
[ -n \"$l_fafile\" ] && l_output2=\"$l_output2\\n - \\\"$l_kpname\\\" is set incorrectly in \\\"$l_fafile\\\"\"
}
for l_kpe in $l_parlist; do
l_kpname=\"$(awk -F= '{print $1}' <<< \"$l_kpe\")\"
l_kpvalue=\"$(awk -F= '{print $2}' <<< \"$l_kpe\")\"
KPC
done
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"
expect : "PASS"
system : "Linux"
type : RPM_CHECK
description : "1.6.1.1 Ensure SELinux is installed"
info : "SELinux provides Mandatory Access Control.
Rationale:
Without a Mandatory Access Control system installed only the default Discretionary Access Control system will be available."
solution : "Run the following command to install SELinux:
# dnf install libselinux
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "libselinux-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : CMD_EXEC
description : "1.6.1.2 Ensure SELinux is not disabled in bootloader configuration"
info : "Configure SELINUX to be enabled at boot time and verify that it has not been overwritten by the grub boot parameters.
Rationale:
SELinux must be enabled at boot time in your grub configuration to ensure that the controls it provides are not overridden.
Impact:
ob体育s created while SELinux is disabled are not labeled at all. This behavior causes problems when changing to enforcing mode because files are labeled incorrectly or are not labeled at all. To prevent incorrectly labeled and unlabeled files from causing problems, file systems are automatically relabeled when changing from the disabled state to permissive or enforcing mode. This can be a long running process that should be accounted for as it may extend downtime during initial re-boot."
solution : "Run the following command to remove the selinux=0 and enforcing=0 parameters:
grubby --update-kernel ALL --remove-args 'selinux=0 enforcing=0'
Run the following command to remove the selinux=0 and enforcing=0 parameters if they were created by the deprecated grub2-mkconfig command:
# grep -Prsq -- '\h*([^#\n\r]+\h+)?kernelopts=([^#\n\r]+\h+)?(selinux|enforcing)=0\b' /boot/grub2 /boot/efi && grub2-mkconfig -o '$(grep -Prl -- '\h*([^#\n\r]+\h+)?kernelopts=([^#\n\r]+\h+)?(selinux|enforcing)=0\b' /boot/grub2 /boot/efi)'
Additional Information:
This recommendation is designed around the grub 2 bootloader, if another bootloader is in use in your environment enact equivalent settings.
grubby is a command line tool for updating and displaying information about the configuration files for the grub2 and zipl boot loaders. It is primarily designed to be used from scripts which install new kernels and need to find information about the current boot environment.
All bootloaders define the boot entries as individual configuration fragments that are stored by default in /boot/loader/entries. The format for the config files is specified at https://systemd.io/BOOT_LOADER_SPECIFICATION. The grubby tool is used to update and display the configuration defined in the BootLoaderSpec fragment files.
There are a number of ways to specify the kernel used for --info, --remove-kernel, and --update-kernel. Specifying DEFAULT or ALL selects the de-fault entry and all of the entries, respectively. Also, the title of a boot entry may be specified by using TITLE=title as the argument; all entries with that title are used."
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/grubby --info=ALL | /usr/bin/grep '(selinux|enforcing)=0' | /usr/bin/awk '{print} END {if (NR == 0) print \"pass\" ; else print \"fail\"}'"
expect : "pass"
type : FILE_CONTENT_CHECK
description : "1.6.1.3 Ensure SELinux policy is configured - /etc/selinux/config"
info : "Configure SELinux to meet or exceed the default targeted policy, which constrains daemons and system software only.
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 at least the default recommendations are met."
solution : "Edit the /etc/selinux/config file to set the SELINUXTYPE parameter:
SELINUXTYPE=targeted
Additional Information:
If your organization requires stricter policies, ensure that they are set in the /etc/selinux/config file.
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/selinux/config"
regex : "^[\\s]*[sS][eE][lL][iI][nN][uU][xX][tT][yY][pP][eE][\\s]*="
expect : "^[\\s]*[sS][eE][lL][iI][nN][uU][xX][tT][yY][pP][eE][\\s]*=[\\s]*[Tt][Aa][Rr][Gg][Ee][Tt][Ee][Dd][\\s]*$"
system : "Linux"
type : CMD_EXEC
description : "1.6.1.3 Ensure SELinux policy is configured - sestatus"
info : "Configure SELinux to meet or exceed the default targeted policy, which constrains daemons and system software only.
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 at least the default recommendations are met."
solution : "Edit the /etc/selinux/config file to set the SELINUXTYPE parameter:
SELINUXTYPE=targeted
Additional Information:
If your organization requires stricter policies, ensure that they are set in the /etc/selinux/config file.
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/sestatus"
expect : "^[\\s]*Loaded policy name:[\\s]+([Tt][Aa][Rr][Gg][Ee][Tt][Ee][Dd]|[Mm][Ll][Ss])$"
system : "Linux"
type : CMD_EXEC
description : "1.6.1.4 Ensure the SELinux mode is not disabled - getenforce"
info : "SELinux can run in one of three modes: disabled, permissive, or enforcing:
Enforcing - Is the default, and recommended, mode of operation; in enforcing mode SELinux operates normally, enforcing the loaded security policy on the entire system.
Permissive - The system acts as if SELinux is enforcing the loaded security policy, including labeling objects and emitting access denial entries in the logs, but it does not actually deny any operations. While not recommended for production systems, permissive mode can be helpful for SELinux policy development.
Disabled - Is strongly discouraged; not only does the system avoid enforcing the SELinux policy, it also avoids labeling any persistent objects such as files, making it difficult to enable SELinux in the future
Note: you can set individual domains to permissive mode while the system runs in enforcing mode. For example, to make the httpd_t domain permissive:
# semanage permissive -a httpd_t
Rationale:
Running SELinux in disabled mode is strongly discouraged; not only does the system avoid enforcing the SELinux policy, it also avoids labeling any persistent objects such as files, making it difficult to enable SELinux in the future."
solution : "Run one of the following commands to set SELinux's running mode:
To set SELinux mode to Enforcing:
# setenforce 1
OR
To set SELinux mode to Permissive:
# setenforce 0
Edit the /etc/selinux/config file to set the SELINUX parameter:
For Enforcing mode:
SELINUX=enforcing
OR
For Permissive mode:
SELINUX=permissive"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/getenforce"
expect : "([\\s]*[,]?Enforcing|Permissive)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "1.6.1.4 Ensure the SELinux mode is not disabled - /etc/selinux/config"
info : "SELinux can run in one of three modes: disabled, permissive, or enforcing:
Enforcing - Is the default, and recommended, mode of operation; in enforcing mode SELinux operates normally, enforcing the loaded security policy on the entire system.
Permissive - The system acts as if SELinux is enforcing the loaded security policy, including labeling objects and emitting access denial entries in the logs, but it does not actually deny any operations. While not recommended for production systems, permissive mode can be helpful for SELinux policy development.
Disabled - Is strongly discouraged; not only does the system avoid enforcing the SELinux policy, it also avoids labeling any persistent objects such as files, making it difficult to enable SELinux in the future
Note: you can set individual domains to permissive mode while the system runs in enforcing mode. For example, to make the httpd_t domain permissive:
# semanage permissive -a httpd_t
Rationale:
Running SELinux in disabled mode is strongly discouraged; not only does the system avoid enforcing the SELinux policy, it also avoids labeling any persistent objects such as files, making it difficult to enable SELinux in the future."
solution : "Run one of the following commands to set SELinux's running mode:
To set SELinux mode to Enforcing:
# setenforce 1
OR
To set SELinux mode to Permissive:
# setenforce 0
Edit the /etc/selinux/config file to set the SELINUX parameter:
For Enforcing mode:
SELINUX=enforcing
OR
For Permissive mode:
SELINUX=permissive"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/selinux/config"
regex : "^[\\s]*[sS][eE][lL][iI][nN][uU][xX][\\s]*="
expect : "(^[\\s]*[sS][eE][lL][iI][nN][uU][xX][\\s]*=[\\s]*([eE][nN][fF][oO][rR][cC][iI][nN][gG]|[pP][eE][rR][mM][iI][sS][sS][iI][vV][eE])[\\s]*$)"
system : "Linux"
type : CMD_EXEC
description : "1.6.1.6 Ensure no unconfined services exist"
info : "Unconfined processes run in unconfined domains
Rationale:
For unconfined processes, SELinux policy rules are applied, but policy rules exist that allow processes running in unconfined domains almost all access. Processes running in unconfined domains fall back to using DAC rules exclusively. If an unconfined process is compromised, SELinux does not prevent an attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement on top of DAC rules - it does not replace them"
solution : "Investigate any unconfined processes found during the audit action. They may need to have an existing security context assigned to them or a policy built for them.
Additional Information:
Occasionally certain daemons such as backup or centralized management software may require running unconfined. Any such software should be carefully analyzed and documented before such an exception is made.
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|9.2,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/ps -eZ | /usr/bin/grep unconfined_service_t | /usr/bin/awk -F: '{ print $NF } END {if (NR == 0) print \"none\"}'"
expect : "none"
dont_echo_cmd : YES
system : "Linux"
type : RPM_CHECK
description : "1.6.1.7 Ensure SETroubleshoot is not installed"
info : "The SETroubleshoot service notifies desktop users of SELinux denials through a user-friendly interface. The service provides important information around configuration errors, unauthorized intrusions, and other potential errors.
Rationale:
The SETroubleshoot service is an unnecessary daemon to have running on a server, especially if X Windows is disabled."
solution : "Run the following command to uninstall setroubleshoot:
# dnf remove setroubleshoot
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|14.6,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "setroubleshoot-0.0.0-0"
operator : "lt"
system : "Linux"
type : RPM_CHECK
description : "1.6.1.8 Ensure the MCS Translation Service (mcstrans) is not installed"
info : "The mcstransd daemon provides category label information to client processes requesting information. The label translations are defined in /etc/selinux/targeted/setrans.conf
Rationale:
Since this service is not used very often, remove it to reduce the amount of potentially vulnerable code running on the system."
solution : "Run the following command to uninstall mcstrans:
# dnf remove mcstrans"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "mcstrans-0.0.0-0"
operator : "lt"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "1.7.1 Ensure message of the day is configured properly"
info : "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."
solution : "Edit the /etc/motd file with the appropriate contents according to your site policy, remove any instances of \m , \r , \s , \v or references to the OS platform
OR
If the motd is not used, this file can be removed.
Run the following command to remove the motd file:
# rm /etc/motd
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1082, T1082.000, T1592, T1592.004
TA0007"
reference : "800-171|3.4.2,800-53|CM-6b.,800-53r5|CM-6b.,CN-L3|8.1.10.6(d),CSF|PR.IP-1,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6b.,LEVEL|1A,NESA|T3.2.1,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/motd"
regex : "\\\\[mrsv]"
expect : "\\\\[mrsv]"
required : NO
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "1.7.2 Ensure local login warning banner is configured properly"
info : "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."
solution : "Edit the /etc/issue file with the appropriate contents according to your site policy, remove any instances of \m , \r , \s , \v or references to the OS platform
# echo 'Authorized uses only. All activity may be monitored and reported.' > /etc/issue
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1082, T1082.000, T1592, T1592.004
TA0007"
reference : "800-171|3.4.2,800-53|CM-6b.,800-53r5|CM-6b.,CN-L3|8.1.10.6(d),CSF|PR.IP-1,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6b.,LEVEL|1A,NESA|T3.2.1,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/issue"
regex : "\\\\[mrsv]"
expect : "\\\\[mrsv]"
required : NO
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "1.7.3 Ensure remote login warning banner is configured properly"
info : "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."
solution : "Edit the /etc/issue.net file with the appropriate contents according to your site policy, remove any instances of \m , \r , \s , \v or references to the OS platform
# echo 'Authorized uses only. All activity may be monitored and reported.' > /etc/issue.net
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1018, T1018.000, T1082, T1082.000, T1592, T1592.004
TA0007"
reference : "800-171|3.4.2,800-53|CM-6b.,800-53r5|CM-6b.,CN-L3|8.1.10.6(d),CSF|PR.IP-1,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6b.,LEVEL|1A,NESA|T3.2.1,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/issue.net"
regex : "\\\\[mrsv]"
expect : "\\\\[mrsv]"
required : NO
system : "Linux"
type : FILE_CHECK
description : "1.7.4 Ensure permissions on /etc/motd are configured"
info : "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."
solution : "Run the following commands to set permissions on /etc/motd :
# chown root:root /etc/motd
# chmod u-x,go-wx /etc/motd
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/motd"
owner : "root"
mask : "133"
required : NO
group : "root"
system : "Linux"
type : FILE_CHECK
description : "1.7.5 Ensure permissions on /etc/issue are configured"
info : "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."
solution : "Run the following commands to set permissions on /etc/issue :
# chown root:root /etc/issue
# chmod u-x,go-wx /etc/issue
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/issue"
owner : "root"
mask : "133"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "1.7.6 Ensure permissions on /etc/issue.net are configured"
info : "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."
solution : "Run the following commands to set permissions on /etc/issue.net :
# chown root:root /etc/issue.net
# chmod u-x,go-wx /etc/issue.net
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/issue.net"
owner : "root"
mask : "133"
group : "root"
system : "Linux"
type : CMD_EXEC
description : "1.8.2 Ensure GDM login banner is configured"
info : "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."
solution : "Run the following script to verify that the banner message is enabled and set:
#!/usr/bin/env bash
{
l_pkgoutput=''
if command -v dpkg-query > /dev/null 2>&1; then
l_pq='dpkg-query -W'
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
}
Note:
There is no character limit for the banner message. gnome-shell autodetects longer stretches of text and enters two column mode.
The banner message cannot be read from an external file.
OR
Run the following command to remove the gdm package:
# dnf remove gdm
Default Value:
disabled"
reference : "800-171|3.1.9,800-53|AC-8,800-53r5|AC-8,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|AC-8,LEVEL|1A,NESA|M1.3.6,TBA-FIISB|45.2.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_pkgoutput=\"\"
if command -v dpkg-query > /dev/null 2>&1; then
l_pq=\"dpkg-query -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.3 Ensure GDM disable-user-list option is enabled"
info : "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."
solution : "Run the following script to enable the disable-user-list option:
Note: the l_gdm_profile variable in the script can be changed if a different profile name is desired in accordance with local site policy.
#!/usr/bin/env bash
{
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:
# dnf remove gdm
Default Value:
false"
reference : "800-171|3.1.10,800-53|AC-11(1),800-53r5|AC-11(1),CN-L3|8.1.4.1(b),GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(iii),ISO/IEC-27001|A.11.2.8,ITSG-33|AC-11(1),LEVEL|1A,NIAv2|AM23c,NIAv2|AM23d,PCI-DSSv3.2.1|8.1.8,PCI-DSSv4.0|8.2.8"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_pkgoutput=\"\"
if command -v dpkg-query > /dev/null 2>&1; then
l_pq=\"dpkg-query -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.4 Ensure GDM screen locks when the user is idle"
info : "GNOME Desktop Manager can make the screen lock automatically whenever the user is idle for some amount of time.
idle-delay=uint32 {n} - Number of seconds of inactivity before the screen goes blank
lock-delay=uint32 {n} - Number of seconds after the screen is blank before locking the screen
Example key file:
# Specify the dconf path
[org/gnome/desktop/session]
# Number of seconds of inactivity before the screen goes blank
# Set to 0 seconds if you want to deactivate the screensaver.
idle-delay=uint32 900
# Specify the dconf path
[org/gnome/desktop/screensaver]
# 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."
solution : "Create or edit a file in the /etc/dconf/profile/ and verify it includes the following:
user-db:user
system-db:{NAME_OF_DCONF_DATABASE}
Note: local is the name of a dconf database used in the examples.
Example:
# echo -e '\nuser-db:user\nsystem-db:local' >> /etc/dconf/profile/user
Create the directory /etc/dconf/db/{NAME_OF_DCONF_DATABASE}.d/ if it doesn't already exist:
Example:
# mkdir /etc/dconf/db/local.d
Create the key file '/etc/dconf/db/{NAME_OF_DCONF_DATABASE}.d/{FILE_NAME} to provide information for the {NAME_OF_DCONF_DATABASE} database:
Example script:
#!/usr/bin/env bash
{
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."
reference : "800-171|3.1.1,800-171|3.1.10,800-171|3.1.11,800-53|AC-2(5),800-53|AC-11,800-53|AC-11(1),800-53|AC-12,800-53r5|AC-2(5),800-53r5|AC-11,800-53r5|AC-11(1),800-53r5|AC-12,CN-L3|7.1.2.2(d),CN-L3|7.1.3.2(d),CN-L3|7.1.3.7(b),CN-L3|8.1.4.1(b),CSCv7|16.11,CSCv8|4.3,CSF|PR.AC-1,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(a)(2)(iii),ISO/IEC-27001|A.9.2.1,ISO/IEC-27001|A.11.2.8,ITSG-33|AC-2(5),ITSG-33|AC-11,ITSG-33|AC-11(1),ITSG-33|AC-12,LEVEL|1A,NIAv2|AM23c,NIAv2|AM23d,NIAv2|AM28,NIAv2|NS5j,NIAv2|NS49,NIAv2|SS14e,PCI-DSSv3.2.1|8.1.8,PCI-DSSv4.0|8.2.8,QCSC-v1|5.2.2,QCSC-v1|8.2.1,QCSC-v1|13.2,QCSC-v1|15.2,TBA-FIISB|36.2.1,TBA-FIISB|37.1.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_pkgoutput=\"\"
if command -v dpkg-query > /dev/null 2>&1; then
l_pq=\"dpkg-query -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.5 Ensure GDM screen locks cannot be overridden"
info : "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 ob体育:
# 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."
solution : "Run the following script to ensure screen locks cannot be overridden:
#!/usr/bin/env bash
{
# 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 -W'
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
}
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."
reference : "800-171|3.1.1,800-171|3.1.10,800-171|3.1.11,800-53|AC-2(5),800-53|AC-11,800-53|AC-11(1),800-53|AC-12,800-53r5|AC-2(5),800-53r5|AC-11,800-53r5|AC-11(1),800-53r5|AC-12,CN-L3|7.1.2.2(d),CN-L3|7.1.3.2(d),CN-L3|7.1.3.7(b),CN-L3|8.1.4.1(b),CSCv7|16.11,CSCv8|4.3,CSF|PR.AC-1,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(a)(2)(iii),ISO/IEC-27001|A.9.2.1,ISO/IEC-27001|A.11.2.8,ITSG-33|AC-2(5),ITSG-33|AC-11,ITSG-33|AC-11(1),ITSG-33|AC-12,LEVEL|1A,NIAv2|AM23c,NIAv2|AM23d,NIAv2|AM28,NIAv2|NS5j,NIAv2|NS49,NIAv2|SS14e,PCI-DSSv3.2.1|8.1.8,PCI-DSSv4.0|8.2.8,QCSC-v1|5.2.2,QCSC-v1|8.2.1,QCSC-v1|13.2,QCSC-v1|15.2,TBA-FIISB|36.2.1,TBA-FIISB|37.1.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_pkgoutput=\"\"
if command -v dpkg-query > /dev/null 2>&1; then
l_pq=\"dpkg-query -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.6 Ensure GDM automatic mounting of removable media is disabled"
info : "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."
solution : "Run the following script to disable automatic mounting of media for all GNOME users:
#!/usr/bin/env bash
{
l_pkgoutput=''
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 -W'
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')'
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
if [ ! -f '/etc/dconf/profile/user' ]; then
l_gpfile='/etc/dconf/profile/user'
else
l_gpfile='/etc/dconf/profile/user2'
fi
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 '[org/gnome/desktop/media-handling]' >> '$l_kfile'
sed -ri '/^\s*\[org\/gnome\/desktop\/media-handling\]/a \\nautomount=false' '$l_kfile'
fi
# update dconf database
dconf update
else
echo -e '\n - GNOME Desktop Manager package is not installed on the system\n - Recommendation is not applicable'
fi
}
OR
Run the following command to uninstall the GNOME desktop Manager package:
# dnf remove gdm"
reference : "800-171|3.8.7,800-53|MP-7,800-53r5|MP-7,CN-L3|8.5.4.1(c),CSCv7|8.5,CSCv8|10.3,CSF|PR.PT-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.8.3.1,ISO/IEC-27001|A.8.3.3,LEVEL|1A,NESA|T1.4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "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 -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.7 Ensure GDM disabling automatic mounting of removable media is not overridden"
info : "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 ob体育:
# Lock automount 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"
solution : "Run the following script to lock disable automatic mounting of media for all GNOME users:
#!/usr/bin/env bash
{
# 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 -W'
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
}"
reference : "800-171|3.8.7,800-53|MP-7,800-53r5|MP-7,CN-L3|8.5.4.1(c),CSCv7|8.5,CSCv8|10.3,CSF|PR.PT-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.8.3.1,ISO/IEC-27001|A.8.3.3,LEVEL|1A,NESA|T1.4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_pkgoutput=\"\"
if command -v dpkg-query > /dev/null 2>&1; then
l_pq=\"dpkg-query -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.8 Ensure GDM autorun-never is enabled"
info : "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."
solution : "Run the following script to set autorun-never to true for GDM users:
#!/usr/bin/env bash
{
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 -W'
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
}
Default Value:
false"
reference : "800-171|3.8.7,800-53|MP-7,800-53r5|MP-7,CN-L3|8.5.4.1(c),CSCv7|8.5,CSCv8|10.3,CSF|PR.PT-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.8.3.1,ISO/IEC-27001|A.8.3.3,LEVEL|1A,NESA|T1.4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "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 -W\"
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "1.8.9 Ensure GDM autorun-never is not overridden"
info : "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 ob体育:
# 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."
solution : "Run the following script to ensure that autorun-never=true cannot be overridden:
#!/usr/bin/env bash
{
# 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 -W'
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 -Priq '^\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
}"
reference : "800-171|3.8.7,800-53|MP-7,800-53r5|MP-7,CN-L3|8.5.4.1(c),CSCv7|8.5,CSCv8|10.3,CSF|PR.PT-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.8.3.1,ISO/IEC-27001|A.8.3.3,LEVEL|1A,NESA|T1.4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_pkgoutput=\"\"
if command -v dpkg-query > /dev/null 2>&1; then
l_pq=\"dpkg-query -W\"
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 -Piq '^\\h*\\/org/gnome\\/desktop\\/media-handling\\/autorun-never\\b' \"$l_kfd\"; then
l_output=\"$l_output\\n - \\\"autorun-never\\\" is locked in \\\"$(grep -Pil '^\\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"
expect : "PASS"
type : RPM_CHECK
description : "Check GDM installed"
rpm : "gdm-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "1.8.10 Ensure XDCMP is not enabled"
info : "X Display Manager Control Protocol (XDMCP) is designed to provide authenticated access to display management services for remote displays
Rationale:
XDMCP is inherently insecure.
XDMCP is not a ciphered protocol. This may allow an attacker to capture keystrokes entered by a user
XDMCP is vulnerable to man-in-the-middle attacks. This may allow an attacker to steal the credentials of legitimate users by impersonating the XDMCP server."
solution : "Edit the file /etc/gdm/custom.conf and remove the line:
Enable=true
Default Value:
false (This is denoted by no Enabled= entry in the file /etc/gdm/custom.conf in the [xdmcp] section"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/gdm/custom.conf"
regex : "^[\\s]*[Ee]nable[\\s]*="
expect : "^[\\s]*[Ee]nable[\\s]*=[\\s]*true[\\s]*$"
description : "1.8.10 Ensure XDCMP is not enabled"
info : "X Display Manager Control Protocol (XDMCP) is designed to provide authenticated access to display management services for remote displays
Rationale:
XDMCP is inherently insecure.
XDMCP is not a ciphered protocol. This may allow an attacker to capture keystrokes entered by a user
XDMCP is vulnerable to man-in-the-middle attacks. This may allow an attacker to steal the credentials of legitimate users by impersonating the XDMCP server."
solution : "Edit the file /etc/gdm/custom.conf and remove the line:
Enable=true
Default Value:
false (This is denoted by no Enabled= entry in the file /etc/gdm/custom.conf in the [xdmcp] section"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "1.9 Ensure updates, patches, and additional security software are installed"
info : "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."
solution : "Use your package manager to update all packages on the system according to site policy.
The following command will install all available updates:
# dnf update
Once the update process is complete, verify if reboot is required to load changes.
dnf needs-restarting -r
Additional Information:
Site policy may mandate a testing period before install onto production systems for available updates.
# dnf check-update"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.14.1,800-53|RA-5,800-53|SI-2,800-53|SI-2(2),800-53r5|RA-5,800-53r5|SI-2,800-53r5|SI-2(2),CN-L3|8.1.4.4(e),CN-L3|8.1.10.5(a),CN-L3|8.1.10.5(b),CN-L3|8.5.4.1(b),CN-L3|8.5.4.1(d),CN-L3|8.5.4.1(e),CSCv7|3.4,CSCv8|7.3,CSCv8|7.4,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|RA-5,ITSG-33|SI-2,ITSG-33|SI-2(2),LEVEL|1M,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.6.2,NESA|T7.7.1,NIAv2|PR9,PCI-DSSv3.2.1|6.1,PCI-DSSv3.2.1|6.2,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,PCI-DSSv4.0|6.3.3,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/dnf check-update && echo 'pass' || echo 'fail'"
expect : "^pass$"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "1.10 Ensure system-wide crypto policy is not legacy"
info : "The system-wide crypto-policies followed by the crypto core components allow consistently deprecating and disabling algorithms system-wide.
The individual policy levels (DEFAULT, LEGACY, FUTURE, and FIPS) are included in the crypto-policies(7) package.
Rationale:
If the Legacy system-wide crypto policy is selected, it includes support for TLS 1.0, TLS 1.1, and SSH2 protocols or later. The algorithms DSA, 3DES, and RC4 are allowed, while RSA and Diffie-Hellman parameters are accepted if larger than 1023-bits.
These legacy protocols and algorithms can make the system vulnerable to attacks, including those listed in RFC 7457
Impact:
Environments that require compatibility with older insecure protocols may require the use of the less secure LEGACY policy level."
solution : "Run the following command to change the system-wide crypto policy
# update-crypto-policies --set
Example:
# update-crypto-policies --set DEFAULT
Run the following to make the updated system-wide crypto policy active
# update-crypto-policies
Default Value:
DEFAULT"
reference : "800-171|3.1.13,800-171|3.5.2,800-171|3.13.8,800-53|AC-17(2),800-53|IA-5,800-53|IA-5(1),800-53|SC-8,800-53|SC-8(1),800-53r5|AC-17(2),800-53r5|IA-5,800-53r5|IA-5(1),800-53r5|SC-8,800-53r5|SC-8(1),CN-L3|7.1.2.7(g),CN-L3|7.1.3.1(d),CN-L3|8.1.2.2(a),CN-L3|8.1.2.2(b),CN-L3|8.1.4.1(c),CN-L3|8.1.4.7(a),CN-L3|8.1.4.8(a),CN-L3|8.2.4.5(c),CN-L3|8.2.4.5(d),CN-L3|8.5.2.2,CSCv7|14.4,CSCv8|3.10,CSF|PR.AC-1,CSF|PR.AC-3,CSF|PR.DS-2,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),HIPAA|164.312(e)(1),HIPAA|164.312(e)(2)(i),ISO/IEC-27001|A.6.2.2,ISO/IEC-27001|A.10.1.1,ISO/IEC-27001|A.13.2.3,ITSG-33|AC-17(2),ITSG-33|IA-5,ITSG-33|IA-5(1),ITSG-33|SC-8,ITSG-33|SC-8(1),ITSG-33|SC-8a.,LEVEL|1A,NESA|T4.3.1,NESA|T4.3.2,NESA|T4.5.1,NESA|T4.5.2,NESA|T5.2.3,NESA|T5.4.2,NESA|T7.3.3,NESA|T7.4.1,NIAv2|AM37,NIAv2|IE8,NIAv2|IE9,NIAv2|IE12,NIAv2|NS5d,NIAv2|NS6b,NIAv2|NS29,NIAv2|SS24,PCI-DSSv3.2.1|2.3,PCI-DSSv3.2.1|4.1,PCI-DSSv4.0|2.2.7,PCI-DSSv4.0|4.2.1,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|2.1,SWIFT-CSCv1|2.6,SWIFT-CSCv1|4.1,TBA-FIISB|29.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/crypto-policies/config"
regex : "^[\\s]*(?i)LEGACY(?-i)[\\s]*([\\s]+#.*)?$"
expect : "^[\\s]*(?i)LEGACY(?-i)[\\s]*([\\s]+#.*)?$"
system : "Linux"
type : RPM_CHECK
description : "2.1.1 Ensure time synchronization is in use"
info : "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: If another method for time synchronization is being used, this section may be skipped.
Rationale:
Time synchronization is important to support time sensitive security mechanisms like Kerberos and also ensures log files have consistent time records across the enterprise, which aids in forensic investigations."
solution : "Run the following command to install chrony:
# dnf install chrony
Additional Information:
On systems where host based time synchronization is not available, verify that chrony is installed.
On systems where host based time synchronization is available consult your documentation and verify that host based synchronization is in use.
NIST SP 800-53 Rev. 5:
AU-3
AU-12"
reference : "800-171|3.3.6,800-171|3.3.7,800-53|AU-7,800-53|AU-8,800-53r5|AU-7,800-53r5|AU-8,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(b),CSCv7|6.1,CSCv8|8.4,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-7,ITSG-33|AU-8,LEVEL|1A,NESA|T3.6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4,TBA-FIISB|37.4"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "chrony-0.0.0-0"
operator : "gt"
required : YES
#Removed NTP Test case
system : "Linux"
type : FILE_CONTENT_CHECK
description : "2.1.2 Ensure chrony is configured - user"
info : "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. More information on chrony can be found at http://chrony.tuxfamily.org/. chrony can be configured to be a client and/or a server.
Rationale:
If chrony is in use on the system proper configuration is vital to ensuring time synchronization is working properly."
solution : "Add or edit server or pool lines to /etc/chrony.conf as appropriate:
server
Add or edit the OPTIONS in /etc/sysconfig/chronyd to include '-u chrony':
OPTIONS='-u chrony'
Additional Information:
On systems where host based time synchronization is not available, verify that chrony is installed.
On systems where host based time synchronization is available consult your documentation and verify that host based synchronization is in use.
NIST SP 800-53 Rev. 5:
AU-3
AU-12"
reference : "800-171|3.3.6,800-171|3.3.7,800-53|AU-7,800-53|AU-8,800-53r5|AU-7,800-53r5|AU-8,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(b),CSCv7|6.1,CSCv8|8.4,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-7,ITSG-33|AU-8,LEVEL|1A,NESA|T3.6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4,TBA-FIISB|37.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/sysconfig/chronyd"
regex : "^[\\s]*OPTIONS[\\s]*="
expect : "^[\\s]*OPTIONS[\\s]*=[\\s]*\"([^\"#]*\\s+)*-u\\schrony\\b[^\"#]*\"\\s*(?:#.*)?$"
system : "Linux"
type : RPM_CHECK
description : "2.2.2 Ensure Avahi Server is not installed"
info : "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."
solution : "Run the following commands to stop, mask and remove avahi:
# systemctl stop avahi-daemon.socket avahi-daemon.service
# dnf remove avahi
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "avahi-0.0.0-0"
operator : "lt"
system : "Linux"
type : RPM_CHECK
description : "2.2.3 Ensure CUPS is not installed"
info : "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.
Note: Removing CUPS will prevent printing from the system
Impact:
Disabling CUPS will prevent printing from the system, a common task for workstation systems."
solution : "Run the following command to remove cups:
# dnf remove cups"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "cups-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.4 Ensure DHCP Server is not installed"
info : "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 the dhcp-server package be removed to reduce the potential attack surface."
solution : "Run the following command to remove dhcp:
# dnf remove dhcp-server"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "dhcp-server-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.5 Ensure DNS Server is not installed"
info : "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 removed to reduce the potential attack surface."
solution : "Run the following command to remove bind:
# dnf remove bind
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "bind-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.6 Ensure VSFTP Server is not installed"
info : "FTP (ob体育 Transfer Protocol) is a traditional and widely used standard tool for transferring files between a server and clients over a network, especially where no authentication is necessary (permits anonymous users to connect to a server).
Rationale:
Unless there is a need to run the system as a FTP server, it is recommended that the package be removed to reduce the potential attack surface."
solution : "Run the following command to remove vsftpd:
# dnf remove vsftpd
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "vsftpd-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.7 Ensure TFTP Server is not installed"
info : "Trivial ob体育 Transfer Protocol (TFTP) is a simple protocol for exchanging files between two TCP/IP machines. TFTP servers allow connections from a TFTP Client for sending and receiving files.
Rationale:
Unless there is a need to run the system as a TFTP server, it is recommended that the package be removed to reduce the potential attack surface.
TFTP does not have built-in encryption, access control or authentication. This makes it very easy for an attacker to exploit TFTP to gain access to files
Impact:
TFTP is often used to provide files for network booting such as for PXE based installation of servers."
solution : "Run the following command to remove tftp-server:
# dnf remove tftp-server
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "tftp-server-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.8 Ensure a web server is not installed - httpd"
info : "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 packages be removed to reduce the potential attack surface.
Note: Several http servers exist. They should also be audited, and removed, if not required."
solution : "Run the following command to remove httpd and nginx:
# dnf remove httpd nginx
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "httpd-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.8 Ensure a web server is not installed - nginx"
info : "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 packages be removed to reduce the potential attack surface.
Note: Several http servers exist. They should also be audited, and removed, if not required."
solution : "Run the following command to remove httpd and nginx:
# dnf remove httpd nginx
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "nginx-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.9 Ensure IMAP and POP3 server is not installed - dovecot"
info : "dovecot is 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.
Note: Several IMAP/POP3 servers exist and can use other service names. These should also be audited and the packages removed if not required."
solution : "Run the following command to remove dovecot and cyrus-imapd:
# dnf remove dovecot cyrus-imapd
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "dovecot-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.9 Ensure IMAP and POP3 server is not installed - cyrus-imapd"
info : "dovecot is 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.
Note: Several IMAP/POP3 servers exist and can use other service names. These should also be audited and the packages removed if not required."
solution : "Run the following command to remove dovecot and cyrus-imapd:
# dnf remove dovecot cyrus-imapd
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "cyrus-imapd-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.10 Ensure Samba is not installed"
info : "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 package can be removed to reduce the potential attack surface."
solution : "Run the following command to remove samba:
# dnf remove samba
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "samba-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.11 Ensure HTTP Proxy Server is not installed"
info : "Squid is a standard proxy server used in many distributions and environments.
Rationale:
Unless a system is specifically set up to act as a proxy server, it is recommended that the squid package be removed to reduce the potential attack surface.
Note: Several HTTP proxy servers exist. These should be checked and removed unless required."
solution : "Run the following command to remove the squid package:
# dnf remove squid
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "squid-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "net-snmp is installed"
rpm : "net-snmp-0.0.0-0"
operator : "lt"
description : "2.2.12 Ensure net-snmp is not installed"
info : "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 net-snmp 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."
solution : "Run the following command to remove net-snmpd:
# dnf remove net-snmp
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|2.6,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "v1 enabled"
file : "/etc/snmp/snmpd.conf"
regex : "^[\\s]*group.*v1"
expect : "^[\\s]*group.*v1"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "v2c community string"
file : "/etc/snmp/snmpd.conf"
regex : "^[\\s]*r[ow]community"
expect : "^[\\s]*r[ow]community (public|private)"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "v2c community string"
file : "/etc/snmp/snmpd.conf"
regex : "^[\\s]*com2sec"
expect : "^[\\s]*com2sec.*(public|private)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "v3 users"
file : "/etc/snmp/snmpd.conf"
regex : "^[\\s]*r[ow]user"
expect : "^[\\s]*r[ow]user.*authPriv"
string_required : NO
description : "2.2.12 Ensure net-snmp is not installed"
info : "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 net-snmp 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."
solution : "Run the following command to remove net-snmpd:
# dnf remove net-snmp
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|2.6,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
show_output : YES
system : "Linux"
type : RPM_CHECK
description : "2.2.13 Ensure telnet-server is not installed"
info : "The telnet-server package contains the telnet daemon, which accepts connections from users from other systems via the telnet protocol.
Rationale:
The telnet protocol is insecure and unencrypted. The use of an unencrypted transmission medium could allow a user with access to sniff network traffic the ability to steal credentials. The ssh package provides an encrypted session and stronger security."
solution : "Run the following command to remove the telnet-server package:
# dnf remove telnet-server
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|2.6,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "telnet-server-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.14 Ensure dnsmasq is not installed"
info : "dnsmasq is 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."
solution : "Run the following command to remove dnsmasq:
# dnf remove dnsmasq
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1203, T1203.000, T1210, T1210.000, T1543, T1543.002
TA0008
M1042"
reference : "800-171|3.4.6,800-171|3.4.7,800-53|CM-7b.,800-53r5|CM-7b.,CN-L3|7.1.3.5(c),CN-L3|7.1.3.7(d),CN-L3|8.1.4.4(b),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-7a.,LEVEL|1A,NIAv2|SS13b,NIAv2|SS14a,NIAv2|SS14c,PCI-DSSv3.2.1|2.2.2,PCI-DSSv4.0|2.2.4,QCSC-v1|3.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "dnsmasq-0.0.0-0"
operator : "lte"
type : RPM_CHECK
description : "Check if Postfix is installed"
rpm : "postfix-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : CMD_EXEC
description : "2.2.15 Ensure mail transfer agent is configured for local-only mode"
info : "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.
Note:
This recommendation is designed around the postfix mail server.
Depending on your environment you may have an alternative MTA installed such as sendmail. If this is the case consult the documentation for your installed MTA to configure the recommended state."
solution : "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
Run the following command to restart postfix:
# systemctl restart postfix"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/ss -lntu 2>&1 | /usr/bin/grep -E ':25\s' | /usr/bin/grep -E -v '\s(127.0.0.1|::1):25\s' | /usr/bin/awk '{print} END {if (NR == 0) print \"pass\" ; else print \"fail\"}'"
expect : "pass"
description : "2.2.15 Ensure mail transfer agent is configured for local-only mode"
info : "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.
Note:
This recommendation is designed around the postfix mail server.
Depending on your environment you may have an alternative MTA installed such as sendmail. If this is the case consult the documentation for your installed MTA to configure the recommended state."
solution : "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
Run the following command to restart postfix:
# systemctl restart postfix"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
type : RPM_CHECK
description : "Check if nfs-utils is installed"
rpm : "nfs-utils-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.16 Ensure nfs-utils is not installed or the nfs-server service is masked"
info : "The Network ob体育 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 require network shares, it is recommended that the nfs-utils package be removed to reduce the attack surface of the system.
Impact:
Many of the libvirt packages used by Enterprise Linux virtualization are dependent on the nfs-utils package. If the nfs-utils package is required as a dependency, the nfs-server service should be disabled and masked to reduce the attack surface of the system."
solution : "Run the following command to remove nfs-utils:
# dnf remove nfs-utils
OR
If the nfs-utils package is required as a dependency, run the following command to stop and mask the nfs-server service:
# systemctl --now mask nfs-server
Additional Information:
Many of the libvirt packages used by Enterprise Linux virtualization are dependent on the nfs-utils package. If the nfs-utils package is required as a dependency, the nfs-server service should be disabled and masked to reduce the attack surface of the system."
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "nfs-utils-0.0.0-0"
operator : "lte"
system : "Linux"
type : CMD_EXEC
description : "2.2.16 Ensure nfs-utils is not installed or the nfs-server service is masked"
info : "The Network ob体育 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 require network shares, it is recommended that the nfs-utils package be removed to reduce the attack surface of the system.
Impact:
Many of the libvirt packages used by Enterprise Linux virtualization are dependent on the nfs-utils package. If the nfs-utils package is required as a dependency, the nfs-server service should be disabled and masked to reduce the attack surface of the system."
solution : "Run the following command to remove nfs-utils:
# dnf remove nfs-utils
OR
If the nfs-utils package is required as a dependency, run the following command to stop and mask the nfs-server service:
# systemctl --now mask nfs-server
Additional Information:
Many of the libvirt packages used by Enterprise Linux virtualization are dependent on the nfs-utils package. If the nfs-utils package is required as a dependency, the nfs-server service should be disabled and masked to reduce the attack surface of the system."
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled nfs-server"
expect : "masked"
type : RPM_CHECK
description : "Check if rpcbind is installed"
rpm : "rpcbind-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.17 Ensure rpcbind is not installed or the rpcbind services are masked - rpcbind"
info : "The rpcbind utility maps RPC services to the ports on which they listen. RPC processes notify rpcbind when they start, registering the ports they are listening on and the RPC program numbers they expect to serve. The client system then contacts rpcbind on the server with a particular RPC program number. The rpcbind service redirects the client to the proper port number so it can communicate with the requested service
Portmapper is an RPC service, which always listens on tcp and udp 111, and is used to map other RPC services (such as nfs, nlockmgr, quotad, mountd, etc.) to their corresponding port number on the server. When a remote host makes an RPC call to that server, it first consults with portmap to determine where the RPC server is listening.
Rationale:
A small request (~82 bytes via UDP) sent to the Portmapper generates a large response (7x to 28x amplification), which makes it a suitable tool for DDoS attacks. If rpcbind is not required, it is recommended that the rpcbind package be removed to reduce the attack surface of the system.
Impact:
Many of the libvirt packages used by Enterprise Linux virtualization, and the nfs-utils package used for The Network ob体育 System (NFS), are dependent on the rpcbind package. If the rpcbind package is required as a dependency, the services rpcbind.service and rpcbind.socket should be stopped and masked to reduce the attack surface of the system."
solution : "Run the following command to remove nfs-utils:
# dnf remove rpcbind
OR
If the rpcbind package is required as a dependency, run the following commands to stop and mask the rpcbind.service and rpcbind.socket systemd units:
# systemctl --now mask rpcbind.service
# systemctl --now mask rpcbind.socket"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "rpcbind-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.17 Ensure rpcbind is not installed or the rpcbind services are masked - rpcbind.socket"
info : "The rpcbind utility maps RPC services to the ports on which they listen. RPC processes notify rpcbind when they start, registering the ports they are listening on and the RPC program numbers they expect to serve. The client system then contacts rpcbind on the server with a particular RPC program number. The rpcbind service redirects the client to the proper port number so it can communicate with the requested service
Portmapper is an RPC service, which always listens on tcp and udp 111, and is used to map other RPC services (such as nfs, nlockmgr, quotad, mountd, etc.) to their corresponding port number on the server. When a remote host makes an RPC call to that server, it first consults with portmap to determine where the RPC server is listening.
Rationale:
A small request (~82 bytes via UDP) sent to the Portmapper generates a large response (7x to 28x amplification), which makes it a suitable tool for DDoS attacks. If rpcbind is not required, it is recommended that the rpcbind package be removed to reduce the attack surface of the system.
Impact:
Many of the libvirt packages used by Enterprise Linux virtualization, and the nfs-utils package used for The Network ob体育 System (NFS), are dependent on the rpcbind package. If the rpcbind package is required as a dependency, the services rpcbind.service and rpcbind.socket should be stopped and masked to reduce the attack surface of the system."
solution : "Run the following command to remove nfs-utils:
# dnf remove rpcbind
OR
If the rpcbind package is required as a dependency, run the following commands to stop and mask the rpcbind.service and rpcbind.socket systemd units:
# systemctl --now mask rpcbind.service
# systemctl --now mask rpcbind.socket"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "rpcbind-0.0.0-0"
operator : "lte"
system : "Linux"
type : CMD_EXEC
description : "2.2.17 Ensure rpcbind is not installed or the rpcbind services are masked - rpcbind"
info : "The rpcbind utility maps RPC services to the ports on which they listen. RPC processes notify rpcbind when they start, registering the ports they are listening on and the RPC program numbers they expect to serve. The client system then contacts rpcbind on the server with a particular RPC program number. The rpcbind service redirects the client to the proper port number so it can communicate with the requested service
Portmapper is an RPC service, which always listens on tcp and udp 111, and is used to map other RPC services (such as nfs, nlockmgr, quotad, mountd, etc.) to their corresponding port number on the server. When a remote host makes an RPC call to that server, it first consults with portmap to determine where the RPC server is listening.
Rationale:
A small request (~82 bytes via UDP) sent to the Portmapper generates a large response (7x to 28x amplification), which makes it a suitable tool for DDoS attacks. If rpcbind is not required, it is recommended that the rpcbind package be removed to reduce the attack surface of the system.
Impact:
Many of the libvirt packages used by Enterprise Linux virtualization, and the nfs-utils package used for The Network ob体育 System (NFS), are dependent on the rpcbind package. If the rpcbind package is required as a dependency, the services rpcbind.service and rpcbind.socket should be stopped and masked to reduce the attack surface of the system."
solution : "Run the following command to remove nfs-utils:
# dnf remove rpcbind
OR
If the rpcbind package is required as a dependency, run the following commands to stop and mask the rpcbind.service and rpcbind.socket systemd units:
# systemctl --now mask rpcbind.service
# systemctl --now mask rpcbind.socket"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled rpcbind"
expect : "masked"
system : "Linux"
type : CMD_EXEC
description : "2.2.17 Ensure rpcbind is not installed or the rpcbind services are masked - rpcbind.socket"
info : "The rpcbind utility maps RPC services to the ports on which they listen. RPC processes notify rpcbind when they start, registering the ports they are listening on and the RPC program numbers they expect to serve. The client system then contacts rpcbind on the server with a particular RPC program number. The rpcbind service redirects the client to the proper port number so it can communicate with the requested service
Portmapper is an RPC service, which always listens on tcp and udp 111, and is used to map other RPC services (such as nfs, nlockmgr, quotad, mountd, etc.) to their corresponding port number on the server. When a remote host makes an RPC call to that server, it first consults with portmap to determine where the RPC server is listening.
Rationale:
A small request (~82 bytes via UDP) sent to the Portmapper generates a large response (7x to 28x amplification), which makes it a suitable tool for DDoS attacks. If rpcbind is not required, it is recommended that the rpcbind package be removed to reduce the attack surface of the system.
Impact:
Many of the libvirt packages used by Enterprise Linux virtualization, and the nfs-utils package used for The Network ob体育 System (NFS), are dependent on the rpcbind package. If the rpcbind package is required as a dependency, the services rpcbind.service and rpcbind.socket should be stopped and masked to reduce the attack surface of the system."
solution : "Run the following command to remove nfs-utils:
# dnf remove rpcbind
OR
If the rpcbind package is required as a dependency, run the following commands to stop and mask the rpcbind.service and rpcbind.socket systemd units:
# systemctl --now mask rpcbind.service
# systemctl --now mask rpcbind.socket"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/bin/systemctl is-enabled rpcbind.socket"
expect : "masked"
type : RPM_CHECK
description : "Check rsync installed"
rpm : "rsync-daemon-0.0.0-0"
operator : "lte"
system : "Linux"
type : RPM_CHECK
description : "2.2.18 Ensure rsync-daemon is not installed or the rsyncd service is masked"
info : "The rsyncd service can be used to synchronize files between systems over network links.
Rationale:
Unless required, the rsync-daemon package should be removed to reduce the attack surface area of the system.
The rsyncd service presents a security risk as it uses unencrypted protocols for communication.
Note: If a required dependency exists for the rsync-daemon package, but the rsyncd service is not required, the service should be masked.
Impact:
There are packages that are dependent on the rsync package. If the rsync package is removed, these packages will be removed as well.
Before removing the rsync-daemon package, review any dependent packages to determine if they are required on the system. If a dependent package is required, mask the rsyncd service and leave the rsync-daemon package installed."
solution : "Run the following command to remove the rsync package:
# dnf remove rsync-daemon
OR
Run the following command to mask the rsyncd service:
# systemctl --now mask rsyncd"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "rsync-daemon-0.0.0-0"
operator : "lte"
system : "Linux"
type : CMD_EXEC
description : "2.2.18 Ensure rsync-daemon is not installed or the rsyncd service is masked"
info : "The rsyncd service can be used to synchronize files between systems over network links.
Rationale:
Unless required, the rsync-daemon package should be removed to reduce the attack surface area of the system.
The rsyncd service presents a security risk as it uses unencrypted protocols for communication.
Note: If a required dependency exists for the rsync-daemon package, but the rsyncd service is not required, the service should be masked.
Impact:
There are packages that are dependent on the rsync package. If the rsync package is removed, these packages will be removed as well.
Before removing the rsync-daemon package, review any dependent packages to determine if they are required on the system. If a dependent package is required, mask the rsyncd service and leave the rsync-daemon package installed."
solution : "Run the following command to remove the rsync package:
# dnf remove rsync-daemon
OR
Run the following command to mask the rsyncd service:
# systemctl --now mask rsyncd"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled rsyncd"
expect : "(disabled|masked|Failed to get unit file state)"
system : "Linux"
type : RPM_CHECK
description : "2.3.1 Ensure telnet client is not installed"
info : "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."
solution : "Run the following command to remove the telnet package:
# dnf remove telnet
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|2.6,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "telnet-0"
operator : "lt"
required : NO
system : "Linux"
type : RPM_CHECK
description : "2.3.2 Ensure LDAP client is not installed"
info : "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."
solution : "Run the following command to remove the openldap-clients package:
# dnf remove openldap-clients
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|2.6,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "openldap-clients-0-0"
operator : "lt"
required : NO
system : "Linux"
type : RPM_CHECK
description : "2.3.3 Ensure TFTP client is not installed"
info : "Trivial ob体育 Transfer Protocol (TFTP) is a simple protocol for exchanging files between two TCP/IP machines. TFTP servers allow connections from a TFTP Client for sending and receiving files.
Rationale:
TFTP does not have built-in encryption, access control or authentication. This makes it very easy for an attacker to exploit TFTP to gain access to files"
solution : "Run the following command to remove tftp:
# dnf remove tftp
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "tftp-0-0"
operator : "lt"
required : NO
system : "Linux"
type : RPM_CHECK
description : "2.3.4 Ensure FTP client is not installed"
info : "FTP (ob体育 Transfer Protocol) is a traditional and widely used standard tool for transferring files between a server and clients over a network, especially where no authentication is necessary (permits anonymous users to connect to a server).
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 removed to reduce the potential attack surface."
solution : "Run the following command to remove ftp:
# dnf remove ftp
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "ftp-0-0"
operator : "lt"
required : NO
system : "Linux"
type : CMD_EXEC
description : "2.4 Ensure nonessential services listening on the system are removed or masked"
info : "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.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Run the following command to remove the package containing the service:
# dnf remove
OR If required packages have a dependency:
Run the following commands to stop and mask the service:
# systemctl stop .socket
# systemctl stop .service
# systemctl mask .socket
# systemctl mask .service
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1M,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/ss -plntu"
expect : "Manual Review Required"
severity : MEDIUM
system : "Linux"
type : FILE_CONTENT_CHECK
description : "3.1.1 Ensure IPv6 status is identified"
info : "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 addresses, which is 340 followed by 36 zeroes.
Features of IPv6
Hierarchical addressing and routing infrastructure
Stateful and Stateless configuration
Support for quality of service (QoS)
An ideal protocol for neighboring node interaction
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.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Enable or disable IPv6 in accordance with system requirements and local site policy
Default Value:
IPv6 is enabled
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.
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1M,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/sys/module/ipv6/parameters/disable"
regex : ".*"
expect : "Manual Review Required"
severity : MEDIUM
system : "Linux"
type : CMD_EXEC
description : "3.1.2 Ensure wireless interfaces are disabled"
info : "Wireless networking is used when wired networks are unavailable.
Rationale:
If wireless is not to be used, wireless devices should 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."
solution : "Run the following script to disable any wireless interfaces:
#!/usr/bin/env bash
{
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
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-7"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|15.4,CSCv7|15.5,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "3.2.1 Ensure IP forwarding is disabled"
info : "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 the flags 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."
solution : "Set the following parameter in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.ip_forward = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.ip_forward=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameter in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.forwarding = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.forwarding=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_output=\"\" l_output2=\"\"
l_kparameters=\"net.ipv4.ip_forward=0 net.ipv6.conf.all.forwarding=0\" # Space separated list
searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf $([ -f /etc/default/ufw ] && awk -F= '/^\\s*IPT_SYSCTL=/ {print $2}' /etc/default/ufw)\"
kernel_par_chk()
{
krp=\"\" pafile=\"\" fafile=\"\"
krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"
pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(#.*)?$\" $searchloc)\"
fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"
[ \"$krp\" = \"$kpvalue\" ] && l_output=\"$l_output\\n - \\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration\"
[ -n \"$pafile\" ] && l_output=\"$l_output\\n - \\\"$kpname\\\" is set to \\\"$kpvalue\\\" in \\\"$pafile\\\"\"
[ -z \"$fafile\" ] && l_output=\"$l_output\\n - \\\"$kpname\\\" is not set incorectly in a kernel parameter configuration file\"
[ \"$krp\" != \"$kpvalue\" ] && l_output2=\"$l_output2\\n - \\\"$kpname\\\" is incorrectly set to \\\"$krp\\\" in the running configuration\"
[ -n \"$fafile\" ] && l_output2=\"$l_output2\\n - \\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"
[ -z \"$pafile\" ] && l_output2=\"$l_output2\\n - \\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\"
}
for l_kpar in $l_kparameters; do
kpname=\"$(awk -F\"=\" '{print $1}' <<< \"$l_kpar\" | xargs)\"
kpvalue=\"$(awk -F\"=\" '{print $2}' <<< \"$l_kpar\" | xargs)\"
if grep -Pq '^\\h*net\\.ipv6\\.' <<< \"$l_kpname\"; then
if grep -Pqs '^\\h*0\\b' /sys/module/ipv6/parameters/disable; then
kernel_par_chk
else
l_output=\"$l_output\\n - IPv6 is not enabled, check for: \\\"$l_kpar\\\" is not applicable\"
fi
else
kernel_par_chk
fi
done
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"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "3.2.2 Ensure packet redirect sending is disabled - net.ipv4.conf.all.send_redirects"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.default.send_redirects=0
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.all.send_redirects\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
system : "Linux"
type : CMD_EXEC
description : "3.2.2 Ensure packet redirect sending is disabled - net.ipv4.conf.default.send_redirects"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.default.send_redirects=0
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.default.send_redirects\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
system : "Linux"
type : CMD_EXEC
description : "3.3.1 Ensure source routed packets are not accepted - 'net.ipv4.conf.all.accept_source_route = 0'"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.all.accept_source_route\" ; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
system : "Linux"
type : CMD_EXEC
description : "3.3.1 Ensure source routed packets are not accepted - 'net.ipv4.conf.default.accept_source_route = 0'"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.default.accept_source_route\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi "
expect : "^PASS.*$"
type : CMD_EXEC
description : "Check to see if IPv6 is enabled"
cmd : "/usr/bin/grep -Pqs '^\\h*0\\b' /sys/module/ipv6/parameters/disable && echo -e 'IPv6 is enabled' || echo -e 'IPv6 is not enabled'"
expect : "IPv6 is enabled"
system : "Linux"
type : CMD_EXEC
description : "3.3.1 Ensure source routed packets are not accepted - 'net.ipv6.conf.all.accept_source_route = 0'"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv6.conf.all.accept_source_route\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
system : "Linux"
type : CMD_EXEC
description : "3.3.1 Ensure source routed packets are not accepted - 'net.ipv6.conf.default.accept_source_route = 0'"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv6.conf.default.accept_source_route\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
description : "3.3.1 Ensure source routed packets are not accepted - 'net.ipv6.conf.all.accept_source_route = 0'"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "3.3.1 Ensure source routed packets are not accepted - 'net.ipv6.conf.default.accept_source_route = 0'"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_source_route=0
sysctl -w net.ipv6.conf.default.accept_source_route=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "3.3.2 Ensure ICMP redirects are not accepted - 'net.ipv4.conf.all.accept_redirects = 0'"
info : "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 and net.ipv6.conf.all.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.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing tables and get them to send packets to incorrect networks and allow your system packets to be captured."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.all.accept_redirects\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
system : "Linux"
type : CMD_EXEC
description : "3.3.2 Ensure ICMP redirects are not accepted - 'net.ipv4.conf.default.accept_redirects = 0'"
info : "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 and net.ipv6.conf.all.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.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing tables and get them to send packets to incorrect networks and allow your system packets to be captured."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.default.accept_redirects\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
type : CMD_EXEC
description : "Check to see if IPv6 is enabled"
cmd : "/usr/bin/grep -Pqs '^\\h*0\\b' /sys/module/ipv6/parameters/disable && echo -e 'IPv6 is enabled' || echo -e 'IPv6 is not enabled'"
expect : "IPv6 is enabled"
system : "Linux"
type : CMD_EXEC
description : "3.3.2 Ensure ICMP redirects are not accepted - 'net.ipv6.conf.all.accept_redirects = 0'"
info : "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 and net.ipv6.conf.all.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.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing tables and get them to send packets to incorrect networks and allow your system packets to be captured."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv6.conf.all.accept_redirects\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
system : "Linux"
type : CMD_EXEC
description : "3.3.2 Ensure ICMP redirects are not accepted - 'net.ipv6.conf.default.accept_redirects = 0'"
info : "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 and net.ipv6.conf.all.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.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing tables and get them to send packets to incorrect networks and allow your system packets to be captured."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv6.conf.default.accept_redirects\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^PASS.*$"
description : "3.3.2 Ensure ICMP redirects are not accepted - 'net.ipv6.conf.all.accept_redirects = 0'"
info : "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 and net.ipv6.conf.all.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.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing tables and get them to send packets to incorrect networks and allow your system packets to be captured."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "3.3.2 Ensure ICMP redirects are not accepted - 'net.ipv6.conf.default.accept_redirects = 0'"
info : "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 and net.ipv6.conf.all.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.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing tables and get them to send packets to incorrect networks and allow your system packets to be captured."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.route.flush=1
}
IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.default.accept_redirects=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "3.3.3 Ensure secure ICMP redirects are not accepted - net.ipv4.conf.all.secure_redirects"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following commands to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.secure_redirects=0
sysctl -w net.ipv4.conf.default.secure_redirects=0
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"
kpname=\"net.ipv4.conf.all.secure_redirects\"
kpvalue=\"0\"
searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"
krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"
pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(#.*)?$\" $searchloc)\"
fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"
if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then
echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"
else
echo -e \"\\nFAIL: \"
[ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"
[ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"
[ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"
fi"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.3 Ensure secure ICMP redirects are not accepted - net.ipv4.conf.default.secure_redirects"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following commands to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.secure_redirects=0
sysctl -w net.ipv4.conf.default.secure_redirects=0
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"
kpname=\"net.ipv4.conf.default.secure_redirects\"
kpvalue=\"0\"
searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"
krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"
pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(#.*)?$\" $searchloc)\"
fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"
if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then
echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"
else
echo -e \"\\nFAIL: \"
[ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"
[ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"
[ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"
fi"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.4 Ensure suspicious packets are logged - 'net.ipv4.conf.all.log_martians = 1'"
info : "When enabled, this feature logs packets with un-routable source addresses to the kernel log.
Rationale:
Enabling this feature and logging these packets allows an administrator to investigate the possibility that an attacker is sending spoofed packets to their system."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.log_martians=1
sysctl -w net.ipv4.conf.default.log_martians=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
AU-3
AU-3(1)"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-3,800-53|AU-3(1),800-53|AU-7,800-53|AU-12,800-53r5|AU-3,800-53r5|AU-3(1),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(a),CN-L3|7.1.2.3(b),CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(a),CN-L3|7.1.3.3(b),CN-L3|8.1.4.3(b),CSCv7|6.2,CSCv7|6.3,CSCv8|8.5,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-3,ITSG-33|AU-3(1),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|T3.6.2,NIAv2|AM34a,NIAv2|AM34b,NIAv2|AM34c,NIAv2|AM34d,NIAv2|AM34e,NIAv2|AM34f,NIAv2|AM34g,PCI-DSSv3.2.1|10.1,PCI-DSSv3.2.1|10.3,PCI-DSSv3.2.1|10.3.1,PCI-DSSv3.2.1|10.3.2,PCI-DSSv3.2.1|10.3.3,PCI-DSSv3.2.1|10.3.4,PCI-DSSv3.2.1|10.3.5,PCI-DSSv3.2.1|10.3.6,PCI-DSSv4.0|10.2.2,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.all.log_martians\"; kpvalue=\"1\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.4 Ensure suspicious packets are logged - 'net.ipv4.conf.default.log_martians = 1'"
info : "When enabled, this feature logs packets with un-routable source addresses to the kernel log.
Rationale:
Enabling this feature and logging these packets allows an administrator to investigate the possibility that an attacker is sending spoofed packets to their system."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.log_martians=1
sysctl -w net.ipv4.conf.default.log_martians=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
AU-3
AU-3(1)"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-3,800-53|AU-3(1),800-53|AU-7,800-53|AU-12,800-53r5|AU-3,800-53r5|AU-3(1),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(a),CN-L3|7.1.2.3(b),CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(a),CN-L3|7.1.3.3(b),CN-L3|8.1.4.3(b),CSCv7|6.2,CSCv7|6.3,CSCv8|8.5,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-3,ITSG-33|AU-3(1),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|T3.6.2,NIAv2|AM34a,NIAv2|AM34b,NIAv2|AM34c,NIAv2|AM34d,NIAv2|AM34e,NIAv2|AM34f,NIAv2|AM34g,PCI-DSSv3.2.1|10.1,PCI-DSSv3.2.1|10.3,PCI-DSSv3.2.1|10.3.1,PCI-DSSv3.2.1|10.3.2,PCI-DSSv3.2.1|10.3.3,PCI-DSSv3.2.1|10.3.4,PCI-DSSv3.2.1|10.3.5,PCI-DSSv3.2.1|10.3.6,PCI-DSSv4.0|10.2.2,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.default.log_martians\"; kpvalue=\"1\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.5 Ensure broadcast ICMP requests are ignored"
info : "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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.icmp_echo_ignore_broadcasts = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.icmp_echo_ignore_broadcasts\"; kpvalue=\"1\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.6 Ensure bogus ICMP responses are ignored"
info : "Setting 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."
solution : "Set the following parameter in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.icmp_ignore_bogus_error_responses = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.icmp_ignore_bogus_error_responses=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.icmp_ignore_bogus_error_responses\"; kpvalue=\"1\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.7 Ensure Reverse Path Filtering is enabled - net.ipv4.conf.all.rp_filter = 1"
info : "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 these flags is a good way to deter attackers from sending your system bogus packets that cannot be responded to. One instance where this feature breaks 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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following commands to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.rp_filter=1
sysctl -w net.ipv4.conf.default.rp_filter=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.all.rp_filter\"; kpvalue=\"1\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\ PASS:\ \\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\ FAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\ \"; [ -n \"$fafile\" ] && echo -e \"\ \\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\ \\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\ \"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.7 Ensure Reverse Path Filtering is enabled - net.ipv4.conf.default.rp_filter = 1"
info : "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 these flags is a good way to deter attackers from sending your system bogus packets that cannot be responded to. One instance where this feature breaks 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."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following commands to set the active kernel parameters:
# {
sysctl -w net.ipv4.conf.all.rp_filter=1
sysctl -w net.ipv4.conf.default.rp_filter=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv4.conf.default.rp_filter\"; kpvalue=\"1\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.8 Ensure TCP SYN Cookies is enabled"
info : "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. SYN cookies allow the system to keep accepting valid connections, even if under a denial of service attack."
solution : "Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv4.tcp_syncookies = 1
' >> /etc/sysctl.d/60-netipv4_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"
kpname=\"net.ipv4.tcp_syncookies\"
kpvalue=\"1\"
searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"
krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"
pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(#.*)?$\" $searchloc)\"
fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"
if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then
echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"
else
echo -e \"\\nFAIL: \"
[ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"
[ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"
[ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"
fi"
expect : "PASS"
type : CMD_EXEC
description : "Check to see if IPv6 is enabled"
cmd : "/usr/bin/grep -Pqs '^\\h*0\\b' /sys/module/ipv6/parameters/disable && echo -e 'IPv6 is enabled' || echo -e 'IPv6 is not enabled'"
expect : "IPv6 is enabled"
system : "Linux"
type : CMD_EXEC
description : "3.3.9 Ensure IPv6 router advertisements are not accepted - net.ipv6.conf.all.accept_ra = 0"
info : "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."
solution : "IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_ra=0
sysctl -w net.ipv6.conf.default.accept_ra=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv6.conf.all.accept_ra\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
system : "Linux"
type : CMD_EXEC
description : "3.3.9 Ensure IPv6 router advertisements are not accepted - net.ipv6.conf.default.accept_ra = 0"
info : "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."
solution : "IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_ra=0
sysctl -w net.ipv6.conf.default.accept_ra=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "krp=\"\" pafile=\"\" fafile=\"\"; kpname=\"net.ipv6.conf.default.accept_ra\"; kpvalue=\"0\"; searchloc=\"/run/sysctl.d/*.conf /etc/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf /lib/sysctl.d/*.conf /etc/sysctl.conf\"; krp=\"$(sysctl \"$kpname\" | awk -F= '{print $2}' | xargs)\"; pafile=\"$(grep -Psl -- \"^\\h*$kpname\\h*=\\h*$kpvalue\\b\\h*(\#.*)?$\" $searchloc)\"; fafile=\"$(grep -s -- \"^\\s*$kpname\" $searchloc | /usr/bin/grep -Pv -- \"\\h*=\\h*$kpvalue\\b\\h*\" | awk -F: '{print $1}')\"; if [ \"$krp\" = \"$kpvalue\" ] && [ -n \"$pafile\" ] && [ -z \"$fafile\" ]; then echo -e \"\\nPASS:\\n\\\"$kpname\\\" is set to \\\"$kpvalue\\\" in the running configuration and in \\\"$pafile\\\"\"; else echo -e \"\\nFAIL: \"; [ \"$krp\" != \"$kpvalue\" ] && echo -e \"\\\"$kpname\\\" is set to \\\"$krp\\\" in the running configuration\\n\"; [ -n \"$fafile\" ] && echo -e \"\\n\\\"$kpname\\\" is set incorrectly in \\\"$fafile\\\"\"; [ -z \"$pafile\" ] && echo -e \"\\n\\\"$kpname = $kpvalue\\\" is not set in a kernel parameter configuration file\\n\"; fi"
expect : "^[\\s]*PASS"
description : "3.3.9 Ensure IPv6 router advertisements are not accepted - net.ipv6.conf.all.accept_ra = 0"
info : "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."
solution : "IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_ra=0
sysctl -w net.ipv6.conf.default.accept_ra=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "3.3.9 Ensure IPv6 router advertisements are not accepted - net.ipv6.conf.default.accept_ra = 0"
info : "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."
solution : "IF IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a /etc/sysctl.d/* file:
Example:
# printf '
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
' >> /etc/sysctl.d/60-netipv6_sysctl.conf
Run the following command to set the active kernel parameters:
# {
sysctl -w net.ipv6.conf.all.accept_ra=0
sysctl -w net.ipv6.conf.default.accept_ra=0
sysctl -w net.ipv6.route.flush=1
}
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|CM-6,800-53|CM-7,800-53r5|CM-6,800-53r5|CM-7,CSCv7|9.2,CSCv8|4.8,CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : RPM_CHECK
description : "3.4.1.1 Ensure nftables is installed"
info : "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.
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.
Impact:
Changing firewall settings while connected over the network can result in being locked out of the system."
solution : "Run the following command to install nftables
# dnf install nftables
Additional Information:
NIST SP 800-53 Rev. 5:
CA-9"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "nftables-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : CMD_EXEC
description : "3.4.1.2 Ensure a single firewall configuration utility is in use"
info : "FirewallD - Is a firewall service daemon that provides a dynamic customizable host-based firewall with a D-Bus interface. Being dynamic, it enables creating, changing, and deleting the rules without the necessity to restart the firewall daemon each time the rules are changed
NFTables - Includes the nft utility for configuration of the nftables subsystem of the Linux kernel
Note: firewalld with nftables backend does not support passing custom nftables rules to firewalld, using the --direct option.
Rationale:
In order to configure firewall rules for nftables, a firewall utility needs to be installed and active of the system. The use of more than one firewall utility may produce unexpected results."
solution : "Run the following script to ensure that a single firewall utility is in use on the system:
#!/usr/bin/env bash
{
l_output='' l_output2='' l_fwd_status='' l_nft_status='' l_fwutil_status=''
# Determine FirewallD utility Status
rpm -q firewalld > /dev/null 2>&1 && l_fwd_status='$(systemctl is-enabled firewalld.service):$(systemctl is-active firewalld.service)'
# Determine NFTables utility Status
rpm -q nftables > /dev/null 2>&1 && l_nft_status='$(systemctl is-enabled nftables.service):$(systemctl is-active nftables.service)'
l_fwutil_status='$l_fwd_status:$l_nft_status'
case $l_fwutil_status in
enabled:active:masked:inactive|enabled:active:disabled:inactive)
echo -e '\n - FirewallD utility is in use, enabled and active\n - NFTables utility is correctly disabled or masked and inactive\n - no remediation required' ;;
masked:inactive:enabled:active|disabled:inactive:enabled:active)
echo -e '\n - NFTables utility is in use, enabled and active\n - FirewallD utility is correctly disabled or masked and inactive\n - no remediation required' ;;
enabled:active:enabled:active)
echo -e '\n - Both FirewallD and NFTables utilities are enabled and active\n - stopping and masking NFTables utility'
systemctl stop nftables && systemctl --now mask nftables ;;
enabled:*:enabled:*)
echo -e '\n - Both FirewallD and NFTables utilities are enabled\n - remediating'
if [ '$(awk -F: '{print $2}' <<< '$l_fwutil_status')' = 'active' ] && [ '$(awk -F: '{print $4}' <<< '$l_fwutil_status')' = 'inactive' ]; then
echo ' - masking NFTables utility'
systemctl stop nftables && systemctl --now mask nftables
elif [ '$(awk -F: '{print $4}' <<< '$l_fwutil_status')' = 'active' ] && [ '$(awk -F: '{print $2}' <<< '$l_fwutil_status')' = 'inactive' ]; then
echo ' - masking FirewallD utility'
systemctl stop firewalld && systemctl --now mask firewalld
fi ;;
*:active:*:active)
echo -e '\n - Both FirewallD and NFTables utilities are active\n - remediating'
if [ '$(awk -F: '{print $1}' <<< '$l_fwutil_status')' = 'enabled' ] && [ '$(awk -F: '{print $3}' <<< '$l_fwutil_status')' != 'enabled' ]; then
echo ' - stopping and masking NFTables utility'
systemctl stop nftables && systemctl --now mask nftables
elif [ '$(awk -F: '{print $3}' <<< '$l_fwutil_status')' = 'enabled' ] && [ '$(awk -F: '{print $1}' <<< '$l_fwutil_status')' != 'enabled' ]; then
echo ' - stopping and masking FirewallD utility'
systemctl stop firewalld && systemctl --now mask firewalld
fi ;;
:enabled:active)
echo -e '\n - NFTables utility is in use, enabled, and active\n - FirewallD package is not installed\n - no remediation required' ;;
:)
echo -e '\n - Neither FirewallD or NFTables is installed.\n - remediating\n - installing NFTables'
dnf -q install nftables ;;
*:*:)
echo -e '\n - NFTables package is not installed on the system\n - remediating\n - installing NFTables'
dnf -q install nftables ;;
*)
echo -e '\n - Unable to determine firewall state' ;;
esac
}"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSCv8|4.5,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_output=\"\" l_output2=\"\" l_fwd_status=\"\" l_nft_status=\"\" l_fwutil_status=\"\"
rpm -q firewalld > /dev/null 2>&1 && l_fwd_status=\"$(systemctl is-enabled firewalld.service):$(systemctl is-active firewalld.service)\"
rpm -q nftables > /dev/null 2>&1 && l_nft_status=\"$(systemctl is-enabled nftables.service):$(systemctl is-active nftables.service)\"
l_fwutil_status=\"$l_fwd_status:$l_nft_status\"
case $l_fwutil_status in
enabled:active:masked:inactive|enabled:active:disabled:inactive)
l_output=\"\n - FirewallD utility is in use, enabled and active\n - NFTables utility is correctly disabled or masked and inactive\" ;;
masked:inactive:enabled:active|disabled:inactive:enabled:active)
l_output=\"\n - NFTables utility is in use, enabled and active\n - FirewallD utility is correctly disabled or masked and inactive\" ;;
enabled:active:enabled:active)
l_output2=\"\n - Both FirewallD and NFTables utilities are enabled and active\" ;;
enabled:*:enabled:*)
l_output2=\"\n - Both FirewallD and NFTables utilities are enabled\" ;;
*:active:*:active)
l_output2=\"\n - Both FirewallD and NFTables utilities are enabled\" ;;
:enabled:active)
l_output=\"\n - NFTables utility is in use, enabled, and active\n - FirewallD package is not installed\" ;;
:)
l_output2=\"\n - Neither FirewallD or NFTables is installed.\" ;;
*:*:)
l_output2=\"\n - NFTables package is not installed on the system\" ;;
*)
l_output2=\"\n - Unable to determine firewall state\" ;;
esac
if [ -z \"$l_output2\" ]; then
echo -e \"\n- Audit Results:\n ** Pass **\n$l_output\n\"
else
echo -e \"\n- Audit Results:\n ** Fail **\n$l_output2\n\"
fi"
expect : "Pass"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.1 Ensure firewalld default zone is set"
info : "A firewall zone defines the trust level for a connection, interface or source address binding. This is a one to many relation, which means that a connection, interface or source can only be part of one zone, but a zone can be used for many network connections, interfaces and sources.
The default zone is the zone that is used for everything that is not explicitly bound/assigned to another zone.
If no zone assigned to a connection, interface or source, only the default zone is used.
The default zone is not always listed as being used for an interface or source as it will be used for it either way. This depends on the manager of the interfaces.
Connections handled by NetworkManager are listed as NetworkManager requests to add the zone binding for the interface used by the connection. Also interfaces under control of the network service are listed also because the service requests it.
Note:
A firewalld zone configuration file contains the information for a zone.
These are the zone description, services, ports, protocols, icmp-blocks, masquerade, forward-ports and rich language rules in an XML file format.
The file name has to be zone_name.xml where length of zone_name is currently limited to 17 chars.
NetworkManager binds interfaces to zones automatically
Rationale:
Because the default zone is the zone that is used for everything that is not explicitly bound/assigned to another zone, if FirewallD is being used, it is important for the default zone to set"
solution : "Run the following script to set the default zone:
!/usr/bin/env bash
{
l_zname='public' # <- Update to local site zone name if desired
l_zone=''
if systemctl is-enabled firewalld.service | grep -q 'enabled'; then
l_zone='$(firewall-cmd --get-default-zone)'
if [ '$l_zone' = '$l_zname' ]; then
echo -e '\n - The default zone is set to: \'$l_zone\'\n - No remediation required'
elif [ -n '$l_zone' ]; then
echo -e '\n - The default zone is set to: \'$l_zone\'\n - Updating default zone to: \'l_zname\''
firewall-cmd --set-default-zone='$l_zname'
else
echo -e '\n - The default zone is set to: \'$l_zone\'\n - Updating default zone to: \'l_zname\''
firewall-cmd --set-default-zone='$l_zname'
fi
else
echo -e '\n - FirewallD is not in use on the system\n - No remediation required'
fi
}
Default Value:
public"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "#!/usr/bin/bash
{
l_output=\"\" l_output2=\"\" l_zone=\"\"
if systemctl is-enabled firewalld.service | grep -q 'enabled'; then
l_zone=\"$(firewall-cmd --get-default-zone)\"
if [ -n \"$l_zone\" ]; then
l_output=\" - The default zone is set to: \\\"$l_zone\\\"\"
else
l_output2=\" - The default zone is not set\"
fi
else
l_output=\" - FirewallD is not in use on the system\"
fi
if [ -z \"$l_output2\" ]; then
echo -e \"\\n- Audit Results:\\n ** Pass **\\n$l_output\\n\"
else
echo -e \"\\n- Audit Results:\\n ** Fail **\\n$l_output2\\n\"
fi
}"
expect : "\\*\\* Pass \\*\\*"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.2 Ensure at least one nftables table exists"
info : "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:
Without a table, nftables will not filter network traffic.
Impact:
Adding or modifying firewall rules can cause loss of connectivity to the system"
solution : "Run the following command to create a table in nftables
# nft create table inet
Example if FirewallD is not in use on the system:
# nft create table inet filter
Note: FirewallD uses the table inet firewalld NFTables table that is created when FirewallD is installed.
Additional Information:
NIST SP 800-53 Rev. 5:
CA-9"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/nft list tables"
expect : "^table[\\s]+inet[\\s]+"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.3 Ensure nftables base chains exist - hook forward"
info : "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 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"
solution : "Run the following command to create the base chains:
# nft create chain inet
{ type filter hook <(input|forward|output)> priority 0 \; }
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 \; }
Additional Information:
NIST SP 800-53 Rev. 5:
CA-9"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/nft -n list ruleset | /usr/bin/grep 'hook forward'"
expect : "type[\\s]+filter[\\s]+hook[\\s]+forward[\\s]+priority[\\s]+(0|10);"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.3 Ensure nftables base chains exist - hook input"
info : "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 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"
solution : "Run the following command to create the base chains:
# nft create chain inet
{ type filter hook <(input|forward|output)> priority 0 \; }
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 \; }
Additional Information:
NIST SP 800-53 Rev. 5:
CA-9"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/nft -n list ruleset | /usr/bin/grep 'hook input'"
expect : "type[\\s]+filter[\\s]+hook[\\s]+input[\\s]+priority[\\s]+(0|10);"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.3 Ensure nftables base chains exist - hook output"
info : "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 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"
solution : "Run the following command to create the base chains:
# nft create chain inet
{ type filter hook <(input|forward|output)> priority 0 \; }
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 \; }
Additional Information:
NIST SP 800-53 Rev. 5:
CA-9"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/nft -n list ruleset | /usr/bin/grep 'hook output'"
expect : "type[\\s]+filter[\\s]+hook[\\s]+output[\\s]+priority[\\s]+(0|10);"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.4 Ensure host based firewall loopback traffic is configured"
info : "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."
solution : "Run the following script to implement the loopback rules:
#!/usr/bin/env bash
{
l_hbfw=''
if systemctl is-enabled firewalld.service | grep -q 'enabled' && systemctl is-enabled nftables.service | grep -q 'enabled'; then
echo -e '\n - Error - Both FirewallD and NFTables are enabled\n - Please follow recommendation: \'Ensure a single firewall configuration utility is in use\''
elif ! systemctl is-enabled firewalld.service | grep -q 'enabled' && ! systemctl is-enabled nftables.service | grep -q 'enabled'; then
echo -e '\n - Error - Neither FirewallD or NFTables is enabled\n - Please follow recommendation: \'Ensure a single firewall configuration utility is in use\''
else
if systemctl is-enabled firewalld.service | grep -q 'enabled' && ! systemctl is-enabled nftables.service | grep -q 'enabled'; then
echo -e '\n - FirewallD is in use on the system' && l_hbfw='fwd'
elif ! systemctl is-enabled firewalld.service | grep -q 'enabled' && systemctl is-enabled nftables.service | grep -q 'enabled'; then
echo -e '\n - NFTables is in use on the system' && l_hbfw='nft'
fi
l_ipsaddr='$(nft list ruleset | awk '/filter_IN_public_deny|hook\s+input\s+/,/\}\s*(#.*)?$/' | grep -P -- 'ip\h+saddr')'
if ! nft list ruleset | awk '/hook\s+input\s+/,/\}\s*(#.*)?$/' | grep -Pq -- '\H+\h+'lo'\h+accept'; then
echo -e '\n - Enabling input to accept for loopback address'
if [ '$l_hbfw' = 'fwd' ]; then
firewall-cmd --permanent --zone=trusted --add-interface=lo
firewall-cmd --reload
elif [ '$l_hbfw' = 'nft' ]; then
nft add rule inet filter input iif lo accept
fi
fi
if ! grep -Pq -- 'ip\h+saddr\h+127\.0\.0\.0\/8\h+(counter\h+packets\h+\d+\h+bytes\h+\d+\h+)?drop' <<< '$l_ipsaddr' && ! grep -Pq -- 'ip\h+daddr\h+\!\=\h+127\.0\.0\.1\h+ip\h+saddr\h+127\.0\.0\.1\h+drop' <<< '$l_ipsaddr'; then
echo -e '\n - Setting IPv4 network traffic from loopback address to drop'
if [ '$l_hbfw' = 'fwd' ]; then
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address='127.0.0.1' destination not address='127.0.0.1' drop'
firewall-cmd --permanent --zone=trusted --add-rich-rule='rule family=ipv4 source address='127.0.0.1' destination not address='127.0.0.1' drop'
firewall-cmd --reload
elif [ '$l_hbfw' = 'nft' ]; then
nft create rule inet filter input ip saddr 127.0.0.0/8 counter drop
fi
fi
if grep -Pq -- '^\h*0\h*$' /sys/module/ipv6/parameters/disable; then
l_ip6saddr='$(nft list ruleset | awk '/filter_IN_public_deny|hook input/,/}/' | grep 'ip6 saddr')'
if ! grep -Pq 'ip6\h+saddr\h+::1\h+(counter\h+packets\h+\d+\h+bytes\h+\d+\h+)?drop' <<< '$l_ip6saddr' && ! grep -Pq -- 'ip6\h+daddr\h+\!=\h+::1\h+ip6\h+saddr\h+::1\h+drop' <<< '$l_ip6saddr'; then
echo -e '\n - Setting IPv6 network traffic from loopback address to drop'
if [ '$l_hbfw' = 'fwd' ]; then
firewall-cmd --permanent --add-rich-rule='rule family=ipv6 source address='::1' destination not address='::1' drop'
firewall-cmd --permanent --zone=trusted --add-rich-rule='rule family=ipv6 source address='::1' destination not address='::1' drop'
firewall-cmd --reload
elif [ '$l_hbfw' = 'nft' ]; then
nft add rule inet filter input ip6 saddr ::1 counter drop
fi
fi
fi
fi
}
Additional Information:
NIST SP 800-53 Rev. 5:
CA-9"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "#!/usr/bin/bash
{
l_output=\"\" l_output2=\"\"
if nft list ruleset | awk '/hook\\s+input\\s+/,/\\}\\s*(#.*)?$/' | grep -Pq -- '\\H+\\h+\"lo\"\\h+accept'; then
l_output=\"$l_output\\n - Network traffic to the loopback address is correctly set to accept\"
else
l_output2=\"$l_output2\\n - Network traffic to the loopback address is not set to accept\"
fi
l_ipsaddr=\"$(nft list ruleset | awk '/filter_IN_public_deny|hook\\s+input\\s+/,/\\}\\s*(#.*)?$/' | grep -P -- 'ip\\h+saddr')\"
if grep -Pq -- 'ip\\h+saddr\\h+127\\.0\\.0\\.0\\/8\\h+(counter\\h+packets\\h+\\d+\\h+bytes\\h+\\d+\\h+)?drop' <<< \"$l_ipsaddr\" || grep -Pq -- 'ip\\h+daddr\\h+\\!\\=\\h+127\\.0\\.0\\.1\\h+ip\\h+saddr\\h+127\\.0\\.0\\.1\\h+drop' <<< \"$l_ipsaddr\"; then
l_output=\"$l_output\\n - IPv4 network traffic from loopback address correctly set to drop\"
else
l_output2=\"$l_output2\\n - IPv4 network traffic from loopback address not set to drop\"
fi
if grep -Pq -- '^\\h*0\\h*$' /sys/module/ipv6/parameters/disable; then
l_ip6saddr=\"$(nft list ruleset | awk '/filter_IN_public_deny|hook input/,/}/' | grep 'ip6 saddr')\"
if grep -Pq 'ip6\\h+saddr\\h+::1\\h+(counter\\h+packets\\h+\\d+\\h+bytes\\h+\\d+\\h+)?drop' <<< \"$l_ip6saddr\" || grep -Pq -- 'ip6\\h+daddr\\h+\\!=\\h+::1\\h+ip6\\h+saddr\\h+::1\\h+drop' <<< \"$l_ip6saddr\"; then
l_output=\"$l_output\\n - IPv6 network traffic from loopback address correctly set to drop\"
else
l_output2=\"$l_output2\\n - IPv6 network traffic from loopback address not set to drop\"
fi
fi
if [ -z \"$l_output2\" ]; then
echo -e \"\\n- Audit Result:\\n *** PASS ***\\n$l_output\"
else
echo -e \"\\n- Audit Result:\\n *** FAIL ***\\n$l_output2\\n\\n - Correctly set:\\n$l_output\"
fi
}"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.5 Ensure firewalld drops unnecessary services and ports"
info : "Services and ports can be accepted or explicitly rejected or dropped by a zone.
For every zone, you can set a default behavior that handles incoming traffic that is not further specified. Such behavior is defined by setting the target of the zone. There are three options - default, ACCEPT, REJECT, and DROP.
ACCEPT - you accept all incoming packets except those disabled by a specific rule.
REJECT - you disable all incoming packets except those that you have allowed in specific rules and the source machine is informed about the rejection.
DROP - you disable all incoming packets except those that you have allowed in specific rules and no information sent to the source machine.
Rationale:
To reduce the attack surface of a system, all services and ports should be blocked unless required
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "If Firewalld is in use on the system:
Run the following command to remove an unnecessary service:
# firewall-cmd --remove-service=
Example:
# firewall-cmd --remove-service=cockpit
Run the following command to remove an unnecessary port:
# firewall-cmd --remove-port=/
Example:
# firewall-cmd --remove-port=25/tcp
Run the following command to make new settings persistent:
# firewall-cmd --runtime-to-permanent"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1M,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "systemctl is-enabled firewalld.service | /usr/bin/grep -q 'enabled' && /usr/bin/firewall-cmd --list-all --zone=\"$(firewall-cmd --list-all | /usr/bin/awk '/\(active\)/ { print $1 }')\" | /usr/bin/grep -P -- '^\h*(services:|ports:)'"
expect : "Manual Review Required"
severity : MEDIUM
system : "Linux"
type : CMD_EXEC
description : "3.4.2.6 Ensure nftables established connections are configured"
info : "Configure the firewall rules for new outbound and established connections
Rationale:
If rules are not in place for established connections, all packets will be dropped by the default policy preventing network usage.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "If NFTables utility is in use on your system:
Configure nftables in accordance with site policy. The following commands will implement a policy to allow all established connections:
# systemctl is-enabled nftables.service | grep -q 'enabled' && nft add rule inet filter input ip protocol tcp ct state established accept
# systemctl is-enabled nftables.service | grep -q 'enabled' && nft add rule inet filter input ip protocol udp ct state established accept
# systemctl is-enabled nftables.service | grep -q 'enabled' && nft add rule inet filter input ip protocol icmp ct state established accept"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1M,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "systemctl is-enabled nftables.service | /usr/bin/grep -q 'enabled' && /usr/sbin/nft list ruleset | /usr/bin/awk '/hook input/,/}/' | /usr/bin/grep 'ct state'"
expect : "Manual Review Required"
severity : MEDIUM
system : "Linux"
type : CMD_EXEC
description : "3.4.2.7 Ensure nftables default deny firewall policy - hook input"
info : "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 traversing the network stack.
It is easier to explicitly permit acceptable usage than to deny unacceptable usage.
Note: Changing firewall settings while connected over the 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"
solution : "If NFTables utility is in use on your system:
Run the following command for the base chains with the input, forward, and output hooks to implement a default DROP policy:
# nft chain
{ policy drop \; }
Example:
# nft chain inet filter input { policy drop \; }
# nft chain inet filter forward { policy drop \; }
Default Value:
accept"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "output=$(systemctl --quiet is-enabled nftables.service && nft list ruleset); echo $output | grep 'hook input' | grep -v 'policy drop' | /usr/bin/awk '{print} END {if (NR == 0) print \"pass\" ; else print \"fail\"}'"
expect : "pass"
system : "Linux"
type : CMD_EXEC
description : "3.4.2.7 Ensure nftables default deny firewall policy - hook forward"
info : "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 traversing the network stack.
It is easier to explicitly permit acceptable usage than to deny unacceptable usage.
Note: Changing firewall settings while connected over the 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"
solution : "If NFTables utility is in use on your system:
Run the following command for the base chains with the input, forward, and output hooks to implement a default DROP policy:
# nft chain
{ policy drop \; }
Example:
# nft chain inet filter input { policy drop \; }
# nft chain inet filter forward { policy drop \; }
Default Value:
accept"
reference : "800-171|3.13.1,800-171|3.13.5,800-171|3.13.6,800-53|CA-9,800-53|SC-7,800-53|SC-7(5),800-53r5|CA-9,800-53r5|SC-7,800-53r5|SC-7(5),CN-L3|7.1.2.2(c),CN-L3|8.1.10.6(j),CSCv7|9.4,CSCv8|4.4,CSF|DE.CM-1,CSF|ID.AM-3,CSF|PR.AC-5,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.13.1.3,ITSG-33|SC-7,ITSG-33|SC-7(5),LEVEL|1A,NESA|T4.5.4,NIAv2|GS1,NIAv2|GS2a,NIAv2|GS2b,NIAv2|GS7b,NIAv2|NS25,PCI-DSSv3.2.1|1.1,PCI-DSSv3.2.1|1.2,PCI-DSSv3.2.1|1.2.1,PCI-DSSv3.2.1|1.3,PCI-DSSv4.0|1.2.1,PCI-DSSv4.0|1.4.1,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,SWIFT-CSCv1|2.1,TBA-FIISB|43.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "output=$(systemctl --quiet is-enabled nftables.service && nft list ruleset); echo $output | grep 'hook forward' | grep -v 'policy drop' | /usr/bin/awk '{print} END {if (NR == 0) print \"pass\" ; else print \"fail\"}'"
expect : "pass"
type : RPM_CHECK
description : "rsyslog check - installed"
rpm : "rsyslog-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : CMD_EXEC
description : "rsyslog check - enabled"
cmd : "/usr/bin/systemctl is-enabled rsyslog"
expect : "^enabled$"
system : "Linux"
type : CMD_EXEC
description : "rsyslog check - active"
cmd : "/usr/bin/systemctl is-active rsyslog"
expect : "^active$"
system : "Linux"
type : RPM_CHECK
description : "4.2.1.1 Ensure rsyslog is installed"
info : "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."
solution : "Run the following command to install rsyslog:
# apt install rsyslog"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "rsyslog-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : CMD_EXEC
description : "4.2.1.2 Ensure rsyslog service is enabled"
info : "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."
solution : "Run the following command to enable rsyslog:
# systemctl --now enable rsyslog"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/bin/systemctl is-enabled rsyslog | /usr/bin/awk '{print} END {if(NR==0) print \"disabled\" }'"
expect : "enabled"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "4.2.1.3 Ensure journald is configured to send logs to rsyslog"
info : "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."
solution : "Edit the /etc/systemd/journald.conf file and add the following line:
ForwardToSyslog=yes
Restart the service:
# systemctl restart rsyslog"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.5,800-171|3.3.6,800-53|AU-2,800-53|AU-6(3),800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-6(3),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(d),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv7|6.5,CSCv8|8.2,CSCv8|8.9,CSF|DE.AE-2,CSF|DE.AE-3,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|DE.DP-4,CSF|PR.PT-1,CSF|RS.AN-1,CSF|RS.AN-3,CSF|RS.CO-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-6(3),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1M,NESA|M1.2.2,NESA|M5.2.5,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/systemd/journald.conf"
regex : "^[\\s]*ForwardToSyslog[\\s]*="
expect : "^[\\s]*ForwardToSyslog[\\s]*=[\\s]*['\"]?yes[\"']?[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "4.2.1.4 Ensure rsyslog default file permissions are configured"
info : "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 ob体育CreateMode 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 ob体育CreateMode 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 ob体育CreateMode is set before any file is created."
solution : "Edit either /etc/rsyslog.conf or a dedicated .conf file in /etc/rsyslog.d/ and set $ob体育CreateMode to 0640 or more restrictive:
$ob体育CreateMode 0640
Restart the service:
# systemctl restart rsyslog"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,800-53r5|MP-2,CN-L3|7.1.2.3(c),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.3(a),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv7|6.2,CSCv7|6.3,CSCv8|3.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-1,CSF|PR.PT-2,CSF|PR.PT-3,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/rsyslog.conf /etc/rsyslog.d/*.conf"
regex : "^[\\s]*\\$ob体育CreateMode"
expect : "\\$ob体育CreateMode 0[246][04]0[\\s]*$"
min_occurrences : "1"
string_required : NO
# Removed 4.2.1.5 and 4.2.1.6 and 4.2.1.7 and made them manual checks
# Removed 4.2.2.1.2
system : "Linux"
type : CMD_EXEC
description : "4.2.2.1.3 Ensure systemd-journal-remote is enabled"
info : "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 centralized 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."
solution : "Run the following command to enable systemd-journal-remote:
# systemctl --now enable systemd-journal-upload.service
Additional Information:
NIST SP 800-53 Rev. 5:
AU-2
AU-12
CM-7
SI-5"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1M,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "systemctl is-enabled systemd-journal-upload.service"
expect : "^[\\s]*enabled.*$"
system : "Linux"
type : CMD_EXEC
description : "4.2.2.1.4 Ensure journald is not configured to receive logs from a remote client"
info : "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:
The same package, systemd-journal-remote, is used for both sending logs to remote hosts and receiving incoming logs.
With regards to receiving logs, there are two services; systemd-journal-remote.socket and systemd-journal-remote.service.
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."
solution : "Run the following command to disable systemd-journal-remote.socket:
# systemctl --now mask systemd-journal-remote.socket"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53|CM-6,800-53|CM-7,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,800-53r5|CM-6,800-53r5|CM-7,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv7|9.2,CSCv8|4.8,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.IP-1,CSF|PR.PT-1,CSF|PR.PT-3,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,ITSG-33|CM-6,ITSG-33|CM-7,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS15a,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|2.2.2,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|2.3,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "systemctl is-enabled systemd-journal-remote.socket"
expect : "^[\\s]*masked.*$"
system : "Linux"
type : CMD_EXEC
description : "4.2.2.2 Ensure journald service is enabled"
info : "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."
solution : "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."
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "systemctl is-enabled systemd-journald.service"
expect : "^[\\s]*static.*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "4.2.2.3 Ensure journald is configured to compress large log files"
info : "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."
solution : "Edit the /etc/systemd/journald.conf file and add the following line:
Compress=yes
Restart the service:
# systemctl restart systemd-journald.service
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."
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-4,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-4,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv7|6.4,CSCv8|8.2,CSCv8|8.3,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.DS-4,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-4,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NESA|T3.3.1,NESA|T3.6.2,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/systemd/journald.conf"
regex : "^[\\s]*Compress[\\s]*="
expect : "^[\\s]*Compress[\\s]*=[\\s]*yes[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "4.2.2.4 Ensure journald is configured to write logfiles to persistent disk"
info : "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."
solution : "Edit the /etc/systemd/journald.conf file and add the following line:
Storage=persistent
Restart the service:
# systemctl restart systemd-journald.service
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."
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/systemd/journald.conf"
regex : "^[\\s]*Storage[\\s]*="
expect : "^[\\s]*Storage[\\s]*=[\\s]*['\"]?persistent[\"']?[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "4.2.2.5 Ensure journald is not configured to send logs to rsyslog"
info : "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.
Note: This recommendation only applies if journald is the chosen method for client side logging. Do not apply this recommendation if rsyslog is used."
solution : "Edit the /etc/systemd/journald.conf file and ensure that ForwardToSyslog=yes is removed.
Restart the service:
# systemctl restart systemd-journald.service"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.5,800-171|3.3.6,800-53|AU-2,800-53|AU-6(3),800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-6(3),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(d),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv7|6.5,CSCv8|8.2,CSCv8|8.9,CSF|DE.AE-2,CSF|DE.AE-3,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|DE.DP-4,CSF|PR.PT-1,CSF|RS.AN-1,CSF|RS.AN-3,CSF|RS.CO-2,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-6(3),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1M,NESA|M1.2.2,NESA|M5.2.5,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|5.2.3,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/systemd/journald.conf"
regex : "^[\\s]*ForwardToSyslog[\\s]*="
expect : "^[\\s]*ForwardToSyslog[\\s]*="
description : "4.2.2.6 Ensure journald log rotation is configured per site policy"
info : "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.
NOTE: Nessus has not performed this check. Please review the benchmark to ensure target compliance."
solution : "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 prioritization of parameters.
The specific parameters for log rotation are:
SystemMaxUse=
SystemKeepFree=
RuntimeMaxUse=
RuntimeKeepFree=
Maxob体育Sec=
Additional Information:
See man 5 journald.conf for detailed information regarding the parameters in use."
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1M,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
description : "4.2.2.7 Ensure journald default file permissions configured"
info : "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.
NOTE: Nessus has not performed this check. Please review the benchmark to ensure target compliance."
solution : "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.
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
NIST SP 800-53 Rev. 5:
AC-3
AU-2
AU-12
MP-2
SI-5"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,800-53r5|MP-2,CN-L3|7.1.2.3(c),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.3(a),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv7|6.2,CSCv7|6.3,CSCv8|3.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-1,CSF|PR.PT-2,CSF|PR.PT-3,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(b),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1M,NESA|M1.2.2,NESA|M5.5.1,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|7.1.2,PCI-DSSv3.2.1|10.1,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,SWIFT-CSCv1|6.4,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "4.2.3 Ensure all logfiles have appropriate permissions and ownership"
info : "Log files contain information from many services on the local system, or in the event of a centralized log server, others system's logs as well. In general log files are found in /var/log/, although application can be configured to store logs elsewhere. Should your application store its logs in another location, ensure to run the same test on that location.
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."
solution : "Run the following script to update permissions and ownership on files in /var/log.
Although the script is not destructive, ensure that the output of the audit procedure is captured in the event that the remediation causes issues.
#!/usr/bin/env bash
{
echo -e '\n- Start remediation - logfiles have appropriate permissions and ownership'
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
find /var/log -type f | while read -r fname; do
bname='$(basename '$fname')'
fugname='$(stat -Lc '%U %G' '$fname')'
funame='$(awk '{print $1}' <<< '$fugname')'
fugroup='$(awk '{print $2}' <<< '$fugname')'
fuid='$(stat -Lc '%u' '$fname')'
fmode='$(stat -Lc '%a' '$fname')'
case '$bname' in
lastlog | lastlog.* | wtmp | wtmp.* | wtmp-* | btmp | btmp.* | btmp-*)
! grep -Pq -- '^\h*[0,2,4,6][0,2,4,6][0,4]\h*$' <<< '$fmode' && echo -e '- changing mode on \'$fname\'' && chmod ug-x,o-wx '$fname'
! grep -Pq -- '^\h*root\h*$' <<< '$funame' && echo -e '- changing owner on \'$fname\'' && chown root '$fname'
! grep -Pq -- '^\h*(utmp|root)\h*$' <<< '$fugroup' && echo -e '- changing group on \'$fname\'' && chgrp root '$fname'
;;
secure | auth.log | syslog | messages)
! grep -Pq -- '^\h*[0,2,4,6][0,4]0\h*$' <<< '$fmode' && echo -e '- changing mode on \'$fname\'' && chmod u-x,g-wx,o-rwx '$fname'
! grep -Pq -- '^\h*(syslog|root)\h*$' <<< '$funame' && echo -e '- changing owner on \'$fname\'' && chown root '$fname'
! grep -Pq -- '^\h*(adm|root)\h*$' <<< '$fugroup' && echo -e '- changing group on \'$fname\'' && chgrp root '$fname'
;;
SSSD | sssd)
! grep -Pq -- '^\h*[0,2,4,6][0,2,4,6]0\h*$' <<< '$fmode' && echo -e '- changing mode on \'$fname\'' && chmod ug-x,o-rwx '$fname'
! grep -Piq -- '^\h*(SSSD|root)\h*$' <<< '$funame' && echo -e '- changing owner on \'$fname\'' && chown root '$fname'
! grep -Piq -- '^\h*(SSSD|root)\h*$' <<< '$fugroup' && echo -e '- changing group on \'$fname\'' && chgrp root '$fname'
;;
gdm | gdm3)
! grep -Pq -- '^\h*[0,2,4,6][0,2,4,6]0\h*$' <<< '$fmode' && echo -e '- changing mode on \'$fname\'' && chmod ug-x,o-rwx
! grep -Pq -- '^\h*root\h*$' <<< '$funame' && echo -e '- changing owner on \'$fname\'' && chown root '$fname'
! grep -Pq -- '^\h*(gdm3?|root)\h*$' <<< '$fugroup' && echo -e '- changing group on \'$fname\'' && chgrp root '$fname'
;;
*.journal | *.journal~)
! grep -Pq -- '^\h*[0,2,4,6][0,4]0\h*$' <<< '$fmode' && echo -e '- changing mode on \'$fname\'' && chmod u-x,g-wx,o-rwx '$fname'
! grep -Pq -- '^\h*root\h*$' <<< '$funame' && echo -e '- changing owner on \'$fname\'' && chown root '$fname'
! grep -Pq -- '^\h*(systemd-journal|root)\h*$' <<< '$fugroup' && echo -e '- changing group on \'$fname\'' && chgrp root '$fname'
;;
*)
! grep -Pq -- '^\h*[0,2,4,6][0,4]0\h*$' <<< '$fmode' && echo -e '- changing mode on \'$fname\'' && chmod u-x,g-wx,o-rwx '$fname'
if [ '$fuid' -ge '$UID_MIN' ] || ! grep -Pq -- '(adm|root|''$(id -gn '$funame')'')' <<< '$fugroup'; then
if [ -n '$(awk -v grp='$fugroup' -F: '$1==grp {print $4}' /etc/group)' ] || ! grep -Pq '(syslog|root)' <<< '$funame'; then
[ '$fuid' -ge '$UID_MIN' ] && echo -e '- changing owner on \'$fname\'' && chown root '$fname'
! grep -Pq -- '^\h*(adm|root)\h*$' <<< '$fugroup' && echo -e '- changing group on \'$fname\'' && chgrp root '$fname'
fi
fi
;;
esac
done
echo -e '- End remediation - logfiles have appropriate permissions and ownership\n'
}
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 permissions.
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "echo -e \"\\n- Start check - logfiles have appropriate permissions and ownership\"
output=\"\"
UID_MIN=$(awk '/^\\s*UID_MIN/{print $2}' /etc/login.defs)
find /var/log -type f | (while read -r fname; do
bname=\"$(basename \"$fname\")\"
fugname=\"$(stat -Lc \"%U %G\" \"$fname\")\"
funame=\"$(awk '{print $1}' <<< \"$fugname\")\"
fugroup=\"$(awk '{print $2}' <<< \"$fugname\")\"
fuid=\"$(stat -Lc \"%u\" \"$fname\")\"
fmode=\"$(stat -Lc \"%a\" \"$fname\")\"
case \"$bname\" in
lastlog | lastlog.* | wtmp | wtmp.* | wtmp-* | btmp | btmp.* | btmp-*)
if ! grep -Pq -- '^\\h*[0,2,4,6][0,2,4,6][0,4]\\h*$' <<< \"$fmode\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" mode: \\\"$fmode\\\"\\n\"
fi
if ! grep -Pq -- '^\\h*root\\h+(utmp|root)\\h*$' <<< \"$fugname\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" ownership: \\\"$fugname\\\"\\n\"
fi
;;
secure | auth.log | syslog | messages)
if ! grep -Pq -- '^\\h*[0,2,4,6][0,4]0\\h*$' <<< \"$fmode\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" mode: \\\"$fmode\\\"\\n\"
fi
if ! grep -Pq -- '^\\h*(syslog|root)\\h+(adm|root)\\h*$' <<< \"$fugname\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" ownership: \\\"$fugname\\\"\\n\"
fi
;;
SSSD | sssd)
if ! grep -Pq -- '^\\h*[0,2,4,6][0,2,4,6]0\\h*$' <<< \"$fmode\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" mode: \\\"$fmode\\\"\\n\"
fi
if ! grep -Piq -- '^\\h*(SSSD|root)\\h+(SSSD|root)\\h*$' <<< \"$fugname\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" ownership: \\\"$fugname\\\"\\n\"
fi
;;
gdm | gdm3)
if ! grep -Pq -- '^\\h*[0,2,4,6][0,2,4,6]0\\h*$' <<< \"$fmode\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" mode: \\\"$fmode\\\"\\n\"
fi
if ! grep -Pq -- '^\\h*(root)\\h+(gdm3?|root)\\h*$' <<< \"$fugname\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" ownership: \\\"$fugname\\\"\\n\"
fi
;;
*.journal | *.journal~)
if ! grep -Pq -- '^\\h*[0,2,4,6][0,4]0\\h*$' <<< \"$fmode\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" mode: \\\"$fmode\\\"\\n\"
fi
if ! grep -Pq -- '^\\h*(root)\\h+(systemd-journal|root)\\h*$' <<< \"$fugname\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" ownership: \\\"$fugname\\\"\\n\"
fi
;;
*)
if ! grep -Pq -- '^\\h*[0,2,4,6][0,4]0\\h*$' <<< \"$fmode\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" mode: \\\"$fmode\\\"\\n\"
fi
if [ \"$fuid\" -ge \"$UID_MIN\" ] || ! grep -Pq -- '(adm|root|'\"$(id -gn \"$funame\")\"')' <<< \"$fugroup\"; then
if [ -n \"$(awk -v grp=\"$fugroup\" -F: '$1==grp {print $4}' /etc/group)\" ] || ! grep -Pq '(syslog|root)' <<< \"$funame\"; then
output=\"$output\\n- ob体育: \\\"$fname\\\" ownership: \\\"$fugname\\\"\\n\"
fi
fi
;;
esac
done
# If all files passed, then we pass
if [ -z \"$output\" ]; then
echo -e \"\\n- Audit Results:\\n ** Pass **\\n- All files in \\\"/var/log/\\\" have appropriate permissions and ownership\\n\"
else
# print the reason why we are failing
echo -e \"\\n- Audit Results:\\n ** Fail **\\n$output\"
fi
echo -e \"- End check - logfiles have appropriate permissions and ownership\\n\"
)"
expect : "Pass"
description : "4.3 Ensure logrotate is configured"
info : "The system 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/logrotate.d/syslog is the configuration file used to rotate log files created by syslog or rsyslog.
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.
NOTE: Nessus has not performed this check. Please review the benchmark to ensure target compliance."
solution : "Edit /etc/logrotate.conf and /etc/logrotate.d/* to ensure logs are rotated according to site policy.
Additional Information:
If no maxage setting is set for logrotate a situation can occur where logrotate is interrupted and fails to delete rotated log files. It is recommended to set this to a value greater than the longest any log file should exist on your system to ensure that any such log file is removed but standard rotation settings are not overridden.
NIST SP 800-53 Rev. 5:
AU-8"
reference : "800-53|AU-4,800-53r5|AU-4,CSCv7|6.4,CSCv8|8.3,CSF|PR.DS-4,CSF|PR.PT-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-4,LEVEL|1M,NESA|T3.3.1,NESA|T3.6.2,QCSC-v1|8.2.1,QCSC-v1|13.2"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : CMD_EXEC
description : "5.1.1 Ensure cron daemon is enabled"
info : "The cron daemon is used to execute batch jobs on the system.
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."
solution : "Run the following command to enable cron:
# systemctl --now enable crond
Additional Information:
Additional methods of enabling a service exist. Consult your distribution documentation for appropriate methods.
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1562, T1562.001
TA0005
M1018"
reference : "800-171|3.4.8,800-53|CM-7(5),800-53r5|CM-7(5),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.5.1,ISO/IEC-27001|A.12.6.2,ITSG-33|CM-7,LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,SWIFT-CSCv1|2.3,TBA-FIISB|44.2.2,TBA-FIISB|49.2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/systemctl is-enabled crond"
expect : "enabled"
dont_echo_cmd : YES
system : "Linux"
type : FILE_CHECK
description : "5.1.2 Ensure permissions on /etc/crontab are configured"
info : "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.
Rationale:
This file contains information on what system jobs are run by cron. Write access to this file could provide unprivileged users with the ability to elevate their privileges. Read access to this file 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."
solution : "Run the following commands to set ownership and permissions on /etc/crontab :
# chown root:root /etc/crontab
# chmod og-rwx /etc/crontab
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/crontab"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "5.1.3 Ensure permissions on /etc/cron.hourly are configured"
info : "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.
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."
solution : "Run the following commands to set ownership and permissions on /etc/cron.hourly :
# chown root:root /etc/cron.hourly
# chmod og-rwx /etc/cron.hourly"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/cron.hourly"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "5.1.4 Ensure permissions on /etc/cron.daily are configured"
info : "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.
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."
solution : "Run the following commands to set ownership and permissions on /etc/cron.daily :
# chown root:root /etc/cron.daily
# chmod og-rwx /etc/cron.daily"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/cron.daily"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "5.1.5 Ensure permissions on /etc/cron.weekly are configured"
info : "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.
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."
solution : "Run the following commands to set ownership and permissions on /etc/cron.weekly :
# chown root:root /etc/cron.weekly
# chmod og-rwx /etc/cron.weekly"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/cron.weekly"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "5.1.6 Ensure permissions on /etc/cron.monthly are configured"
info : "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.
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."
solution : "Run the following commands to set ownership and permissions on /etc/cron.monthly :
# chown root:root /etc/cron.monthly
# chmod og-rwx /etc/cron.monthly"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/cron.monthly"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "5.1.7 Ensure permissions on /etc/cron.d are configured"
info : "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.
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."
solution : "Run the following commands to set ownership and permissions on /etc/cron.d :
# chown root:root /etc/cron.d
# chmod og-rwx /etc/cron.d
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/cron.d"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : CMD_EXEC
description : "5.1.8 Ensure cron is restricted to authorized users"
info : "If cron is installed in the system, configure /etc/cron.allow to allow specific users to use these services. If /etc/cron.allow does not exist, then /etc/cron.deny is checked. Any user not specifically defined in those files is allowed to use cron. By removing the file, only users in /etc/cron.allow are allowed to use cron.
Note: 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."
solution : "Run the following script to remove /etc/cron.deny, create /etc/cron.allow, and set the file mode on /etc/cron.allow:
#!/usr/bin/env bash
{
if rpm -q cronie >/dev/null; then
[ -e /etc/cron.deny ] && rm -f /etc/cron.deny
[ ! -e /etc/cron.allow ] && touch /etc/cron.allow
chown root:root /etc/cron.allow
chmod u-x,go-rwx /etc/cron.allow
else
echo 'cron is not installed on the system'
fi
}
OR Run the following command to remove cron:
# dnf remove cronie
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "if rpm -q cronie >/dev/null; then [ -e /etc/cron.deny ] && echo \"Fail: cron.deny exists\"; if [ ! -e /etc/cron.allow ]; then echo \"Fail: cron.allow doesn't exist\"; else ! stat -Lc \"%a\" /etc/cron.allow | /usr/bin/grep -Eq \"[0,2,4,6]00\" && echo \"Fail: cron.allow mode too permissive\"; ! stat -Lc \"%u:%g\" /etc/cron.allow | /usr/bin/grep -Eq \"^0:0$\" && echo \"Fail: cron.allow owner and/or group not root\"; fi; if [ ! -e /etc/cron.deny ] && [ -e /etc/cron.allow ] && stat -Lc \"%a\" /etc/cron.allow | /usr/bin/grep -Eq \"[0,2,4,6]00\" && stat -Lc \"%u:%g\" /etc/cron.allow | /usr/bin/grep -Eq \"^0:0$\"; then echo \"Pass\"; fi; else echo \"Pass: cron is not installed on the system\"; fi"
expect : "Pass"
system : "Linux"
type : CMD_EXEC
description : "5.1.9 Ensure at is restricted to authorized users"
info : "If at is installed in the system, configure /etc/at.allow to allow specific users to use these services. If /etc/at.allow does not exist, then /etc/at.deny is checked. Any user not specifically defined in those files is allowed to use at. By removing the file, only users in /etc/at.allow are allowed to use at.
Note: Even though a given user is not listed in at.allow, at jobs can still be run as that user. The at.allow file only controls administrative access to the at command for scheduling and modifying at jobs.
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."
solution : "Run the following script to remove /etc/at.deny, create /etc/at.allow, and set the file mode for /etc/at.allow:
#!/usr/bin/env bash
{
if rpm -q at >/dev/null; then
[ -e /etc/at.deny ] && rm -f /etc/at.deny
[ ! -e /etc/at.allow ] && touch /etc/at.allow
chown root:root /etc/at.allow
chmod u-x,go-rwx /etc/at.allow
else
echo 'at is not installed on the system'
fi
}
OR Run the following command to remove at:
# dnf remove at
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "if rpm -q at >/dev/null; then [ -e /etc/at.deny ] && echo \"Fail: at.deny exists\"; if [ ! -e /etc/at.allow ]; then echo \"Fail: at.allow doesn't exist\"; else ! stat -Lc \"%a\" /etc/at.allow | /usr/bin/grep -Eq \"[0,2,4,6]00\" && echo \"Fail: at.allow mode too permissive\"; ! stat -Lc \"%u:%g\" /etc/at.allow | /usr/bin/grep -Eq \"^0:0$\" && echo \"Fail: at.allow owner and/or group not root\"; fi; if [ ! -e /etc/at.deny ] && [ -e /etc/at.allow ] && stat -Lc \"%a\" /etc/at.allow | /usr/bin/grep -Eq \"[0,2,4,6]00\" && stat -Lc \"%u:%g\" /etc/at.allow | /usr/bin/grep -Eq \"^0:0$\"; then echo \"Pass\"; fi; else echo \"Pass: at is not installed on the system\"; fi"
expect : "Pass"
system : "Linux"
type : FILE_CHECK
description : "5.2.1 Ensure permissions on /etc/ssh/sshd_config are configured"
info : "The /etc/ssh/sshd_config file contains configuration specifications for sshd. The command below sets the owner and group of the file to root.
Rationale:
The /etc/ssh/sshd_config file needs to be protected from unauthorized changes by non-privileged users."
solution : "Run the following commands to set ownership and permissions on /etc/ssh/sshd_config:
# chown root:root /etc/ssh/sshd_config
# chmod u-x,go-rwx /etc/ssh/sshd_config
Default Value:
/etc/ssh/sshd_config 600 0/root 0/root"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config"
owner : "root"
mask : "077"
group : "root"
system : "Linux"
type : CMD_EXEC
description : "5.2.2 Ensure permissions on SSH private host key files are configured"
info : "An SSH private key is one of two files 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.
Rationale:
If an unauthorized user obtains the private SSH host key file, the host could be impersonated"
solution : "Run the following script to set mode, ownership, and group on the private SSH host key files:
#!/usr/bin/env bash
{
l_skgn='ssh_keys' # Group designated to own openSSH keys
l_skgid='$(awk -F: '($1 == '''$l_skgn'''){print $3}' /etc/group)'
[ -n '$l_skgid' ] && l_cga='$l_skgn' || l_cga='root'
awk '{print}' <<< '$(find -L /etc/ssh -xdev -type f -exec stat -L -c '%n %#a %U %G %g' {} +)' | (while read -r l_file l_mode l_owner l_group l_gid; do
if file '$l_file' | grep -Pq ':\h+OpenSSH\h+private\h+key\b'; then
[ '$l_gid' = '$l_skgid' ] && l_pmask='0137' || l_pmask='0177'
l_maxperm='$( printf '%o' $(( 0777 & ~$l_pmask )) )'
if [ $(( $l_mode & $l_pmask )) -gt 0 ]; then
echo -e ' - ob体育: \'$l_file\' is mode \'$l_mode\' changing to mode: \'$l_maxperm\''
if [ -n '$l_skgid' ]; then
chmod u-x,g-wx,o-rwx '$l_file'
else
chmod u-x,go-rwx '$l_file'
fi
fi
if [ '$l_owner' != 'root' ]; then
echo -e ' - ob体育: \'$l_file\' is owned by: \'$l_owner\' changing owner to \'root\''
chown root '$l_file'
fi
if [ '$l_group' != 'root' ] && [ '$l_gid' != '$l_skgid' ]; then
echo -e ' - ob体育: \'$l_file\' is owned by group \'$l_group\' should belong to group \'$l_cga\''
chgrp '$l_cga' '$l_file'
fi
fi
done
)
}
Default Value:
640 0/root 999/ssh_keys"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_output=\"\" l_output2=\"\"
l_skgn=\"ssh_keys\" # Group designated to own openSSH keys
l_skgid=\"$(awk -F: '($1 == \"'\"$l_skgn\"'\"){print $3}' /etc/group)\"
[ -n \"$l_skgid\" ] && l_cga=\"$l_skgn\" || l_cga=\"root\"
awk '{print}' <<< \"$(find -L /etc/ssh -xdev -type f -exec stat -Lc \"%n %#a %U %G %g\" {} +)\" | (while read -r l_file l_mode l_owner l_group l_gid; do
if file \"$l_file\" | grep -Pq ':\\h+OpenSSH\\h+private\\h+key\\b'; then
[ \"$l_gid\" = \"$l_skgid\" ] && l_pmask=\"0137\" || l_pmask=\"0177\"
l_maxperm=\"$( printf '%o' $(( 0777 & ~$l_pmask )) )\"
if [ $(( $l_mode & $l_pmask )) -gt 0 ]; then
l_output2=\"$l_output2\\n - ob体育: \\\"$l_file\\\" is mode \\\"$l_mode\\\" should be mode: \\\"$l_maxperm\\\" or more restrictive\"
else
l_output=\"$l_output\\n - ob体育: \\\"$l_file\\\" is mode \\\"$l_mode\\\" should be mode: \\\"$l_maxperm\\\" or more restrictive\"
fi
if [ \"$l_owner\" != \"root\" ]; then
l_output2=\"$l_output2\\n - ob体育: \\\"$l_file\\\" is owned by: \\\"$l_owner\\\" should be owned by \\\"root\\\"\"
else
l_output=\"$l_output\\n - ob体育: \\\"$l_file\\\" is owned by: \\\"$l_owner\\\" should be owned by \\\"root\\\"\"
fi
if [ \"$l_group\" != \"root\" ] && [ \"$l_gid\" != \"$l_skgid\" ]; then
l_output2=\"$l_output2\\n - ob体育: \\\"$l_file\\\" is owned by group \\\"$l_group\\\" should belong to group \\\"$l_cga\\\"\"
else
l_output=\"$l_output\\n - ob体育: \\\"$l_file\\\" is owned by group \\\"$l_group\\\" should belong to group \\\"$l_cga\\\"\"
fi
fi
done
if [ -z \"$l_output2\" ]; then
echo -e \"\\n- Audit Result:\\n *** PASS ***\\n$l_output\"
else
echo -e \"\\n- Audit Result:\\n *** FAIL ***\\n$l_output2\\n\\n - Correctly set:\\n$l_output\"
fi
)"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "5.2.3 Ensure permissions on SSH public host key files are configured"
info : "An SSH public key is one of two files used in SSH public key authentication. In this authentication method, 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."
solution : "Run the following script to set mode, ownership, and group on the public SSH host key files:
#!/usr/bin/env bash
{
l_pmask='0133'
l_maxperm='$( printf '%o' $(( 0777 & ~$l_pmask )) )'
awk '{print}' <<< '$(find -L /etc/ssh -xdev -type f -exec stat -Lc '%n %#a %U %G' {} +)' | (while read -r l_file l_mode l_owner l_group; do
if file '$l_file' | grep -Pq ':\h+OpenSSH\h+(\H+\h+)?public\h+key\b'; then
echo -e ' - Checking private key file: \'$l_file\''
if [ $(( $l_mode & $l_pmask )) -gt 0 ]; then
echo -e ' - ob体育: \'$l_file\' is mode \'$l_mode\' changing to mode: \'$l_maxperm\''
chmod u-x,go-wx '$l_file'
fi
if [ '$l_owner' != 'root' ]; then
echo -e ' - ob体育: \'$l_file\' is owned by: \'$l_owner\' changing owner to \'root\''
chown root '$l_file'
fi
if [ '$l_group' != 'root' ]; then
echo -e ' - ob体育: \'$l_file\' is owned by group \'$l_group\' changing to group \'root\''
chgrp 'root' '$l_file'
fi
fi
done
)
}
Default Value:
644 0/root 0/root"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "l_output=\"\" l_output2=\"\"
l_pmask=\"0133\"
awk '{print}' <<< \"$(find -L /etc/ssh -xdev -type f -exec stat -Lc \"%n %#a %U %G\" {} +)\" | (while read -r l_file l_mode l_owner l_group; do
if file \"$l_file\" | grep -Pq ':\\h+OpenSSH\\h+(\\H+\\h+)?public\\h+key\\b'; then
l_maxperm=\"$( printf '%o' $(( 0777 & ~$l_pmask )) )\"
if [ $(( $l_mode & $l_pmask )) -gt 0 ]; then
l_output2=\"$l_output2\\n - Public key file: \\\"$l_file\\\" is mode \\\"$l_mode\\\" should be mode: \\\"$l_maxperm\\\" or more restrictive\"
else
l_output=\"$l_output\\n - Public key file: \\\"$l_file\\\" is mode \\\"$l_mode\\\" should be mode: \\\"$l_maxperm\\\" or more restrictive\"
fi
if [ \"$l_owner\" != \"root\" ]; then
l_output2=\"$l_output2\\n - Public key file: \\\"$l_file\\\" is owned by: \\\"$l_owner\\\" should be owned by \\\"root\\\"\"
else
l_output=\"$l_output\\n - Public key file: \\\"$l_file\\\" is owned by: \\\"$l_owner\\\" should be owned by \\\"root\\\"\"
fi
if [ \"$l_group\" != \"root\" ]; then
l_output2=\"$l_output2\\n - Public key file: \\\"$l_file\\\" is owned by group \\\"$l_group\\\" should belong to group \\\"root\\\"\\n\"
else
l_output=\"$l_output\\n - Public key file: \\\"$l_file\\\" is owned by group \\\"$l_group\\\" should belong to group \\\"root\\\"\\n\"
fi
fi
done
if [ -z \"$l_output2\" ]; then
echo -e \"\\n- Audit Result:\\n *** PASS ***\\n$l_output\"
else
echo -e \"\\n- Audit Result:\\n *** FAIL ***\\n$l_output2\\n\\n - Correctly set:\\n$l_output\"
fi
)"
expect : "PASS"
system : "Linux"
type : CMD_EXEC
description : "5.2.4 Ensure SSH access is limited - sshd output"
info : "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:
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:
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:
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:
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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set one or more of the parameters as follows:
AllowUsers
-OR-
AllowGroups
-OR-
DenyUsers
-OR-
DenyGroups
Default Value:
None"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|4.3,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -Pi '^\\h*(allow|deny)(users|groups)\\h+\\H+(\\h+.*)?$')\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)(Allow|Deny)(Users|Groups)(?-i)[\\s]"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.4 Ensure SSH access is limited - sshd_config"
info : "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:
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:
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:
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:
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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set one or more of the parameters as follows:
AllowUsers
-OR-
AllowGroups
-OR-
DenyUsers
-OR-
DenyGroups
Default Value:
None"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|4.3,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)(Allow|Deny)(Users|Groups)(?-i)[\\s]"
expect : "^[\\s]*(?i)(Allow|Deny)(Users|Groups)(?-i)[\\s]"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.5 Ensure SSH LogLevel is appropriate - sshd output"
info : "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.
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.
Rationale:
SSH provides several logging levels with varying amounts of verbosity. DEBUG is specifically not recommended other than strictly for debugging SSH communications since it provides so much data that it is difficult to identify important security information."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the LogLevel parameter as follows:
LogLevel VERBOSE
OR
LogLevel INFO
Run the following command to comment out any LogLevel parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than VERBOSE or INFO:
# grep -Pi '^\h*LogLevel\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi '(VERBOSE|INFO)' | while read -r l_out; do sed -ri '/^\s*LogLevel\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
LogLevel INFO"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i loglevel)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)LogLevel(?-i)[\\s]+(INFO|VERBOSE)[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.5 Ensure SSH LogLevel is appropriate - sshd_config"
info : "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.
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.
Rationale:
SSH provides several logging levels with varying amounts of verbosity. DEBUG is specifically not recommended other than strictly for debugging SSH communications since it provides so much data that it is difficult to identify important security information."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the LogLevel parameter as follows:
LogLevel VERBOSE
OR
LogLevel INFO
Run the following command to comment out any LogLevel parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than VERBOSE or INFO:
# grep -Pi '^\h*LogLevel\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi '(VERBOSE|INFO)' | while read -r l_out; do sed -ri '/^\s*LogLevel\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
LogLevel INFO"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-2,800-53|AU-7,800-53|AU-12,800-53r5|AU-2,800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(c),CN-L3|8.1.4.3(a),CSCv7|6.2,CSCv7|6.3,CSCv8|8.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-2,ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|M1.2.2,NESA|M5.5.1,NIAv2|AM7,NIAv2|AM11a,NIAv2|AM11b,NIAv2|AM11c,NIAv2|AM11d,NIAv2|AM11e,NIAv2|SS30,NIAv2|VL8,PCI-DSSv3.2.1|10.1,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)LogLevel(?-i)[\\s]"
expect : "^[\\s]*(?i)LogLevel(?-i)[\\s]+(INFO|VERBOSE)[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.6 Ensure SSH PAM is enabled - sshd output"
info : "UsePAM Enables the Pluggable Authentication Module interface. If set to 'yes' this will enable PAM authentication using ChallengeResponseAuthentication and PasswordAuthentication 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
Impact:
If UsePAM is enabled, you will not be able to run sshd as a non-root user."
solution : "Edit or create a file in the directory /etc/ssh/sshd_config.d/ ending in *.conf or the /etc/ssh/sshd_config file and set the parameter as follows:
UsePAM yes
Run the following command to comment out any UsePAM parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than yes
# grep -Pi '^\h*UsePAM\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'yes' | while read -r l_out; do sed -ri '/^\s*UsePAM\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
usePAM yes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i usepam)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)UsePAM(?-i)[\\s]+yes[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.6 Ensure SSH PAM is enabled - sshd_config"
info : "UsePAM Enables the Pluggable Authentication Module interface. If set to 'yes' this will enable PAM authentication using ChallengeResponseAuthentication and PasswordAuthentication 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
Impact:
If UsePAM is enabled, you will not be able to run sshd as a non-root user."
solution : "Edit or create a file in the directory /etc/ssh/sshd_config.d/ ending in *.conf or the /etc/ssh/sshd_config file and set the parameter as follows:
UsePAM yes
Run the following command to comment out any UsePAM parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than yes
# grep -Pi '^\h*UsePAM\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'yes' | while read -r l_out; do sed -ri '/^\s*UsePAM\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
usePAM yes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)UsePAM(?-i)[\\s]"
expect : "^[\\s]*(?i)UsePAM(?-i)[\\s]+yes[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.7 Ensure SSH root login is disabled - sshd output"
info : "The PermitRootLogin parameter specifies if the root user can log in using ssh. The default is no.
Rationale:
Disallowing root logins over SSH requires system admins to authenticate using their own individual account, then escalating to root via sudo or su. This in turn limits opportunity for non-repudiation and provides a clear audit trail in the event of a security incident"
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the PermitRootLogin parameter as follows:
PermitRootLogin no
Run the following command to comment out any PermitRootLogin parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no
# grep -Pi '^\h*PermitRootLogin\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*PermitRootLogin\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
PermitRootLogin without-password"
reference : "800-171|3.1.5,800-171|3.1.6,800-53|AC-6(2),800-53|AC-6(5),800-53r5|AC-6(2),800-53r5|AC-6(5),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSCv7|4.3,CSCv8|5.4,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(2),ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM1,NIAv2|AM23f,NIAv2|AM32,NIAv2|AM33,NIAv2|SS13c,NIAv2|SS15c,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i permitrootlogin)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)PermitRootLogin(?-i)[\\s]+no[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.7 Ensure SSH root login is disabled - sshd_config"
info : "The PermitRootLogin parameter specifies if the root user can log in using ssh. The default is no.
Rationale:
Disallowing root logins over SSH requires system admins to authenticate using their own individual account, then escalating to root via sudo or su. This in turn limits opportunity for non-repudiation and provides a clear audit trail in the event of a security incident"
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the PermitRootLogin parameter as follows:
PermitRootLogin no
Run the following command to comment out any PermitRootLogin parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no
# grep -Pi '^\h*PermitRootLogin\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*PermitRootLogin\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
PermitRootLogin without-password"
reference : "800-171|3.1.5,800-171|3.1.6,800-53|AC-6(2),800-53|AC-6(5),800-53r5|AC-6(2),800-53r5|AC-6(5),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSCv7|4.3,CSCv8|5.4,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(2),ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM1,NIAv2|AM23f,NIAv2|AM32,NIAv2|AM33,NIAv2|SS13c,NIAv2|SS15c,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)PermitRootLogin(?-i)[\\s]"
expect : "^[\\s]*(?i)PermitRootLogin(?-i)[\\s]+no[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.8 Ensure SSH HostbasedAuthentication is disabled - sshd output"
info : "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. This option only applies to SSH Protocol Version 2.
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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the HostbasedAuthentication parameter as follows:
HostbasedAuthentication no
Run the following command to comment out any HostbasedAuthentication parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no:
# grep -Pi '^\h*HostbasedAuthentication\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*HostbasedAuthentication\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
HostbasedAuthentication no"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|16.3,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i hostbasedauthentication)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)HostbasedAuthentication(?-i)[\\s]+no[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.8 Ensure SSH HostbasedAuthentication is disabled - sshd_config"
info : "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. This option only applies to SSH Protocol Version 2.
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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the HostbasedAuthentication parameter as follows:
HostbasedAuthentication no
Run the following command to comment out any HostbasedAuthentication parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no:
# grep -Pi '^\h*HostbasedAuthentication\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*HostbasedAuthentication\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
HostbasedAuthentication no"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|16.3,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)HostbasedAuthentication(?-i)[\\s]"
expect : "^[\\s]*(?i)HostbasedAuthentication(?-i)[\\s]+no[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.9 Ensure SSH PermitEmptyPasswords is disabled - sshd output"
info : "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"
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the PermitEmptyPasswords parameter as follows:
PermitEmptyPasswords no
Run the following command to comment out any PermitEmptyPasswords parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no
# grep -Pi '^\h*PermitEmptyPasswords\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*PermitEmptyPasswords\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
PermitEmptyPasswords no"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i permitemptypasswords)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)PermitEmptyPasswords(?-i)[\\s]+no[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.9 Ensure SSH PermitEmptyPasswords is disabled - sshd_config"
info : "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"
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the PermitEmptyPasswords parameter as follows:
PermitEmptyPasswords no
Run the following command to comment out any PermitEmptyPasswords parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no
# grep -Pi '^\h*PermitEmptyPasswords\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*PermitEmptyPasswords\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
PermitEmptyPasswords no"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)PermitEmptyPasswords(?-i)[\\s]"
expect : "^[\\s]*(?i)PermitEmptyPasswords(?-i)[\\s]+no[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.10 Ensure SSH PermitUserEnvironment is disabled - sshd output"
info : "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)"
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the PermitUserEnvironment parameter as follows:
PermitUserEnvironment no
Run the following command to comment out any PermitUserEnvironment parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no
# grep -Pi '^\h*PermitUserEnvironment\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*PermitUserEnvironment\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
PermitUserEnvironment no"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i permituserenvironment)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)PermitUserEnvironment(?-i)[\\s]+no[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.10 Ensure SSH PermitUserEnvironment is disabled - sshd_config"
info : "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)"
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the PermitUserEnvironment parameter as follows:
PermitUserEnvironment no
Run the following command to comment out any PermitUserEnvironment parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than no
# grep -Pi '^\h*PermitUserEnvironment\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'no' | while read -r l_out; do sed -ri '/^\s*PermitUserEnvironment\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
PermitUserEnvironment no"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)PermitUserEnvironment(?-i)[\\s]"
expect : "^[\\s]*(?i)PermitUserEnvironment(?-i)[\\s]+no[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.11 Ensure SSH IgnoreRhosts is enabled - sshd output"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the IgnoreRhosts parameter as follows:
IgnoreRhosts yes
Run the following command to comment out any IgnoreRhosts parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than yes
# grep -Pi '^\h*IgnoreRhosts\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'yes' | while read -r l_out; do sed -ri '/^\s*IgnoreRhosts\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
IgnoreRhosts yes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|9.2,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i ignorerhosts)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)IgnoreRhosts(?-i)[\\s]+yes[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.11 Ensure SSH IgnoreRhosts is enabled - sshd_config"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the IgnoreRhosts parameter as follows:
IgnoreRhosts yes
Run the following command to comment out any IgnoreRhosts parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting other than yes
# grep -Pi '^\h*IgnoreRhosts\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -Evi 'yes' | while read -r l_out; do sed -ri '/^\s*IgnoreRhosts\s+/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
IgnoreRhosts yes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|9.2,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)IgnoreRhosts(?-i)[\\s]"
expect : "^[\\s]*(?i)IgnoreRhosts(?-i)[\\s]+yes[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "5.2.14 Ensure system-wide crypto policy is not over-ridden"
info : "System-wide Crypto policy can be over-ridden or opted out of for openSSH
Rationale:
Over-riding or opting out of the system-wide crypto policy could allow for the use of less secure Ciphers, MACs, KexAlgorithms and GSSAPIKexAlgorithm"
solution : "Run the following commands:
# sed -ri 's/^\s*(CRYPTO_POLICY\s*=.*)$/# \1/' /etc/sysconfig/sshd /etc/ssh/sshd_config.d/*.conf
# systemctl reload sshd
Additional Information:
NIST SP 800-53 Rev. 5:
SC-8"
reference : "800-171|3.1.13,800-171|3.5.2,800-171|3.13.8,800-53|AC-17(2),800-53|IA-5,800-53|IA-5(1),800-53|SC-8,800-53|SC-8(1),800-53r5|AC-17(2),800-53r5|IA-5,800-53r5|IA-5(1),800-53r5|SC-8,800-53r5|SC-8(1),CN-L3|7.1.2.7(g),CN-L3|7.1.3.1(d),CN-L3|8.1.2.2(a),CN-L3|8.1.2.2(b),CN-L3|8.1.4.1(c),CN-L3|8.1.4.7(a),CN-L3|8.1.4.8(a),CN-L3|8.2.4.5(c),CN-L3|8.2.4.5(d),CN-L3|8.5.2.2,CSCv7|14.4,CSCv8|3.10,CSF|PR.AC-1,CSF|PR.AC-3,CSF|PR.DS-2,CSF|PR.DS-5,CSF|PR.PT-4,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),HIPAA|164.312(e)(1),HIPAA|164.312(e)(2)(i),ISO/IEC-27001|A.6.2.2,ISO/IEC-27001|A.10.1.1,ISO/IEC-27001|A.13.2.3,ITSG-33|AC-17(2),ITSG-33|IA-5,ITSG-33|IA-5(1),ITSG-33|SC-8,ITSG-33|SC-8(1),ITSG-33|SC-8a.,LEVEL|1A,NESA|T4.3.1,NESA|T4.3.2,NESA|T4.5.1,NESA|T4.5.2,NESA|T5.2.3,NESA|T5.4.2,NESA|T7.3.3,NESA|T7.4.1,NIAv2|AM37,NIAv2|IE8,NIAv2|IE9,NIAv2|IE12,NIAv2|NS5d,NIAv2|NS6b,NIAv2|NS29,NIAv2|SS24,PCI-DSSv3.2.1|2.3,PCI-DSSv3.2.1|4.1,PCI-DSSv4.0|2.2.7,PCI-DSSv4.0|4.2.1,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|2.1,SWIFT-CSCv1|2.6,SWIFT-CSCv1|4.1,TBA-FIISB|29.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/sysconfig/sshd"
regex : "^[\\s]*(?i)CRYPTO_POLICY(?-i)="
expect : "^[\\s]*(?i)CRYPTO_POLICY(?-i)="
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.16 Ensure SSH MaxAuthTries is set to 4 or less - sshd output"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxAuthTries parameter as follows:
MaxAuthTries 3
Run the following command to comment out any MaxAuthTries parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 3:
# grep -Pi '^\h*maxauthtries\h+([4-9]|[1-9][0-9]+)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*maxauthtries\s+([5-9]|[1-9][0-9]+)/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
MaxAuthTries 6"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-3,800-53|AU-3(1),800-53|AU-7,800-53|AU-12,800-53r5|AU-3,800-53r5|AU-3(1),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(a),CN-L3|7.1.2.3(b),CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(a),CN-L3|7.1.3.3(b),CN-L3|8.1.4.3(b),CSCv7|16.13,CSCv8|8.5,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-3,ITSG-33|AU-3(1),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|T3.6.2,NIAv2|AM34a,NIAv2|AM34b,NIAv2|AM34c,NIAv2|AM34d,NIAv2|AM34e,NIAv2|AM34f,NIAv2|AM34g,PCI-DSSv3.2.1|10.1,PCI-DSSv3.2.1|10.3,PCI-DSSv3.2.1|10.3.1,PCI-DSSv3.2.1|10.3.2,PCI-DSSv3.2.1|10.3.3,PCI-DSSv3.2.1|10.3.4,PCI-DSSv3.2.1|10.3.5,PCI-DSSv3.2.1|10.3.6,PCI-DSSv4.0|10.2.2,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i maxauthtries)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)MaxAuthTries(?-i)[\\s]+[1-3][\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.16 Ensure SSH MaxAuthTries is set to 3 or less - sshd_config"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxAuthTries parameter as follows:
MaxAuthTries 3
Run the following command to comment out any MaxAuthTries parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 4:
# grep -Pi '^\h*maxauthtries\h+([4-9]|[1-9][0-9]+)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*maxauthtries\s+([5-9]|[1-9][0-9]+)/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
MaxAuthTries 6"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-3,800-53|AU-3(1),800-53|AU-7,800-53|AU-12,800-53r5|AU-3,800-53r5|AU-3(1),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(a),CN-L3|7.1.2.3(b),CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(a),CN-L3|7.1.3.3(b),CN-L3|8.1.4.3(b),CSCv7|16.13,CSCv8|8.5,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-3,ITSG-33|AU-3(1),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|T3.6.2,NIAv2|AM34a,NIAv2|AM34b,NIAv2|AM34c,NIAv2|AM34d,NIAv2|AM34e,NIAv2|AM34f,NIAv2|AM34g,PCI-DSSv3.2.1|10.1,PCI-DSSv3.2.1|10.3,PCI-DSSv3.2.1|10.3.1,PCI-DSSv3.2.1|10.3.2,PCI-DSSv3.2.1|10.3.3,PCI-DSSv3.2.1|10.3.4,PCI-DSSv3.2.1|10.3.5,PCI-DSSv3.2.1|10.3.6,PCI-DSSv4.0|10.2.2,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)MaxAuthTries(?-i)[\\s]"
expect : "^[\\s]*(?i)MaxAuthTries(?-i)[\\s]+[1-3][\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.17 Ensure SSH MaxStartups is configured - sshd output"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxStartups parameter as follows:
MaxStartups 10:30:60
Run the following command to comment out any MaxStartups parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 10:30:60:
# grep -Pi '^\s*maxstartups\s+(((1[1-9]|[1-9][0-9][0-9]+):([0-9]+):([0-9]+))|(([0-9]+):(3[1-9]|[4-9][0-9]|[1-9][0-9][0-9]+):([0-9]+))|(([0-9]+):([0-9]+):(6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+)))' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*MaxStartups\s+(((1[1-9]|[1-9][0-9][0-9]+):([0-9]+):([0-9]+))|(([0-9]+):(3[1-9]|[4-9][0-9]|[1-9][0-9][0-9]+):([0-9]+))|(([0-9]+):([0-9]+):(6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+)))/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
MaxStartups 10:30:100"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i maxstartups)\"; done | /usr/bin/awk '{print} END {if (NR == 0) print \"fail: no results returned\"}'"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)MaxStartups(?-i)[\\s]+(((1[1-9]|[1-9][0-9][0-9]+):([0-9]+):([0-9]+))|(([0-9]+):(3[1-9]|[4-9][0-9]|[1-9][0-9][0-9]+):([0-9]+))|(([0-9]+):([0-9]+):(6[0-9]|[7-9][0-9]|[1-9][0-9][0-9]+)))[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.17 Ensure SSH MaxStartups is configured - sshd_config"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxStartups parameter as follows:
MaxStartups 10:30:60
Run the following command to comment out any MaxStartups parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 10:30:60:
# grep -Pi '^\s*maxstartups\s+(((1[1-9]|[1-9][0-9][0-9]+):([0-9]+):([0-9]+))|(([0-9]+):(3[1-9]|[4-9][0-9]|[1-9][0-9][0-9]+):([0-9]+))|(([0-9]+):([0-9]+):(6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+)))' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*MaxStartups\s+(((1[1-9]|[1-9][0-9][0-9]+):([0-9]+):([0-9]+))|(([0-9]+):(3[1-9]|[4-9][0-9]|[1-9][0-9][0-9]+):([0-9]+))|(([0-9]+):([0-9]+):(6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+)))/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
MaxStartups 10:30:100"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)[Mm]ax[Ss]tartups(?-i)[\\s]"
expect : "^[\\s]*(?i)[Mm]ax[Ss]tartups(?-i)[\\s]+((([0-9]|10):([0-9]|[12][1-9]|30):([0-9]|[1-5][0-9]|60)))[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.18 Ensure SSH MaxSessions is set to 10 or less - sshd output"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxSessions parameter as follows:
MaxSessions 10
Run the following command to comment out any MaxSessions parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 10
# grep -Pi '^\s*MaxSessions\s+(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*MaxSessions\s+(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
MaxSessions 10"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i maxsessions)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)MaxSessions(?-i)[\\s]+([0-9]|10)[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.18 Ensure SSH MaxSessions is set to 10 or less - sshd_config"
info : "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."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxSessions parameter as follows:
MaxSessions 10
Run the following command to comment out any MaxSessions parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 10
# grep -Pi '^\s*MaxSessions\s+(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*MaxSessions\s+(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
MaxSessions 10"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)MaxSessions(?-i)[\\s]"
expect : "^[\\s]*(?i)MaxSessions(?-i)[\\s]+([0-9]|10)[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.19 Ensure SSH LoginGraceTime is set to one minute or less - sshd output"
info : "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."
solution : "Edit the /etc/ssh/sshd_config file to set the parameter as follows:
LoginGraceTime 60
Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the LoginGraceTime parameter as follows:
LoginGraceTime 60
-or-
LoginGraceTime 1m
Run the following command to comment out any LoginGraceTime parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting equal to 0 or greater than 60 seconds:
# grep -Pi '^\s*LoginGraceTime\s+(0|6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+|[^1]m)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*LoginGraceTime\s+(0|6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+|[^1]m)/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
LoginGraceTime 120"
reference : "800-53|AC-10,800-53r5|AC-10,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|AC-10,LEVEL|1A,NESA|T5.5.1,QCSC-v1|5.2.1,QCSC-v1|5.2.2"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i logingracetime)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)LoginGraceTime(?-i)[\\s]+([1-9]|[1-5][0-9]|60|1m)[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.19 Ensure SSH LoginGraceTime is set to one minute or less - sshd_config"
info : "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."
solution : "Edit the /etc/ssh/sshd_config file to set the parameter as follows:
LoginGraceTime 60
Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the LoginGraceTime parameter as follows:
LoginGraceTime 60
-or-
LoginGraceTime 1m
Run the following command to comment out any LoginGraceTime parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting equal to 0 or greater than 60 seconds:
# grep -Pi '^\s*LoginGraceTime\s+(0|6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+|[^1]m)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*LoginGraceTime\s+(0|6[1-9]|[7-9][0-9]|[1-9][0-9][0-9]+|[^1]m)/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
LoginGraceTime 120"
reference : "800-171|3.1.11,800-53|AC-12,800-53r5|AC-12,CN-L3|7.1.2.2(d),CN-L3|7.1.3.7(b),CN-L3|8.1.4.1(b),GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(iii),ITSG-33|AC-12,LEVEL|1A,NIAv2|NS49"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)LoginGraceTime(?-i)[\\s]"
expect : "^[\\s]*(?i)LoginGraceTime(?-i)[\\s]+([1-9]|[1-5][0-9]|60|1m)[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.20 Ensure SSH Idle Timeout Interval is configured - ClientAliveInterval sshd output"
info : "NOTE: To clarify, the two settings described below are only meant for idle connections from a protocol perspective and 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 may no longer be abused to disconnect idle users.
The two options ClientAliveInterval and ClientAliveCountMax control the timeout of SSH sessions. Taken directly from man 5 sshd_config:
ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
ClientAliveCountMax Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option en-abled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.
Rationale:
In order to prevent resource exhaustion, appropriate values should be set for both ClientAliveInterval and ClientAliveCountMax. Specifically, looking at the source code, ClientAliveCountMax must be greater than zero in order to utilize the ability of SSH to drop idle connections. If connections are allowed to stay open indefinitely, this can potentially be used as a DDOS attack or simple resource exhaustion could occur over unreliable networks.
The example set here is a 45 second timeout. Consult your site policy for network timeouts and apply as appropriate."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the ClientAliveInterval and ClientAliveCountMax parameters according to site policy.
Example:
ClientAliveInterval 15
ClientAliveCountMax 3
Edit files ending in *.conf in the /etc/ssh/sshd_config.d/ directory and the /etc/ssh/sshd_config file and remove occurrences of the ClientAliveInterval and ClientAliveCountMax parameters not in accordence with local site policy.
Run the following command to comment out any ClientAliveCountMax parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include the setting of 0 'disabled':
# grep -Pi '^\h*ClientAliveCountMax\h+0\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*ClientAliveCountMax\s+0/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
ClientAliveInterval 0
ClientAliveCountMax 3"
reference : "800-171|3.4.6,800-171|3.4.7,800-53|CM-7b.,800-53r5|CM-7b.,CN-L3|7.1.3.5(c),CN-L3|7.1.3.7(d),CN-L3|8.1.4.4(b),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-7a.,LEVEL|1A,NIAv2|SS13b,NIAv2|SS14a,NIAv2|SS14c,PCI-DSSv3.2.1|2.2.2,PCI-DSSv4.0|2.2.4,QCSC-v1|3.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i clientaliveinterval)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)ClientAliveInterval(?-i)[\\s]+[1-9][0-9]*[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.20 Ensure SSH Idle Timeout Interval is configured - ClientAliveInterval sshd_config"
info : "NOTE: To clarify, the two settings described below are only meant for idle connections from a protocol perspective and 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 may no longer be abused to disconnect idle users.
The two options ClientAliveInterval and ClientAliveCountMax control the timeout of SSH sessions. Taken directly from man 5 sshd_config:
ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
ClientAliveCountMax Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option en-abled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.
Rationale:
In order to prevent resource exhaustion, appropriate values should be set for both ClientAliveInterval and ClientAliveCountMax. Specifically, looking at the source code, ClientAliveCountMax must be greater than zero in order to utilize the ability of SSH to drop idle connections. If connections are allowed to stay open indefinitely, this can potentially be used as a DDOS attack or simple resource exhaustion could occur over unreliable networks.
The example set here is a 45 second timeout. Consult your site policy for network timeouts and apply as appropriate."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the ClientAliveInterval and ClientAliveCountMax parameters according to site policy.
Example:
ClientAliveInterval 15
ClientAliveCountMax 3
Edit files ending in *.conf in the /etc/ssh/sshd_config.d/ directory and the /etc/ssh/sshd_config file and remove occurrences of the ClientAliveInterval and ClientAliveCountMax parameters not in accordence with local site policy.
Run the following command to comment out any ClientAliveCountMax parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include the setting of 0 'disabled':
# grep -Pi '^\h*ClientAliveCountMax\h+0\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*ClientAliveCountMax\s+0/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
ClientAliveInterval 0
ClientAliveCountMax 3"
reference : "800-171|3.4.6,800-171|3.4.7,800-53|CM-7b.,800-53r5|CM-7b.,CN-L3|7.1.3.5(c),CN-L3|7.1.3.7(d),CN-L3|8.1.4.4(b),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-7a.,LEVEL|1A,NIAv2|SS13b,NIAv2|SS14a,NIAv2|SS14c,PCI-DSSv3.2.1|2.2.2,PCI-DSSv4.0|2.2.4,QCSC-v1|3.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)ClientAliveInterval(?-i)[\\s]"
expect : "^[\\s]*(?i)ClientAliveInterval(?-i)[\\s]+[1-9][0-9]*[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : CMD_EXEC
description : "5.2.20 Ensure SSH Idle Timeout Interval is configured - ClientAliveCountMax sshd output"
info : "NOTE: To clarify, the two settings described below are only meant for idle connections from a protocol perspective and 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 may no longer be abused to disconnect idle users.
The two options ClientAliveInterval and ClientAliveCountMax control the timeout of SSH sessions. Taken directly from man 5 sshd_config:
ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
ClientAliveCountMax Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option en-abled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.
Rationale:
In order to prevent resource exhaustion, appropriate values should be set for both ClientAliveInterval and ClientAliveCountMax. Specifically, looking at the source code, ClientAliveCountMax must be greater than zero in order to utilize the ability of SSH to drop idle connections. If connections are allowed to stay open indefinitely, this can potentially be used as a DDOS attack or simple resource exhaustion could occur over unreliable networks.
The example set here is a 45 second timeout. Consult your site policy for network timeouts and apply as appropriate."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the ClientAliveInterval and ClientAliveCountMax parameters according to site policy.
Example:
ClientAliveInterval 15
ClientAliveCountMax 3
Edit files ending in *.conf in the /etc/ssh/sshd_config.d/ directory and the /etc/ssh/sshd_config file and remove occurrences of the ClientAliveInterval and ClientAliveCountMax parameters not in accordence with local site policy.
Run the following command to comment out any ClientAliveCountMax parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include the setting of 0 'disabled':
# grep -Pi '^\h*ClientAliveCountMax\h+0\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*ClientAliveCountMax\s+0/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
ClientAliveInterval 0
ClientAliveCountMax 3"
reference : "800-171|3.4.6,800-171|3.4.7,800-53|CM-7b.,800-53r5|CM-7b.,CN-L3|7.1.3.5(c),CN-L3|7.1.3.7(d),CN-L3|8.1.4.4(b),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-7a.,LEVEL|1A,NIAv2|SS13b,NIAv2|SS14a,NIAv2|SS14c,PCI-DSSv3.2.1|2.2.2,PCI-DSSv4.0|2.2.4,QCSC-v1|3.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "ports=$(grep -s -P \"^(Port|Match)\" /etc/ssh/sshd_config /etc/sshd_config.d/*.conf | grep -P -o \"(Port|LocalPort)[\\s]+[\\d]+\" | /usr/bin/awk '{print $2}; END {if (NR == 0) print \"22\"}'); for port in ${ports[@]}; do /usr/sbin/sshd -T -C user=root -C host=\"$(hostname)\" -C addr=\"$(/usr/bin/grep $(hostname) /etc/hosts | /usr/bin/awk '{print $1}')\" -C lport=$port | echo \"port $port: $(/usr/bin/grep -i clientalivecountmax)\"; done"
expect : "^port[\\s]+[\\d]+:[\\s]*(?i)ClientAliveCountMax(?-i)[\\s]+[1-9][0-9]*[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.2.20 Ensure SSH Idle Timeout Interval is configured - ClientAliveCountMax sshd_config"
info : "NOTE: To clarify, the two settings described below are only meant for idle connections from a protocol perspective and 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 may no longer be abused to disconnect idle users.
The two options ClientAliveInterval and ClientAliveCountMax control the timeout of SSH sessions. Taken directly from man 5 sshd_config:
ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
ClientAliveCountMax Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option en-abled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.
Rationale:
In order to prevent resource exhaustion, appropriate values should be set for both ClientAliveInterval and ClientAliveCountMax. Specifically, looking at the source code, ClientAliveCountMax must be greater than zero in order to utilize the ability of SSH to drop idle connections. If connections are allowed to stay open indefinitely, this can potentially be used as a DDOS attack or simple resource exhaustion could occur over unreliable networks.
The example set here is a 45 second timeout. Consult your site policy for network timeouts and apply as appropriate."
solution : "Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the ClientAliveInterval and ClientAliveCountMax parameters according to site policy.
Example:
ClientAliveInterval 15
ClientAliveCountMax 3
Edit files ending in *.conf in the /etc/ssh/sshd_config.d/ directory and the /etc/ssh/sshd_config file and remove occurrences of the ClientAliveInterval and ClientAliveCountMax parameters not in accordence with local site policy.
Run the following command to comment out any ClientAliveCountMax parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include the setting of 0 'disabled':
# grep -Pi '^\h*ClientAliveCountMax\h+0\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri '/^\s*ClientAliveCountMax\s+0/s/^/# /' '$(awk -F: '{print $1}' <<< $l_out)';done
Default Value:
ClientAliveInterval 0
ClientAliveCountMax 3"
reference : "800-171|3.4.6,800-171|3.4.7,800-53|CM-7b.,800-53r5|CM-7b.,CN-L3|7.1.3.5(c),CN-L3|7.1.3.7(d),CN-L3|8.1.4.4(b),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-7a.,LEVEL|1A,NIAv2|SS13b,NIAv2|SS14a,NIAv2|SS14c,PCI-DSSv3.2.1|2.2.2,PCI-DSSv4.0|2.2.4,QCSC-v1|3.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf"
regex : "^[\\s]*(?i)ClientAliveCountMax(?-i)[\\s]"
expect : "^[\\s]*(?i)ClientAliveCountMax(?-i)[\\s]+[1-9][0-9]*[\\s]*$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : RPM_CHECK
description : "5.3.1 Ensure sudo is installed"
info : "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."
solution : "Run the following command to install sudo
# dnf install sudo"
reference : "800-171|3.1.5,800-171|3.1.6,800-53|AC-6(2),800-53|AC-6(5),800-53r5|AC-6(2),800-53r5|AC-6(5),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSCv7|4.3,CSCv8|5.4,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(2),ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM1,NIAv2|AM23f,NIAv2|AM32,NIAv2|AM33,NIAv2|SS13c,NIAv2|SS15c,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
rpm : "sudo-0.0.0-0"
operator : "gt"
required : YES
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.3.2 Ensure sudo commands use pty"
info : "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."
solution : "Edit the file /etc/sudoers with visudo or a file in /etc/sudoers.d/ with visudo -f and add the following line:
Defaults use_pty"
reference : "800-171|3.1.5,800-171|3.1.6,800-53|AC-6(2),800-53|AC-6(5),800-53r5|AC-6(2),800-53r5|AC-6(5),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSCv7|5.1,CSCv8|5.4,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(2),ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM1,NIAv2|AM23f,NIAv2|AM32,NIAv2|AM33,NIAv2|SS13c,NIAv2|SS15c,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/sudoers /etc/sudoers.d/*"
regex : "^\\h*Defaults\\h+([^#\n\r]+,)?use_pty(,\\h*\\h+\\h*)*\\h*(#.*)?$"
expect : "^\\h*Defaults\\h+([^#\n\r]+,)?use_pty(,\\h*\\h+\\h*)*\\h*(#.*)?$"
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.3.3 Ensure sudo log file exists"
info : "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.
Creation of additional log files can cause disk space exhaustion if not correctly managed. You should configure logrotate to manage the sudo log in accordance with your local policy."
solution : "Edit the file /etc/sudoers or a file in /etc/sudoers.d/ with visudo or visudo -f and add the following line:
Defaults logfile=''
Example
Defaults logfile='/var/log/sudo.log'"
reference : "800-171|3.3.1,800-171|3.3.2,800-171|3.3.6,800-53|AU-3,800-53|AU-3(1),800-53|AU-7,800-53|AU-12,800-53r5|AU-3,800-53r5|AU-3(1),800-53r5|AU-7,800-53r5|AU-12,CN-L3|7.1.2.3(a),CN-L3|7.1.2.3(b),CN-L3|7.1.2.3(c),CN-L3|7.1.3.3(a),CN-L3|7.1.3.3(b),CN-L3|8.1.4.3(b),CSCv7|6.3,CSCv8|8.5,CSF|DE.CM-1,CSF|DE.CM-3,CSF|DE.CM-7,CSF|PR.PT-1,CSF|RS.AN-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(b),ITSG-33|AU-3,ITSG-33|AU-3(1),ITSG-33|AU-7,ITSG-33|AU-12,LEVEL|1A,NESA|T3.6.2,NIAv2|AM34a,NIAv2|AM34b,NIAv2|AM34c,NIAv2|AM34d,NIAv2|AM34e,NIAv2|AM34f,NIAv2|AM34g,PCI-DSSv3.2.1|10.1,PCI-DSSv3.2.1|10.3,PCI-DSSv3.2.1|10.3.1,PCI-DSSv3.2.1|10.3.2,PCI-DSSv3.2.1|10.3.3,PCI-DSSv3.2.1|10.3.4,PCI-DSSv3.2.1|10.3.5,PCI-DSSv3.2.1|10.3.6,PCI-DSSv4.0|10.2.2,QCSC-v1|3.2,QCSC-v1|6.2,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,QCSC-v1|13.2,SWIFT-CSCv1|6.4"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/sudoers /etc/sudoers.d/*"
regex : "^[\\s]*Defaults[\\s]+(\[^#]+,[\\s]*)?logfile="
expect : "^[\\s]*Defaults[\\s]+(\[^#]+,[\\s]*)?logfile="
min_occurrences : "1"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "5.3.5 Ensure re-authentication for privilege escalation is not disabled globally"
info : "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."
solution : "Configure the operating system to require users to reauthenticate for privilege escalation.
Based on the outcome of the audit procedure, use visudo -f to edit the relevant sudoers file.
Remove any occurrences of !authenticate tags in the file(s)."
reference : "800-171|3.1.5,800-171|3.1.6,800-53|AC-6(2),800-53|AC-6(5),800-53r5|AC-6(2),800-53r5|AC-6(5),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSCv7|4.3,CSCv8|5.4,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(2),ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM1,NIAv2|AM23f,NIAv2|AM32,NIAv2|AM33,NIAv2|SS13c,NIAv2|SS15c,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/sudoers /etc/sudoers.d/*"
regex : "^[^#].*\!authenticate"
expect : "^[^#].*\!authenticate"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "On disk timestamp_timeout"
file : "/etc/sudoers /etc/sudoers.d/*"
regex : "(?i)^\\h*defaults\\h+(?:[^#\\n\\r]+\\h*,\\h*)?timestamp_timeout=(-1|1[6-9]|[2-9][0-9]|[1-9][0-9][0-9]+)\\b(\\h*,\\h*.*)?$"
expect : "(?i)^\\h*defaults\\h+(?:[^#\\n\\r]+\\h*,\\h*)?timestamp_timeout=(-1|1[6-9]|[2-9][0-9]|[1-9][0-9][0-9]+)\\b(\\h*,\\h*.*)?$"
required : NO
min_occurrences : "1"
system : "Linux"
type : CMD_EXEC
description : "sudo timeout"
cmd : "/usr/bin/sudo -V | /usr/bin/grep 'Authentication timestamp timeout:'"
expect : "Authentication timestamp timeout:[\\s]*([1-9]|1[0-5])\\."
description : "5.3.6 Ensure sudo authentication timeout is configured correctly"
info : "sudo caches used credentials for a default of 5 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.
Rationale:
Setting a timeout value reduces the window of opportunity for unauthorized privileged access to another user."
solution : "If the currently configured timeout is larger than 15 minutes, edit the file listed in the audit section with visudo -f and modify the entry timestamp_timeout= to 15 minutes or less as per your site policy. The value is in minutes. This particular entry may appear on its own, or on the same line as env_reset. See the following two examples:
Defaults env_reset, timestamp_timeout=15
Defaults timestamp_timeout=15
Defaults env_reset"
reference : "800-171|3.1.5,800-171|3.1.6,800-53|AC-6(2),800-53|AC-6(5),800-53r5|AC-6(2),800-53r5|AC-6(5),CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.10.6(a),CSCv7|4.3,CSCv8|5.4,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(2),ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM1,NIAv2|AM23f,NIAv2|AM32,NIAv2|AM33,NIAv2|SS13c,NIAv2|SS15c,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
show_output : YES
system : "Linux"
type : CMD_EXEC
description : "5.3.7 Ensure access to the su command is restricted"
info : "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."
solution : "Create an empty group that will be specified for use of the su command. The group should be named according to site policy.
Example:
# groupadd sugroup
Add the following line to the /etc/pam.d/su file, specifying the empty group:
auth required pam_wheel.so use_uid group=sugroup
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "sugroup=$(/usr/bin/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 | /usr/bin/awk 'BEGIN { FS = \"=\"} ; { print $2 }'); if [ ! -z $sugroup ]; then /usr/bin/grep $sugroup /etc/group | /usr/bin/awk 'BEGIN { FS = \":\" }; { print $4 }' | /usr/bin/awk '{print} END {if (NF == 0) print \"pass - group empty\"; else print \"fail - group not empty\"}'; else echo \"fail - sugroup not found in /etc/pam.d/su\"; fi"
expect : "pass - group empty"
type : CMD_EXEC
description : "Determine if custom authselect profiles exist"
cmd : "authselect list | /usr/bin/grep '^-\s*custom' | /usr/bin/awk '{print} END {if (NR != 0) print \"pass\" ; else print \"Manual Review\"}'"
expect : "[\s]*?custom"
system : "Linux"
type : CMD_EXEC
description : "5.4.1 Ensure custom authselect profile is used"
info : "A custom profile can be created by copying and customizing one of the default profiles. The default profiles include: sssd, winbind, or the nis. This profile can then be customized to follow site specific requirements.
You can select a profile for the authselect utility for a specific host. The profile will be applied to every user logging into the host.
Rationale:
A custom profile is required to customize many of the pam options.
When you deploy a profile, the profile is applied to every user logging into the given host"
solution : "Run the following command to create a custom authselect profile:
# authselect create-profile
Example:
# authselect create-profile custom-profile -b sssd --symlink-meta
Run the following command to select a custom authselect profile:
# authselect select custom/ {with-}
Example:
# authselect select custom/custom-profile with-sudo with-faillock without-nullok"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.12.2,800-53|CA-5,800-53|RA-1,800-53|RA-5,800-53r5|CA-5,800-53r5|RA-1,800-53r5|RA-5,CSCv7|16.7,CSCv8|16.2,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.GV-1,CSF|ID.GV-3,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|CA-5,ITSG-33|RA-1,ITSG-33|RA-5,LEVEL|1M,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.7.1,NIAv2|NS9,PCI-DSSv3.2.1|6.1,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "head -1 /etc/authselect/authselect.conf | /usr/bin/grep 'custom/'"
expect : "[\\s]*?custom"
description : "5.4.1 Ensure custom authselect profile is used"
info : "A custom profile can be created by copying and customizing one of the default profiles. The default profiles include: sssd, winbind, or the nis. This profile can then be customized to follow site specific requirements.
You can select a profile for the authselect utility for a specific host. The profile will be applied to every user logging into the host.
Rationale:
A custom profile is required to customize many of the pam options.
When you deploy a profile, the profile is applied to every user logging into the given host"
solution : "Run the following command to create a custom authselect profile:
# authselect create-profile
Example:
# authselect create-profile custom-profile -b sssd --symlink-meta
Run the following command to select a custom authselect profile:
# authselect select custom/ {with-}
Example:
# authselect select custom/custom-profile with-sudo with-faillock without-nullok"
reference : "800-171|3.11.2,800-171|3.11.3,800-171|3.12.2,800-53|CA-5,800-53|RA-1,800-53|RA-5,800-53r5|CA-5,800-53r5|RA-1,800-53r5|RA-5,CSCv7|16.7,CSCv8|16.2,CSF|DE.CM-8,CSF|DE.DP-4,CSF|DE.DP-5,CSF|ID.GV-1,CSF|ID.GV-3,CSF|ID.RA-1,CSF|PR.IP-12,CSF|RS.CO-3,CSF|RS.MI-3,GDPR|32.1.b,GDPR|32.1.d,GDPR|32.2,HIPAA|164.306(a)(1),ISO/IEC-27001|A.12.6.1,ITSG-33|CA-5,ITSG-33|RA-1,ITSG-33|RA-5,LEVEL|1M,NESA|M1.2.2,NESA|M5.4.1,NESA|T7.7.1,NIAv2|NS9,PCI-DSSv3.2.1|6.1,PCI-DSSv4.0|6.3,PCI-DSSv4.0|6.3.1,QCSC-v1|3.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|5.2.3,QCSC-v1|8.2.1,QCSC-v1|10.2.1,QCSC-v1|11.2,SWIFT-CSCv1|2.7"
see_also : "https://workbench.cisecurity.org/files/4230"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.4.2 Ensure authselect includes with-faillock - password-auth auth required"
info : "The pam_faillock.so module maintains a list of failed authentication attempts per user during a specified interval and locks the account in case there were more than the configured number of consecutive failed authentications (this is defined by the deny parameter in the faillock configuration). It stores the failure records into per-user files in the tally directory.
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems."
solution : "Run the following commands to include the with-faillock option to the current authselect profile:
# authselect enable-feature with-faillock
# authselect apply-changes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|16.7,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/password-auth"
regex : "^[\\h]*auth[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
expect : "^[\\h]*auth[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.4.2 Ensure authselect includes with-faillock - password-auth account required"
info : "The pam_faillock.so module maintains a list of failed authentication attempts per user during a specified interval and locks the account in case there were more than the configured number of consecutive failed authentications (this is defined by the deny parameter in the faillock configuration). It stores the failure records into per-user files in the tally directory.
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems."
solution : "Run the following commands to include the with-faillock option to the current authselect profile:
# authselect enable-feature with-faillock
# authselect apply-changes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|16.7,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/password-auth"
regex : "^[\\h]*account[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
expect : "^[\\h]*account[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.4.2 Ensure authselect includes with-faillock - system-auth auth required"
info : "The pam_faillock.so module maintains a list of failed authentication attempts per user during a specified interval and locks the account in case there were more than the configured number of consecutive failed authentications (this is defined by the deny parameter in the faillock configuration). It stores the failure records into per-user files in the tally directory.
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems."
solution : "Run the following commands to include the with-faillock option to the current authselect profile:
# authselect enable-feature with-faillock
# authselect apply-changes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|16.7,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/system-auth"
regex : "^[\\h]*auth[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
expect : "^[\\h]*auth[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.4.2 Ensure authselect includes with-faillock - system-auth account required"
info : "The pam_faillock.so module maintains a list of failed authentication attempts per user during a specified interval and locks the account in case there were more than the configured number of consecutive failed authentications (this is defined by the deny parameter in the faillock configuration). It stores the failure records into per-user files in the tally directory.
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems."
solution : "Run the following commands to include the with-faillock option to the current authselect profile:
# authselect enable-feature with-faillock
# authselect apply-changes"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|16.7,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/system-auth"
regex : "^[\\h]*account[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
expect : "^[\\h]*account[\\h]+required[\\h]+([^#\\r\\n]+[\\h]+)?pam_faillock\\.so[\\h]*([\\h]+.*)?$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.1 Ensure password creation requirements are configured - try_first_pass /etc/pam.d/system-auth"
info : "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 are definitions of the pam_pwquality.so options.
try_first_pass - retrieve the password from a previous stacked PAM module. If not available, then prompt the user for a password.
retry=3 - Allow 3 tries before sending back a failure.
minlen=14 - password must be 14 characters or more
Either of the following can be used to enforce complex passwords:
minclass=4 - provide at least four classes of characters for the new password
OR
dcredit=-1 - provide at least one digit
ucredit=-1 - provide at least one uppercase character
ocredit=-1 - provide at least one special character
lcredit=-1 - provide at least one lowercase character
The settings shown above are one possible policy. Alter these values to conform to your own organization's password policies
Rationale:
Strong passwords protect systems from being hacked through brute force methods."
solution : "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
minclass = 4
OR
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Run the following script to update the system-auth and password-auth files
#!/usr/bin/env bash
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+.*enforce_for_root\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 enforce_for_root/' '$file'
fi
if grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=([4-9]|[1-9][0-9]+)\b.*$' '$file'; then
sed -ri '/pwquality/s/retry=\S+/retry=3/' '$file'
elif ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 retry=3/' '$file'
fi
done
authselect apply-changes
Additional Information:
all default authselect profiles have pam_pwquality enabled with the expectation that options will be specified in pwquality.conf"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/system-auth"
regex : "^[^#]*pam_pwquality.so.*try_first_pass"
expect : "^[^#]*pam_pwquality.so.*try_first_pass"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.1 Ensure password creation requirements are configured - try_first_pass /etc/pam.d/password-auth"
info : "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 are definitions of the pam_pwquality.so options.
try_first_pass - retrieve the password from a previous stacked PAM module. If not available, then prompt the user for a password.
retry=3 - Allow 3 tries before sending back a failure.
minlen=14 - password must be 14 characters or more
Either of the following can be used to enforce complex passwords:
minclass=4 - provide at least four classes of characters for the new password
OR
dcredit=-1 - provide at least one digit
ucredit=-1 - provide at least one uppercase character
ocredit=-1 - provide at least one special character
lcredit=-1 - provide at least one lowercase character
The settings shown above are one possible policy. Alter these values to conform to your own organization's password policies
Rationale:
Strong passwords protect systems from being hacked through brute force methods."
solution : "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
minclass = 4
OR
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Run the following script to update the system-auth and password-auth files
#!/usr/bin/env bash
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+.*enforce_for_root\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 enforce_for_root/' '$file'
fi
if grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=([4-9]|[1-9][0-9]+)\b.*$' '$file'; then
sed -ri '/pwquality/s/retry=\S+/retry=3/' '$file'
elif ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 retry=3/' '$file'
fi
done
authselect apply-changes
Additional Information:
all default authselect profiles have pam_pwquality enabled with the expectation that options will be specified in pwquality.conf"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/password-auth"
regex : "^[^#]*pam_pwquality.so.*try_first_pass"
expect : "^[^#]*pam_pwquality.so.*try_first_pass"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.1 Ensure password creation requirements are configured - retry /etc/pam.d/system-auth"
info : "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 are definitions of the pam_pwquality.so options.
try_first_pass - retrieve the password from a previous stacked PAM module. If not available, then prompt the user for a password.
retry=3 - Allow 3 tries before sending back a failure.
minlen=14 - password must be 14 characters or more
Either of the following can be used to enforce complex passwords:
minclass=4 - provide at least four classes of characters for the new password
OR
dcredit=-1 - provide at least one digit
ucredit=-1 - provide at least one uppercase character
ocredit=-1 - provide at least one special character
lcredit=-1 - provide at least one lowercase character
The settings shown above are one possible policy. Alter these values to conform to your own organization's password policies
Rationale:
Strong passwords protect systems from being hacked through brute force methods."
solution : "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
minclass = 4
OR
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Run the following script to update the system-auth and password-auth files
#!/usr/bin/env bash
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+.*enforce_for_root\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 enforce_for_root/' '$file'
fi
if grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=([4-9]|[1-9][0-9]+)\b.*$' '$file'; then
sed -ri '/pwquality/s/retry=\S+/retry=3/' '$file'
elif ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 retry=3/' '$file'
fi
done
authselect apply-changes
Additional Information:
all default authselect profiles have pam_pwquality enabled with the expectation that options will be specified in pwquality.conf"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/system-auth"
regex : "^[^#]*pam_pwquality.so.*retry[\\s]*="
expect : "^[^#]*pam_pwquality.so.*retry[\\s]*=[\\s]*[1-3]([\\s]|$)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.1 Ensure password creation requirements are configured - retry /etc/pam.d/password-auth"
info : "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 are definitions of the pam_pwquality.so options.
try_first_pass - retrieve the password from a previous stacked PAM module. If not available, then prompt the user for a password.
retry=3 - Allow 3 tries before sending back a failure.
minlen=14 - password must be 14 characters or more
Either of the following can be used to enforce complex passwords:
minclass=4 - provide at least four classes of characters for the new password
OR
dcredit=-1 - provide at least one digit
ucredit=-1 - provide at least one uppercase character
ocredit=-1 - provide at least one special character
lcredit=-1 - provide at least one lowercase character
The settings shown above are one possible policy. Alter these values to conform to your own organization's password policies
Rationale:
Strong passwords protect systems from being hacked through brute force methods."
solution : "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
minclass = 4
OR
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Run the following script to update the system-auth and password-auth files
#!/usr/bin/env bash
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+.*enforce_for_root\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 enforce_for_root/' '$file'
fi
if grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=([4-9]|[1-9][0-9]+)\b.*$' '$file'; then
sed -ri '/pwquality/s/retry=\S+/retry=3/' '$file'
elif ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 retry=3/' '$file'
fi
done
authselect apply-changes
Additional Information:
all default authselect profiles have pam_pwquality enabled with the expectation that options will be specified in pwquality.conf"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/password-auth"
regex : "^[^#]*pam_pwquality.so.*retry[\\s]*="
expect : "^[^#]*pam_pwquality.so.*retry[\\s]*=[\\s]*[1-3]([\\s]|$)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.1 Ensure password creation requirements are configured - minlen"
info : "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 are definitions of the pam_pwquality.so options.
try_first_pass - retrieve the password from a previous stacked PAM module. If not available, then prompt the user for a password.
retry=3 - Allow 3 tries before sending back a failure.
minlen=14 - password must be 14 characters or more
Either of the following can be used to enforce complex passwords:
minclass=4 - provide at least four classes of characters for the new password
OR
dcredit=-1 - provide at least one digit
ucredit=-1 - provide at least one uppercase character
ocredit=-1 - provide at least one special character
lcredit=-1 - provide at least one lowercase character
The settings shown above are one possible policy. Alter these values to conform to your own organization's password policies
Rationale:
Strong passwords protect systems from being hacked through brute force methods."
solution : "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
minclass = 4
OR
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Run the following script to update the system-auth and password-auth files
#!/usr/bin/env bash
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+.*enforce_for_root\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 enforce_for_root/' '$file'
fi
if grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=([4-9]|[1-9][0-9]+)\b.*$' '$file'; then
sed -ri '/pwquality/s/retry=\S+/retry=3/' '$file'
elif ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 retry=3/' '$file'
fi
done
authselect apply-changes
Additional Information:
all default authselect profiles have pam_pwquality enabled with the expectation that options will be specified in pwquality.conf"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/security/pwquality.conf"
regex : "^[^#]*minlen[\\s]*="
expect : "^[^#]*minlen[\\s]*=[\\s]*(1[4-9]|[2-9][0-9])([\\s]|$)"
system : "Linux"
type : CMD_EXEC
description : "5.5.1 Ensure password creation requirements are configured - password complexity"
info : "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 are definitions of the pam_pwquality.so options.
try_first_pass - retrieve the password from a previous stacked PAM module. If not available, then prompt the user for a password.
retry=3 - Allow 3 tries before sending back a failure.
minlen=14 - password must be 14 characters or more
Either of the following can be used to enforce complex passwords:
minclass=4 - provide at least four classes of characters for the new password
OR
dcredit=-1 - provide at least one digit
ucredit=-1 - provide at least one uppercase character
ocredit=-1 - provide at least one special character
lcredit=-1 - provide at least one lowercase character
The settings shown above are one possible policy. Alter these values to conform to your own organization's password policies
Rationale:
Strong passwords protect systems from being hacked through brute force methods.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "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
minclass = 4
OR
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Run the following script to update the system-auth and password-auth files
#!/usr/bin/env bash
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+.*enforce_for_root\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 enforce_for_root/' '$file'
fi
if grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=([4-9]|[1-9][0-9]+)\b.*$' '$file'; then
sed -ri '/pwquality/s/retry=\S+/retry=3/' '$file'
elif ! grep -Pq -- '^\h*password\h+requisite\h+pam_pwquality.so(\h+[^#\n\r]+)?\h+retry=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+requisite\s+pam_pwquality.so\s+)(.*)$/\1\2 retry=3/' '$file'
fi
done
authselect apply-changes
Additional Information:
all default authselect profiles have pam_pwquality enabled with the expectation that options will be specified in pwquality.conf"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/grep -E '^[[:space:]]*minclass[[:space:]]*=[[:space:]]*4' /etc/security/pwquality.conf | /usr/bin/awk '{print} END {if (NR != 0) print \"pass\" ; else print \"fail\"}'"
expect : "pass"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.2 Ensure lockout for failed password attempts is configured - deny"
info : "Lock out users after n unsuccessful consecutive login attempts.
deny= - Number of attempts before the account is locked
unlock_time= - Time in seconds before the account is unlocked
Note: The maximum configurable value for unlock_time is 604800
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems.
Impact:
Use of unlock_time=0 may allow an attacker to cause denial of service to legitimate users."
solution : "Set password lockouts and unlock times to conform to site policy. deny should be greater than 0 and no greater than 5. unlock_time should be 0 (never), or 900 seconds or greater.
Edit /etc/security/faillock.conf and update or add the following lines:
deny = 5
unlock_time = 900
Default Value:
deny = 3
unlock_time = 600
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
If a user has been locked out because they have reached the maximum consecutive failure count defined by deny= in the pam_faillock.so module, the user can be unlocked by issuing the command faillock --user --reset. This command sets the failed count to 0, effectively unlocking the user.
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."
reference : "800-171|3.1.1,800-53|AC-1,800-53|AC-2,800-53|AC-2(1),800-53r5|AC-1,800-53r5|AC-2,800-53r5|AC-2(1),CN-L3|7.1.3.2(d),CN-L3|8.1.4.2(e),CN-L3|8.1.10.6(c),CSCv7|16.7,CSCv8|6.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.AC-1,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.1.1,ISO/IEC-27001|A.9.2.1,ITSG-33|AC-1,ITSG-33|AC-2,ITSG-33|AC-2(1),LEVEL|1A,NESA|M1.2.2,NIAv2|AM28,NIAv2|AM29,NIAv2|AM30,NIAv2|NS5j,NIAv2|SS14e,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|8.2.1,QCSC-v1|13.2,QCSC-v1|15.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/security/faillock.conf"
regex : "^[\\s]*deny[\\s]*="
expect : "^[\\s]*deny[\\s]*=[\\s]*[1-3]$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.2 Ensure lockout for failed password attempts is configured - unlock_time"
info : "Lock out users after n unsuccessful consecutive login attempts.
deny= - Number of attempts before the account is locked
unlock_time= - Time in seconds before the account is unlocked
Note: The maximum configurable value for unlock_time is 604800
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems.
Impact:
Use of unlock_time=0 may allow an attacker to cause denial of service to legitimate users."
solution : "Set password lockouts and unlock times to conform to site policy. deny should be greater than 0 and no greater than 5. unlock_time should be 0 (never), or 900 seconds or greater.
Edit /etc/security/faillock.conf and update or add the following lines:
deny = 5
unlock_time = 900
Default Value:
deny = 3
unlock_time = 600
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
If a user has been locked out because they have reached the maximum consecutive failure count defined by deny= in the pam_faillock.so module, the user can be unlocked by issuing the command faillock --user --reset. This command sets the failed count to 0, effectively unlocking the user.
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."
reference : "800-171|3.1.1,800-53|AC-1,800-53|AC-2,800-53|AC-2(1),800-53r5|AC-1,800-53r5|AC-2,800-53r5|AC-2(1),CN-L3|7.1.3.2(d),CN-L3|8.1.4.2(e),CN-L3|8.1.10.6(c),CSCv7|16.7,CSCv8|6.2,CSF|DE.CM-1,CSF|DE.CM-3,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.AC-1,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.1.1,ISO/IEC-27001|A.9.2.1,ITSG-33|AC-1,ITSG-33|AC-2,ITSG-33|AC-2(1),LEVEL|1A,NESA|M1.2.2,NIAv2|AM28,NIAv2|AM29,NIAv2|AM30,NIAv2|NS5j,NIAv2|SS14e,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|8.2.1,QCSC-v1|13.2,QCSC-v1|15.2"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/security/faillock.conf"
regex : "^[\\s]*unlock_time[\\s]*="
expect : "^[\\s]*unlock_time[\\s]*=[\\s]*(9[0-9][0-9]|\d{4,})$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.3 Ensure password reuse is limited"
info : "The /etc/security/opasswd file stores the users' old passwords and can be checked to ensure that users are not recycling recent passwords.
remember=<5> - Number of old passwords to remember
Rationale:
Forcing users not to reuse their past 5 passwords make it less likely that an attacker will be able to guess the password.
Note: These change only apply to accounts configured on the local system."
solution : "Set remembered password history to conform to site policy.
Run the following script to add or modify the pam_pwhistory.so and pam_unix.so lines to include the remember option:
#!/usr/bin/env bash
{
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/system-auth'
if ! grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_pwhistory\.so\h+([^#\n\r]+\h+)?remember=*(2|[4-9][2-9][0-9]+)\b.*$' '$file'; then
if grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_pwhistory\.so\h+([^#\n\r]+\h+)?remember=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+(requisite|required|sufficient)\s+pam_pwhistory\.so\s+([^#\n\r]+\s+)?)(remember=\S+\s*)(\s+.*)?$/\1 remember=5 \5/' $file
elif grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_pwhistory\.so\h+([^#\n\r]+\h+)?.*$' '$file'; then
sed -ri '/^\s*password\s+(requisite|required|sufficient)\s+pam_pwhistory\.so/ s/$/ remember=24/' $file
else
sed -ri '/^\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so/i password required pam_pwhistory.so remember=24 use_authtok' $file
fi
fi
if ! grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so\h+([^#\n\r]+\h+)?remember=([5-9]|[1-9][0-9]+)\b.*$' '$file'; then
if grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so\h+([^#\n\r]+\h+)?remember=\d+\b.*$' '$file'; then
sed -ri 's/^\s*(password\s+(requisite|required|sufficient)\s+pam_unix\.so\s+([^#\n\r]+\s+)?)(remember=\S+\s*)(\s+.*)?$/\1 remember=5 \5/' $file
else
sed -ri '/^\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so/ s/$/ remember=5/' $file
fi
fi
authselect apply-changes
}
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
NIST SP 800-53 Rev. 5:
IA-5(1)"
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/system-auth"
regex : "^\\h*password\\h+(requisite|sufficient)\\h+(pam_pwhistory\\.so|pam_unix\\.so)\\h+([^#\\r]+\\h+)?remember=*(2|[4-9][2-9][0-9]+)\\h*(\\h+.*)?$"
expect : "^\\h*password\\h+(requisite|sufficient)\\h+(pam_pwhistory\\.so|pam_unix\\.so)\\h+([^#\\r]+\\h+)?remember=*(2|[4-9][2-9][0-9]+)\\h*(\\h+.*)?$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.4 Ensure password hashing algorithm is SHA-512 or yescrypt - /etc/libuser.conf"
info : "A cryptographic hash function converts an arbitrary-length input into a fixed length output. Password hashing performs a one-way transformation of a password, turning the password into another string, called the hashed password.
Rationale:
The SHA-512 algorithm provides stronger hashing than other hashing algorithms used for password hashing with Linux, providing additional protection to the system by increasing the level of effort for an attacker to successfully determine passwords.
Note: These changes only apply to accounts configured on the local system."
solution : "Set password hashing algorithm to sha512.
Edit /etc/libuser.conf and edit of add the following line:
crypt_style = sha512
Edit /etc/login.defs and edit or add the following line:
ENCRYPT_METHOD SHA512
Run the following script to configure pam_unix.so to use the sha512 hashing algorithm:
#!/usr/bin/env bash
{
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+sha512\b.*$' '$file'; then
if grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+(md5|blowfish|bigcrypt|sha256|yescrypt)\b.*$' '$file'; then
sed -ri 's/(md5|blowfish|bigcrypt|sha256|yescrypt)/sha512/' '$file'
else
sed -ri 's/(^\s*password\s+(requisite|required|sufficient)\s+pam_unix.so\s+)(.*)$/\1sha512 \3/' '$file'
fi
fi
done
authselect apply-changes
}
Note: This only effects local users and passwords created after updating the files to use sha512. If it is determined that the password algorithm being used is not SHA-512, once it is changed, it is recommended that all user ID's be immediately expired and forced to change their passwords on next login.
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
The following command may be used to expire all non-system user ID's immediately and force them to change their passwords on next login. Any system accounts that need to be expired should be carefully done separately by the system administrator to prevent any potential problems.
# awk -F: '( $3<''$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)'' && $1 != 'nfsnobody' ) { print $1 }' /etc/passwd | xargs -n 1 chage -d 0
NIST SP 800-53 Rev. 5:
IA-5(1)"
reference : "800-171|3.5.2,800-171|3.13.16,800-53|IA-5(1),800-53|SC-28,800-53|SC-28(1),800-53r5|IA-5(1),800-53r5|SC-28,800-53r5|SC-28(1),CN-L3|8.1.4.7(b),CN-L3|8.1.4.8(b),CSCv7|16.4,CSCv8|3.11,CSF|PR.AC-1,CSF|PR.DS-1,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(a)(2)(iv),HIPAA|164.312(d),HIPAA|164.312(e)(2)(ii),ITSG-33|IA-5(1),ITSG-33|SC-28,ITSG-33|SC-28(1),ITSG-33|SC-28a.,LEVEL|1A,NESA|T5.2.3,PCI-DSSv3.2.1|3.4,PCI-DSSv4.0|3.3.2,PCI-DSSv4.0|3.5.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1,TBA-FIISB|28.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/libuser.conf"
regex : "^[\\s]*crypt_style[\\s]*=[\\s]*"
expect : "(sha512|yescrypt)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.4 Ensure password hashing algorithm is SHA-512 or yescrypt - /etc/login.defs"
info : "A cryptographic hash function converts an arbitrary-length input into a fixed length output. Password hashing performs a one-way transformation of a password, turning the password into another string, called the hashed password.
Rationale:
The SHA-512 algorithm provides stronger hashing than other hashing algorithms used for password hashing with Linux, providing additional protection to the system by increasing the level of effort for an attacker to successfully determine passwords.
Note: These changes only apply to accounts configured on the local system."
solution : "Set password hashing algorithm to sha512.
Edit /etc/libuser.conf and edit of add the following line:
crypt_style = sha512
Edit /etc/login.defs and edit or add the following line:
ENCRYPT_METHOD SHA512
Run the following script to configure pam_unix.so to use the sha512 hashing algorithm:
#!/usr/bin/env bash
{
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+sha512\b.*$' '$file'; then
if grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+(md5|blowfish|bigcrypt|sha256|yescrypt)\b.*$' '$file'; then
sed -ri 's/(md5|blowfish|bigcrypt|sha256|yescrypt)/sha512/' '$file'
else
sed -ri 's/(^\s*password\s+(requisite|required|sufficient)\s+pam_unix.so\s+)(.*)$/\1sha512 \3/' '$file'
fi
fi
done
authselect apply-changes
}
Note: This only effects local users and passwords created after updating the files to use sha512. If it is determined that the password algorithm being used is not SHA-512, once it is changed, it is recommended that all user ID's be immediately expired and forced to change their passwords on next login.
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
The following command may be used to expire all non-system user ID's immediately and force them to change their passwords on next login. Any system accounts that need to be expired should be carefully done separately by the system administrator to prevent any potential problems.
# awk -F: '( $3<''$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)'' && $1 != 'nfsnobody' ) { print $1 }' /etc/passwd | xargs -n 1 chage -d 0
NIST SP 800-53 Rev. 5:
IA-5(1)"
reference : "800-171|3.5.2,800-171|3.13.16,800-53|IA-5(1),800-53|SC-28,800-53|SC-28(1),800-53r5|IA-5(1),800-53r5|SC-28,800-53r5|SC-28(1),CN-L3|8.1.4.7(b),CN-L3|8.1.4.8(b),CSCv7|16.4,CSCv8|3.11,CSF|PR.AC-1,CSF|PR.DS-1,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(a)(2)(iv),HIPAA|164.312(d),HIPAA|164.312(e)(2)(ii),ITSG-33|IA-5(1),ITSG-33|SC-28,ITSG-33|SC-28(1),ITSG-33|SC-28a.,LEVEL|1A,NESA|T5.2.3,PCI-DSSv3.2.1|3.4,PCI-DSSv4.0|3.3.2,PCI-DSSv4.0|3.5.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1,TBA-FIISB|28.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/login.defs"
regex : "^[\\s]*ENCRYPT_METHOD[\\s]*"
expect : "(sha512|yescrypt)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.4 Ensure password hashing algorithm is SHA-512 or yescrypt - /etc/pam.d/password-auth"
info : "A cryptographic hash function converts an arbitrary-length input into a fixed length output. Password hashing performs a one-way transformation of a password, turning the password into another string, called the hashed password.
Rationale:
The SHA-512 algorithm provides stronger hashing than other hashing algorithms used for password hashing with Linux, providing additional protection to the system by increasing the level of effort for an attacker to successfully determine passwords.
Note: These changes only apply to accounts configured on the local system."
solution : "Set password hashing algorithm to sha512.
Edit /etc/libuser.conf and edit of add the following line:
crypt_style = sha512
Edit /etc/login.defs and edit or add the following line:
ENCRYPT_METHOD SHA512
Run the following script to configure pam_unix.so to use the sha512 hashing algorithm:
#!/usr/bin/env bash
{
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+sha512\b.*$' '$file'; then
if grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+(md5|blowfish|bigcrypt|sha256|yescrypt)\b.*$' '$file'; then
sed -ri 's/(md5|blowfish|bigcrypt|sha256|yescrypt)/sha512/' '$file'
else
sed -ri 's/(^\s*password\s+(requisite|required|sufficient)\s+pam_unix.so\s+)(.*)$/\1sha512 \3/' '$file'
fi
fi
done
authselect apply-changes
}
Note: This only effects local users and passwords created after updating the files to use sha512. If it is determined that the password algorithm being used is not SHA-512, once it is changed, it is recommended that all user ID's be immediately expired and forced to change their passwords on next login.
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
The following command may be used to expire all non-system user ID's immediately and force them to change their passwords on next login. Any system accounts that need to be expired should be carefully done separately by the system administrator to prevent any potential problems.
# awk -F: '( $3<''$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)'' && $1 != 'nfsnobody' ) { print $1 }' /etc/passwd | xargs -n 1 chage -d 0
NIST SP 800-53 Rev. 5:
IA-5(1)"
reference : "800-171|3.5.2,800-171|3.13.16,800-53|IA-5(1),800-53|SC-28,800-53|SC-28(1),800-53r5|IA-5(1),800-53r5|SC-28,800-53r5|SC-28(1),CN-L3|8.1.4.7(b),CN-L3|8.1.4.8(b),CSCv7|16.4,CSCv8|3.11,CSF|PR.AC-1,CSF|PR.DS-1,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(a)(2)(iv),HIPAA|164.312(d),HIPAA|164.312(e)(2)(ii),ITSG-33|IA-5(1),ITSG-33|SC-28,ITSG-33|SC-28(1),ITSG-33|SC-28a.,LEVEL|1A,NESA|T5.2.3,PCI-DSSv3.2.1|3.4,PCI-DSSv4.0|3.3.2,PCI-DSSv4.0|3.5.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1,TBA-FIISB|28.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/password-auth"
regex : "^[\\s]*password[\\s]+(requisite|required|sufficient)[\\s]+pam_unix\\.so[\\s]*"
expect : "(sha512|yescrypt)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.5.4 Ensure password hashing algorithm is SHA-512 or yescrypt - /etc/pam.d/system-auth"
info : "A cryptographic hash function converts an arbitrary-length input into a fixed length output. Password hashing performs a one-way transformation of a password, turning the password into another string, called the hashed password.
Rationale:
The SHA-512 algorithm provides stronger hashing than other hashing algorithms used for password hashing with Linux, providing additional protection to the system by increasing the level of effort for an attacker to successfully determine passwords.
Note: These changes only apply to accounts configured on the local system."
solution : "Set password hashing algorithm to sha512.
Edit /etc/libuser.conf and edit of add the following line:
crypt_style = sha512
Edit /etc/login.defs and edit or add the following line:
ENCRYPT_METHOD SHA512
Run the following script to configure pam_unix.so to use the sha512 hashing algorithm:
#!/usr/bin/env bash
{
for fn in system-auth password-auth; do
file='/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/$fn'
if ! grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+sha512\b.*$' '$file'; then
if grep -Pq -- '^\h*password\h+(requisite|required|sufficient)\h+pam_unix\.so(\h+[^#\n\r]+)?\h+(md5|blowfish|bigcrypt|sha256|yescrypt)\b.*$' '$file'; then
sed -ri 's/(md5|blowfish|bigcrypt|sha256|yescrypt)/sha512/' '$file'
else
sed -ri 's/(^\s*password\s+(requisite|required|sufficient)\s+pam_unix.so\s+)(.*)$/\1sha512 \3/' '$file'
fi
fi
done
authselect apply-changes
}
Note: This only effects local users and passwords created after updating the files to use sha512. If it is determined that the password algorithm being used is not SHA-512, once it is changed, it is recommended that all user ID's be immediately expired and forced to change their passwords on next login.
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
The following command may be used to expire all non-system user ID's immediately and force them to change their passwords on next login. Any system accounts that need to be expired should be carefully done separately by the system administrator to prevent any potential problems.
# awk -F: '( $3<''$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)'' && $1 != 'nfsnobody' ) { print $1 }' /etc/passwd | xargs -n 1 chage -d 0
NIST SP 800-53 Rev. 5:
IA-5(1)"
reference : "800-171|3.5.2,800-171|3.13.16,800-53|IA-5(1),800-53|SC-28,800-53|SC-28(1),800-53r5|IA-5(1),800-53r5|SC-28,800-53r5|SC-28(1),CN-L3|8.1.4.7(b),CN-L3|8.1.4.8(b),CSCv7|16.4,CSCv8|3.11,CSF|PR.AC-1,CSF|PR.DS-1,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(a)(2)(iv),HIPAA|164.312(d),HIPAA|164.312(e)(2)(ii),ITSG-33|IA-5(1),ITSG-33|SC-28,ITSG-33|SC-28(1),ITSG-33|SC-28a.,LEVEL|1A,NESA|T5.2.3,PCI-DSSv3.2.1|3.4,PCI-DSSv4.0|3.3.2,PCI-DSSv4.0|3.5.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1,TBA-FIISB|28.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/pam.d/system-auth"
regex : "^[\\s]*password[\\s]+(requisite|required|sufficient)[\\s]+pam_unix\\.so[\\s]*"
expect : "(sha512|yescrypt)"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.1 Ensure password expiration is 365 days or less - login.defs"
info : "The PASS_MAX_DAYS parameter in /etc/login.defs allows an administrator to force passwords to expire once they reach a defined age. It is recommended that the PASS_MAX_DAYS parameter be set to less than or equal to 365 days.
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."
solution : "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
Additional Information:
You can also check this setting in /etc/shadow directly. The 5th field should be 365 or less for all users with a password.
Note: A value of -1 will disable password expiration. Additionally, the password expiration must be greater than the minimum days between password changes or users will be unable to change their password.
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|4.4,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/login.defs"
regex : "^[\\s]*PASS_MAX_DAYS[\\s]"
expect : "^[\\s]*PASS_MAX_DAYS[\\s]+([1-9]|[1-8][0-9]|90)[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.1 Ensure password expiration is 365 days or less - users"
info : "The PASS_MAX_DAYS parameter in /etc/login.defs allows an administrator to force passwords to expire once they reach a defined age. It is recommended that the PASS_MAX_DAYS parameter be set to less than or equal to 365 days.
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."
solution : "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
Additional Information:
You can also check this setting in /etc/shadow directly. The 5th field should be 365 or less for all users with a password.
Note: A value of -1 will disable password expiration. Additionally, the password expiration must be greater than the minimum days between password changes or users will be unable to change their password.
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|4.4,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/shadow"
regex : "^[\\s]*PASS_MAX_DAYS[\\s]"
expect : "^[\\s]*PASS_MAX_DAYS[\\s]+([1-9]|[1-8][0-9]|90)\\s*$"
string_required : NO
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.2 Ensure minimum days between password changes is configured - login.defs"
info : "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."
solution : "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
Default Value:
PASS_MIN_DAYS 0
Additional Information:
You can also check this setting in /etc/shadow directly. The 4th field should be 1 or more for all users with a password."
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/login.defs"
regex : "^[\\s\\t]*PASS_MIN_DAYS\\s+"
expect : "PASS_MIN_DAYS\\s+([1-9]|[1-9][0-9]+)\\s*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.2 Ensure minimum days between password changes is configured - users"
info : "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."
solution : "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
Default Value:
PASS_MIN_DAYS 0
Additional Information:
You can also check this setting in /etc/shadow directly. The 4th field should be 1 or more for all users with a password."
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/shadow"
regex : "^[\\s\\t]*PASS_MIN_DAYS\\s+"
expect : "PASS_MIN_DAYS\\s+([1-9]|[1-9][0-9]+)\\s*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.3 Ensure password expiration warning days is 7 or more - login.defs"
info : "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."
solution : "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
Additional Information:
You can also check this setting in /etc/shadow directly. The 6th field should be 7 or more for all users with a password."
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|4.4,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/login.defs"
regex : "^[\\s]*PASS_WARN_AGE\\s+"
expect : "^[\\s]*PASS_WARN_AGE\\s+([1-9]|1[0-4]?)\\s*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.3 Ensure password expiration warning days is 7 or more - users"
info : "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."
solution : "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
Additional Information:
You can also check this setting in /etc/shadow directly. The 6th field should be 7 or more for all users with a password."
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|4.4,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/shadow"
cmd : "echo 'Username, Number of days of warning before password expires'; output=\"\"; failures=0; for i in $(egrep \"^[^:]+:[^\!*]\" /etc/shadow | cut -d: -f1); do change_date=$(chage --list \"$i\" | grep 'Number of days of warning before password expires' | cut -d: -f2 | awk '{$1=$1};1'); output=\"${i}, ${change_date}\"; if [ $change_date -ge 7 ]; then output=\"${output} - Pass\"; else output=\"${output} - Fail\"; failures=$((failures+1)); fi; echo \"${output}\"; done; echo \"Number of failures: ${failures}\""
expect : "^Number of failures: 0$"
system : "Linux"
type : CMD_EXEC
description : "5.6.1.4 Ensure inactive password lock is 30 days or less - useradd"
info : "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."
solution : "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
Default Value:
INACTIVE=-1
Additional Information:
You can also check this setting in /etc/shadow directly. The 7th field should be 30 or less for all users with a password.
Note: A value of -1 would disable this setting."
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/sbin/useradd -D | /usr/bin/grep 'INACTIVE'"
expect : "^[\\s]*INACTIVE[\\s]*=[\\s]*(120|1[0-1][0-9]|[1-9][0-9]|[1-9])[\\s]*$"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.1.4 Ensure inactive password lock is 30 days or less - users"
info : "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."
solution : "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
Default Value:
INACTIVE=-1
Additional Information:
You can also check this setting in /etc/shadow directly. The 7th field should be 30 or less for all users with a password.
Note: A value of -1 would disable this setting."
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/shadow"
cmd : "echo 'Username, Current Days, Last Password Change Days'; output=\"\"; failures=0; for i in $(cut -d: -f1 < /etc/shadow); do now=$(($(date +%s) / 86400)); change_date=$(chage --list \"$i\" | grep 'Last password change' | cut -d: -f2 | awk '{$1=$1};1'); if [[ $change_date != \"never\" ]]; then epoch_change_date=$(($(date -d \"${change_date}\" +%s) / 86400)); else epoch_change_date='Never'; fi; output=\"${i}, ${now}, ${epoch_change_date}\"; if [[ $epoch_change_date -le $now ]]; then output=\"${output} - Pass\"; else output=\"${output} - Fail\"; ((failures++)); fi; echo \"${output}\"; done; echo \"Number of failures: ${failures}\""
expect : "^Number of failures: 0$"
system : "Linux"
type : CMD_EXEC
description : "5.6.1.5 Ensure all users last password change date is in the past"
info : "All users should have a password change date in the past.
Rationale:
If a user's recorded password change date is in the future, then they could bypass any set password expiration."
solution : "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."
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "awk -F: '/^[^:]+:[^!*]/{print $1}' /etc/shadow | while read -r usr; do change=$(date -d \"$(chage --list $usr | grep '^Last password change' | cut -d: -f2 | grep -v 'never$')\" +%s); if [[ \"$change\" -gt \"$(date +%s)\" ]]; then echo \"User: \\\"$usr\\\" last password change was \\\"$(chage --list $usr | grep '^Last password change' | cut -d: -f2)\\\"\"; fi; done | /usr/bin/awk '{ print } END { if (NR==0) print \"pass\" }'"
expect : "^pass"
system : "Linux"
type : CMD_EXEC
description : "5.6.2 Ensure system accounts are secured - non login"
info : "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. Furthermore, a user may add special accounts that 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."
solution : "System accounts
Set the shell for any accounts returned by the audit to nologin:
# usermod -s $(command -v nologin)
Disabled accounts
Lock any non root accounts returned by the audit:
# usermod -L
Large scale changes
The following command will set all system accounts to nologin:
# awk -F: '($1!~/^(root|halt|sync|shutdown|nfsnobody)$/ && ($3<''$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)'' || $3 == 65534)) { print $1 }' /etc/passwd | while read user; do usermod -s $(command -v nologin) $user >/dev/null; done
The following command will automatically lock all accounts that have their shell set to nologin:
# awk -F: '/nologin/ {print $1}' /etc/passwd | while read user; do usermod -L $user; done
Additional Information:
The root, sync, shutdown, and halt users are exempted from requiring a non-login shell.
NIST SP 800-53 Rev. 5:
AC-2(5)
AC-3
AC-11
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/awk -F: '($1!=\"root\" && $1!=\"sync\" && $1!=\"shutdown\" && $1!=\"halt\" && $1!~\/^\\+\/ && $3<'\"$(/usr/bin/awk '\/^[\\s]*UID_MIN\/{print $2}' /etc/login\.defs)\"' && $7!=\"'\"$(which nologin)\"'\" && $7!=\"\/bin\/false\" && $7 != \"/sbin/nologin\" && $7 != \"/usr/sbin/nologin\") {print}' /etc/passwd | /usr/bin/awk '{print} END {if (NR == 0) print \"pass\" ; else print \"fail\"}'"
expect : "^pass$"
system : "Linux"
type : CMD_EXEC
description : "5.6.2 Ensure system accounts are secured - lock not root"
info : "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. Furthermore, a user may add special accounts that 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."
solution : "System accounts
Set the shell for any accounts returned by the audit to nologin:
# usermod -s $(command -v nologin)
Disabled accounts
Lock any non root accounts returned by the audit:
# usermod -L
Large scale changes
The following command will set all system accounts to nologin:
# awk -F: '($1!~/^(root|halt|sync|shutdown|nfsnobody)$/ && ($3<''$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)'' || $3 == 65534)) { print $1 }' /etc/passwd | while read user; do usermod -s $(command -v nologin) $user >/dev/null; done
The following command will automatically lock all accounts that have their shell set to nologin:
# awk -F: '/nologin/ {print $1}' /etc/passwd | while read user; do usermod -L $user; done
Additional Information:
The root, sync, shutdown, and halt users are exempted from requiring a non-login shell.
NIST SP 800-53 Rev. 5:
AC-2(5)
AC-3
AC-11
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/awk -F: '($1!~/^(root|halt|sync|shutdown|nfsnobody)$/ && ($3<'\"$(/usr/bin/awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)\"' || $3 == 65534) && $7!~/^(\/usr)?\/sbin\/nologin$/) { print $1 }' /etc/passwd | /usr/bin/awk '{print} END {if (NR == 0) print \"pass\" ; else print \"fail\"}'"
expect : "^pass$"
system : "Linux"
type : CMD_EXEC
description : "5.6.3 Ensure default user shell timeout is 900 seconds or less"
info : "TMOUT is an environmental setting that determines the timeout of a shell in seconds.
TMOUT=n - Sets the shell timeout to n seconds. A setting of TMOUT=0 disables timeout.
readonly TMOUT- Sets the TMOUT environmental variable as readonly, preventing unwanted modification during run-time.
export TMOUT - exports the TMOUT variable
System Wide Shell Configuration ob体育s:
/etc/profile - used to set system wide environmental variables on users shells. The variables are sometimes the same ones that are in the .bash_profile, however this file is used to set an initial PATH or PS1 for all shell users of the system. is only executed for interactive login shells, or shells executed with the --login parameter.
/etc/profile.d - /etc/profile will execute the scripts within /etc/profile.d/*.sh. It is recommended to place your configuration in a shell script within /etc/profile.d to set your own system wide environmental variables.
/etc/bashrc - System wide version of .bashrc. In Fedora derived distributions, /etc/bashrc also invokes /etc/profile.d/*.sh if non-login shell, but redirects output to /dev/null if non-interactive. Is only executed for interactive shells or if BASH_ENV is set to /etc/bashrc.
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."
solution : "Review /etc/bashrc, /etc/profile, and all files ending in *.sh in the /etc/profile.d/ directory and remove or edit all TMOUT=_n_ entries to follow local site policy. TMOUT should not exceed 900 or be equal to 0.
Configure TMOUT in one of the following files:
A file in the /etc/profile.d/ directory ending in .sh
/etc/profile
/etc/bashrc
TMOUT configuration examples:
As multiple lines:
TMOUT=900
readonly TMOUT
export TMOUT
As a single line:
readonly TMOUT=900 ; export TMOUT
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 also are checked. Other methods of setting a timeout exist for other shells not covered here.
Ensure that the timeout conforms to your local policy."
reference : "800-171|3.1.1,800-171|3.1.10,800-171|3.1.11,800-53|AC-2(5),800-53|AC-11,800-53|AC-11(1),800-53|AC-12,800-53r5|AC-2(5),800-53r5|AC-11,800-53r5|AC-11(1),800-53r5|AC-12,CN-L3|7.1.2.2(d),CN-L3|7.1.3.2(d),CN-L3|7.1.3.7(b),CN-L3|8.1.4.1(b),CSCv7|16.11,CSCv8|4.3,CSF|PR.AC-1,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),HIPAA|164.312(a)(2)(iii),ISO/IEC-27001|A.9.2.1,ISO/IEC-27001|A.11.2.8,ITSG-33|AC-2(5),ITSG-33|AC-11,ITSG-33|AC-11(1),ITSG-33|AC-12,LEVEL|1A,NIAv2|AM23c,NIAv2|AM23d,NIAv2|AM28,NIAv2|NS5j,NIAv2|NS49,NIAv2|SS14e,PCI-DSSv3.2.1|8.1.8,PCI-DSSv4.0|8.2.8,QCSC-v1|5.2.2,QCSC-v1|8.2.1,QCSC-v1|13.2,QCSC-v1|15.2,TBA-FIISB|36.2.1,TBA-FIISB|37.1.4"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "output1=\"\" output2=\"\"; [ -f /etc/bashrc ] && BRC=\"/etc/bashrc\"; for f in \"$BRC\" /etc/profile /etc/profile.d/*.sh ; do grep -Pq '^\\s*([^#]+\\s+)?TMOUT=(900|[1-8][0-9][0-9]|[1-9][0-9]|[1-9])\\b' \"$f\" && grep -Pq '^\\s*([^#]+;\\s*)?readonly\\s+TMOUT(\\s+|\\s*;|\\s*$|=(900|[1-8][0-9][0-9]|[1-9][0-9]|[1-9]))\\b' \"$f\" && grep -Pq '^\\s*([^#]+;\\s*)?export\\s+TMOUT(\\s+|\\s*;|\\s*$|=(900|[1-8][0-9][0-9]|[1-9][0-9]|[1-9]))\\b' \"$f\" && output1=\"$f\"; done; grep -Pq '^\\s*([^#]+\\s+)?TMOUT=(9[0-9][1-9]|9[1-9][0-9]|0+|[1-9]\\d{3,})\\b' /etc/profile /etc/profile.d/*.sh \"$BRC\" && output2=$(grep -Ps '^\\s*([^#]+\\s+)?TMOUT=(9[0-9][1-9]|9[1-9][0-9]|0+|[1-9]\\d{3,})\\b' /etc/profile /etc/profile.d/*.sh $BRC); if [ -n \"$output1\" ] && [ -z \"$output2\" ]; then echo -e \"\\nPASSED\\n\\nTMOUT is configured in: \\\"$output1\\\"\\n\"; else [ -z \"$output1\" ] && echo -e \"\\nFAILED\\n\\nTMOUT is not configured\\n\"; [ -n \"$output2\" ] && echo -e \"\\nFAILED\\n\\nTMOUT is incorrectly configured in: \\\"$output2\\\"\\n\"; fi"
expect : "^[\\s]*PASSED"
system : "Linux"
type : FILE_CONTENT_CHECK
description : "5.6.4 Ensure default group for the root account is GID 0"
info : "The usermod command can be used to specify which group the root account belongs to. This affects permissions of files that are created by the root account.
Rationale:
Using GID 0 for the root account helps prevent root -owned files from accidentally becoming accessible to non-privileged users."
solution : "Run the following command to set the root account default group to GID 0 :
# usermod -g 0 root
Additional Information:
NIST SP 800-53 Rev. 5:
CM-1
CM-2
CM-6
CM-7
IA-5"
reference : "800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.13.1,800-171|3.13.2,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CSCv7|5.1,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS15a,NIAv2|SS16,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|7.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/passwd"
regex : "^root:"
expect : "^root:x:0:0:"
system : "Linux"
type : CMD_EXEC
description : "5.6.5 Ensure default user umask is 027 or more restrictive - default user umask"
info : "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.
umask can be set with either octal or Symbolic values:
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-----.
The default umask can be set to use the pam_umask module or in a System Wide Shell Configuration ob体育. The user creating the directories or files has the discretion of changing the permissions via the chmod command, or choosing a different default umask by adding the umask command into a User Shell Configuration ob体育, ( .bash_profile or .bashrc), in their home directory.
Setting the default umask:
pam_umask module:
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.
umask= value in the /etc/login.defs file is interpreted as Octal
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
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 ob体育:
/etc/profile - used to set system wide environmental variables on users shells. The variables are sometimes the same ones that are in the .bash_profile, however this file is used to set an initial PATH or PS1 for all shell users of the system. is only executed for interactive login shells, or shells executed with the --login parameter.
/etc/profile.d - /etc/profile will execute the scripts within /etc/profile.d/*.sh. It is recommended to place your configuration in a shell script within /etc/profile.d to set your own system wide environmental variables.
/etc/bashrc - System wide version of .bashrc. In Fedora derived distributions, etc/bashrc also invokes /etc/profile.d/*.sh if non-login shell, but redirects output to /dev/null if non-interactive. Is only executed for interactive shells or if BASH_ENV is set to /etc/bashrc.
User Shell Configuration ob体育s:
~/.bash_profile - Is executed to configure your shell before the initial command prompt. Is only read by login shells.
~/.bashrc - Is executed for interactive shells. only read by a shell that's both interactive and non-login
Rationale:
Setting a secure default value for umask ensures that users make a conscious choice about their file permissions. A permissive umask value could result in directories or files with excessive permissions that can be read and/or written to by unauthorized users."
solution : "Review /etc/bashrc, /etc/profile, and all files ending in *.sh in the /etc/profile.d/ directory and remove or edit all umask entries to follow local site policy. Any remaining entries should be: umask 027, umask u=rwx,g=rx,o= or more restrictive.
Configure umask in one of the following files:
A file in the /etc/profile.d/ directory ending in .sh
/etc/profile
/etc/bashrc
Example:
# vi /etc/profile.d/set_umask.sh
umask 027
Run the following command and remove or modify the umask of any returned files:
# grep -RPi '(^|^[^#]*)\s*umask\s+([0-7][0-7][01][0-7]\b|[0-7][0-7][0-7][0-6]\b|[0-7][01][0-7]\b|[0-7][0-7][0-6]\b|(u=[rwx]{0,3},)?(g=[rwx]{0,3},)?o=[rwx]+\b|(u=[rwx]{1,3},)?g=[^rx]{1,3}(,o=[rwx]{0,3})?\b)' /etc/login.defs /etc/profile* /etc/bashrc*
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
Edit the files /etc/pam.d/password-auth and /etc/pam.d/system-auth and add or edit the following:
session optional pam_umask.so
OR Configure umask in one of the following files:
A file in the /etc/profile.d/ directory ending in .sh
/etc/profile
/etc/bashrc
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
Additional Information:
Other methods of setting a default user umask exist
If other methods are in use in your environment they should be audited
The default user umask can be overridden with a user specific umask
The user creating the directories or files has the discretion of changing the permissions:
Using the chmod command
Setting a different default umask by adding the umask command into a User Shell Configuration ob体育, (.bashrc), in their home directory
Manually changing the umask for the duration of a login session by running the umask command
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "passing=\"\"; /usr/bin/grep -Eiq '^\\s*UMASK\\s+(0[0-7][2-7]7|[0-7][2-7]7)\\b' /etc/login.defs && /usr/bin/grep -Eqi '^\\s*USERGROUPS_ENAB\\s*\"?no\"?\\b' /etc/login.defs && /usr/bin/grep -Eq '^\\s*session\\s+(optional|requisite|required)\\s+pam_umask\\.so\\b' /etc/pam.d/common-session && passing=true; /usr/bin/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/bashrc* && passing=true; [ \"$passing\" = true ] && echo \"Default user umask is set\" || echo \"Default user umask not found or invalid\""
expect : "Default user umask is set"
system : "Linux"
type : FILE_CONTENT_CHECK_NOT
description : "5.6.5 Ensure default user umask is 027 or more restrictive - less restrictive system wide umask"
info : "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.
umask can be set with either octal or Symbolic values:
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-----.
The default umask can be set to use the pam_umask module or in a System Wide Shell Configuration ob体育. The user creating the directories or files has the discretion of changing the permissions via the chmod command, or choosing a different default umask by adding the umask command into a User Shell Configuration ob体育, ( .bash_profile or .bashrc), in their home directory.
Setting the default umask:
pam_umask module:
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.
umask= value in the /etc/login.defs file is interpreted as Octal
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
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 ob体育:
/etc/profile - used to set system wide environmental variables on users shells. The variables are sometimes the same ones that are in the .bash_profile, however this file is used to set an initial PATH or PS1 for all shell users of the system. is only executed for interactive login shells, or shells executed with the --login parameter.
/etc/profile.d - /etc/profile will execute the scripts within /etc/profile.d/*.sh. It is recommended to place your configuration in a shell script within /etc/profile.d to set your own system wide environmental variables.
/etc/bashrc - System wide version of .bashrc. In Fedora derived distributions, etc/bashrc also invokes /etc/profile.d/*.sh if non-login shell, but redirects output to /dev/null if non-interactive. Is only executed for interactive shells or if BASH_ENV is set to /etc/bashrc.
User Shell Configuration ob体育s:
~/.bash_profile - Is executed to configure your shell before the initial command prompt. Is only read by login shells.
~/.bashrc - Is executed for interactive shells. only read by a shell that's both interactive and non-login
Rationale:
Setting a secure default value for umask ensures that users make a conscious choice about their file permissions. A permissive umask value could result in directories or files with excessive permissions that can be read and/or written to by unauthorized users."
solution : "Review /etc/bashrc, /etc/profile, and all files ending in *.sh in the /etc/profile.d/ directory and remove or edit all umask entries to follow local site policy. Any remaining entries should be: umask 027, umask u=rwx,g=rx,o= or more restrictive.
Configure umask in one of the following files:
A file in the /etc/profile.d/ directory ending in .sh
/etc/profile
/etc/bashrc
Example:
# vi /etc/profile.d/set_umask.sh
umask 027
Run the following command and remove or modify the umask of any returned files:
# grep -RPi '(^|^[^#]*)\s*umask\s+([0-7][0-7][01][0-7]\b|[0-7][0-7][0-7][0-6]\b|[0-7][01][0-7]\b|[0-7][0-7][0-6]\b|(u=[rwx]{0,3},)?(g=[rwx]{0,3},)?o=[rwx]+\b|(u=[rwx]{1,3},)?g=[^rx]{1,3}(,o=[rwx]{0,3})?\b)' /etc/login.defs /etc/profile* /etc/bashrc*
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
Edit the files /etc/pam.d/password-auth and /etc/pam.d/system-auth and add or edit the following:
session optional pam_umask.so
OR Configure umask in one of the following files:
A file in the /etc/profile.d/ directory ending in .sh
/etc/profile
/etc/bashrc
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
Additional Information:
Other methods of setting a default user umask exist
If other methods are in use in your environment they should be audited
The default user umask can be overridden with a user specific umask
The user creating the directories or files has the discretion of changing the permissions:
Using the chmod command
Setting a different default umask by adding the umask command into a User Shell Configuration ob体育, (.bashrc), in their home directory
Manually changing the umask for the duration of a login session by running the umask command
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/login.defs /etc/profile* /etc/profile.d/*.sh /etc/bashrc*"
regex : "(^|^[^#]*)[\\s]*umask[\\s]+([0-7][0-7][01][0-7]\\b|[0-7][0-7][0-7][0-6]\\b|[0-7][01][0-7]\\b|[0-7][0-7][0-6]\\b|(u=[rwx]{0,3},)?(g=[rwx]{0,3},)?o=[rwx]+\\b|(u=[rwx]{1,3},)?g=[^rx]{1,3}(,o=[rwx]{0,3})?\\b)"
expect : "(^|^[^#]*)[\\s]*umask[\\s]+([0-7][0-7][01][0-7]\\b|[0-7][0-7][0-7][0-6]\\b|[0-7][01][0-7]\\b|[0-7][0-7][0-6]\\b|(u=[rwx]{0,3},)?(g=[rwx]{0,3},)?o=[rwx]+\\b|(u=[rwx]{1,3},)?g=[^rx]{1,3}(,o=[rwx]{0,3})?\\b)"
system : "Linux"
type : CMD_EXEC
description : "5.6.6 Ensure root password is set"
info : "There are a number of methods to access the root account directly. Without a password set any user would be able to gain access and thus control over the entire system.
Rationale:
Access to root should be secured at all times.
Impact:
If there are any automated processes that relies on access to the root account without authentication, they will fail after remediation."
solution : "Set the root password with:
# passwd root"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/passwd -S root"
expect : "Password set"
system : "Linux"
type : FILE_CHECK
description : "6.1.1 Ensure permissions on /etc/passwd are configured"
info : "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."
solution : "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:
/etc/passwd 644 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/passwd"
owner : "root"
mask : "133"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.2 Ensure permissions on /etc/passwd- are configured"
info : "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."
solution : "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:
/etc/passwd- 644 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/passwd-"
owner : "root"
mask : "133"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.3 Ensure permissions on /etc/group are configured"
info : "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."
solution : "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:
/etc/group 644 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/group"
owner : "root"
mask : "133"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.4 Ensure permissions on /etc/group- are configured"
info : "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."
solution : "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:
/etc/group- 644 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/group-"
owner : "root"
mask : "133"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.5 Ensure permissions on /etc/shadow are configured"
info : "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."
solution : "Run the following commands to set mode, owner, and group on /etc/shadow:
# chown root:root /etc/shadow
# chmod 0000 /etc/shadow
Default Value:
/etc/shadow 0 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/shadow"
owner : "root"
mask : "777"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.6 Ensure permissions on /etc/shadow- are configured"
info : "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."
solution : "Run the following commands to set mode, owner, and group on /etc/shadow-:
# chown root:root /etc/shadow-
# chmod 0000 /etc/shadow-
Default Value:
/etc/shadow- 0 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/shadow-"
owner : "root"
mask : "777"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.7 Ensure permissions on /etc/gshadow are configured"
info : "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."
solution : "Run the following commands to set mode, owner, and group on /etc/gshadow:
# chown root:root /etc/gshadow
# chmod 0000 /etc/gshadow
Default Value:
/etc/gshadow 0 0/root 0/root
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/gshadow"
owner : "root"
mask : "777"
group : "root"
system : "Linux"
type : FILE_CHECK
description : "6.1.8 Ensure permissions on /etc/gshadow- are configured"
info : "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."
solution : "Run the following commands to set mode, owner, and group on /etc/gshadow-:
# chown root:root /etc/gshadow-
# chmod 0000 /etc/gshadow-
Default Value:
/etc/gshadow- 0 0/root 0/root"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|16.4,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "/etc/gshadow-"
owner : "root"
mask : "777"
group : "root"
system : "Linux"
description : "6.1.9 Ensure no world writable files exist"
info : "Unix-based systems support variable settings to control access to files. World writable files are the least secure. See the chmod(2) man page for more information.
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."
solution : "Removing write access for the 'other' category ( chmod o-w ) is advisable, but always consult relevant vendor documentation to avoid breaking any application dependencies on a given file.
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|13,CSCv7|5.1,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "find_world_writeable_files"
system : "Linux"
description : "6.1.10 Ensure no unowned files or directories exist"
info : "Sometimes when administrators delete users from the password file, they neglect to remove all files owned by those users from the system.
Rationale:
A new user who is assigned the deleted user's user ID or group ID may then end up 'owning' these files, and thus have more access on the system than was intended."
solution : "Locate files that are owned by users or groups not listed in the system configuration files, and reset the ownership of these files to some active user on the system as appropriate.
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|13.2,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "find_orphan_files"
find_option : "nouser"
system : "Linux"
description : "6.1.11 Ensure no ungrouped files or directories exist"
info : "Sometimes when administrators delete users or groups from the system, they neglect to remove all files owned by those users or groups.
Rationale:
A new user who is assigned the deleted user's user ID or group ID may then end up 'owning' these files, and thus have more access on the system than was intended."
solution : "Locate files that are owned by users or groups not listed in the system configuration files, and reset the ownership of these files to some active user on the system as appropriate.
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|13.2,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "find_orphan_files"
find_option : "nogroup"
system : "Linux"
description : "6.1.12 Ensure sticky bit is set on all world-writable directories"
info : "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:
This feature prevents the ability to delete or rename files in world writable directories (such as /tmp ) that are owned by another user."
solution : "Run the following command to set the sticky bit on all world writable directories:
# df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -type d \( -perm -0002 -a ! -perm -1000 \) 2>/dev/null | xargs -I '{}' chmod a+t '{}'"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.4.1,800-171|3.4.2,800-171|3.4.6,800-171|3.4.7,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-171|3.13.1,800-171|3.13.2,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|CM-1,800-53|CM-2,800-53|CM-6,800-53|CM-7,800-53|CM-7(1),800-53|CM-9,800-53|MP-2,800-53|SA-3,800-53|SA-8,800-53|SA-10,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|CM-1,800-53r5|CM-2,800-53r5|CM-6,800-53r5|CM-7,800-53r5|CM-7(1),800-53r5|CM-9,800-53r5|MP-2,800-53r5|SA-3,800-53r5|SA-8,800-53r5|SA-10,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv8|3.3,CSCv8|4.1,CSF|DE.AE-1,CSF|ID.GV-1,CSF|ID.GV-3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.DS-7,CSF|PR.IP-1,CSF|PR.IP-2,CSF|PR.IP-3,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,GDPR|32.4,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|CM-1,ITSG-33|CM-2,ITSG-33|CM-6,ITSG-33|CM-7,ITSG-33|CM-7(1),ITSG-33|CM-9,ITSG-33|MP-2,ITSG-33|MP-2a.,ITSG-33|SA-3,ITSG-33|SA-8,ITSG-33|SA-8a.,ITSG-33|SA-10,LEVEL|1A,NESA|M1.2.2,NESA|T1.2.1,NESA|T1.2.2,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T3.2.5,NESA|T3.4.1,NESA|T4.2.1,NESA|T4.5.3,NESA|T4.5.4,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.2.1,NESA|T7.5.1,NESA|T7.5.2,NESA|T7.5.3,NESA|T7.6.1,NESA|T7.6.2,NESA|T7.6.3,NESA|T7.6.5,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|GS8b,NIAv2|SS3,NIAv2|SS13c,NIAv2|SS15a,NIAv2|SS15c,NIAv2|SS16,NIAv2|SS29,NIAv2|VL2,NIAv2|VL7a,NIAv2|VL7b,PCI-DSSv3.2.1|2.2.2,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|4.2,QCSC-v1|5.2.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|7.2,QCSC-v1|13.2,SWIFT-CSCv1|2.3,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "find_world_writeable_directories"
system : "Linux"
description : "6.1.13 Audit SUID executables"
info : "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 program is to enable users to perform functions (such as changing their password) that require root privileges.
Rationale:
There are valid reasons for SUID programs, but it is important to identify and review such programs to ensure they are legitimate.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Ensure that no rogue SUID programs have been introduced into the system. Review the files returned by the action in the Audit section and confirm the integrity of these binaries.
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1M,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "find_suid_sgid_files"
find_option : "suid"
severity : MEDIUM
system : "Linux"
description : "6.1.14 Audit SGID executables"
info : "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 SGID program is to enable users to perform functions (such as changing their password) that require root privileges.
Rationale:
There are valid reasons for 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 md5 checksum than what from the package. This is an indication that the binary may have been replaced.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target compliance."
solution : "Ensure that no rogue SGID programs have been introduced into the system. Review the files returned by the action in the Audit section and confirm the integrity of these binaries.
Additional Information:
NIST SP 800-53 Rev. 5:
AC-3
MP-2"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|5.1,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1M,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "find_suid_sgid_files"
find_option : "sgid"
severity : MEDIUM
system : "Linux"
type : CMD_EXEC
description : "6.2.1 Ensure accounts in /etc/passwd use shadowed passwords"
info : "Local accounts can use 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."
solution : "Run the following command to set accounts to use shadowed passwords:
# sed -e 's/^\([a-zA-Z0-9_]*\):[^:]*:/\1:x:/' -i /etc/passwd
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."
reference : "800-171|3.5.2,800-171|3.13.16,800-53|IA-5(1),800-53|SC-28,800-53|SC-28(1),800-53r5|IA-5(1),800-53r5|SC-28,800-53r5|SC-28(1),CN-L3|8.1.4.7(b),CN-L3|8.1.4.8(b),CSCv7|16.4,CSCv8|3.11,CSF|PR.AC-1,CSF|PR.DS-1,GDPR|32.1.a,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(a)(2)(iv),HIPAA|164.312(d),HIPAA|164.312(e)(2)(ii),ITSG-33|IA-5(1),ITSG-33|SC-28,ITSG-33|SC-28(1),ITSG-33|SC-28a.,LEVEL|1A,NESA|T5.2.3,PCI-DSSv3.2.1|3.4,PCI-DSSv4.0|3.3.2,PCI-DSSv4.0|3.5.1,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1,TBA-FIISB|28.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/awk -F: '($2 != \"x\" ) { print $1 \" is not set to shadowed passwords \"}' /etc/passwd | /usr/bin/awk \'{print} END {if (NR == 0) print \"none\"}\'"
expect : "none"
system : "Linux"
type : CMD_EXEC
description : "6.2.2 Ensure /etc/shadow password fields are not empty"
info : "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."
solution : "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
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."
reference : "800-171|3.5.2,800-53|IA-5(1),800-53r5|IA-5(1),CSCv7|4.4,CSCv8|5.2,CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-5(1),LEVEL|1A,NESA|T5.2.3,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|4.1"
see_also : "https://workbench.cisecurity.org/files/4230"
cmd : "/usr/bin/awk -F : \'($2 == \"\") { print $1 \" does not have a password.\"}\' /etc/shadow | /usr/bin/awk \'{print} END {if (NR == 0) print \"none\"}\'"
expect : "none"
system : "Linux"
description : "6.2.3 Ensure all groups in /etc/passwd exist in /etc/group"
info : "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."
solution : "Analyze the output of the Audit step above and perform the appropriate action to correct any discrepancies found.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1222, T1222.002
TA0003
M1027"
reference : "800-171|3.1.1,800-53|AC-2c.,800-53r5|AC-2c.,CN-L3|7.1.3.2(d),CSF|DE.CM-1,CSF|DE.CM-3,CSF|PR.AC-1,CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.1,ITSG-33|AC-2c.,LEVEL|1A,NESA|T5.2.1,NESA|T5.2.2,NIAv2|AM28,NIAv2|NS5j,NIAv2|SS14e,PCI-DSSv3.2.1|1.1.5,PCI-DSSv3.2.1|7.1.1,PCI-DSSv3.2.1|7.1.3,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|8.2.1,QCSC-v1|13.2,QCSC-v1|15.2"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "passwd_invalid_gid"
system : "Linux"
description : "6.2.4 Ensure no duplicate UIDs exist"
info : "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."
solution : "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.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1078, T1078.001, T1078.003
TA0005
M1027"
reference : "800-171|3.5.5,800-171|3.5.6,800-53|IA-4d.,800-53r5|IA-4d.,CN-L3|8.1.4.1(a),CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-4d.,LEVEL|1A,NESA|T5.5.2,NIAv2|AM14a,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|5"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "passwd_duplicate_uid"
system : "Linux"
description : "6.2.5 Ensure no duplicate GIDs exist"
info : "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."
solution : "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.
Additional Information:
You can also use the grpck command to check for other inconsistencies in the /etc/group file.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1078, T1078.001, T1078.003
TA0005
M1027"
reference : "800-171|3.5.5,800-171|3.5.6,800-53|IA-4d.,800-53r5|IA-4d.,CN-L3|8.1.4.1(a),CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-4d.,LEVEL|1A,NESA|T5.5.2,NIAv2|AM14a,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|5"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "group_duplicate_gid"
system : "Linux"
description : "6.2.6 Ensure no duplicate user names exist"
info : "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 username.
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."
solution : "Based on the results of the audit script, establish unique user names for the users. ob体育 ownerships will automatically reflect the change as long as the users have unique UIDs.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1078, T1078.001, T1078.003
TA0004
M1027"
reference : "800-171|3.5.5,800-171|3.5.6,800-53|IA-4d.,800-53r5|IA-4d.,CN-L3|8.1.4.1(a),CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-4d.,LEVEL|1A,NESA|T5.5.2,NIAv2|AM14a,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|5"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "passwd_duplicate_username"
system : "Linux"
description : "6.2.7 Ensure no duplicate group names exist"
info : "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."
solution : "Based on the results of the audit script, establish unique names for the user groups. ob体育 group ownerships will automatically reflect the change as long as the groups have unique GIDs.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1078, T1078.001, T1078.003
TA0004
M1027"
reference : "800-171|3.5.5,800-171|3.5.6,800-53|IA-4d.,800-53r5|IA-4d.,CN-L3|8.1.4.1(a),CSF|PR.AC-1,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(2)(i),HIPAA|164.312(d),ITSG-33|IA-4d.,LEVEL|1A,NESA|T5.5.2,NIAv2|AM14a,QCSC-v1|5.2.2,QCSC-v1|13.2,SWIFT-CSCv1|5"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "group_duplicate_name"
system : "Linux"
description : "Check root path variable"
name : "dot_in_root_path_variable"
system : "Linux"
description : "Check writable dirs in root path variable"
name : "writeable_dirs_in_root_path_variable"
description : "6.2.8 Ensure root PATH Integrity"
info : "The root user can execute any command on the system and could be fooled into executing programs unintentionally if the PATH is not set correctly.
Rationale:
Including the current working directory (.) or other writable directory in root's executable path makes it likely that an attacker can gain superuser access by forcing an administrator operating as root to execute a Trojan horse program."
solution : "Correct or justify any items discovered in the Audit step.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1204, T1204.002
TA0006
M1022"
reference : "800-171|3.4.7,800-53|CM-7(2),800-53r5|CM-7(2),CSF|PR.IP-1,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),ITSG-33|CM-7(2),LEVEL|1A,NIAv2|SS15a,PCI-DSSv3.2.1|2.2.2,QCSC-v1|3.2,SWIFT-CSCv1|2.3"
see_also : "https://workbench.cisecurity.org/files/4230"
show_output : YES
system : "Linux"
description : "6.2.9 Ensure root is the only UID 0 account"
info : "Any account with UID 0 has superuser privileges on the system.
Rationale:
This access must be limited to only the default root account and only from the system console. Administrative access must be through an unprivileged account using an approved mechanism as noted in Item 5.6 Ensure access to the su command is restricted."
solution : "Remove any users other than root with UID 0 or assign them a new UID if appropriate.
MITRE ATT&CK Mappings:
Techniques / Sub-techniques
Tactics
Mitigations
T1548, T1548.000
TA0001
M1026"
reference : "800-171|3.1.5,800-53|AC-6(5),800-53r5|AC-6(5),CN-L3|8.1.10.6(a),CSF|PR.AC-4,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.9.2.3,ITSG-33|AC-6(5),LEVEL|1A,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.6.1,NIAv2|AM32,NIAv2|AM33,NIAv2|VL3a,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|5.2.2,QCSC-v1|6.2,SWIFT-CSCv1|1.2,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "passwd_zero_uid"
system : "Linux"
description : "6.2.10 Ensure local interactive user home directories exist"
info : "Users can be defined in /etc/passwd without a home directory or with a home directory that does not actually exist.
Rationale:
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."
solution : "If any users' home directories do not exist, create them and make sure the respective user owns the directory. Users without an assigned home directory should be removed or assigned a home directory as appropriate.
The following script will create a home directory for users with an interactive shell whose home directory doesn't exist:
#!/usr/bin/env bash
{
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | while read -r user home; do
if [ ! -d '$home' ]; then
echo -e '\n- User \'$user\' home directory \'$home\' doesn't exist\n- creating home directory \'$home\'\n'
mkdir '$home'
chmod g-w,o-wrx '$home'
chown '$user' '$home'
fi
done
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "active_accounts_without_home_dir"
system : "Linux"
description : "6.2.11 Ensure local interactive users own their home directories"
info : "The user home directory is space defined for the particular user to set local environment variables and to store personal files.
Rationale:
Since the user is accountable for files stored in the user home directory, the user must be the owner of the directory."
solution : "Change the ownership of any home directories that are not owned by the defined user to the correct user.
The following script will update local interactive user home directories to be owned by the user:
#!/usr/bin/env bash
{
output=''
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | while read -r user home; do
owner='$(stat -L -c '%U' '$home')'
if [ '$owner' != '$user' ]; then
echo -e '\n- User \'$user\' home directory \'$home\' is owned by user \'$owner\'\n - changing ownership to \'$user\'\n'
chown '$user' '$home'
fi
done
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "accounts_bad_home_permissions"
mask : "0000"
use_valid_shells : YES
system : "Linux"
description : "6.2.12 Ensure local interactive user home directories are mode 750 or more restrictive"
info : "While the system administrator can establish secure permissions for users' home directories, the users can easily override these.
Rationale:
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."
solution : "Making global modifications to user home directories without alerting the user community can result in unexpected outages and unhappy users. Therefore, it is recommended that a monitoring policy be established to report user file permissions and determine the action to be taken in accordance with site policy.
The following script can be used to remove permissions is excess of 750 from interactive user home directories:
#!/usr/bin/env bash
{
perm_mask='0027'
maxperm='$( printf '%o' $(( 0777 & ~$perm_mask)) )'
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | (while read -r user home; do
mode=$( stat -L -c '%#a' '$home' )
if [ $(( $mode & $perm_mask )) -gt 0 ]; then
echo -e '- modifying User $user home directory: \'$home\'\n- removing excessive permissions from current mode of \'$mode\''
chmod g-w,o-rwx '$home'
fi
done
)
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
name : "accounts_bad_home_permissions"
mask : "0027"
use_valid_shells : YES
system : "Linux"
type : FILE_CHECK_NOT
description : "6.2.13 Ensure no local interactive user has .netrc files"
info : "The .netrc file contains data for logging into a remote host for file transfers via FTP.
While the system administrator can establish secure permissions for users' .netrc files, the users can easily override these.
Rationale:
The .netrc file presents a significant security risk since it stores passwords in unencrypted form. Even if FTP is disabled, user accounts may have brought over .netrc files from other systems which could pose a risk to those systems.
If a .netrc file is required, and follows local site policy, it should have permissions of 600 or more restrictive."
solution : "Making global modifications to users' files without alerting the user community can result in unexpected outages and unhappy users. Therefore, it is recommended that a monitoring policy be established to report user .netrc file permissions and determine the action to be taken in accordance with local site policy.
The following script will remove .netrc files from interactive users' home directories
#!/usr/bin/env bash
{
perm_mask='0177'
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | while read -r user home; do
if [ -f '$home/.netrc' ]; then
echo -e '\n- User \'$user\' file: \'$home/.netrc\' exists\n - removing file: \'$home/.netrc\'\n'
rm -f '$home/.netrc'
fi
done
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "~/.netrc"
system : "Linux"
type : FILE_CHECK_NOT
description : "6.2.14 Ensure no local interactive user has .forward files"
info : "The .forward file specifies an email address to forward the user's mail to.
Rationale:
Use of the .forward file poses a security risk in that sensitive data may be inadvertently transferred outside the organization. The .forward file also poses a risk as it can be used to execute commands that may perform unintended actions."
solution : "Making global modifications to users' files without alerting the user community can result in unexpected outages and unhappy users. Therefore, it is recommended that a monitoring policy be established to report user .forward files and determine the action to be taken in accordance with site policy.
The following script will remove .forward files from interactive users' home directories
#!/usr/bin/env bash
{
output=''
fname='.forward'
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | (while read -r user home; do
if [ -f '$home/$fname' ]; then
echo -e '$output\n- User \'$user\' file: \'$home/$fname\' exists\n - removing file: \'$home/$fname\'\n'
rm -r '$home/$fname'
fi
done
)
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "~/.forward"
system : "Linux"
type : FILE_CHECK_NOT
description : "6.2.15 Ensure no local interactive user has .rhosts files"
info : "While no .rhosts files are shipped by default, users can easily create them.
Rationale:
This action is only meaningful if .rhosts support is permitted in the file /etc/pam.conf . Even though the .rhosts files are ineffective if support is disabled in /etc/pam.conf, they may have been brought over from other systems and could contain information useful to an attacker for those other systems."
solution : "Making global modifications to users' files without alerting the user community can result in unexpected outages and unhappy users. Therefore, it is recommended that a monitoring policy be established to report user .rhosts files and determine the action to be taken in accordance with site policy.
The following script will remove .rhosts files from interactive users' home directories
#!/usr/bin/env bash
{
perm_mask='0177'
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | while read -r user home; do
if [ -f '$home/.rhosts' ]; then
echo -e '\n- User \'$user\' file: \'$home/.rhosts\' exists\n - removing file: \'$home/.rhosts\'\n'
rm -f '$home/.rhosts'
fi
done
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "~/.rhosts"
system : "Linux"
type : FILE_CHECK
description : "6.2.16 Ensure local interactive user dot files are not group or world writable"
info : "While the system administrator can establish secure permissions for users' 'dot' files, the users can easily override these.
Rationale:
Group or world-writable user configuration files may enable malicious users to steal or modify other users' data or to gain another user's system privileges."
solution : "Making global modifications to users' files without alerting the user community can result in unexpected outages and unhappy users. Therefore, it is recommended that a monitoring policy be established to report user dot file permissions and determine the action to be taken in accordance with site policy.
The following script will remove excessive permissions on dot files within interactive users' home directories.
#!/usr/bin/env bash
{
perm_mask='0022'
valid_shells='^($( sed -rn '/^\//{s,/,\\\\/,g;p}' /etc/shells | paste -s -d '|' - ))$'
awk -v pat='$valid_shells' -F: '$(NF) ~ pat { print $1 ' ' $(NF-1) }' /etc/passwd | while read -r user home; do
find '$home' -type f -name '.*' | while read -r dfile; do
mode=$( stat -L -c '%#a' '$dfile' )
if [ $(( $mode & $perm_mask )) -gt 0 ]; then
echo -e '\n- Modifying User \'$user\' file: \'$dfile\'\n- removing group and other write permissions'
chmod go-w '$dfile'
fi
done
done
}"
reference : "800-171|3.1.1,800-171|3.1.4,800-171|3.1.5,800-171|3.8.1,800-171|3.8.2,800-171|3.8.3,800-53|AC-3,800-53|AC-5,800-53|AC-6,800-53|MP-2,800-53r5|AC-3,800-53r5|AC-5,800-53r5|AC-6,800-53r5|MP-2,CN-L3|7.1.3.2(b),CN-L3|7.1.3.2(g),CN-L3|8.1.4.2(d),CN-L3|8.1.4.2(f),CN-L3|8.1.4.11(b),CN-L3|8.1.10.2(c),CN-L3|8.1.10.6(a),CN-L3|8.5.3.1,CN-L3|8.5.4.1(a),CSCv7|14.6,CSCv8|3.3,CSF|PR.AC-4,CSF|PR.DS-5,CSF|PR.PT-2,CSF|PR.PT-3,GDPR|32.1.b,HIPAA|164.306(a)(1),HIPAA|164.312(a)(1),ISO/IEC-27001|A.6.1.2,ISO/IEC-27001|A.9.4.1,ISO/IEC-27001|A.9.4.5,ITSG-33|AC-3,ITSG-33|AC-5,ITSG-33|AC-6,ITSG-33|MP-2,ITSG-33|MP-2a.,LEVEL|1A,NESA|T1.3.2,NESA|T1.3.3,NESA|T1.4.1,NESA|T4.2.1,NESA|T5.1.1,NESA|T5.2.2,NESA|T5.4.1,NESA|T5.4.4,NESA|T5.4.5,NESA|T5.5.4,NESA|T5.6.1,NESA|T7.5.2,NESA|T7.5.3,NIAv2|AM1,NIAv2|AM3,NIAv2|AM23f,NIAv2|SS13c,NIAv2|SS15c,NIAv2|SS29,PCI-DSSv3.2.1|7.1.2,PCI-DSSv4.0|7.2.1,PCI-DSSv4.0|7.2.2,QCSC-v1|3.2,QCSC-v1|5.2.2,QCSC-v1|6.2,QCSC-v1|13.2,SWIFT-CSCv1|5.1,TBA-FIISB|31.1,TBA-FIISB|31.4.2,TBA-FIISB|31.4.3"
see_also : "https://workbench.cisecurity.org/files/4230"
file : "~/.[!.]*"
mask : "022"
description : "CIS_Rocky_Linux_9_v1.0.0_L1_Server.audit from CIS Rocky Linux 9 Benchmark v1.0.0"
info : "NOTE: Nessus has not identified that the chosen audit applies to the target device."
see_also : "https://workbench.cisecurity.org/files/4230"