Skip to content

Instantly share code, notes, and snippets.

@AfroThundr3007730
Created April 11, 2024 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AfroThundr3007730/a65a171eb0e53ebd31ee34d6f7d08748 to your computer and use it in GitHub Desktop.
Save AfroThundr3007730/a65a171eb0e53ebd31ee34d6f7d08748 to your computer and use it in GitHub Desktop.
Notes on getting Rocky 9 compliant with DISA STIGs

Rocky 9 STIG notes

RHEL-09-211045: Red Hat Enterprise Linux 9 Security Technical Implementation Guide :: Version 1, Release: 2 Benchmark Date: 24 Jan 2024

Updated on 2024-04-05

Utilities

All fix and check commands must be run as root.

The fix snippets listed later make use of the following helper functions:

# paste this block in before running the later fix commands

utils.add_if_missing() {
    [[ $# -eq 2 ]] || return
    [[ $1 != "${1%/*}" && ! -d ${1%/*} ]] && mkdir -p "${1%/*}"
    grep -qsF -- "$2" "$1" || printf '%s\n' "$2" >>"$1"
}

utils.set_sysctl_option() {
    [[ $# -eq 2 ]] || return
    [[ $(sysctl -n "$1") == "$2" ]] ||
        utils.add_if_missing /etc/sysctl.d/99-sysctl.conf "$1 = $2"
}

utils.set_ssh_option() {
    [[ $# -eq 1 ]] || return
    grep -qrsE -- "^$1" /etc/ssh/sshd_config /etc/ssh/sshd_config.d/* ||
        utils.add_if_missing /etc/ssh/sshd_config.d/99-stig.conf "$1"
}

utils.blacklist_kernel_module() {
    [[ $# -eq 1 ]] || return
    utils.add_if_missing "/etc/modprobe.d/$1.conf" \
        "$(printf 'install %s /bin/false\nblacklist %s' "$1" "$1")"
}

utils.add_audit_rule() {
    [[ $# -eq 1 ]] || return
    grep -qrs -- "$1" /etc/audit/audit.rules /etc/audit/rules.d/* ||
        utils.add_if_missing /etc/audit/rules.d/stig.rules "$1"
}

utils.add_kernel_cmdline() {
    [[ $# -eq 1 ]] || return
    awk -i inplace -v p="$1" '
        /CMDLINE/ && $0 !~ p {gsub(/(["'\''])$/, " "p"&")} 1
    ' /etc/default/grub
    grubby --update-kernel=ALL --args="$1"
}

utils.ensure_package_installed() {
    [[ $# -eq 1 ]] || return
    rpm --quiet -q $1 || dnf -qy install $1
}

utils.ensure_package_removed() {
    [[ $# -eq 1 ]] || return
    rpm --quiet -q $1 && dnf -qy remove $1
}

utils.get_config_option() {
    [[ $# -ge 2 ]] || return
    local c='#' a d i=0 r1 r2
    while [[ $# -gt 2 ]]; do
        [[ $1 == -d ]] && d=$2 && shift 2
        [[ $1 == -i ]] && i=1 && shift
    done
    [[ $# -eq 2 ]] || return
    [[ $i -eq 1 ]] && a=$c c=''
    r1="^[ \t]*(|${c:-}+.*)$"
    r2="^[ \t${a:-}]*${2}[ \t]*${d:-[ \t]+}[ \t]*([^${c:-$a}]*).*$"
    awk -v r1="$r1" -v r2="$r2" '$0 !~ r1 && $0 ~ r2 {match($0, r2, m);
        gsub(/^[ \t]*|[ \t]*$/, "", m[1]); print m[1]; exit}' "$1"
}

utils.set_config_option() {
    [[ $# -ge 3 ]] || return
    local a c='#' a d i o r1 r2
    while [[ $# -gt 3 ]]; do
        [[ $1 == -a ]] && a=1 && shift
        [[ $1 == -d ]] && d=$2 && shift 2
        [[ $1 == -i ]] && i='-i' && shift
    done
    [[ $# -eq 3 ]] || return
    [[ -f $1 ]] && o=$(utils.get_config_option -d "$d" ${i:-} "$1" "$2")
    [[ ${a:-} || ! ${o:-} ]] &&
        utils.add_if_missing "$1" "${2}${d:- }${3}" && return
    [[ ${i:-} ]] && a=$c c=''
    r1="^[ \t]*(|${c:-}+.*)$"
    r2="^([ \t${a:-}]*)(${2}[ \t]*${d:-[ \t]+}[ \t]*)([^${c:-$a}]*)(.*)$"
    awk -i inplace -v r1="$r1" -v r2="$r2" -v new="$3" '
        $0 !~ r1 && $0 ~ r2 && c == 0 {
            match($0, r2, m); gsub($0, m[2] new m[4]); c = 1
        } 1' "$1"
}

CAT I Checks

V-257777

RHEL 9 must be a vendor-supported release.

. /etc/os-release && echo $NAME $VERSION  # RHEL 9.x

V-257784

The systemd Ctrl-Alt-Delete burst key sequence in RHEL 9 must be disabled.

utils.add_if_missing /etc/systemd/system.conf.d/stig.conf 'CtrlAltDelBurstAction=none'

V-257785

The x86 Ctrl-Alt-Delete key sequence must be disabled on RHEL 9.

systemctl mask --now ctrl-alt-del.target

V-257789

RHEL 9 must require a unique superusers name upon booting into single-user and maintenance modes.

# superuser name is root

V-257820

RHEL 9 must check the GPG signature of software packages originating from external software repositories before installation.

utils.set_config_option -d = /etc/dnf/dnf.conf gpgcheck 1

V-257821

RHEL 9 must check the GPG signature of locally installed software packages before installation.

utils.set_config_option -d = /etc/dnf/dnf.conf localpkg_gpgcheck 1

V-257822

RHEL 9 must have GPG signature verification enabled for all software repositories.

sed -i 's/gpgcheck\s*=.*/gpgcheck=1/g' /etc/yum.repos.d/*

V-257826

RHEL 9 must not have a File Transfer Protocol (FTP) server package installed.

# not installed in baseline
utils.ensure_package_removed vsftpd

V-257835

RHEL 9 must not have a Trivial File Transfer Protocol (TFTP) server package installed.

# not installed in baseline
utils.ensure_package_removed tftp

V-257879

RHEL 9 local disk partitions must implement cryptographic mechanisms to prevent unauthorized disclosure or modification of all information that requires at rest protection.

# Not applicable to VMs

V-257955

There must be no shosts.equiv files on RHEL 9.

find / -name shosts.equiv -delete

V-257956

There must be no .shosts files on RHEL 9.

find / -name .shosts -delete

V-257984

RHEL 9 SSHD must not allow blank passwords.

utils.set_ssh_option 'PermitEmptyPasswords no'

V-257986

RHEL 9 must enable the Pluggable Authentication Module (PAM) interface for SSHD.

utils.set_ssh_option 'UsePAM yes'

V-258018

RHEL 9 must not allow unattended or automatic logon via the graphical user interface.

# no graphical interface installed

V-258059

The root account must be the only account having unrestricted access to RHEL 9 system.

awk -F: '$3 == 0 {print $1}' /etc/passwd  # only root

V-258078

RHEL 9 must use a Linux Security Module configured to enforce limits on system services.

sed -i 's/SELINUX\s*=.*/SELINUX=enforcing/g' /etc/selinux/config

V-258094

RHEL 9 must not allow blank or null passwords.

# managed by authselect
# TODO: add authselect command to validate

V-258230

RHEL 9 must enable FIPS mode.

fips-mode-setup --enable

V-258235

RHEL 9 crypto policy files must match files shipped with the operating system.

rpm -V crypto-policies  # no output

V-258238

RHEL 9 must implement DOD-approved TLS encryption in the GnuTLS package.

update-crypto-policies --show  # FIPS

CAT II Checks

V-257778

RHEL 9 vendor packaged system security patches and updates must be installed and up to date.

# install updates
dnf -y update

V-257779

RHEL 9 must display the Standard Mandatory DOD Notice and Consent Banner before granting local or remote access to the system via a command line user logon.

cat <<'EOF' >/etc/issue
US Department of Defense Warning Statement

You are accessing a U.S. Government (USG) Information System (IS) that is
provided for USG-authorized use only. By using this IS (which includes any
device attached to this IS), you consent to the following conditions:

-The USG routinely intercepts and monitors communications on this IS for
purposes including, but not limited to, penetration testing, COMSEC monitoring,
network operations and defense, personnel misconduct (PM), law enforcement
(LE), and counterintelligence (CI) investigations.

-At any time, the USG may inspect and seize data stored on this IS.

-Communications using, or data stored on, this IS are not private, are subject
to routine monitoring, interception, and search, and may be disclosed or used
for any USG-authorized purpose.

-This IS includes security measures (e.g., authentication and access controls)
to protect USG interests -- not for your personal benefit or privacy.

-Notwithstanding the above, using this IS does not constitute consent to PM, LE
or CI investigative searching or monitoring of the content of privileged
communications, or work product, related to personal representation or services
by attorneys, psychotherapists, or clergy, and their assistants. Such
communications and work product are private and confidential. See User
Agreement for details.
EOF

V-257780

RHEL 9 must implement the Endpoint Security for Linux Threat Prevention tool.

# not implemented in baseline

V-257781

The graphical display manager must not be the default target on RHEL 9 unless approved.

systemctl set-default multi-user.target

V-257783

RHEL 9 systemd-journald service must be enabled.

# enabled by default
systemctl -q is-active systemd-journald || systemctl enable --now systemd-journald

V-257786

RHEL 9 debug-shell systemd service must be disabled.

# disabled by default
systemctl -q is-active debug-shell && systemctl disable --now debug-shell

V-257787

RHEL 9 must require a boot loader superuser password.

grub2-set-password
# Follow the prompts to set password

V-257788

RHEL 9 must disable the ability of systemd to spawn an interactive boot process.

# not enabled by default
grubby --info=ALL | awk '/args/ && /systemd.confirm_spawn/'

V-257790

RHEL 9 /boot/grub2/grub.cfg file must be group-owned by root.

# owned by root by default
chown root:root /boot/grub2/grub.cfg

V-257791

RHEL 9 /boot/grub2/grub.cfg file must be owned by root.

# owned by root by default
chown root:root /boot/grub2/grub.cfg

V-257792

RHEL 9 must disable virtual system calls.

utils.add_kernel_cmdline 'vsyscall=none'

V-257793

RHEL 9 must clear the page allocator to prevent use-after-free attacks.

utils.add_kernel_cmdline 'page_poison=1'

V-257794

RHEL 9 must clear SLUB/SLAB objects to prevent use-after-free attacks.

utils.add_kernel_cmdline 'slub_debug=P'

V-257797

RHEL 9 must restrict access to the kernel message buffer.

utils.set_sysctl_option kernel.dmesg_restrict 1

V-257798

RHEL 9 must prevent kernel profiling by nonprivileged users.

utils.set_sysctl_option kernel.perf_event_paranoid 2

V-257799

RHEL 9 must prevent the loading of a new kernel for later execution.

utils.set_sysctl_option kernel.kexec_load_disabled 1

V-257800

RHEL 9 must restrict exposed kernel pointer addresses access.

utils.set_sysctl_option kernel.kptr_restrict 1

V-257801

RHEL 9 must enable kernel parameters to enforce discretionary access control on hardlinks.

utils.set_sysctl_option fs.protected_hardlinks 1

V-257802

RHEL 9 must enable kernel parameters to enforce discretionary access control on symlinks.

utils.set_sysctl_option fs.protected_symlinks 1

V-257803

RHEL 9 must disable the kernel.core_pattern.

utils.set_sysctl_option kernel.core_pattern '|/bin/false'

V-257804

RHEL 9 must be configured to disable the Asynchronous Transfer Mode kernel module.

utils.blacklist_kernel_module atm

V-257805

RHEL 9 must be configured to disable the Controller Area Network kernel module.

utils.blacklist_kernel_module can

V-257806

RHEL 9 must be configured to disable the FireWire kernel module.

utils.blacklist_kernel_module firewire-core

V-257807

RHEL 9 must disable the Stream Control Transmission Protocol (SCTP) kernel module.

utils.blacklist_kernel_module sctp

V-257808

RHEL 9 must disable the Transparent Inter Process Communication (TIPC) kernel module.

utils.blacklist_kernel_module tipc

V-257809

RHEL 9 must implement address space layout randomization (ASLR) to protect its memory from unauthorized code execution.

utils.set_sysctl_option kernel.randomize_va_space 2

V-257810

RHEL 9 must disable access to network bpf system call from nonprivileged processes.

utils.set_sysctl_option kernel.unprivileged_bpf_disabled 1

V-257811

RHEL 9 must restrict usage of ptrace to descendant processes.

utils.set_sysctl_option kernel.yama.ptrace_scope 1

V-257812

RHEL 9 must disable core dump backtraces.

utils.add_if_missing /etc/systemd/coredump.conf.d/stig.conf 'ProcessSizeMax=0'

V-257813

RHEL 9 must disable storing core dumps.

utils.add_if_missing /etc/systemd/coredump.conf.d/stig.conf 'Storage=none'

V-257814

RHEL 9 must disable core dumps for all users.

utils.add_if_missing '/etc/security/limits.d/stig.conf' '* hard core 0'

V-257815

RHEL 9 must disable acquiring, saving, and processing core dumps.

systemctl mask --now systemd-coredump.socket

V-257816

RHEL 9 must disable the use of user namespaces.

# Ignore this if containers are used
utils.set_sysctl_option user.max_user_namespaces 0

V-257817

RHEL 9 must implement nonexecutable data to protect its memory from unauthorized code execution.

# enabled by default
dmesg | grep '[NX|DX]*protection'

V-257818

The kdump service on RHEL 9 must be disabled.

systemctl mask --now kdump

V-257819

RHEL 9 must ensure cryptographic verification of vendor software packages.

# Correct keys installed for Rocky Linux system
rpm -q --queryformat "%{SUMMARY}\n" gpg-pubkey

V-257823

RHEL 9 must be configured so that the cryptographic hashes of system files match vendor values.

rpm -Va --noconfig | awk '$1 ~ /..5/ && $2 != "c"'

V-257825

RHEL 9 subscription-manager package must be installed.

# not applicable to RHEL derivatives

V-257827

RHEL 9 must not have the sendmail package installed.

# not installed in baseline
utils.ensure_package_removed sendmail

V-257828

RHEL 9 must not have the nfs-utils package installed.

# not installed in baseline
utils.ensure_package_removed nfs-utils

V-257829

RHEL 9 must not have the ypserv package installed.

# not installed in baseline
utils.ensure_package_removed ypserv

V-257830

RHEL 9 must not have the rsh-server package installed.

# not installed in baseline
utils.ensure_package_removed rsh-server

V-257831

RHEL 9 must not have the telnet-server package installed.

# not installed in baseline
utils.ensure_package_removed telnet-server

V-257832

RHEL 9 must not have the gssproxy package installed.

# not installed in baseline
utils.ensure_package_removed gssproxy

V-257833

RHEL 9 must not have the iprutils package installed.

# not installed in baseline
utils.ensure_package_removed iprutils

V-257834

RHEL 9 must not have the tuned package installed.

# not installed in baseline
utils.ensure_package_removed tuned

V-257836

RHEL 9 must not have the quagga package installed.

# not installed in baseline
utils.ensure_package_removed quagga

V-257837

A graphical display manager must not be installed on RHEL 9 unless approved.

# not installed in baseline
dnf list --installed "xorg*common"

V-257838

RHEL 9 must have the openssl-pkcs11 package installed.

utils.ensure_package_installed  openssl-pkcs11

V-257839

RHEL 9 must have the gnutls-utils package installed.

utils.ensure_package_installed  gnutls-utils

V-257840

RHEL 9 must have the nss-tools package installed.

utils.ensure_package_installed  nss-tools

V-257841

RHEL 9 must have the rng-tools package installed.

utils.ensure_package_installed  rng-tools

V-257842

RHEL 9 must have the s-nail package installed.

utils.ensure_package_installed  s-nail

V-257843

A separate RHEL 9 file system must be used for user home directories (such as /home or an equivalent).

# Already implemented during install
mountpoint /home

V-257844

RHEL 9 must use a separate file system for /tmp.

# Already implemented during install
mountpoint /tmp

V-257848

RHEL 9 must use a separate file system for /var/tmp.

# Already implemented during install
mountpoint /var/tmp

V-257849

RHEL 9 file system automount function must be disabled unless required.

# not installed in baseline

V-257850

RHEL 9 must prevent device files from being interpreted on file systems that contain user home directories.

# Already implemented during install
mount | grep /home

V-257851

RHEL 9 must prevent files with the setuid and setgid bit set from being executed on file systems that contain user home directories.

# Already implemented during install
mount | grep /home

V-257852

RHEL 9 must prevent code from being executed on file systems that contain user home directories.

# Already implemented during install
mount | grep /home

V-257853

RHEL 9 must be configured so that the Network File System (NFS) is configured to use RPCSEC_GSS.

# no NFS mounts present

V-257854

RHEL 9 must prevent special devices on file systems that are imported via Network File System (NFS).

# no NFS mounts present

V-257855

RHEL 9 must prevent code from being executed on file systems that are imported via Network File System (NFS).

# no NFS mounts present

V-257856

RHEL 9 must prevent files with the setuid and setgid bit set from being executed on file systems that are imported via Network File System (NFS).

# no NFS mounts present

V-257857

RHEL 9 must prevent code from being executed on file systems that are used with removable media.

# no removable media mounts present

V-257858

RHEL 9 must prevent special devices on file systems that are used with removable media.

# no removable media mounts present

V-257859

RHEL 9 must prevent files with the setuid and setgid bit set from being executed on file systems that are used with removable media.

# no removable media mounts present

V-257860

RHEL 9 must mount /boot with the nodev option.

mount | grep /boot

V-257861

RHEL 9 must prevent files with the setuid and setgid bit set from being executed on the /boot directory.

# Already implemented during install
mount | grep /home

V-257862

RHEL 9 must prevent files with the setuid and setgid bit set from being executed on the /boot/efi directory.

# Already implemented during install
mount | grep /home

V-257863

RHEL 9 must mount /dev/shm with the nodev option.

# Implemented by default
mount | grep /dev/shm

V-257864

RHEL 9 must mount /dev/shm with the noexec option.

# Implemented by default
mount | grep /dev/shm

V-257865

RHEL 9 must mount /dev/shm with the nosuid option.

# Implemented by default
mount | grep /dev/shm

V-257866

RHEL 9 must mount /tmp with the nodev option.

# Already implemented during install
mount | grep /tmp

V-257867

RHEL 9 must mount /tmp with the noexec option.

# Already implemented during install
mount | grep /tmp

V-257868

RHEL 9 must mount /tmp with the nosuid option.

# Already implemented during install
mount | grep /tmp

V-257869

RHEL 9 must mount /var with the nodev option.

# Already implemented during install
mount | grep /var

V-257870

RHEL 9 must mount /var/log with the nodev option.

# Already implemented during install
mount | grep /var/log

V-257871

RHEL 9 must mount /var/log with the noexec option.

# Already implemented during install
mount | grep /var/log

V-257872

RHEL 9 must mount /var/log with the nosuid option.

# Already implemented during install
mount | grep /var/log

V-257873

RHEL 9 must mount /var/log/audit with the nodev option.

# Already implemented during install
mount | grep /var/log/audit

V-257874

RHEL 9 must mount /var/log/audit with the noexec option.

# Already implemented during install
mount | grep /var/log/audit

V-257875

RHEL 9 must mount /var/log/audit with the nosuid option.

# Already implemented during install
mount | grep /var/log/audit

V-257876

RHEL 9 must mount /var/tmp with the nodev option.

# Already implemented during install
mount | grep /var/tmp

V-257877

RHEL 9 must mount /var/tmp with the noexec option.

# Already implemented during install
mount | grep /var/tmp

V-257878

RHEL 9 must mount /var/tmp with the nosuid option.

# Already implemented during install
mount | grep /var/tmp

V-257881

RHEL 9 must prevent special devices on non-root local partitions.

# Already implemented during install
mount | awk '$1 ~ /\/dev/ && $6 !~ /nodev/'

V-257882

RHEL 9 system commands must have mode 755 or less permissive.

# permissions correct by default
find -L /usr{/local,}/{s,}bin /usr/libexec -perm /022 -exec ls -l {} \;

V-257883

RHEL 9 library directories must have mode 755 or less permissive.

# permissions correct by default
find -L /usr/lib{64,} -perm /022 -type d -exec ls -l {} \;

V-257884

RHEL 9 library files must have mode 755 or less permissive.

# permissions correct by default
find -L /usr/lib{64,} -perm /022 -type f -exec ls -l {} \;

V-257885

RHEL 9 /var/log directory must have mode 0755 or less permissive.

# permissions correct by default
ls -ld /var/log

V-257886

RHEL 9 /var/log/messages file must have mode 0640 or less permissive.

# permissions correct by default
ls -la /var/log/messages

V-257887

RHEL 9 audit tools must have a mode of 0755 or less permissive.

# permissions correct by default
ls -la /sbin/{auditctl,aureport,ausearch,autrace,auditd,rsyslogd,augenrules}

V-257888

RHEL 9 cron configuration directories must have a mode of 0700 or less permissive.

find /etc/cron* -type d -exec chmod 0700 {} \;

V-257889

All RHEL 9 local initialization files must have mode 0740 or less permissive.

awk -F: '$3 >= 1000 && $7 !~ /nologin/ {print $6}' /etc/passwd |
    xargs -I_ find _ -maxdepth 1 -exec chmod g-w,o-rwx "{}" \;

V-257890

All RHEL 9 local interactive user home directories must have mode 0750 or less permissive.

awk -F: '$3 >= 1000 && $7 !~ /nologin/ {print $6}' /etc/passwd |
    xargs -l chmod 0750

V-257891

RHEL 9 /etc/group file must have mode 0644 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257892

RHEL 9 /etc/group- file must have mode 0644 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257893

RHEL 9 /etc/gshadow file must have mode 0000 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257894

RHEL 9 /etc/gshadow- file must have mode 0000 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257895

RHEL 9 /etc/passwd file must have mode 0644 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257896

RHEL 9 /etc/passwd- file must have mode 0644 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257897

RHEL 9 /etc/shadow- file must have mode 0000 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257898

RHEL 9 /etc/group file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257899

RHEL 9 /etc/group file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257900

RHEL 9 /etc/group- file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257901

RHEL 9 /etc/group- file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257902

RHEL 9 /etc/gshadow file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257903

RHEL 9 /etc/gshadow file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257904

RHEL 9 /etc/gshadow- file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257905

RHEL 9 /etc/gshadow- file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257906

RHEL 9 /etc/passwd file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257907

RHEL 9 /etc/passwd file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257908

RHEL 9 /etc/passwd- file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257909

RHEL 9 /etc/passwd- file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257910

RHEL 9 /etc/shadow file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257911

RHEL 9 /etc/shadow file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257912

RHEL 9 /etc/shadow- file must be owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257913

RHEL 9 /etc/shadow- file must be group-owned by root.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257914

RHEL 9 /var/log directory must be owned by root.

# permissions correct by default
ls -ld /var/log

V-257915

RHEL 9 /var/log directory must be group-owned by root.

# permissions correct by default
ls -ld /var/log

V-257916

RHEL 9 /var/log/messages file must be owned by root.

# permissions correct by default
ls -ld /var/log/messages

V-257917

RHEL 9 /var/log/messages file must be group-owned by root.

# permissions correct by default
ls -ld /var/messages

V-257918

RHEL 9 system commands must be owned by root.

# permissions correct by default
find -L /usr{/local,}/{s,}bin /usr/libexec ! -user root -exec ls -l {} \;

V-257919

RHEL 9 system commands must be group-owned by root or a system account.

# permissions correct by default
find -L /usr{/local,}/{s,}bin /usr/libexec ! -group root -exec ls -l {} \;

V-257920

RHEL 9 library files must be owned by root.

# permissions correct by default
find -L /usr/lib{64,} ! -user root -type f -exec ls -l {} \;

V-257921

RHEL 9 library files must be group-owned by root or a system account.

# permissions correct by default
find -L /usr/lib{64,} ! -group root -type f -exec ls -l {} \;

V-257922

RHEL 9 library directories must be owned by root.

# permissions correct by default
find -L /usr/lib{64,} ! -user root -type d -exec ls -l {} \;

V-257923

RHEL 9 library directories must be group-owned by root or a system account.

# permissions correct by default
find -L /usr/lib{64,} ! -group root -type d -exec ls -l {} \;

V-257924

RHEL 9 audit tools must be owned by root.

# permissions correct by default
ls -la /sbin/{auditctl,aureport,ausearch,autrace,auditd,rsyslogd,augenrules}

V-257925

RHEL 9 audit tools must be group-owned by root.

# permissions correct by default
ls -la /sbin/{auditctl,aureport,ausearch,autrace,auditd,rsyslogd,augenrules}

V-257926

RHEL 9 cron configuration files directory must be owned by root.

# permissions correct by default
ls -ld /etc/cron*

V-257927

RHEL 9 cron configuration files directory must be group-owned by root.

# permissions correct by default
ls -ld /etc/cron*

V-257928

All RHEL 9 world-writable directories must be owned by root, sys, bin, or an application user.

# permissions correct by default
df --local -P | awk '{if (NR!=1) print $6}' |
    xargs -I_ find _ -xdev -type d -perm -0002 -uid +0 -print

V-257929

A sticky bit must be set on all RHEL 9 public directories.

# permissions correct by default
find / -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null

V-257930

All RHEL 9 local files and directories must have a valid group owner.

# All ownership valid in the baseline
df --local -P | awk '{if (NR!=1) print $6}' | xargs -I_ find _ -xdev -nogroup

V-257931

All RHEL 9 local files and directories must have a valid owner.

# All ownership valid in the baseline
df --local -P | awk '{if (NR!=1) print $6}' | xargs -I_ find _ -xdev -nouser

V-257932

RHEL 9 must be configured so that all system device files are correctly labeled to prevent unauthorized modification.

# labels correct by default
find /dev -context *:device_t:* \( -type c -o -type b \) -printf "%p %Z\n"
find /dev -context *:unlabeled_t:* \( -type c -o -type b \) -printf "%p %Z\n"

V-257933

RHEL 9 /etc/crontab file must have mode 0600.

chmod 0600 /etc/crontab

V-257934

RHEL 9 /etc/shadow file must have mode 0000 to prevent unauthorized access.

# permissions correct by default
ls -alh /etc/{passwd,{g,}shadow,group}*

V-257935

RHEL 9 must have the firewalld package installed.

# installed by default
utils.ensure_package_installed firewalld

V-257936

The firewalld service on RHEL 9 must be active.

# enabled by default
systemctl -q is-active firewalld || systemctl enable --now firewalld

V-257937

A RHEL 9 firewall must employ a deny-all, allow-by-exception policy for allowing connections to other systems.

# Correct zone for servers is work zone
firewall-cmd --list-all

V-257938

RHEL 9 must control remote access methods.

# Baseline configuration is secure
firewall-cmd --list-all

V-257939

RHEL 9 must protect against or limit the effects of denial-of-service (DoS) attacks by ensuring rate-limiting measures on impacted network interfaces are implemented.

utils.set_config_option -i -d = /etc/firewalld/firewalld.conf FirewallBackend nftables

V-257940

RHEL 9 must be configured to prohibit or restrict the use of functions, ports, protocols, and/or services, as defined in the Ports, Protocols, and Services Management (PPSM) Category Assignments List (CAL) and vulnerability assessments.

# only necessary services enabled by default
firewall-cmd --list-all

V-257941

RHEL 9 network interfaces must not be in promiscuous mode.

# correctly configured by default
ip link | grep -i promisc

V-257942

RHEL 9 must enable hardening for the Berkeley Packet Filter just-in-time compiler.

utils.set_sysctl_option net.core.bpf_jit_harden 2

V-257943

RHEL 9 must have the chrony package installed.

# installed by default
utils.ensure_package_installed  chrony

V-257944

RHEL 9 chronyd service must be enabled.

# enabled by default
systemctl -q is-active chronyd || systemctl enable --now chronyd

V-257945

RHEL 9 must securely compare internal information system clocks at least every 24 hours.

# Point to domain controllers
sed -i '/^server/d' /etc/chrony.conf
utils.add_if_missing /etc/chrony.conf 'server time.home.cpt.local iburst maxpoll 16'
utils.add_if_missing /etc/chrony.conf 'server time.kitX.cpt.local iburst maxpoll 16'

V-257948

RHEL 9 systems using Domain Name Servers (DNS) resolution must have at least two name servers configured.

# nameservers set via DHCP
grep nameserver /etc/resolv.conf

V-257949

RHEL 9 must configure a DNS processing mode set be Network Manager.

utils.add_if_missing /etc/NetworkManager/conf.d/dns.conf $'[main]\ndns=none'

V-257950

RHEL 9 must not have unauthorized IP tunnels configured.

# IPsec tunnels not configured

V-257951

RHEL 9 must be configured to prevent unrestricted mail relaying.

# Postfix is not installed

V-257952

If the Trivial File Transfer Protocol (TFTP) server is required, RHEL 9 TFTP daemon must be configured to operate in secure mode.

# no tftp server installed
utils.ensure_package_removed tftp-server

V-257953

RHEL 9 must forward mail from postmaster to the root account using a postfix alias.

# correctly configured by default
grep "postmaster:\s*root$" /etc/aliases

V-257954

RHEL 9 libreswan package must be installed.

utils.ensure_package_installed libreswan

V-257957

RHEL 9 must be configured to use TCP syncookies.

utils.set_sysctl_option net.ipv4.tcp_syncookies 1

V-257958

RHEL 9 must ignore Internet Protocol version 4 (IPv4) Internet Control Message Protocol (ICMP) redirect messages.

utils.set_sysctl_option net.ipv4.conf.all.accept_redirects 0

V-257959

RHEL 9 must not forward Internet Protocol version 4 (IPv4) source-routed packets.

utils.set_sysctl_option net.ipv4.conf.all.accept_source_route 0

V-257960

RHEL 9 must log IPv4 packets with impossible addresses.

utils.set_sysctl_option net.ipv4.conf.all.log_martians 1

V-257961

RHEL 9 must log IPv4 packets with impossible addresses by default.

utils.set_sysctl_option net.ipv4.conf.default.log_martians 1

V-257962

RHEL 9 must use reverse path filtering on all IPv4 interfaces.

utils.set_sysctl_option net.ipv4.conf.all.rp_filter 1

V-257963

RHEL 9 must prevent IPv4 Internet Control Message Protocol (ICMP) redirect messages from being accepted.

utils.set_sysctl_option net.ipv4.conf.default.accept_redirects 0

V-257964

RHEL 9 must not forward IPv4 source-routed packets by default.

utils.set_sysctl_option net.ipv4.conf.default.accept_source_route 0

V-257965

RHEL 9 must use a reverse-path filter for IPv4 network traffic when possible by default.

utils.set_sysctl_option net.ipv4.conf.default.rp_filter 1

V-257966

RHEL 9 must not respond to Internet Control Message Protocol (ICMP) echoes sent to a broadcast address.

utils.set_sysctl_option net.ipv4.icmp_echo_ignore_broadcasts 1

V-257967

RHEL 9 must limit the number of bogus Internet Control Message Protocol (ICMP) response errors logs.

utils.set_sysctl_option net.ipv4.icmp_ignore_bogus_error_response 1

V-257968

RHEL 9 must not send Internet Control Message Protocol (ICMP) redirects.

utils.set_sysctl_option net.ipv4.conf.all.send_redirects 0

V-257969

RHEL 9 must not allow interfaces to perform Internet Control Message Protocol (ICMP) redirects by default.

utils.set_sysctl_option net.ipv4.conf.default.send_redirects 0

V-257970

RHEL 9 must not enable IPv4 packet forwarding unless the system is a router.

utils.set_sysctl_option net.ipv4.conf.all.forwarding 0

V-257971

RHEL 9 must not accept router advertisements on all IPv6 interfaces.

utils.set_sysctl_option net.ipv6.conf.all.accept_ra 0

V-257972

RHEL 9 must ignore IPv6 Internet Control Message Protocol (ICMP) redirect messages.

utils.set_sysctl_option net.ipv6.conf.all.accept_redirects 0

V-257973

RHEL 9 must not forward IPv6 source-routed packets.

utils.set_sysctl_option net.ipv6.conf.all.accept_source_route 0

V-257974

RHEL 9 must not enable IPv6 packet forwarding unless the system is a router.

utils.set_sysctl_option net.ipv6.conf.all.forwarding 0

V-257975

RHEL 9 must not accept router advertisements on all IPv6 interfaces by default.

utils.set_sysctl_option net.ipv6.conf.default.accept_ra 0

V-257976

RHEL 9 must prevent IPv6 Internet Control Message Protocol (ICMP) redirect messages from being accepted.

utils.set_sysctl_option net.ipv6.conf.default.accept_redirects 0

V-257977

RHEL 9 must not forward IPv6 source-routed packets by default.

utils.set_sysctl_option net.ipv6.conf.default.accept_source_route 0

V-257978

All RHEL 9 networked systems must have SSH installed.

# installed by default
utils.ensure_package_installed openssh-server

V-257979

All RHEL 9 networked systems must have and implement SSH to protect the confidentiality and integrity of transmitted and received information, as well as information during preparation for transmission.

# enabled by default
systemctl -q is-active sshd || systemctl enable --now sshd

V-257980

RHEL 9 must have the openssh-clients package installed.

# installed by default
utils.ensure_package_installed openssh-clients

V-257981

RHEL 9 must display the Standard Mandatory DOD Notice and Consent Banner before granting local or remote access to the system via a SSH logon.

utils.set_ssh_option 'banner /etc/issue'

V-257982

RHEL 9 must log SSH connection attempts and failures to the server.

utils.set_ssh_option 'LogLevel VERBOSE'

V-257983

RHEL 9 SSHD must accept public key authentication.

utils.set_ssh_option 'PubkeyAuthentication yes'

V-257985

RHEL 9 must not permit direct logons to the root account using remote access via SSH.

utils.set_ssh_option 'PermitRootLogin no'

V-257987

RHEL 9 SSH daemon must be configured to use system-wide crypto policies.

# configured by default
grep Include /etc/ssh/sshd_config  /etc/ssh/sshd_config.d/*

V-257988

RHEL 9 must implement DOD-approved encryption ciphers to protect the confidentiality of SSH client connections.

# configured by default
grep Include /etc/ssh/sshd_config  /etc/ssh/sshd_config.d/*

V-257989

RHEL 9 must implement DOD-approved encryption ciphers to protect the confidentiality of SSH server connections.

# configured by default
grep Ciphers /etc/crypto-policies/back-ends/openssh.config

V-257990

RHEL 9 SSH client must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-3 validated cryptographic hash algorithms.

# configured by default
grep MACs /etc/crypto-policies/back-ends/openssh.config

V-257991

RHEL 9 SSH server must be configured to use only Message Authentication Codes (MACs) employing FIPS 140-3 validated cryptographic hash algorithms.

# configured by default
grep MACs /etc/crypto-policies/back-ends/openssh.config

V-257992

RHEL 9 must not allow a noncertificate trusted host SSH logon to the system.

utils.set_ssh_option 'HostbasedAuthentication no'

V-257993

RHEL 9 must not allow users to override SSH environment variables.

utils.set_ssh_option 'PermitUserEnvironment no'

V-257994

RHEL 9 must force a frequent session key renegotiation for SSH connections to the server.

utils.set_ssh_option 'RekeyLimit 1G 1h'

V-257995

RHEL 9 must be configured so that all network connections associated with SSH traffic terminate after becoming unresponsive.

utils.set_ssh_option 'ClientAliveCountMax 1'

V-257996

RHEL 9 must be configured so that all network connections associated with SSH traffic are terminated after 10 minutes of becoming unresponsive.

utils.set_ssh_option 'ClientAliveInterval 600'

V-257997

RHEL 9 SSH server configuration file must be group-owned by root.

# permissions correct by default
ls -l /etc/ssh/sshd_config

V-257998

RHEL 9 SSH server configuration file must be owned by root.

# permissions correct by default
ls -l /etc/ssh/sshd_config

V-257999

RHEL 9 SSH server configuration file must have mode 0600 or less permissive.

# permissions correct by default
ls -l /etc/ssh/sshd_config

V-258000

RHEL 9 SSH private host key files must have mode 0640 or less permissive.

# permissions correct by default
ls -l /etc/ssh/*_key

V-258001

RHEL 9 SSH public host key files must have mode 0644 or less permissive.

# permissions correct by default
ls -l /etc/ssh/*.pub

V-258002

RHEL 9 SSH daemon must not allow compression or must only allow compression after successful authentication.

utils.set_ssh_option 'Compression delayed'

V-258003

RHEL 9 SSH daemon must not allow GSSAPI authentication.

utils.set_ssh_option 'GSSAPIAuthentication no'

V-258004

RHEL 9 SSH daemon must not allow Kerberos authentication.

utils.set_ssh_option 'KerberosAuthentication no'

V-258005

RHEL 9 SSH daemon must not allow rhosts authentication.

utils.set_ssh_option 'IgnoreRhosts yes'

V-258006

RHEL 9 SSH daemon must not allow known hosts authentication.

utils.set_ssh_option 'IgnoreUserKnownHosts yes'

V-258007

RHEL 9 SSH daemon must disable remote X connections for interactive users.

utils.set_ssh_option 'X11forwarding no'

V-258008

RHEL 9 SSH daemon must perform strict mode checking of home directory configuration files.

utils.set_ssh_option 'StrictModes yes'

V-258009

RHEL 9 SSH daemon must display the date and time of the last successful account logon upon an SSH logon.

utils.set_ssh_option 'PrintLastLog yes'

V-258010

RHEL 9 SSH daemon must be configured to use privilege separation.

utils.set_ssh_option 'UsePrivilegeSeparation sandbox'

V-258011

RHEL 9 SSH daemon must prevent remote hosts from connecting to the proxy display.

utils.set_ssh_option 'X11UseLocalhost yes'

V-258012

RHEL 9 must display the Standard Mandatory DOD Notice and Consent Banner before granting local or remote access to the system via a graphical user logon.

# no graphical interface installed

V-258013

RHEL 9 must prevent a user from overriding the banner-message-enable setting for the graphical user interface.

# no graphical interface installed

V-258014

RHEL 9 must disable the graphical user interface automount function unless required.

# no graphical interface installed

V-258015

RHEL 9 must prevent a user from overriding the disabling of the graphical user interface automount function.

# no graphical interface installed

V-258016

RHEL 9 must disable the graphical user interface autorun function unless required.

# no graphical interface installed

V-258017

RHEL 9 must prevent a user from overriding the disabling of the graphical user interface autorun function.

# no graphical interface installed

V-258019

RHEL 9 must be able to initiate directly a session lock for all connection types using smart card when the smart card is removed.

# no graphical interface installed

V-258020

RHEL 9 must prevent a user from overriding the disabling of the graphical user smart card removal action.

# no graphical interface installed

V-258021

RHEL 9 must enable a user session lock until that user re-establishes access using established identification and authentication procedures for graphical user sessions.

# no graphical interface installed

V-258022

RHEL 9 must prevent a user from overriding the screensaver lock-enabled setting for the graphical user interface.

# no graphical interface installed

V-258023

RHEL 9 must automatically lock graphical user sessions after 15 minutes of inactivity.

# no graphical interface installed

V-258024

RHEL 9 must prevent a user from overriding the session idle-delay setting for the graphical user interface.

# no graphical interface installed

V-258025

RHEL 9 must initiate a session lock for graphical user interfaces when the screensaver is activated.

# no graphical interface installed

V-258026

RHEL 9 must prevent a user from overriding the session lock-delay setting for the graphical user interface.

# no graphical interface installed

V-258027

RHEL 9 must conceal, via the session lock, information previously visible on the display with a publicly viewable image.

# no graphical interface installed

V-258028

RHEL 9 effective dconf policy must match the policy keyfiles.

# no graphical interface installed

V-258029

RHEL 9 must disable the ability of a user to restart the system from the login screen.

# no graphical interface installed

V-258030

RHEL 9 must prevent a user from overriding the disable-restart-buttons setting for the graphical user interface.

# no graphical interface installed

V-258031

RHEL 9 must disable the ability of a user to accidentally press Ctrl-Alt-Del and cause a system to shut down or reboot.

# no graphical interface installed

V-258032

RHEL 9 must prevent a user from overriding the Ctrl-Alt-Del sequence settings for the graphical user interface.

# no graphical interface installed

V-258033

RHEL 9 must disable the user list at logon for graphical user interfaces.

# no graphical interface installed

V-258034

RHEL 9 must be configured to disable USB mass storage.

# storage controller disabled on baseline vm anyway
utils.blacklist_kernel_module usb-storage

V-258035

RHEL 9 must have the USBGuard package installed.

# USB controller not present in VM

V-258036

RHEL 9 must have the USBGuard package enabled.

# USB controller not present in VM

V-258038

RHEL 9 must block unauthorized peripherals before establishing a connection.

# USB controller not present in VM

V-258039

RHEL 9 Bluetooth must be disabled.

utils.blacklist_kernel_module bluetooth

V-258040

RHEL 9 wireless network adapters must be disabled.

# no wireless radios in a VM

V-258041

RHEL 9 user account passwords for new users or password changes must have a 60-day maximum password lifetime restriction in /etc/login.defs.

utils.set_config_option /etc/login.defs PASS_MAX_DAYS 60

V-258042

RHEL 9 user account passwords must have a 60-day maximum password lifetime restriction.

# correctly configured by default
awk -F: '$5 <= 0 {print $1 "" "" $5}' /etc/shadow

V-258043

All RHEL 9 local interactive user accounts must be assigned a home directory upon creation.

utils.set_config_option /etc/login.defs CREATE_HOME yes

V-258044

RHEL 9 must set the umask value to 077 for all local interactive user accounts.

# no umask in user profiles by default

V-258045

RHEL 9 duplicate User IDs (UIDs) must not exist for interactive users.

# correctly configured by default
awk -F ":" 'list[$3]++ {print $1, $3}' /etc/passwd

V-258046

RHEL 9 system accounts must not have an interactive login shell.

# correctly configured by default
awk -F: '$3 < 1000 && $7 !~ /nologin/ {print $1 ":" $3 ":" $7}' /etc/passwd

V-258047

RHEL 9 must automatically expire temporary accounts within 72 hours.

# no temp accounts exist by default

V-258048

All RHEL 9 interactive users must have a primary group that exists.

# correctly configured by default
pwck -qr

V-258049

RHEL 9 must disable account identifiers (individuals, groups, roles, and devices) after 35 days of inactivity.

useradd -D -f 35

V-258050

Executable search paths within the initialization files of all local interactive RHEL 9 users must only contain paths that resolve to the system default or the users home directory.

# correctly configured by default
grep -si path= /home/*/.*

V-258051

All RHEL 9 local interactive users must have a home directory assigned in the /etc/passwd file.

# correctly configured by default
awk -F: '$3 >= 1000 && $7 !~ /nologin/ {print $1, $3, $6}' /etc/passwd

V-258052

All RHEL 9 local interactive user home directories defined in the /etc/passwd file must exist.

# correctly configured by default
pwck -r

V-258053

All RHEL 9 local interactive user home directories must be group-owned by the home directory owner's primary group.

# correctly configured by default
awk -F: '$3 >= 1000 && $7 !~ /nologin/ {print $6}' /etc/passwd

V-258054

RHEL 9 must automatically lock an account when three unsuccessful logon attempts occur.

utils.set_config_option -i -d = /etc/security/faillock.conf deny 3

V-258055

RHEL 9 must automatically lock the root account until the root account is released by an administrator when three unsuccessful logon attempts occur during a 15-minute time period.

utils.set_config_option -i /etc/security/faillock.conf even_deny_root ''

V-258056

RHEL 9 must automatically lock an account when three unsuccessful logon attempts occur during a 15-minute time period.

utils.set_config_option -i -d = /etc/security/faillock.conf fail_interval 900

V-258057

RHEL 9 must maintain an account lock until the locked account is released by an administrator.

utils.set_config_option -i -d = /etc/security/faillock.conf unlock_time 0

V-258058

RHEL 9 must not have unauthorized accounts.

# correctly configured by default
awk -F: '$3 >= 1000 && $7 !~ /nologin/ {print $6}' /etc/passwd

V-258060

RHEL 9 must ensure account lockouts persist.

utils.set_config_option -i -d = /etc/security/faillock.conf dir /var/log/faillock

V-258061

RHEL 9 groups must have unique Group ID (GID).

# correctly configured by default
cut -d : -f 3 /etc/group | uniq -d

V-258062

Local RHEL 9 initialization files must not execute world-writable programs.

# correctly configured by default
find /home -perm -002 -type f -name ".[^.]*" -exec ls -ld {} \;

V-258063

RHEL 9 must have the tmux package installed.

utils.ensure_package_installed tmux

V-258064

RHEL 9 must ensure session control is automatically started at shell initialization.

cat <<'EOF' >/etc/profile.d/tmux.sh
#!/bin/bash                                                                                                           │
[[ -n $PS1 && -z $TMUX && -z $DISPLAY && ! $(pstree -s $$) =~ tmux|sudo ]] && exec tmux new -As0
EOF

V-258065

RHEL 9 must enable a user session lock until that user re-establishes access using established identification and authentication procedures for command line sessions.

utils.add_if_missing /etc/tmux.conf 'set -g lock-command vlock'
utils.add_if_missing /etc/tmux.conf 'bind X lock-session'

V-258066

RHEL 9 must automatically lock command line user sessions after 15 minutes of inactivity.

utils.add_if_missing /etc/tmux.conf 'set -g lock-after-time 900'

V-258068

RHEL 9 must automatically exit interactive command shell user sessions after 15 minutes of inactivity.

utils.add_if_missing /etc/profile.d/tmout.sh  $'#!/bin/bash\ndeclare -xr TMOUT=900'

V-258070

RHEL 9 must log username information when unsuccessful logon attempts occur.

utils.set_config_option -i /etc/security/faillock.conf audit ''

V-258071

RHEL 9 must enforce a delay of at least four seconds between logon prompts following a failed logon attempt.

utils.set_config_option /etc/login.defs FAIL_DELAY 4

V-258072

RHEL 9 must define default permissions for the bash shell.

# Don't edit /etc/bashrc directly, use drop-ins in /etc/profile.d/
utils.add_if_missing /etc/profile.d/umask.sh 'umask 077'

V-258073

RHEL 9 must define default permissions for the c shell.

# Don't edit /etc/csh.cshrc directly, use drop-ins in /etc/profile.d/
utils.add_if_missing /etc/profile.d/umask.csh 'umask 077'

V-258074

RHEL 9 must define default permissions for all authenticated users in such a way that the user can only read and modify their own files.

utils.set_config_option /etc/login.defs UMASK 077

V-258075

RHEL 9 must define default permissions for the system default profile.

# Don't edit /etc/profile directly, use drop-ins in /etc/profile.d/
utils.add_if_missing /etc/profile.d/umask.sh 'umask 077'

V-258077

RHEL 9 must terminate idle user sessions.

utils.add_if_missing /etc/systemd/logind.conf.d/stig.conf 'StopIdleSessionSec=900'

V-258079

RHEL 9 must enable the SELinux targeted policy.

# Targeted policy is default
grep SELINUXTYPE /etc/selinux/config

V-258080

RHEL 9 must configure SELinux context type to allow the use of a nondefault faillock tally directory.

dir='/var/log/faillock'
utils.set_config_option -i -d = /etc/security/faillock.conf dir "$dir"
semanage fcontext -a -t faillog_t "$dir(/.*)?"
mkdir -p "$dir" && restorecon -R "$dir"

V-258081

RHEL 9 must have policycoreutils package installed.

# installed by default
utils.ensure_package_installed policycoreutils

V-258082

RHEL 9 policycoreutils-python-utils package must be installed.

utils.ensure_package_installed policycoreutils-python-utils

V-258083

RHEL 9 must have the sudo package installed.

# installed by default
utils.ensure_package_installed sudo

V-258084

RHEL 9 must require reauthentication when using the "sudo" command.

utils.add_if_missing /etc/sudoers.d/01_stig 'Defaults timestamp_timeout=0'

V-258085

RHEL 9 must use the invoking user's password for privilege escalation when using "sudo".

utils.add_if_missing /etc/sudoers.d/01_stig $'Defaults !targetpw\nDefaults !rootpw\nDefaults !runaspw'

V-258086

RHEL 9 must require users to reauthenticate for privilege escalation.

# Configured correctly by default
grep -ir '!authenticate' /etc/sudoers /etc/sudoers.d/*

V-258087

RHEL 9 must restrict privilege elevation to authorized personnel.

# Configured correctly by default
grep -wE '^ALL' /etc/sudoers /etc/sudoers.d/*

V-258088

RHEL 9 must restrict the use of the "su" command.

sed -i -E 's/#auth(.+pam_wheel.so use_uid)/auth\1/' /etc/pam.d/su

V-258089

RHEL 9 fapolicy module must be installed.

utils.ensure_package_installed fapolicyd

V-258090

RHEL 9 fapolicy module must be enabled.

systemctl -q is-active fapolicyd || systemctl enable --now fapolicyd

V-258091

RHEL 9 must ensure the password complexity module in the system-auth file is configured for three retries or less.

...

V-258092

RHEL 9 must be configured in the password-auth file to prohibit password reuse for a minimum of five generations.

...

V-258093

RHEL 9 must be configured in the system-auth file to prohibit password reuse for a minimum of five generations.

...

V-258095

RHEL 9 must configure the use of the pam_faillock.so module in the /etc/pam.d/system-auth file.

...

V-258096

RHEL 9 must configure the use of the pam_faillock.so module in the /etc/pam.d/password-auth file.

...

V-258097

RHEL 9 must ensure the password complexity module is enabled in the password-auth file.

...

V-258098

RHEL 9 must ensure the password complexity module is enabled in the system-auth file.

...

V-258099

RHEL 9 password-auth must be configured to use a sufficient number of hashing rounds.

...

V-258100

RHEL 9 system-auth must be configured to use a sufficient number of hashing rounds.

...

V-258101

RHEL 9 must enforce password complexity rules for the root account.

utils.set_config_option -i /etc/security/pwquality.conf enforce_for_root ''

V-258102

RHEL 9 must enforce password complexity by requiring that at least one lowercase character be used.

utils.set_config_option -i -d = /etc/security/pwquality.conf lcredit '-1'

V-258103

RHEL 9 must enforce password complexity by requiring that at least one numeric character be used.

utils.set_config_option -i -d = /etc/security/pwquality.conf dcredit '-1'

V-258104

RHEL 9 passwords for new users or password changes must have a 24 hours minimum password lifetime restriction in /etc/login.defs.

utils.set_config_option /etc/login.defs PASS_MIN_DAYS 1

V-258105

RHEL 9 passwords must have a 24 hours minimum password lifetime restriction in /etc/shadow.

# Set correctly on the default account
awk -F: '$3 >= 1000 && $3 < 65534 {print $1}' /etc/passwd |
    xargs -I{} awk -F: -v u="{}" '$1 == u {print $1 " " $4}' /etc/shadow

V-258106

RHEL 9 must require users to provide a password for privilege escalation.

# configured correctly by default
grep -ri nopasswd /etc/sudoers /etc/sudoers.d/*

V-258107

RHEL 9 passwords must be created with a minimum of 15 characters.

utils.set_config_option -i -d = /etc/security/pwquality.conf minlen '15'

V-258108

RHEL 9 passwords for new users must have a minimum of 15 characters.

utils.set_config_option /etc/login.defs PASS_MIN_LEN 15

V-258109

RHEL 9 must enforce password complexity by requiring that at least one special character be used.

 utils.set_config_option -i -d = /etc/security/pwquality.conf ocredit '-1'

V-258110

RHEL 9 must prevent the use of dictionary words for passwords.

utils.set_config_option -i -d = /etc/security/pwquality.conf dictcheck 1

V-258111

RHEL 9 must enforce password complexity by requiring that at least one uppercase character be used.

utils.set_config_option -i -d = /etc/security/pwquality.conf ucredit '-1'

V-258112

RHEL 9 must require the change of at least eight characters when passwords are changed.

utils.set_config_option -i -d = /etc/security/pwquality.conf difok 8

V-258113

RHEL 9 must require the maximum number of repeating characters of the same character class be limited to four when passwords are changed.

utils.set_config_option -i -d = /etc/security/pwquality.conf maxclassrepeat 4

V-258114

RHEL 9 must require the maximum number of repeating characters be limited to three when passwords are changed.

utils.set_config_option -i -d = /etc/security/pwquality.conf maxrepeat 3

V-258115

RHEL 9 must require the change of at least four character classes when passwords are changed.

utils.set_config_option -i -d = /etc/security/pwquality.conf minclass 4

V-258116

RHEL 9 must be configured so that user and group account administration utilities are configured to store only encrypted representations of passwords.

utils.set_config_option -d = /etc/libuser.conf crypt_style sha512

V-258117

RHEL 9 must be configured to use the shadow file to store only encrypted representations of passwords.

utils.set_config_option /etc/login.defs ENCRYPT_METHOD SHA512

V-258118

RHEL 9 must not be configured to bypass password requirements for privilege escalation.

...

V-258119

RHEL 9 shadow password suite must be configured to use a sufficient number of hashing rounds.

utils.set_config_option /etc/login.defs SHA_CRYPT_MIN_ROUNDS 5000

V-258120

RHEL 9 must not have accounts configured with blank or null passwords.

# Configured correctly by default
awk -F: '!$2 {print $1}' /etc/shadow

V-258121

RHEL 9 must use the CAC smart card driver.

...

V-258122

RHEL 9 must enable certificate based smart card authentication.

...

V-258123

RHEL 9 must implement certificate status checking for multifactor authentication.

...

V-258124

RHEL 9 must have the pcsc-lite package installed.

utils.ensure_package_installed pcsc-lite

V-258125

The pcscd service on RHEL 9 must be active.

# enabled by default (indirectly)
systemctl -q is-active pcscd.socket || systemctl enable --now pcscd.socket

V-258126

RHEL 9 must have the opensc package installed.

utils.ensure_package_installed opensc

V-258127

RHEL 9, for PKI-based authentication, must enforce authorized access to the corresponding private key.

# no key files in baseline

V-258128

RHEL 9 must require authentication to access emergency mode.

# set by default
grep sulogin /usr/lib/systemd/system/emergency.service

V-258129

RHEL 9 must require authentication to access single-user mode.

# set by default
grep sulogin /usr/lib/systemd/system/rescue.service

V-258130

RHEL 9 must prevent system daemons from using Kerberos for authentication.

# No keytabs installed by default
ls -al /etc/*.keytab

V-258131

RHEL 9, for PKI-based authentication, must validate certificates by constructing a certification path (which includes status information) to an accepted trust anchor.

...

V-258132

RHEL 9 must map the authenticated identity to the user or group account for PKI-based authentication.

...

V-258133

RHEL 9 must prohibit the use of cached authenticators after one day.

...

V-258134

RHEL 9 must have the AIDE package installed.

utils.ensure_package_installed aide

V-258135

RHEL 9 must routinely check the baseline configuration for unauthorized changes and notify the system administrator when anomalies in the operation of any security functions are discovered.

cat <<'EOF' >/etc/cron.daily/aide
#!/bin/bash
/usr/sbin/aide --check | /bin/mail -s "$HOSTNAME - Daily aide integrity check run" root@sysname.mil
EOF

V-258136

RHEL 9 must use a file integrity tool that is configured to use FIPS 140-3-approved cryptographic hashes for validating file contents and directories.

# configured by default
grep sha512 /etc/aide.conf

V-258137

RHEL 9 must use cryptographic mechanisms to protect the integrity of audit tools.

cat <<'EOF' >>/etc/aide.conf
# STIG V-258137
/usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
/usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
EOF

V-258140

RHEL 9 must have the rsyslog package installed.

# installed by default
utils.ensure_package_installed rsyslog

V-258141

RHEL 9 must have the packages required for encrypting offloaded audit logs installed.

# installed by default
utils.ensure_package_installed rsyslog-gnutls

V-258142

The rsyslog service on RHEL 9 must be active.

# enabled by default
systemctl -q is-active rsyslog || systemctl enable --now rsyslog

V-258143

RHEL 9 must be configured so that the rsyslog daemon does not accept log messages from other servers unless the server is being used for log aggregation.

# not enabled by default
grep -sE 'ModLoad|ServerRun' /etc/rsyslog.conf /etc/rsyslog.d/*

V-258144

All RHEL 9 remote access methods must be monitored.

utils.add_if_missing /etc/rsyslog.d/stig.conf 'auth.*;authpriv.*;daemon.* /var/log/secure'

V-258145

RHEL 9 must be configured to offload audit records onto a different system from the system being audited via syslog.

utils.set_config_option -d = /etc/audit/plugins.d/syslog.conf active yes

V-258146

RHEL 9 must authenticate the remote logging server for offloading audit logs via rsyslog.

...

V-258147

RHEL 9 must encrypt the transfer of audit records offloaded onto a different system or media from the system being audited via rsyslog.

...

V-258148

RHEL 9 must encrypt via the gtls driver the transfer of audit records offloaded onto a different system or media from the system being audited via rsyslog.

...

V-258149

RHEL 9 must be configured to forward audit records via TCP to a different system or media from the system being audited via rsyslog.

...

V-258150

RHEL 9 must use cron logging.

# configured correctly by default
grep -s cron /etc/rsyslog.conf /etc/rsyslog.d/*.conf

V-258151

RHEL 9 audit package must be installed.

# installed by default
utils.ensure_package_installed audit

V-258152

RHEL 9 audit service must be enabled.

# enabled by default
systemctl -q is-active auditd || systemctl enable --now auditd

V-258153

RHEL 9 audit system must take appropriate action when an error writing to the audit storage volume occurs.

utils.set_config_option -d = /etc/audit/auditd.conf disk_error_action SYSLOG

V-258154

RHEL 9 audit system must take appropriate action when the audit storage volume is full.

utils.set_config_option -d = /etc/audit/auditd.conf disk_full_action SYSLOG

V-258155

RHEL 9 must allocate audit record storage capacity to store at least one week's worth of audit records.

df -h /var/log/audit

V-258156

RHEL 9 must take action when allocated audit record storage volume reaches 75 percent of the repository maximum audit record storage capacity.

utils.set_config_option -d = /etc/audit/auditd.conf space_left '25%'

V-258157

RHEL 9 must notify the system administrator (SA) and information system security officer (ISSO) (at a minimum) when allocated audit record storage volume 75 percent utilization.

utils.set_config_option -d = /etc/audit/auditd.conf space_left_action email

V-258158

RHEL 9 must take action when allocated audit record storage volume reaches 95 percent of the audit record storage capacity.

utils.set_config_option -d = /etc/audit/auditd.conf admin_space_left '5%'

V-258159

RHEL 9 must take action when allocated audit record storage volume reaches 95 percent of the repository maximum audit record storage capacity.

utils.set_config_option -d = /etc/audit/auditd.conf admin_space_left_action single

V-258160

RHEL 9 audit system must take appropriate action when the audit files have reached maximum size.

utils.set_config_option -d = /etc/audit/auditd.conf max_log_file_action ROTATE

V-258161

RHEL 9 must label all offloaded audit logs before sending them to the central log server.

utils.set_config_option -d = /etc/audit/auditd.conf name_format hostname

V-258162

RHEL 9 must take appropriate action when the internal event queue is full.

utils.set_config_option -d = /etc/audit/auditd.conf overflow_action syslog

V-258163

RHEL 9 System Administrator (SA) and/or information system security officer (ISSO) (at a minimum) must be alerted of an audit processing failure event.

utils.set_config_option -d = /etc/audit/auditd.conf action_mail_acct root

V-258164

RHEL 9 audit system must audit local events.

utils.set_config_option -d = /etc/audit/auditd.conf local_events yes

V-258165

RHEL 9 audit logs must be group-owned by root or by a restricted logging group to prevent unauthorized read access.

# permissions correct by default
ls -l /var/log/audit/audit.log

V-258166

RHEL 9 audit log directory must be owned by root to prevent unauthorized read access.

# permissions correct by default
ls -ld /var/log/audit

V-258167

RHEL 9 audit logs file must have mode 0600 or less permissive to prevent unauthorized access to the audit log.

# permissions correct by default
ls -l /var/log/audit/audit.log

V-258168

RHEL 9 must periodically flush audit records to disk to prevent the loss of audit records.

utils.set_config_option -d = /etc/audit/auditd.conf freq 100

V-258169

RHEL 9 must produce audit records containing information to establish the identity of any individual or process associated with the event.

utils.set_config_option -d = /etc/audit/auditd.conf log_format ENRICHED

V-258170

RHEL 9 must write audit records to disk.

utils.set_config_option -d = /etc/audit/auditd.conf write_logs yes

V-258171

RHEL 9 must allow only the information system security manager (ISSM) (or individuals or roles appointed by the ISSM) to select which auditable events are to be audited.

# permissions correct by default
ls -l /etc/audit/auditd.conf /etc/audit/rules.d/*.rules

V-258172

RHEL 9 /etc/audit/auditd.conf file must have 0640 or less permissive to prevent unauthorized access.

# permissions correct by default
ls -l /etc/audit/auditd.conf /etc/audit/rules.d/*.rules

V-258174

RHEL 9 must have mail aliases to notify the information system security officer (ISSO) and system administrator (SA) (at a minimum) in the event of an audit processing failure.

# Postfix package is not installed

V-258175

RHEL 9 audispd-plugins package must be installed.

utils.ensure_package_installed audispd-plugins

V-258176

RHEL 9 must audit uses of the "execve" system call.

utils.add_audit_rule '-a always,exit -F arch=b32 -S execve -C uid!=euid -F euid=0 -k execpriv '
utils.add_audit_rule '-a always,exit -F arch=b64 -S execve -C uid!=euid -F euid=0 -k execpriv'
utils.add_audit_rule '-a always,exit -F arch=b32 -S execve -C gid!=egid -F egid=0 -k execpriv'
utils.add_audit_rule '-a always,exit -F arch=b64 -S execve -C gid!=egid -F egid=0 -k execpriv'

V-258177

RHEL 9 must audit all uses of the chmod, fchmod, and fchmodat system calls.

utils.add_audit_rule '-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=1000 -F auid!=unset -k perm_mod'
utils.add_audit_rule '-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat -F auid>=1000 -F auid!=unset -k perm_mod'

V-258178

RHEL 9 must audit all uses of the chown, fchown, fchownat, and lchown system calls.

utils.add_audit_rule '-a always,exit -F arch=b32 -S chown,fchown,fchownat,lchown -F auid>=1000 -F auid!=unset -k perm_mod'
utils.add_audit_rule '-a always,exit -F arch=b64 -S chown,fchown,fchownat,lchown -F auid>=1000 -F auid!=unset -k perm_mod'

V-258179

RHEL 9 must audit all uses of the setxattr, fsetxattr, lsetxattr, removexattr, fremovexattr, and lremovexattr system calls.

utils.add_audit_rule '-a always,exit -F arch=b32 -S setxattr,fsetxattr,lsetxattr,removexattr,fremovexattr,lremovexattr -F auid>=1000 -F auid!=unset -k perm_mod'
utils.add_audit_rule '-a always,exit -F arch=b64 -S setxattr,fsetxattr,lsetxattr,removexattr,fremovexattr,lremovexattr -F auid>=1000 -F auid!=unset -k perm_mod'
utils.add_audit_rule '-a always,exit -F arch=b32 -S setxattr,fsetxattr,lsetxattr,removexattr,fremovexattr,lremovexattr -F auid=0 -k perm_mod'
utils.add_audit_rule '-a always,exit -F arch=b64 -S setxattr,fsetxattr,lsetxattr,removexattr,fremovexattr,lremovexattr -F auid=0 -k perm_mod'

V-258180

RHEL 9 must audit all uses of umount system calls.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/umount -F perm=x -F auid>=1000 -F auid!=unset -k privileged-mount'

V-258181

RHEL 9 must audit all uses of the chacl command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/chacl -F perm=x -F auid>=1000 -F auid!=unset -k perm_mod'

V-258182

RHEL 9 must audit all uses of the setfacl command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/setfacl -F perm=x -F auid>=1000 -F auid!=unset -k perm_mod'

V-258183

RHEL 9 must audit all uses of the chcon command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/chcon -F perm=x -F auid>=1000 -F auid!=unset -k perm_mod'

V-258184

RHEL 9 must audit all uses of the semanage command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/semanage -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258185

RHEL 9 must audit all uses of the setfiles command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/setfiles -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258186

RHEL 9 must audit all uses of the setsebool command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/setsebool -F perm=x -F auid>=1000 -F auid!=unset -F key=privileged'

V-258187

RHEL 9 must audit all uses of the rename, unlink, rmdir, renameat, and unlinkat system calls.

utils.add_audit_rule '-a always,exit -F arch=b32 -S rename,unlink,rmdir,renameat,unlinkat -F auid>=1000 -F auid!=unset -k delete'
utils.add_audit_rule '-a always,exit -F arch=b64 -S rename,unlink,rmdir,renameat,unlinkat -F auid>=1000 -F auid!=unset -k delete'

V-258188

RHEL 9 must audit all uses of the truncate, ftruncate, creat, open, openat, and open_by_handle_at system calls.

utils.add_audit_rule '-a always,exit -F arch=b32 -S truncate,ftruncate,creat,open,openat,open_by_handle_at -F exit=-EPERM -F auid>=1000 -F auid!=unset -k perm_access'
utils.add_audit_rule '-a always,exit -F arch=b64 -S truncate,ftruncate,creat,open,openat,open_by_handle_at -F exit=-EPERM -F auid>=1000 -F auid!=unset -k perm_access'
utils.add_audit_rule '-a always,exit -F arch=b32 -S truncate,ftruncate,creat,open,openat,open_by_handle_at -F exit=-EACCES -F auid>=1000 -F auid!=unset -k perm_access'
utils.add_audit_rule '-a always,exit -F arch=b64 -S truncate,ftruncate,creat,open,openat,open_by_handle_at -F exit=-EACCES -F auid>=1000 -F auid!=unset -k perm_access'

V-258189

RHEL 9 must audit all uses of the delete_module system call.

utils.add_audit_rule '-a always,exit -F arch=b32 -S delete_module -F auid>=1000 -F auid!=unset -k module_chng'
utils.add_audit_rule '-a always,exit -F arch=b64 -S delete_module -F auid>=1000 -F auid!=unset -k module_chng'

V-258190

RHEL 9 must audit all uses of the init_module and finit_module system calls.

utils.add_audit_rule '-a always,exit -F arch=b32 -S init_module,finit_module -F auid>=1000 -F auid!=unset -k module_chng'
utils.add_audit_rule '-a always,exit -F arch=b64 -S init_module,finit_module -F auid>=1000 -F auid!=unset -k module_chng'

V-258191

RHEL 9 must audit all uses of the chage command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/chage -F perm=x -F auid>=1000 -F auid!=unset -k privileged-chage'

V-258192

RHEL 9 must audit all uses of the chsh command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/chsh -F perm=x -F auid>=1000 -F auid!=unset -k priv_cmd'

V-258193

RHEL 9 must audit all uses of the crontab command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/crontab -F perm=x -F auid>=1000 -F auid!=unset -k privileged-crontab'

V-258194

RHEL 9 must audit all uses of the gpasswd command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/gpasswd -F perm=x -F auid>=1000 -F auid!=unset -k privileged-gpasswd'

V-258195

RHEL 9 must audit all uses of the kmod command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/kmod -F perm=x -F auid>=1000 -F auid!=unset -k modules'

V-258196

RHEL 9 must audit all uses of the newgrp command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/newgrp -F perm=x -F auid>=1000 -F auid!=unset -k priv_cmd'

V-258197

RHEL 9 must audit all uses of the pam_timestamp_check command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/pam_timestamp_check -F perm=x -F auid>=1000 -F auid!=unset -k privileged-pam_timestamp_check'

V-258198

RHEL 9 must audit all uses of the passwd command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/passwd -F perm=x -F auid>=1000 -F auid!=unset -k privileged-passwd'

V-258199

RHEL 9 must audit all uses of the postdrop command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/postdrop -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258200

RHEL 9 must audit all uses of the postqueue command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/postqueue -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258201

RHEL 9 must audit all uses of the ssh-agent command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/ssh-agent -F perm=x -F auid>=1000 -F auid!=unset -k privileged-ssh'

V-258202

RHEL 9 must audit all uses of the ssh-keysign command.

utils.add_audit_rule '-a always,exit -F path=/usr/libexec/openssh/ssh-keysign -F perm=x -F auid>=1000 -F auid!=unset -k privileged-ssh'

V-258203

RHEL 9 must audit all uses of the su command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/su -F perm=x -F auid>=1000 -F auid!=unset -k privileged-priv_change'

V-258204

RHEL 9 must audit all uses of the sudo command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/sudo -F perm=x -F auid>=1000 -F auid!=unset -k priv_cmd'

V-258205

RHEL 9 must audit all uses of the sudoedit command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/sudoedit -F perm=x -F auid>=1000 -F auid!=unset -k priv_cmd'

V-258206

RHEL 9 must audit all uses of the unix_chkpwd command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/unix_chkpwd -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258207

RHEL 9 must audit all uses of the unix_update command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/unix_update -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258208

RHEL 9 must audit all uses of the userhelper command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/userhelper -F perm=x -F auid>=1000 -F auid!=unset -k privileged-unix-update'

V-258209

RHEL 9 must audit all uses of the usermod command.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/usermod -F perm=x -F auid>=1000 -F auid!=unset -k privileged-usermod'

V-258210

RHEL 9 must audit all uses of the mount command.

utils.add_audit_rule '-a always,exit -F path=/usr/bin/mount -F perm=x -F auid>=1000 -F auid!=unset -k privileged-mount'

V-258211

Successful/unsuccessful uses of the init command in RHEL 9 must generate an audit record.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/init -F perm=x -F auid>=1000 -F auid!=unset -k privileged-init'

V-258212

Successful/unsuccessful uses of the poweroff command in RHEL 9 must generate an audit record.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/poweroff -F perm=x -F auid>=1000 -F auid!=unset -k privileged-poweroff'

V-258213

Successful/unsuccessful uses of the reboot command in RHEL 9 must generate an audit record.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/reboot -F perm=x -F auid>=1000 -F auid!=unset -k privileged-reboot'

V-258214

Successful/unsuccessful uses of the shutdown command in RHEL 9 must generate an audit record.

utils.add_audit_rule '-a always,exit -F path=/usr/sbin/shutdown -F perm=x -F auid>=1000 -F auid!=unset -k privileged-shutdown'

V-258215

Successful/unsuccessful uses of the umount system call in RHEL 9 must generate an audit record.

utils.add_audit_rule '-a always,exit -F arch=b32 -S umount -F auid>=1000 -F auid!=unset -k privileged-umount'

V-258216

Successful/unsuccessful uses of the umount2 system call in RHEL 9 must generate an audit record.

utils.add_audit_rule '-a always,exit -F arch=b32 -S umount2 -F auid>=1000 -F auid!=unset -k perm_mod'
utils.add_audit_rule '-a always,exit -F arch=b64 -S umount2 -F auid>=1000 -F auid!=unset -k perm_mod'

V-258217

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/sudoers.

utils.add_audit_rule '-w /etc/sudoers -p wa -k identity'

V-258218

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/sudoers.d/ directory.

utils.add_audit_rule '-w /etc/sudoers.d/ -p wa -k identity'

V-258219

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/group.

utils.add_audit_rule '-w /etc/group -p wa -k identity'

V-258220

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/gshadow.

utils.add_audit_rule '-w /etc/gshadow -p wa -k identity'

V-258221

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/opasswd.

utils.add_audit_rule '-w /etc/security/opasswd -p wa -k identity'

V-258222

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/passwd.

utils.add_audit_rule '-w /etc/passwd -p wa -k identity'

V-258223

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /etc/shadow.

utils.add_audit_rule '-w /etc/shadow -p wa -k identity'

V-258224

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /var/log/faillock.

utils.add_audit_rule '-w /var/log/faillock -p wa -k logins'

V-258225

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /var/log/lastlog.

utils.add_audit_rule '-w /var/log/lastlog -p wa -k logins'

V-258226

RHEL 9 must generate audit records for all account creations, modifications, disabling, and termination events that affect /var/log/tallylog.

utils.add_audit_rule '-w /var/log/tallylog -p wa -k logins'

V-258227

RHEL 9 must take appropriate action when a critical audit processing failure occurs.

utils.add_audit_rule '-f 2'

V-258228

RHEL 9 audit system must protect logon UIDs from unauthorized change.

utils.add_audit_rule '--loginuid-immutable'

V-258229

RHEL 9 audit system must protect auditing rules from unauthorized change.

utils.add_audit_rule '-e 2'

V-258231

RHEL 9 must employ FIPS 140-3 approved cryptographic hashing algorithms for all stored passwords.

# configured correctly by default
awk -F: '$2 !~ /[!\*]+/ {print $2}' /etc/shadow

V-258232

RHEL 9 IP tunnels must use FIPS 140-2/140-3 approved cryptographic algorithms.

# IPsec service not installed

V-258233

RHEL 9 pam_unix.so module must be configured in the password-auth file to use a FIPS 140-3 approved cryptographic hashing algorithm for system authentication.

...

V-258234

RHEL 9 must have the crypto-policies package installed.

# installed by default
utils.ensure_package_installed crypto-policies

V-258236

RHEL 9 crypto policy must not be overridden.

# default configuration
ls -l /etc/crypto-policies/back-ends/

V-258237

RHEL 9 must use mechanisms meeting the requirements of applicable federal laws, executive orders, directives, policies, regulations, standards, and guidance for authentication to a cryptographic module.

# configured correctly by default
ls -l /etc/crypto-policies/back-ends/krb5.config

V-258239

RHEL 9 must implement DOD-approved encryption in the OpenSSL package.

# configured correctly by default
grep -i opensslcnf.config /etc/pki/tls/openssl.cnf

V-258240

RHEL 9 must implement DOD-approved TLS encryption in the OpenSSL package.

# configured correctly by default
grep -i  minprotocol /etc/crypto-policies/back-ends/opensslcnf.config

V-258241

RHEL 9 must implement a system-wide encryption policy.

update-crypto-policies --show

V-258242

RHEL 9 must implement DOD-approved encryption in the bind package.

# bind package is not installed

CAT III Checks

V-257782

RHEL 9 must enable the hardware random number generator entropy gatherer service.

# not applicable for FIPS mode system

V-257795

RHEL 9 must enable mitigations against processor-based vulnerabilities.

# enabled by default
dmesg | grep 'page tables'
# to enable anyway
utils.add_kernel_cmdline 'pti=on'

V-257796

RHEL 9 must enable auditing of processes that start prior to the audit daemon.

# both should be set together, see: V-258173
utils.add_kernel_cmdline 'audit=1 audit_backlog_limit=8192'

V-257824

RHEL 9 must remove all software components after updated versions have been installed.

utils.set_config_option -d = /etc/dnf/dnf.conf clean_requirements_on_remove 1

V-257845

RHEL 9 must use a separate file system for /var.

# Already implemented during install
mountpoint /var

V-257846

RHEL 9 must use a separate file system for /var/log.

# Already implemented during install
mountpoint /var/log

V-257847

RHEL 9 must use a separate file system for the system audit data path.

# Already implemented during install
mountpoint /var/log/audit

V-257880

RHEL 9 must disable mounting of cramfs.

# cramfs was removed in RHEL 9
utils.blacklist_kernel_module cramfs

V-257946

RHEL 9 must disable the chrony daemon from acting as a server.

utils.set_config_option /etc/chrony.conf port 0

V-257947

RHEL 9 must disable network management of the chrony daemon.

utils.set_config_option /etc/chrony.conf cmdport 0

V-258037

RHEL 9 must enable Linux audit logging for the USBGuard daemon.

# no USB controller present in VM

V-258067

RHEL 9 must prevent users from disabling session control mechanisms.

sed -i '/tmux/d' /etc/shells

V-258069

RHEL 9 must limit the number of concurrent sessions to ten for all accounts and/or account types.

utils.add_if_missing /etc/security/limits.d/stig.conf '* hard maxlogins 10'

V-258076

RHEL 9 must display the date and time of the last successful account logon upon logon.

# default behavior
grep pam_lastlog /etc/pam.d/postlogin

V-258138

RHEL 9 must be configured so that the file integrity tool verifies Access Control Lists (ACLs).

# configured by default
grep acl /etc/aide.conf

V-258139

RHEL 9 must be configured so that the file integrity tool verifies extended attributes.

# configured by default
grep xattrs /etc/aide.conf

V-258173

RHEL 9 must allocate an audit_backlog_limit of sufficient size to capture processes that start prior to the audit daemon.

# both should be set together, see: V-257796
utils.add_kernel_cmdline 'audit=1 audit_backlog_limit=8192'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment