CIS Ubuntu Linux 20.04 LTS Benchmark v2.0.1
CIS Ubuntu Linux 20.04 LTS Benchmark v2.0.1
04
LTS Benchmark
v2.0.1 - 06-29-2023
Terms of Use
Please see the below link for our current terms of use:
https://www.cisecurity.org/cis-securesuite/cis-securesuite-membership-terms-of-use/
Page 1
Table of Contents
Terms of Use ................................................................................................................. 1
Table of Contents .......................................................................................................... 2
Overview ...................................................................................................................... 10
Intended Audience................................................................................................................11
Consensus Guidance ...........................................................................................................12
Typographical Conventions .................................................................................................13
Recommendation Definitions ..................................................................................... 14
Title ........................................................................................................................................14
Assessment Status...............................................................................................................14
Automated ............................................................................................................................................ 14
Manual ................................................................................................................................................... 14
Profile ....................................................................................................................................14
Description ............................................................................................................................14
Rationale Statement .............................................................................................................14
Impact Statement ..................................................................................................................15
Audit Procedure ....................................................................................................................15
Remediation Procedure........................................................................................................15
Default Value .........................................................................................................................15
References ............................................................................................................................15
CIS Critical Security Controls® (CIS Controls®) ..................................................................15
Additional Information..........................................................................................................15
Profile Definitions .................................................................................................................16
Acknowledgements ..............................................................................................................18
Recommendations ...................................................................................................... 20
1 Initial Setup ........................................................................................................................20
1.1 Filesystem Configuration .............................................................................................................. 21
1.1.1 Disable unused filesystems .................................................................................................... 22
1.1.1.1 Ensure mounting of cramfs filesystems is disabled (Automated) .................................................... 23
1.1.1.2 Ensure mounting of freevxfs filesystems is disabled (Automated) .................................................. 28
1.1.1.3 Ensure mounting of jffs2 filesystems is disabled (Automated) ........................................................ 33
1.1.1.4 Ensure mounting of hfs filesystems is disabled (Automated) .......................................................... 38
1.1.1.5 Ensure mounting of hfsplus filesystems is disabled (Automated) ................................................... 43
1.1.1.6 Ensure mounting of squashfs filesystems is disabled (Automated) ................................................ 48
1.1.1.7 Ensure mounting of udf filesystems is disabled (Automated) .......................................................... 53
1.1.2 Configure /tmp .......................................................................................................................... 58
1.1.2.1 Ensure /tmp is a separate partition (Automated) ............................................................................. 59
1.1.2.2 Ensure nodev option set on /tmp partition (Automated) .................................................................. 63
Page 2
1.1.2.3 Ensure noexec option set on /tmp partition (Automated) ................................................................ 65
1.1.2.4 Ensure nosuid option set on /tmp partition (Automated) ................................................................. 67
1.1.3 Configure /var ........................................................................................................................... 69
1.1.3.1 Ensure separate partition exists for /var (Automated) ..................................................................... 70
1.1.3.2 Ensure nodev option set on /var partition (Automated) ................................................................... 73
1.1.3.3 Ensure nosuid option set on /var partition (Automated) .................................................................. 75
1.1.4 Configure /var/tmp ................................................................................................................... 77
1.1.4.1 Ensure separate partition exists for /var/tmp (Automated) .............................................................. 78
1.1.4.2 Ensure nodev option set on /var/tmp partition (Automated) ............................................................ 81
1.1.4.3 Ensure noexec option set on /var/tmp partition (Automated) .......................................................... 83
1.1.4.4 Ensure nosuid option set on /var/tmp partition (Automated) ........................................................... 85
1.1.5 Configure /var/log..................................................................................................................... 87
1.1.5.1 Ensure separate partition exists for /var/log (Automated) ............................................................... 88
1.1.5.2 Ensure nodev option set on /var/log partition (Automated) ............................................................. 90
1.1.5.3 Ensure noexec option set on /var/log partition (Automated) ............................................................ 92
1.1.5.4 Ensure nosuid option set on /var/log partition (Automated)............................................................. 94
1.1.6 Configure /var/log/audit ........................................................................................................... 96
1.1.6.1 Ensure separate partition exists for /var/log/audit (Automated) ....................................................... 97
1.1.6.2 Ensure nodev option set on /var/log/audit partition (Automated) ..................................................... 99
1.1.6.3 Ensure noexec option set on /var/log/audit partition (Automated) ................................................. 101
1.1.6.4 Ensure nosuid option set on /var/log/audit partition (Automated) .................................................. 103
1.1.7 Configure /home ..................................................................................................................... 105
1.1.7.1 Ensure separate partition exists for /home (Automated) ............................................................... 106
1.1.7.2 Ensure nodev option set on /home partition (Automated) ............................................................. 109
1.1.7.3 Ensure nosuid option set on /home partition (Automated) ............................................................ 111
1.1.8 Configure /dev/shm ................................................................................................................ 113
1.1.8.1 Ensure nodev option set on /dev/shm partition (Automated)......................................................... 114
1.1.8.2 Ensure noexec option set on /dev/shm partition (Automated) ....................................................... 116
1.1.8.3 Ensure nosuid option set on /dev/shm partition (Automated) ........................................................ 118
1.1.9 Disable Automounting (Automated) ................................................................................................. 120
1.1.10 Disable USB Storage (Automated) ................................................................................................ 122
1.2 Filesystem Integrity Checking .................................................................................................... 127
1.2.1 Ensure AIDE is installed (Automated) .............................................................................................. 128
1.2.2 Ensure filesystem integrity is regularly checked (Automated) .......................................................... 130
1.3 Configure Software and Patch Management ............................................................................ 133
1.3.1 Ensure updates, patches, and additional security software are installed (Manual) .......................... 134
1.3.2 Ensure package manager repositories are configured (Manual)...................................................... 137
1.3.3 Ensure GPG keys are configured (Manual) ..................................................................................... 139
1.4 Secure Boot Settings................................................................................................................... 141
1.4.1 Ensure bootloader password is set (Automated) ............................................................................. 142
1.4.2 Ensure permissions on bootloader config are configured (Automated) ............................................ 145
1.4.3 Ensure authentication required for single user mode (Automated) .................................................. 147
1.5 Additional Process Hardening ................................................................................................... 149
1.5.1 Ensure prelink is not installed (Automated) ...................................................................................... 150
1.5.2 Ensure address space layout randomization (ASLR) is enabled (Automated) ................................. 152
1.5.3 Ensure ptrace_scope is restricted (Automated) ............................................................................... 156
1.5.4 Ensure Automatic Error Reporting is not enabled (Automated) ....................................................... 160
1.5.5 Ensure core dumps are restricted (Automated) ............................................................................... 162
1.6 Mandatory Access Control ......................................................................................................... 165
1.6.1 Configure AppArmor.............................................................................................................. 166
1.6.1.1 Ensure AppArmor is installed (Automated) ................................................................................... 167
Page 3
1.6.1.2 Ensure AppArmor is enabled in the bootloader configuration (Automated)................................... 169
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain mode (Automated) ............................... 171
1.6.1.4 Ensure all AppArmor Profiles are enforcing (Automated) .............................................................. 173
1.7 Command Line Warning Banners .............................................................................................. 175
1.7.1 Ensure message of the day is configured properly (Automated) ...................................................... 176
1.7.2 Ensure local login warning banner is configured properly (Automated) ........................................... 178
1.7.3 Ensure remote login warning banner is configured properly (Automated)........................................ 180
1.7.4 Ensure permissions on /etc/motd are configured (Automated) ........................................................ 182
1.7.5 Ensure permissions on /etc/issue are configured (Automated) ........................................................ 184
1.7.6 Ensure permissions on /etc/issue.net are configured (Automated) .................................................. 186
1.8 GNOME Display Manager ............................................................................................................ 188
1.8.1 Ensure GNOME Display Manager is removed (Automated) ............................................................ 189
1.8.2 Ensure GDM login banner is configured (Automated) ...................................................................... 191
1.8.3 Ensure GDM disable-user-list option is enabled (Automated).......................................................... 195
1.8.4 Ensure GDM screen locks when the user is idle (Automated) ......................................................... 199
1.8.5 Ensure GDM screen locks cannot be overridden (Automated) ........................................................ 204
1.8.6 Ensure GDM automatic mounting of removable media is disabled (Automated) ............................. 208
1.8.7 Ensure GDM disabling automatic mounting of removable media is not overridden (Automated) ..... 214
1.8.8 Ensure GDM autorun-never is enabled (Automated) ....................................................................... 218
1.8.9 Ensure GDM autorun-never is not overridden (Automated) ............................................................. 223
1.8.10 Ensure XDCMP is not enabled (Automated) .................................................................................. 228
2 Services............................................................................................................................230
2.1 Configure Time Synchronization ............................................................................................... 231
2.1.1 Ensure time synchronization is in use................................................................................. 232
2.1.1.1 Ensure a single time synchronization daemon is in use (Automated) ........................................... 233
2.1.2 Configure chrony ................................................................................................................... 237
2.1.2.1 Ensure chrony is configured with authorized timeserver (Manual) ................................................ 238
2.1.2.2 Ensure chrony is running as user _chrony (Automated) ............................................................... 242
2.1.2.3 Ensure chrony is enabled and running (Automated) ..................................................................... 244
2.1.3 Configure systemd-timesyncd.............................................................................................. 246
2.1.3.1 Ensure systemd-timesyncd configured with authorized timeserver (Automated) .......................... 248
2.1.3.2 Ensure systemd-timesyncd is enabled and running (Manual) ....................................................... 252
2.1.4 Configure ntp .......................................................................................................................... 254
2.1.4.1 Ensure ntp access control is configured (Automated) ................................................................... 255
2.1.4.2 Ensure ntp is configured with authorized timeserver (Manual) ...................................................... 259
2.1.4.3 Ensure ntp is running as user ntp (Automated) ............................................................................. 262
2.1.4.4 Ensure ntp is enabled and running (Automated) ........................................................................... 264
2.2 Special Purpose Services ........................................................................................................... 266
2.2.1 Ensure X Window System is not installed (Automated) ................................................................... 267
2.2.2 Ensure Avahi Server is not installed (Automated) ............................................................................ 269
2.2.3 Ensure CUPS is not installed (Automated) ...................................................................................... 271
2.2.4 Ensure DHCP Server is not installed (Automated) ........................................................................... 273
2.2.5 Ensure LDAP server is not installed (Automated) ............................................................................ 275
2.2.6 Ensure NFS is not installed (Automated) ......................................................................................... 277
2.2.7 Ensure DNS Server is not installed (Automated) ............................................................................. 279
2.2.8 Ensure FTP Server is not installed (Automated) .............................................................................. 281
2.2.9 Ensure HTTP server is not installed (Automated) ............................................................................ 283
2.2.10 Ensure IMAP and POP3 server are not installed (Automated) ....................................................... 285
2.2.11 Ensure Samba is not installed (Automated) ................................................................................... 287
2.2.12 Ensure HTTP Proxy Server is not installed (Automated) ............................................................... 289
2.2.13 Ensure SNMP Server is not installed (Automated) ........................................................................ 291
Page 4
2.2.14 Ensure NIS Server is not installed (Automated) ............................................................................. 293
2.2.15 Ensure dnsmasq is not installed (Automated) ................................................................................ 295
2.2.16 Ensure mail transfer agent is configured for local-only mode (Automated) .................................... 297
2.2.17 Ensure rsync service is either not installed or is masked (Automated) .......................................... 299
2.3 Service Clients ............................................................................................................................. 301
2.3.1 Ensure NIS Client is not installed (Automated) ................................................................................ 302
2.3.2 Ensure rsh client is not installed (Automated) .................................................................................. 304
2.3.3 Ensure talk client is not installed (Automated) ................................................................................. 306
2.3.4 Ensure telnet client is not installed (Automated) .............................................................................. 308
2.3.5 Ensure LDAP client is not installed (Automated) .............................................................................. 310
2.3.6 Ensure RPC is not installed (Automated) ......................................................................................... 312
2.4 Ensure nonessential services are removed or masked (Manual) ........................................................ 314
Page 5
3.4.2.8 Ensure nftables default deny firewall policy (Automated) .............................................................. 429
3.4.2.9 Ensure nftables service is enabled (Automated) ........................................................................... 432
3.4.2.10 Ensure nftables rules are permanent (Automated)...................................................................... 434
3.4.3 Configure iptables .................................................................................................................. 437
3.4.3.1.1 Ensure iptables packages are installed (Automated) ................................................................. 439
3.4.3.1.2 Ensure nftables is not installed with iptables (Automated) ......................................................... 441
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables (Automated) ................................................ 443
3.4.3.2.1 Ensure iptables default deny firewall policy (Automated) ........................................................... 446
3.4.3.2.2 Ensure iptables loopback traffic is configured (Automated) ....................................................... 448
3.4.3.2.3 Ensure iptables outbound and established connections are configured (Manual) ..................... 450
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports (Automated) ............................................. 452
3.4.3.3.1 Ensure ip6tables default deny firewall policy (Automated) ......................................................... 456
3.4.3.3.2 Ensure ip6tables loopback traffic is configured (Automated) ..................................................... 459
3.4.3.3.3 Ensure ip6tables outbound and established connections are configured (Manual) ................... 462
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports (Automated) ........................................... 464
Page 6
4.3.2 Ensure sudo commands use pty (Automated) ................................................................................. 549
4.3.3 Ensure sudo log file exists (Automated) ........................................................................................... 551
4.3.4 Ensure users must provide password for privilege escalation (Automated) ..................................... 553
4.3.5 Ensure re-authentication for privilege escalation is not disabled globally (Automated) .................... 555
4.3.6 Ensure sudo authentication timeout is configured correctly (Automated)......................................... 557
4.3.7 Ensure access to the su command is restricted (Automated) .......................................................... 559
4.4 Configure PAM ............................................................................................................................. 561
4.4.1 Ensure password creation requirements are configured (Automated) ............................................. 562
4.4.2 Ensure lockout for failed password attempts is configured (Automated) .......................................... 566
4.4.3 Ensure password reuse is limited (Automated) ................................................................................ 569
4.4.4 Ensure strong password hashing algorithm is configured (Automated) ........................................... 572
4.4.5 Ensure all current passwords uses the configured hashing algorithm (Manual) .............................. 575
4.5 User Accounts and Environment ............................................................................................... 577
4.5.1 Set Shadow Password Suite Parameters ............................................................................ 578
4.5.1.1 Ensure minimum days between password changes is configured (Automated) ........................... 579
4.5.1.2 Ensure password expiration is 365 days or less (Automated) ....................................................... 581
4.5.1.3 Ensure password expiration warning days is 7 or more (Automated) ........................................... 583
4.5.1.4 Ensure inactive password lock is 30 days or less (Automated) ..................................................... 585
4.5.1.5 Ensure all users last password change date is in the past (Automated) ....................................... 587
4.5.1.6 Ensure the number of changed characters in a new password is configured (Automated) ........... 589
4.5.1.7 Ensure preventing the use of dictionary words for passwords is configured (Automated) ............ 591
4.5.2 Ensure system accounts are secured (Automated) ......................................................................... 593
4.5.3 Ensure default group for the root account is GID 0 (Automated) ..................................................... 597
4.5.4 Ensure default user umask is 027 or more restrictive (Automated) .................................................. 599
4.5.5 Ensure default user shell timeout is configured (Automated) ........................................................... 604
4.5.6 Ensure nologin is not listed in /etc/shells (Automated) ..................................................................... 609
4.5.7 Ensure maximum number of same consecutive characters in a password is configured (Automated)
.................................................................................................................................................................. 610
Page 7
5.2.1.1 Ensure auditd is installed (Automated).......................................................................................... 664
5.2.1.2 Ensure auditd service is enabled and active (Automated) ............................................................ 666
5.2.1.3 Ensure auditing for processes that start prior to auditd is enabled (Automated) ........................... 668
5.2.1.4 Ensure audit_backlog_limit is sufficient (Automated) .................................................................... 670
5.2.2 Configure Data Retention ...................................................................................................... 672
5.2.2.1 Ensure audit log storage size is configured (Automated) .............................................................. 673
5.2.2.2 Ensure audit logs are not automatically deleted (Automated) ....................................................... 675
5.2.2.3 Ensure system is disabled when audit logs are full (Automated) .................................................. 677
5.2.3 Configure auditd rules ........................................................................................................... 680
5.2.3.1 Ensure changes to system administration scope (sudoers) is collected (Automated) ................... 681
5.2.3.2 Ensure actions as another user are always logged (Automated) .................................................. 684
5.2.3.3 Ensure events that modify the sudo log file are collected (Automated) ......................................... 688
5.2.3.4 Ensure events that modify date and time information are collected (Automated) ......................... 692
5.2.3.5 Ensure events that modify the system's network environment are collected (Automated) ............ 696
5.2.3.6 Ensure use of privileged commands are collected (Automated) ................................................... 700
5.2.3.7 Ensure unsuccessful file access attempts are collected (Automated) ........................................... 704
5.2.3.8 Ensure events that modify user/group information are collected (Automated) .............................. 708
5.2.3.9 Ensure discretionary access control permission modification events are collected (Automated) .. 712
5.2.3.10 Ensure successful file system mounts are collected (Automated) .............................................. 717
5.2.3.11 Ensure session initiation information is collected (Automated) ................................................... 721
5.2.3.12 Ensure login and logout events are collected (Automated) ......................................................... 725
5.2.3.13 Ensure file deletion events by users are collected (Automated) .................................................. 728
5.2.3.14 Ensure events that modify the system's Mandatory Access Controls are collected (Automated)732
5.2.3.15 Ensure successful and unsuccessful attempts to use the chcon command are recorded
(Automated) .............................................................................................................................................. 736
5.2.3.16 Ensure successful and unsuccessful attempts to use the setfacl command are recorded
(Automated) .............................................................................................................................................. 740
5.2.3.17 Ensure successful and unsuccessful attempts to use the chacl command are recorded
(Automated) .............................................................................................................................................. 744
5.2.3.18 Ensure successful and unsuccessful attempts to use the usermod command are recorded
(Automated) .............................................................................................................................................. 748
5.2.3.19 Ensure kernel module loading unloading and modification is collected (Automated) .................. 752
5.2.3.20 Ensure the audit configuration is immutable (Automated) ........................................................... 757
5.2.3.21 Ensure the running and on disk configuration is the same (Manual) ........................................... 760
5.2.4 Configure auditd file access ................................................................................................. 762
5.2.4.1 Ensure audit log files are mode 0640 or less permissive (Automated) ......................................... 763
5.2.4.2 Ensure only authorized users own audit log files (Automated) ...................................................... 765
5.2.4.3 Ensure only authorized groups are assigned ownership of audit log files (Automated) ................ 767
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive (Automated) ......................................... 769
5.2.4.5 Ensure audit configuration files are 640 or more restrictive (Automated) ...................................... 771
5.2.4.6 Ensure audit configuration files are owned by root (Automated) ................................................... 773
5.2.4.7 Ensure audit configuration files belong to group root (Automated) ............................................... 775
5.2.4.8 Ensure audit tools are 755 or more restrictive (Automated) .......................................................... 777
5.2.4.9 Ensure audit tools are owned by root (Automated) ....................................................................... 779
5.2.4.10 Ensure audit tools belong to group root (Automated) .................................................................. 781
5.2.4.11 Ensure cryptographic mechanisms are used to protect the integrity of audit tools (Automated) . 783
Page 8
6.1.5 Ensure permissions on /etc/shadow are configured (Automated) .................................................... 795
6.1.6 Ensure permissions on /etc/shadow- are configured (Automated) ................................................... 797
6.1.7 Ensure permissions on /etc/gshadow are configured (Automated) .................................................. 799
6.1.8 Ensure permissions on /etc/gshadow- are configured (Automated) ................................................. 801
6.1.9 Ensure permissions on /etc/shells are configured (Automated) ....................................................... 803
6.1.10 Ensure permissions on /etc/opasswd are configured (Automated) ................................................ 805
6.1.11 Ensure world writable files and directories are secured (Automated) ............................................ 807
6.1.12 Ensure no unowned or ungrouped files or directories exist (Automated) ....................................... 811
6.1.13 Ensure SUID and SGID files are reviewed (Manual)...................................................................... 814
6.2 Local User and Group Settings .................................................................................................. 817
6.2.1 Ensure accounts in /etc/passwd use shadowed passwords (Automated) ........................................ 818
6.2.2 Ensure /etc/shadow password fields are not empty (Automated) .................................................... 820
6.2.3 Ensure all groups in /etc/passwd exist in /etc/group (Automated) .................................................... 822
6.2.4 Ensure shadow group is empty (Automated) ................................................................................... 823
6.2.5 Ensure no duplicate UIDs exist (Automated) ................................................................................... 825
6.2.6 Ensure no duplicate GIDs exist (Automated) ................................................................................... 826
6.2.7 Ensure no duplicate user names exist (Automated) ......................................................................... 827
6.2.8 Ensure no duplicate group names exist (Automated) ...................................................................... 828
6.2.9 Ensure root PATH Integrity (Automated).......................................................................................... 829
6.2.10 Ensure root is the only UID 0 account (Automated) ....................................................................... 831
6.2.11 Ensure local interactive user home directories are configured (Automated) .................................. 832
6.2.12 Ensure local interactive user dot files access is configured (Automated) ....................................... 836
Page 9
Overview
All CIS Benchmarks focus on technical configuration settings used to maintain and/or
increase the security of the addressed technology, and they should be used in
conjunction with other essential cyber hygiene tasks like:
• Monitoring the base operating system for vulnerabilities and quickly updating with
the latest security patches
• Monitoring applications and libraries for vulnerabilities and quickly updating with
the latest security patches
In the end, the CIS Benchmarks are designed as a key component of a comprehensive
cybersecurity program.
Page 10
Intended Audience
This benchmark is intended for system and application administrators, security
specialists, auditors, help desk, and platform deployment personnel who plan to
develop, deploy, assess, or secure solutions that incorporate a Ubuntu Linux 20.04 LTS
running on the x64 platform.
Page 11
Consensus Guidance
This CIS Benchmark was created using a consensus review process comprised of a
global community of subject matter experts. The process combines real world
experience with data-based information to create technology specific guidance to assist
users to secure their environments. Consensus participants provide perspective from a
diverse set of backgrounds including consulting, software development, audit and
compliance, security research, operations, government, and legal.
Each CIS Benchmark undergoes two phases of consensus review. The first phase
occurs during initial Benchmark development. During this phase, subject matter experts
convene to discuss, create, and test working drafts of the Benchmark. This discussion
occurs until consensus has been reached on Benchmark recommendations. The
second phase begins after the Benchmark has been published. During this phase, all
feedback provided by the Internet community is reviewed by the consensus team for
incorporation in the Benchmark. If you are interested in participating in the consensus
process, please visit https://workbench.cisecurity.org/.
Page 12
Typographical Conventions
The following typographical conventions are used throughout this guide:
Convention Meaning
Page 13
Recommendation Definitions
The following defines the various components included in a CIS recommendation as
applicable. If any of the components are not applicable it will be noted or the
component will not be included in the recommendation.
Title
Concise description for the recommendation's intended configuration.
Assessment Status
An assessment status is included for every recommendation. The assessment status
indicates whether the given recommendation can be automated or requires manual
steps to implement. Both statuses are equally important and are determined and
supported as defined below:
Automated
Represents recommendations for which assessment of a technical control can be fully
automated and validated to a pass/fail state. Recommendations will include the
necessary information to implement automation.
Manual
Represents recommendations for which assessment of a technical control cannot be
fully automated and requires all or some manual steps to validate that the configured
state is set as expected. The expected state can vary depending on the environment.
Profile
A collection of recommendations for securing a technology or a supporting platform.
Most benchmarks include at least a Level 1 and Level 2 Profile. Level 2 extends Level 1
recommendations and is not a standalone profile. The Profile Definitions section in the
benchmark provides the definitions as they pertain to the recommendations included for
the technology.
Description
Detailed information pertaining to the setting with which the recommendation is
concerned. In some cases, the description will include the recommended value.
Rationale Statement
Detailed reasoning for the recommendation to provide the user a clear and concise
understanding on the importance of the recommendation.
Page 14
Impact Statement
Any security, functionality, or operational consequences that can result from following
the recommendation.
Audit Procedure
Systematic instructions for determining if the target system complies with the
recommendation
Remediation Procedure
Systematic instructions for applying recommendations to the target system to bring it
into compliance according to the recommendation.
Default Value
Default value for the given setting in this recommendation, if known. If not known, either
not configured or not defined will be applied.
References
Additional documentation relative to the recommendation.
Additional Information
Supplementary information that does not correspond to any other field but may be
useful to the user.
Page 15
Profile Definitions
The following configuration profiles are defined by this Benchmark:
• Level 1 - Server
• Level 2 - Server
This profile extends the "Level 1 - Server" profile. Items in this profile exhibit one
or more of the following characteristics:
• Level 1 - Workstation
• Level 2 - Workstation
This profile extends the "Level 1 - Workstation" profile. Items in this profile exhibit
one or more of the following characteristics:
Page 16
This profile is intended for workstations.
Page 17
Acknowledgements
This Benchmark exemplifies the great things a community of users, vendors, and
subject matter experts can accomplish through consensus collaboration. The CIS
community thanks the entire consensus team with special recognition to the following
individuals who contributed greatly to the creation of this guide:
Page 18
This benchmark is based upon previous Linux benchmarks published and would not be
possible without the contributions provided over the history of all of these benchmarks.
The CIS community thanks everyone who has contributed to the Linux benchmarks.
Contributor
Bill Erickson
Dave Billing
Dominic Pace
Elliot Anderson
Ely Pinto
Fredrik Silverskär
Joy Latten
Koen Laevens
Mark Birch
Tom Pietschmann
Vineetha Hari Pai
Anurag Pal
Bradley Hieber
Thomas Sjögren
James Trigg
Kenneth Karlsson
Richard Costa
Alexander Scheel
Martinus Nel
Justin Brown
Graham Eames
Ron Colvin
Simon John
Tamas Tevesz
Ryan Jaynes
Chad Streck
Robert McSulla
Marcus Burghardt
Mike Cross
Matthew Burket , IBM
Mark Hesse
Tom Pietschmann
Rakesh Jain
Pradeep R B
Marcelo Cerri
Agustin Gonzalez
Tobias Brick
Lynsey Rydberg
Editor
Jonathan Lewis Christopherson
Eric Pinnell
Page 19
Recommendations
1 Initial Setup
Items in this section are advised for all systems, but may be difficult or require extensive
preparation after the initial setup of the system.
Page 20
1.1 Filesystem Configuration
Directories that are used for system-wide functions can be further protected by placing
them on separate partitions. This provides protection for resource exhaustion and
enables the use of mounting options that are applicable to the directory's intended use.
Users' data can be stored on separate partitions and have stricter mount options. A user
partition is a filesystem that has been established for use by the users and does not
contain software for system operations.
The recommendations in this section are easier to perform during initial system
installation. If the system is already installed, it is recommended that a full backup be
performed before repartitioning the system.
Note: If you are repartitioning a system that has already been installed (This may
require the system to be in single-user mode):
• Mount the new partition to a temporary mountpoint e.g. mount /dev/sda2 /mnt
• Copy data from the original partition to the new partition. e.g. cp /var/tmp/*
/mnt
• Verify that all data is present on the new partition. e.g. ls -la /mnt
• Unmount the new partition. e.g. umount /mnt
• Remove the data from the original directory that was in the old partition. e.g. rm -
Rf /var/tmp/* Otherwise it will still consume space in the old partition that will be
masked when the new filesystem is mounted.
• Mount the new partition to the desired mountpoint. e.g. mount /dev/sda2
/var/tmp
• Update /etc/fstab with the new mountpoint. e.g. /dev/sda2 /var/tmp xfs
defaults,rw,nosuid,nodev,noexec,relatime 0 0
Page 21
1.1.1 Disable unused filesystems
A number of uncommon filesystem types are supported under Linux. Removing support
for unneeded filesystem types reduces the local attack surface of the system. If a
filesystem type is not needed it should be disabled. Native Linux file systems are
designed to ensure that built-in security controls function as expected. Non-native
filesystems can lead to unexpected consequences to both the security and functionality
of the system and should be used with caution. Many filesystems are created for niche
use cases and are not maintained and supported as the operating systems are updated
and patched. Users of non-native filesystems should ensure that there is attention and
ongoing support for them, especially in light of frequent operating system changes.
Standard network connectivity and Internet access to cloud storage may make the use
of non-standard filesystem formats to directly attach heterogeneous devices much less
attractive.
Note: This should not be considered a comprehensive list of filesystems. You may wish
to consider additions to those listed here for your environment. For the current available
file system modules on the system see /usr/lib/modules/$(uname -r)/kernel/fs
Start up scripts
Kernel modules loaded directly via insmod will ignore what is configured in the relevant
/etc/modprobe.d/*.conf files. If modules are still being loaded after a reboot whilst
having the correctly configured blacklist and install command, check for insmod
entries in start up scripts such as .bashrc.
You may also want to check /lib/modprobe.d/. Please note that this directory should
not be used for user defined module loading. Ensure that all such entries resides in
/etc/modprobe.d/*.conf files.
Return values
Page 22
1.1.1.1 Ensure mounting of cramfs filesystems is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The cramfs filesystem type is a compressed read-only Linux filesystem embedded in
small footprint systems. A cramfs image can be used without having to first decompress
the image.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the cramfs module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 23
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="cramfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 24
Remediation:
Run the following script to disable the cramfs module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 25
#!/usr/bin/env bash
{
l_mname="cramfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 26
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 27
1.1.1.2 Ensure mounting of freevxfs filesystems is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The freevxfs filesystem type is a free version of the Veritas type filesystem. This is the
primary filesystem type for HP-UX operating systems.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the freevxfs module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 28
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="freevxfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 29
Remediation:
Run the following script to disable the freevxfs module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 30
#!/usr/bin/env bash
{
l_mname="freevxfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 31
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 32
1.1.1.3 Ensure mounting of jffs2 filesystems is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The jffs2 (journaling flash filesystem 2) filesystem type is a log-structured filesystem
used in flash memory devices.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the jffs2 module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 33
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="jffs2" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 34
Remediation:
Run the following script to disable the jffs2 module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 35
#!/usr/bin/env bash
{
l_mname="jffs2" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 36
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 37
1.1.1.4 Ensure mounting of hfs filesystems is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The hfs filesystem type is a hierarchical filesystem that allows you to mount Mac OS
filesystems.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the hfs module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 38
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="hfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 39
Remediation:
Run the following script to disable the hfs module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 40
#!/usr/bin/env bash
{
l_mname="hfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 41
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 42
1.1.1.5 Ensure mounting of hfsplus filesystems is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The hfsplus filesystem type is a hierarchical filesystem designed to replace hfs that
allows you to mount Mac OS filesystems.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Audit:
Run the following script to verify the hfsplus module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 43
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="hfsplus" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 44
Remediation:
Run the following script to disable the hfsplus module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 45
#!/usr/bin/env bash
{
l_mname="hfsplus" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 46
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 47
1.1.1.6 Ensure mounting of squashfs filesystems is disabled
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The squashfs filesystem type is a compressed read-only Linux filesystem embedded in
small footprint systems. A squashfs image can be used without having to first
decompress the image.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Impact:
As Snap packages utilizes squashfs as a compressed filesystem, disabling squashfs
will cause Snap packages to fail.
Snap application packages of software are self-contained and work across a range of
Linux distributions. This is unlike traditional Linux package management approaches,
like APT or RPM, which require specifically adapted packages per Linux distribution on
an application update and delay therefore application deployment from developers to
their software's end-user. Snaps themselves have no dependency on any external store
("App store"), can be obtained from any source and can be therefore used for upstream
software deployment.
Audit:
Run the following script to verify the squashfs module is disabled:
If the module is available in the running kernel:
• An entry including /bin/true or /bin/false exists in a file within the
/etc/modprobe.d/ directory
• The module is deny listed in a file within the /etc/modprobe.d/ directory
• The module is not loaded in the kernel
If the kernel module is not available on the system, or pre-compiled into the kernel:
• No additional configuration is necessary
Page 48
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="squashfs" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 49
Note: On operating systems where squashfs is pre-build into the kernel:
Remediation:
Run the following script to disable the squashfs module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 50
#!/usr/bin/env bash
{
l_mname="squashfs" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 51
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 52
1.1.1.7 Ensure mounting of udf filesystems is disabled
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The udf filesystem type is the universal disk format used to implement ISO/IEC 13346
and ECMA-167 specifications. This is an open vendor filesystem type for data storage
on a broad range of media. This filesystem type is necessary to support writing DVDs
and newer optical disc formats.
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
system. If this filesystem type is not needed, disable it.
Impact:
Microsoft Azure requires the usage of udf.
udf should not be disabled on systems run on Microsoft Azure.
Audit:
Run the following script to verify the udf module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 53
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="udf" # set module name
l_mtype="fs" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 54
Remediation:
Run the following script to disable the udf module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 55
#!/usr/bin/env bash
{
l_mname="udf" # set module name
l_mtype="fs" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 56
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 57
1.1.2 Configure /tmp
The /tmp directory is a world-writable directory used for temporary storage by all users
and some applications.
Page 58
1.1.2.1 Ensure /tmp is a separate partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /tmp directory is a world-writable directory used for temporary storage by all users
and some applications.
Rationale:
Making /tmp its own file system allows an administrator to set additional mount options
such as the noexec option on the mount, making /tmp useless for an attacker to install
executable code. It would also prevent an attacker from establishing a hard link to a
system setuid program and wait for it to be updated. Once the program was updated,
the hard link would be broken and the attacker would have his own copy of the program.
If the program happened to have a security vulnerability, the attacker could continue to
exploit the known flaw.
This can be accomplished by either mounting tmpfs to /tmp, or creating a separate
partition for /tmp.
Impact:
Since the /tmp directory is intended to be world-writable, there is a risk of resource
exhaustion if it is not bound to a separate partition.
Running out of /tmp space is a problem regardless of what kind of filesystem lies under
it, but in a configuration where /tmp is not a separate file system it will essentially have
the whole disk available, as the default installation only creates a single / partition. On
the other hand, a RAM-based /tmp (as with tmpfs) will almost certainly be much
smaller, which can lead to applications filling up the filesystem much more easily.
Another alternative is to create a dedicated partition for /tmp from a separate volume or
disk. One of the downsides of a disk-based dedicated partition is that it will be slower
than tmpfs which is RAM-based.
/tmp utilizing tmpfs can be resized using the size={size} parameter in the relevant
entry in /etc/fstab.
Page 59
Audit:
Run the following command and verify the output shows that /tmp is mounted. Particular
requirements pertaining to mount options are covered in ensuing sections.
# findmnt -nk /tmp
Example output:
/tmp tmpfs tmpfs rw,nosuid,nodev,noexec
Remediation:
For specific configuration requirements of the /tmp mount for your environment, modify
/etc/fstab or tmp.mount unit file:
Using /etc/fstab:
Configure /etc/fstab as appropriate:
Example:
tmpfs /tmp tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
-OR-
Using a tmp.mount unit file:
Run the following command to create the tmp.mount file is the correct location:
# cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
Edit /etc/systemd/system/tmp.mount to configure the /tmp mount:
Example:
Page 60
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Temporary Directory (/tmp)
Documentation=https://systemd.io/TEMPORARY_DIRECTORIES
Documentation=man:file-hierarchy(7)
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystem
s
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev,noexec
[Install]
WantedBy=local-fs.target
Run the following command to reload the systemd daemon with the updated tmp.mount
unit file:
# systemctl daemon-reload
Run the following command to enable and start tmp.mount
# systemctl --now enable tmp.mount
Note: A reboot may be required to transition to /tmp mounted to tmpfs
References:
1. https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems/
2. https://www.freedesktop.org/software/systemd/man/systemd-fstab-generator.html
3. NIST SP 800-53 Rev. 5: CM-7
Page 61
Additional Information:
If an entry for /tmp exists in /etc/fstab it will take precedence over entries in systemd
unit file.
tmpfs can be resized using the size={size} parameter in /etc/fstab or on the Options line
in the tmp.mount file. If we don't specify the size, it will be half the RAM
Example resize entry:
/etc/fstab:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 62
1.1.2.2 Ensure nodev option set on /tmp partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /tmp filesystem is not intended to support devices, set this option to ensure
that users cannot create block or character special devices in /tmp.
Audit:
Verify that the nodev option is set for the /tmp mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /tmp | grep nodev
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the /tmp
partition.
Example:
<device> /tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp
References:
Page 63
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 64
1.1.2.3 Ensure noexec option set on /tmp partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /tmp filesystem is only intended for temporary file storage, set this option to
ensure that users cannot run executable binaries from /tmp.
Audit:
Verify that the noexec option is set for the /tmp mount.
Run the following command to verify that the noexec mount option is set.
Example:
# findmnt -kn /tmp | grep noexec
Remediation:
Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the
/tmp partition.
Example:
<device> /tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp
References:
Page 65
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 66
1.1.2.4 Ensure nosuid option set on /tmp partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /tmp filesystem is only intended for temporary file storage, set this option to
ensure that users cannot create setuid files in /tmp.
Audit:
Verify that the nosuid option is set for the /tmp mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /tmp | grep nosuid
Remediation:
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the
/tmp partition.
Example:
<device> /tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /tmp with the configured options:
# mount -o remount /tmp
References:
Page 67
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 68
1.1.3 Configure /var
The /var directory is used by daemons and other system services to temporarily store
dynamic data. Some directories created by these processes may be world-writable.
Page 69
1.1.3.1 Ensure separate partition exists for /var (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The /var directory is used by daemons and other system services to temporarily store
dynamic data. Some directories created by these processes may be world-writable.
Rationale:
The reasoning for mounting /var on a separate partition is as follow.
Protection from resource exhaustion
The default installation only creates a single / partition. Since the /var directory may
contain world-writable files and directories, there is a risk of resource exhaustion. It will
essentially have the whole disk available to fill up and impact the system as a whole. In
addition, other operations on the system could fill up the disk unrelated to /var and
cause unintended behavior across the system as the disk is full. See man auditd.conf
for details.
Fine grained control over the mount
Configuring /var as its own file system allows an administrator to set additional mount
options such as noexec/nosuid/nodev. These options limits an attackers ability to create
exploits on the system. Other options allow for specific behaviour. See man mount for
exact details regarding filesystem-independent and filesystem-specific options.
Protection from exploitation
Page 70
Audit:
Run the following command and verify output shows /var is mounted.
Example:
# findmnt -kn /var
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var it is advisable to bring the system to emergency mode (so auditd
is not running), rename the existing directory, mount the new file system, and migrate
the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 71
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 72
1.1.3.2 Ensure nodev option set on /var partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var filesystem is not intended to support devices, set this option to ensure
that users cannot create block or character special devices in /var.
Audit:
Verify that the nodev option is set for the /var mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /var | grep -v 'nodev'
Remediation:
IF the /var partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /var partition.
Example:
<device> /var <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /var with the configured options:
# mount -o remount /var
References:
Page 73
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 74
1.1.3.3 Ensure nosuid option set on /var partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var filesystem is only intended for variable files such as logs, set this option
to ensure that users cannot create setuid files in /var.
Audit:
Verify that the nosuid option is set for the /var mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /var | grep -v 'nosuid'
Remediation:
IF the /var partition exists, edit the /etc/fstab file and add nosuid to the fourth field
(mounting options) for the /var partition.
Example:
<device> /var <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /var with the configured options:
# mount -o remount /var
References:
Page 75
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 76
1.1.4 Configure /var/tmp
The /var/tmp directory is a world-writable directory used for temporary storage by all
users and some applications. Temporary files residing in /var/tmp are to be preserved
between reboots.
Page 77
1.1.4.1 Ensure separate partition exists for /var/tmp (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The /var/tmp directory is a world-writable directory used for temporary storage by all
users and some applications. Temporary files residing in /var/tmp are to be preserved
between reboots.
Rationale:
The reasoning for mounting /var/tmp on a separate partition is as follows.
Protection from resource exhaustion
The default installation only creates a single / partition. Since the /var/tmp directory
may contain world-writable files and directories, there is a risk of resource exhaustion. It
will essentially have the whole disk available to fill up and impact the system as a whole.
In addition, other operations on the system could fill up the disk unrelated to /var/tmp
and cause the potential disruption to daemons as the disk is full.
Fine grained control over the mount
Configuring /var/tmp as its own file system allows an administrator to set additional
mount options such as noexec/nosuid/nodev. These options limits an attackers ability to
create exploits on the system. Other options allow for specific behavior. See man mount
for exact details regarding filesystem-independent and filesystem-specific options.
Protection from exploitation
Page 78
Audit:
Run the following command and verify output shows /var/tmp is mounted.
Example:
# findmnt -kn /var/tmp
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var/tmp.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var/tmp it is advisable to bring the system to emergency mode (so
auditd is not running), rename the existing directory, mount the new file system, and
migrate the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 79
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 80
1.1.4.2 Ensure nodev option set on /var/tmp partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var/tmp filesystem is not intended to support devices, set this option to
ensure that users cannot create block or character special devices in /var/tmp.
Audit:
Verify that the nodev option is set for the /var/tmp mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /var/tmp | grep -v 'nodev'
Remediation:
IF the /var/tmp partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /var/tmp partition.
Example:
<device> /var/tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0
0
Run the following command to remount /var/tmp with the configured options:
# mount -o remount /var/tmp
References:
Page 81
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 82
1.1.4.3 Ensure noexec option set on /var/tmp partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /var/tmp filesystem is only intended for temporary file storage, set this option
to ensure that users cannot run executable binaries from /var/tmp.
Audit:
Verify that the noexec option is set for the /var/tmp mount.
Run the following command to verify that the noexec mount option is set.
Example:
# findmnt -kn /var/tmp | grep -v 'noexec'
Remediation:
IF the /var/tmp partition exists, edit the /etc/fstab file and add noexec to the fourth
field (mounting options) for the /var/tmp partition.
Example:
<device> /var/tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0
0
Run the following command to remount /var/tmp with the configured options:
# mount -o remount /var/tmp
References:
Page 83
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 84
1.1.4.4 Ensure nosuid option set on /var/tmp partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var/tmp filesystem is only intended for temporary file storage, set this option
to ensure that users cannot create setuid files in /var/tmp.
Audit:
Verify that the nosuid option is set for the /var/tmp mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /var/tmp | grep -v 'nosuid'
Remediation:
IF the /var/tmp partition exists, edit the /etc/fstab file and add nosuid to the fourth
field (mounting options) for the /var/tmp partition.
Example:
<device> /var/tmp <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0
0
Run the following command to remount /var/tmp with the configured options:
# mount -o remount /var/tmp
References:
Page 85
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 86
1.1.5 Configure /var/log
Page 87
1.1.5.1 Ensure separate partition exists for /var/log (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The /var/log directory is used by system services to store log data.
Rationale:
The reasoning for mounting /var/log on a separate partition is as follows.
Protection from resource exhaustion
The default installation only creates a single / partition. Since the /var/log directory
contains log files which can grow quite large, there is a risk of resource exhaustion. It
will essentially have the whole disk available to fill up and impact the system as a whole.
Fine grained control over the mount
Configuring /var/log as its own file system allows an administrator to set additional
mount options such as noexec/nosuid/nodev. These options limits an attackers ability to
create exploits on the system. Other options allow for specific behavior. See man mount
for exact details regarding filesystem-independent and filesystem-specific options.
Protection of log data
As /var/log contains log files, care should be taken to ensure the security and integrity
of the data and mount point.
Impact:
Resizing filesystems is a common activity in cloud-hosted servers. Separate filesystem
partitions may prevent successful resizing, or may require the installation of additional
tools solely for the purpose of resizing operations. The use of these additional tools may
introduce their own security considerations.
Page 88
Audit:
Run the following command and verify output shows /var/log is mounted:
# findmnt -kn /var/log
Example output:
/var/log /dev/sdb ext4 rw,relatime,seclabel,data=ordered
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var/log .
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var/log it is advisable to bring the system to emergency mode (so
auditd is not running), rename the existing directory, mount the new file system, and
migrate the data over before returning to multiuser mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 89
1.1.5.2 Ensure nodev option set on /var/log partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var/log filesystem is not intended to support devices, set this option to
ensure that users cannot create block or character special devices in /var/log.
Audit:
Verify that the nodev option is set for the /var/log mount.
Run the following command to verify that the nodev mount option is set.
Example:
# findmnt -kn /var/log | grep -v 'nodev'
Remediation:
IF the /var/log partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /var/log partition.
Example:
<device> /var/log <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0
0
Run the following command to remount /var/log with the configured options:
# mount -o remount /var/log
References:
Page 90
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 91
1.1.5.3 Ensure noexec option set on /var/log partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /var/log filesystem is only intended for log files, set this option to ensure that
users cannot run executable binaries from /var/log.
Audit:
Verify that the noexec option is set for the /var/log mount.
Run the following command to verify that the noexec mount option is set.
Example:
# findmnt -kn /var/log | grep -v 'noexec'
Remediation:
IF the /var/log partition exists, edit the /etc/fstab file and add noexec to the fourth
field (mounting options) for the /var/log partition.
Example:
<device> /var/log <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0
0
Run the following command to remount /var/log with the configured options:
# mount -o remount /var/log
References:
Page 92
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 93
1.1.5.4 Ensure nosuid option set on /var/log partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var/log filesystem is only intended for log files, set this option to ensure that
users cannot create setuid files in /var/log.
Audit:
Verify that the nosuid option is set for the /var/log mount.
Run the following command to verify that the nosuid mount option is set.
Example:
# findmnt -kn /var/log | grep -v 'nosuid'
Remediation:
IF the /var/log partition exists, edit the /etc/fstab file and add nosuid to the fourth
field (mounting options) for the /var/log partition.
Example:
<device> /var/log <fstype> defaults,rw,nosuid,nodev,noexec,relatime 0
0
Run the following command to remount /var/log with the configured options:
# mount -o remount /var/log
References:
Page 94
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 95
1.1.6 Configure /var/log/audit
The auditing daemon, auditd, stores log data in the /var/log/audit directory.
Page 96
1.1.6.1 Ensure separate partition exists for /var/log/audit
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The auditing daemon, auditd, stores log data in the /var/log/audit directory.
Rationale:
The reasoning for mounting /var/log/audit on a separate partition is as follows.
Protection from resource exhaustion
The default installation only creates a single / partition. Since the /var/log/audit
directory contains the audit.log file which can grow quite large, there is a risk of
resource exhaustion. It will essentially have the whole disk available to fill up and impact
the system as a whole. In addition, other operations on the system could fill up the disk
unrelated to /var/log/audit and cause auditd to trigger it's space_left_action as the
disk is full. See man auditd.conf for details.
Fine grained control over the mount
As /var/log/audit contains audit logs, care should be taken to ensure the security and
integrity of the data and mount point.
Impact:
Resizing filesystems is a common activity in cloud-hosted servers. Separate filesystem
partitions may prevent successful resizing, or may require the installation of additional
tools solely for the purpose of resizing operations. The use of these additional tools may
introduce their own security considerations.
Page 97
Audit:
Run the following command and verify output shows /var/log/audit is mounted:
# findmnt -kn /var/log/audit
Example output:
/var/log/audit /dev/sdb ext4 rw,relatime,seclabel,data=ordered
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /var/log/audit.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /var/log/audit it is advisable to bring the system to emergency mode
(so auditd is not running), rename the existing directory, mount the new file system, and
migrate the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 98
1.1.6.2 Ensure nodev option set on /var/log/audit partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /var/log/audit filesystem is not intended to support devices, set this option
to ensure that users cannot create block or character special devices in
/var/log/audit.
Audit:
Verify that the nodev option is set for the /var/log/audit mount.
Run the following command to verify that the nodev mount option is set.
# findmnt -kn /var/log/audit | grep -v 'nodev'
Remediation:
IF the /var/log/audit partition exists, edit the /etc/fstab file and add nodev to the
fourth field (mounting options) for the /var/log/audit partition.
Example:
<device> /var/log/audit <fstype>
defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log/audit with the configured options:
# mount -o remount /var/log/audit
References:
Page 99
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 100
1.1.6.3 Ensure noexec option set on /var/log/audit partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Since the /var/log/audit filesystem is only intended for audit logs, set this option to
ensure that users cannot run executable binaries from /var/log/audit.
Audit:
Verify that the noexec option is set for the /var/log/audit mount.
Run the following command to verify that the noexec mount option is set.
# findmnt -kn /var/log/audit | grep -v 'noexec'
Remediation:
IF the /var/log/audit partition exists, edit the /etc/fstab file and add noexec to the
fourth field (mounting options) for the /var partition.
Example:
<device> /var/log/audit <fstype>
defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log/audit with the configured options:
# mount -o remount /var/log/audit
References:
Page 101
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 102
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /var/log/audit filesystem is only intended for variable files such as logs, set
this option to ensure that users cannot create setuid files in /var/log/audit.
Audit:
Verify that the nosuid option is set for the /var/log/audit mount.
Run the following command to verify that the nosuid mount option is set.
# findmnt -kn /var/log/audit | grep -v 'nosuid'
Remediation:
IF the /var/log/audit partition exists, edit the /etc/fstab file and add nosuid to the
fourth field (mounting options) for the /var/log/audit partition.
Example:
<device> /var/log/audit <fstype>
defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /var/log/audit with the configured options:
# mount -o remount /var/log/audit
References:
Page 103
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 104
1.1.7 Configure /home
Please note that home directories could be mounted anywhere and are not necessarily
restricted to /home nor restricted to a single location, nor is the name restricted in any
way.
Checks can be made by looking in /etc/passwd, looking over the mounted file systems
with mount or querying the relevant database with getent.
Page 105
1.1.7.1 Ensure separate partition exists for /home (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The /home directory is used to support disk storage needs of local users.
Rationale:
The reasoning for mounting /home on a separate partition is as follows.
Protection from resource exhaustion
The default installation only creates a single / partition. Since the /home directory
contains user generated data, there is a risk of resource exhaustion. It will essentially
have the whole disk available to fill up and impact the system as a whole. In addition,
other operations on the system could fill up the disk unrelated to /home and impact all
local users.
Fine grained control over the mount
Configuring /home as its own file system allows an administrator to set additional mount
options such as noexec/nosuid/nodev. These options limits an attackers ability to create
exploits on the system. In the case of /home options such as usrquota/grpquota may be
considered to limit the impact that users can have on each other with regards to disk
resource exhaustion. Other options allow for specific behavior. See man mount for exact
details regarding filesystem-independent and filesystem-specific options.
Protection of user data
As /home contains user data, care should be taken to ensure the security and integrity of
the data and mount point.
Impact:
Resizing filesystems is a common activity in cloud-hosted servers. Separate filesystem
partitions may prevent successful resizing, or may require the installation of additional
tools solely for the purpose of resizing operations. The use of these additional tools may
introduce their own security considerations.
Page 106
Audit:
Run the following command and verify output shows /home is mounted:
# findmnt -kn /home
Example output:
/home /dev/sdb ext4 rw,relatime,seclabel
Remediation:
For new installations, during installation create a custom partition setup and specify a
separate partition for /home.
For systems that were previously installed, create a new partition and configure
/etc/fstab as appropriate.
References:
Additional Information:
When modifying /home it is advisable to bring the system to emergency mode (so auditd
is not running), rename the existing directory, mount the new file system, and migrate
the data over before returning to multi-user mode.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 107
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 108
1.1.7.2 Ensure nodev option set on /home partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /home filesystem is not intended to support devices, set this option to ensure
that users cannot create block or character special devices in /home.
Audit:
Verify that the nodev option is set for the /home mount.
Run the following command to verify that the nodev mount option is set.
# findmnt -kn /home | grep -v 'nodev'
Remediation:
IF the /home partition exists, edit the /etc/fstab file and add nodev to the fourth field
(mounting options) for the /home partition.
Example:
<device> /home <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /home with the configured options:
# mount -o remount /home
References:
Page 109
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 110
1.1.7.3 Ensure nosuid option set on /home partition (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Since the /home filesystem is only intended for user file storage, set this option to ensure
that users cannot create setuid files in /home.
Audit:
Verify that the nosuid option is set for the /home mount.
Run the following command to verify that the nosuid mount option is set.
# findmnt -kn /home | grep -v 'nosuid'
Remediation:
IF the /home partition exists, edit the /etc/fstab file and add nosuid to the fourth field
(mounting options) for the /home partition.
Example:
<device> /home <fstype> defaults,rw,nosuid,nodev,relatime 0 0
Run the following command to remount /home with the configured options:
# mount -o remount /home
References:
Page 111
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 112
1.1.8 Configure /dev/shm
Page 113
1.1.8.1 Ensure nodev option set on /dev/shm partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nodev mount option specifies that the filesystem cannot contain special devices.
Rationale:
Since the /dev/shm filesystem is not intended to support devices, set this option to
ensure that users cannot attempt to create special devices in /dev/shm partitions.
Audit:
Verify that the nodev option is set for the /dev/shm mount.
Run the following command to verify that the nodev mount option is set.
# findmnt -kn /dev/shm | grep -v 'nodev'
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options) for the
/dev/shm partition. See the fstab(5) manual page for more information.
Example:
tmpfs /dev/shm tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /dev/shm with the configured options:
# mount -o remount /dev/shm
NOTE It is recommended to use tmpfs as the device/filesystem type as /dev/shm is
used as shared memory space by applications.
References:
Page 114
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.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 115
1.1.8.2 Ensure noexec option set on /dev/shm partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The noexec mount option specifies that the filesystem cannot contain executable
binaries.
Rationale:
Setting this option on a file system prevents users from executing programs from shared
memory. This deters users from introducing potentially malicious software on the
system.
Audit:
Verify that the noexec option is set for the /dev/shm mount.
Run the following command to verify that the noexec mount option is set.
# findmnt -kn /dev/shm | grep -v 'noexec'
Remediation:
Edit the /etc/fstab file and add noexec to the fourth field (mounting options) for the
/dev/shm partition.
Example:
tmpfs /dev/shm tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /dev/shm with the configured options:
# mount -o remount /dev/shm
Note: It is recommended to use tmpfs as the device/filesystem type as /dev/shm is used
as shared memory space by applications.
References:
Page 116
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 117
1.1.8.3 Ensure nosuid option set on /dev/shm partition
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nosuid mount option specifies that the filesystem cannot contain setuid files.
Rationale:
Setting this option on a file system prevents users from introducing privileged programs
onto the system and allowing non-root users to execute them.
Audit:
Verify that the nosuid option is set for the /dev/shm mount.
Run the following command to verify that the nosuid mount option is set.
# findmnt -kn /dev/shm | grep -v 'nosuid'
Remediation:
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options) for the
/dev/shm partition. See the fstab(5) manual page for more information.
Example:
tmpfs /dev/shm tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
Run the following command to remount /dev/shm with the configured options:
# mount -o remount /dev/shm
Note: It is recommended to use tmpfs as the device/filesystem type as /dev/shm is used
as shared memory space by applications.
References:
Additional Information:
Some distributions mount /dev/shm through other means and require /dev/shm to be
added to /etc/fstab even though it is already being mounted on boot. Others may
configure /dev/shm in other locations and may override /etc/fstab configuration.
Consult the documentation appropriate for your distribution.
Page 118
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 119
1.1.9 Disable Automounting (Automated)
Profile Applicability:
• Level 1 - Server
• Level 2 - Workstation
Description:
autofs allows automatic mounting of devices, typically including CD/DVDs and USB
drives.
Rationale:
With automounting enabled anyone with physical access could attach a USB drive or
disc and have its contents available in the filesystem even if they lacked permissions to
mount it themselves.
Impact:
The use of portable hard drives is very common for workstation users. If your
organization allows the use of portable storage or media on workstations and physical
access controls to workstations are considered adequate there is little value add in
turning off automounting.
Audit:
As a preference autofs should not be installed unless other packages depend on it.
Run the following command to verify autofs is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
autofs
Page 120
Remediation:
If there are no other packages that depends on autofs, remove the package with:
# apt purge autofs
-OR- if there are dependencies on the autofs package:
Run the following commands to mask autofs:
# systemctl stop autofs
# systemctl mask autofs
References:
Additional Information:
This control should align with the tolerance of the use of portable drives and optical
media in the organization. On a server, requiring an admin to manually mount media
can be part of defense-in-depth to reduce the risk of unapproved software or information
being introduced or proprietary software or information being exfiltrated. If admins
commonly use flash drives and Server access has sufficient physical controls, requiring
manual mounting may not increase security.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 121
1.1.10 Disable USB Storage (Automated)
Profile Applicability:
• Level 1 - Server
• Level 2 - Workstation
Description:
USB storage provides a means to transfer and store files insuring persistence and
availability of the files independent of network connection status. Its popularity and utility
has led to USB-based malware being a simple and common means for network
infiltration and a first step to establishing a persistent threat within a networked
environment.
Rationale:
Restricting USB access on the system will decrease the physical attack surface for a
device and diminish the possible vectors to introduce malware.
Impact:
Disabling the usb-storage module will disable any usage of USB storage devices.
If requirements and local site policy allow the use of such devices, other solutions
should be configured accordingly instead. One example of a commonly used solution is
USBGuard.
Audit:
Run the following script to verify the usb-storage module is disabled:
If the module is available in the running kernel:
Page 122
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="usb-storage" # set module name
l_mtype="drivers" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 123
Remediation:
Run the following script to disable the cramfs module:
If the module is available in the running kernel:
• No remediation is necessary
Page 124
#!/usr/bin/env bash
{
l_mname="usb-storage" # set module name
l_mtype="drivers" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
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.
Page 125
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 126
1.2 Filesystem Integrity Checking
AIDE is a file integrity checking tool, similar in nature to Tripwire. While it cannot prevent
intrusions, it can detect unauthorized changes to configuration files by alerting when the
files are changed. When setting up AIDE, decide internally what the site policy will be
concerning integrity checking. Review the AIDE quick start guide and AIDE
documentation before proceeding.
Page 127
1.2.1 Ensure AIDE is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
AIDE takes a snapshot of filesystem state including modification times, permissions,
and file hashes which can then be used to compare against the current state of the
filesystem to detect modifications to the system.
Rationale:
By monitoring the filesystem state compromised files can be detected to prevent or limit
the exposure of accidental or malicious misconfigurations or modified binaries.
Audit:
Run the following commands to verify AIDE is installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' aide
aide-common
Remediation:
Install AIDE using the appropriate package manager or manual installation:
# apt install aide aide-common
Configure AIDE as appropriate for your environment. Consult the AIDE documentation
for options.
Run the following commands to initialize AIDE:
# aideinit
# mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db
References:
Additional Information:
The prelinking feature can interfere with AIDE because it alters binaries to speed up
their start up times. Run prelink -ua to restore the binaries to their prelinked state, thus
avoiding false positives from AIDE.
Page 128
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1036, T1036.002,
T1036.003, T1036.004,
T1036.005, T1565,
T1565.001
Page 129
1.2.2 Ensure filesystem integrity is regularly checked (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Periodic checking of the filesystem integrity is needed to detect changes to the
filesystem.
Rationale:
Periodic file checking allows the system administrator to determine on a regular basis if
critical files have been changed in an unauthorized fashion.
Audit:
Run the following commands to verify a cron job scheduled to run the aide check.
# grep -Prs '^([^#\n\r]+\h+)?(\/usr\/s?bin\/|^\h*)aide(\.wrapper)?\h+(--
check|([^#\n\r]+\h+)?\$AIDEARGS)\b' /etc/cron.* /etc/crontab /var/spool/cron/
Ensure a cron job in compliance with site policy is returned.
OR
Run the following commands to verify that aidecheck.service and aidecheck.timer are
enabled and aidecheck.timer is running
# systemctl is-enabled aidecheck.service
Page 130
Remediation:
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/bin/aide.wrapper --config /etc/aide/aide.conf --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/bin/aide.wrapper --config /etc/aide/aide.conf --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
References:
1. https://github.com/konstruktoid/hardening/blob/master/config/aidecheck.service
2. https://github.com/konstruktoid/hardening/blob/master/config/aidecheck.timer
3. NIST SP 800-53 Rev. 5: AU-2
Page 131
Additional Information:
The checking in this recommendation occurs every day at 5am. Alter the frequency and
time of the checks in compliance with site policy
systemd timers, timer file aidecheck.timer and service file aidecheck.service, have
been included as an optional alternative to using cron
Ubuntu advises using /usr/bin/aide.wrapper rather than calling /usr/bin/aide directly
in order to protect the database and prevent conflicts
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1036, T1036.002,
T1036.003, T1036.004,
TA0040 M1022
T1036.005, T1565,
T1565.001
Page 132
1.3 Configure Software and Patch Management
Outdated software is vulnerable to cyber criminals and hackers. Software updates help
reduce the risk to your organization. The release of software update notes often reveal
the patched exploitable entry points to the public. Public knowledge of these exploits
cans your organization more vulnerable to malicious actors attempting to gain entry to
your system's data.
Software updates often offer new and improved features and speed enhancements
Page 133
1.3.1 Ensure updates, patches, and additional security software
are installed (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Periodically patches are released for included software either due to security flaws or to
include additional functionality.
Rationale:
Newer patches may contain security enhancements that would not be available through
the latest full update. As a result, it is recommended that the latest software patches be
used to take advantage of the latest functionality. As with any software installation,
organizations need to determine if a given update meets their requirements and verify
the compatibility and supportability of any additional software against the update
revision that is selected.
Audit:
Verify there are no updates or patches to install:
# apt -s upgrade
Remediation:
Run the following command to update all packages following local site policy guidance
on applying updates and patches:
# apt upgrade
OR
# apt dist-upgrade
References:
Page 134
Additional Information:
Site policy may mandate a testing period before install onto production systems for
available updates.
• upgrade - is used to install the newest versions of all packages currently installed
on the system from the sources enumerated in /etc/apt/sources.list. Packages
currently installed with new versions available are retrieved and upgraded; under
no circumstances are currently installed packages removed, or packages not
already installed retrieved and installed. New versions of currently installed
packages that cannot be upgraded without changing the install status of another
package will be left at their current version. An update must be performed first so
that apt knows that new versions of packages are available.
• dist-upgrade - in addition to performing the function of upgrade, also intelligently
handles changing dependencies with new versions of packages; apt has a
"smart" conflict resolution system, and it will attempt to upgrade the most
important packages at the expense of less important ones if necessary. So, dist-
upgrade command may remove some packages. The /etc/apt/sources.list file
contains a list of locations from which to retrieve desired package files. See also
apt_preferences(5) for a mechanism for overriding the general settings for
individual packages.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 135
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 136
1.3.2 Ensure package manager repositories are configured
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Systems need to have package manager repositories configured to ensure they receive
the latest patches and updates.
Rationale:
If a system's package repositories are misconfigured important patches may not be
identified or a rogue repository could introduce compromised software.
Audit:
Run the following command and verify package repositories are configured correctly:
# apt-cache policy
Remediation:
Configure your package manager repositories according to site policy.
References:
Page 137
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 138
1.3.3 Ensure GPG keys are configured (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Most packages managers implement GPG key signing to verify package integrity during
installation.
Rationale:
It is important to ensure that updates are obtained from a valid source to protect against
spoofing that could lead to the inadvertent installation of malware on the system.
Audit:
Verify GPG keys are configured correctly for your package manager:
# apt-key list
Remediation:
Update your package manager GPG keys in accordance with site policy.
References:
Page 139
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1195, T1195.001,
TA0001 M1051
T1195.002
Page 140
1.4 Secure Boot Settings
The recommendations in this section focus on securing the bootloader and settings
involved in the boot process directly.
Page 141
1.4.1 Ensure bootloader password is set (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting the boot loader password will require that anyone rebooting the system must
enter a password before being able to set command line boot parameters
Rationale:
Requiring a boot password upon execution of the boot loader will prevent an
unauthorized user from entering boot parameters or changing the boot partition. This
prevents users from weakening security (e.g. turning off AppArmor at boot time).
Impact:
If password protection is enabled, only the designated superuser can edit a GRUB 2
menu item by pressing "e" or access the GRUB 2 command line by pressing "c"
If GRUB 2 is set up to boot automatically to a password-protected menu entry the user
has no option to back out of the password prompt to select another menu entry. Holding
the SHIFT key will not display the menu in this case. The user must enter the correct
username and password. If unable to do so, the configuration files will have to be edited
via a LiveCD or other means to fix the problem
You can add --unrestricted to the menu entries to allow the system to boot without
entering a password. A password will still be required to edit menu items.
More Information: https://help.ubuntu.com/community/Grub2/Passwords
Audit:
Run the following commands and verify output matches:
# grep "^set superusers" /boot/grub/grub.cfg
set superusers="<username>"
# grep "^password" /boot/grub/grub.cfg
Page 142
Remediation:
Create an encrypted password with grub-mkpasswd-pbkdf2:
# grub-mkpasswd-pbkdf2
Default Value:
This recommendation is designed around the grub bootloader, if LILO or another
bootloader is in use in your environment enact equivalent settings.
Replace /boot/grub/grub.cfg with the appropriate grub configuration file for your
environment.
References:
Additional Information:
Changes to /etc/grub.d/10_linux may be overwritten during updates to the grub-
common package. You should review any changes to this file before rebooting otherwise
the system may unexpectedly prompt for a password on the next boot.
Page 143
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 144
1.4.2 Ensure permissions on bootloader config are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The grub configuration file contains information on boot settings and passwords for
unlocking boot options.
Rationale:
Setting the permissions to read and write for root only prevents non-root users from
seeing the boot parameters or changing them. Non-root users who read the boot
parameters may be able to identify weaknesses in security upon boot and be able to
exploit them.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access is 0600
or more restrictive.
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)'
/boot/grub/grub.cfg
Remediation:
Run the following commands to set permissions on your grub configuration:
# chown root:root /boot/grub/grub.cfg
# chmod u-x,go-rwx /boot/grub/grub.cfg
References:
Additional Information:
This recommendation is designed around the grub bootloader, if LILO or another
bootloader is in use in your environment enact equivalent settings.
Replace /boot/grub/grub.cfg with the appropriate grub configuration file for your
environment
Page 145
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 146
1.4.3 Ensure authentication required for single user mode
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Single user mode is used for recovery when the system detects an issue during boot or
by manual selection from the bootloader.
Rationale:
Requiring authentication in single user mode prevents an unauthorized user from
rebooting the system into single user to gain root privileges without credentials.
Audit:
Perform the following to determine if a password is set for the root user:
# grep -Eq '^root:\$[0-9]' /etc/shadow || echo "root is locked"
No results should be returned.
Remediation:
Run the following command and follow the prompts to set a password for the root user:
# passwd root
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 147
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 148
1.5 Additional Process Hardening
Page 149
1.5.1 Ensure prelink is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
prelink is a program that modifies ELF shared libraries and ELF dynamically linked
binaries in such a way that the time needed for the dynamic linker to perform relocations
at startup significantly decreases.
Rationale:
The prelinking feature can interfere with the operation of AIDE, because it changes
binaries. Prelinking can also increase the vulnerability of the system if a malicious user
is able to compromise a common library such as libc.
Audit:
Verify prelink is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
prelink
Remediation:
Run the following command to restore binaries to normal:
# prelink -ua
Uninstall prelink using the appropriate package manager or manual installation:
# apt purge prelink
References:
Page 150
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 151
1.5.2 Ensure address space layout randomization (ASLR) is
enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Address space layout randomization (ASLR) is an exploit mitigation technique which
randomly arranges the address space of key data areas of a process.
Rationale:
Randomly placing virtual memory regions will make it difficult to write memory page
exploits as the memory placement will be consistently shifting.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• kernel.randomize_va_space is set to 2
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 152
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=(kernel.randomize_va_space=2)
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 153
Remediation:
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• kernel.randomize_va_space = 2
Example:
# printf "
kernel.randomize_va_space = 2
" >> /etc/sysctl.d/60-kernel_sysctl.conf
Run the following command to set the active kernel parameter:
# sysctl -w kernel.randomize_va_space=2
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
kernel.randomize_va_space = 2
References:
1. http://manpages.ubuntu.com/manpages/focal/man5/sysctl.d.5.html
2. CCI-000366: The organization implements the security configuration settings
3. NIST SP 800-53 Rev. 5: CM-6
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 154
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 155
1.5.3 Ensure ptrace_scope is restricted (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The ptrace() system call provides a means by which one process (the "tracer") may
observe and control the execution of another process (the "tracee"), and examine and
change the tracee's memory and registers.
Rationale:
If one application is compromised, it would be possible for an attacker to attach to other
running processes (e.g. Bash, Firefox, SSH sessions, GPG agent, etc) to extract
additional credentials and continue to expand the scope of their attack.
Enabling restricted mode will limit the ability of a compromised process to
PTRACE_ATTACH on other processes running under the same user. With restricted
mode, ptrace will continue to work with root user.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• kernel.yama.ptrace_scope is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 156
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("kernel.yama.ptrace_scope=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 157
Remediation:
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• kernel.yama.ptrace_scope = 1
Example:
# printf "
kernel.yama.ptrace_scope = 1
" >> /etc/sysctl.d/60-kernel_sysctl.conf
Run the following command to set the active kernel parameter:
# sysctl -w kernel.yama.ptrace_scope=1
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
kernel.yama.ptrace_scope=1
References:
1. https://www.kernel.org/doc/Documentation/security/Yama.txt
2. https://github.com/raj3shp/termspy
Additional Information:
Ptrace is very rarely used by regular applications and is mostly used by debuggers such
as gdb and strace.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 158
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1055.008
Page 159
1.5.4 Ensure Automatic Error Reporting is not enabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Apport Error Reporting Service automatically generates crash reports for
debugging
Rationale:
Apport collects potentially sensitive data, such as core dumps, stack traces, and log
files. They can contain passwords, credit card numbers, serial numbers, and other
private material.
Audit:
Run the following command to verify that the Apport Error Reporting Service is not
enabled:
# dpkg-query -s apport > /dev/null 2>&1 && grep -Psi --
'^\h*enabled\h*=\h*[^0]\b' /etc/default/apport
Nothing should be returned
Run the following command to verify that the apport service is not active:
# systemctl is-active apport.service | grep '^active'
Nothing should be returned
Remediation:
Edit /etc/default/apport and add or edit the enabled parameter to equal 0:
enabled=0
Run the following commands to stop and disable the apport service
# systemctl stop apport.service
# systemctl --now disable apport.service
-- OR --
Run the following command to remove the apport package:
# apt purge apport
Default Value:
enabled=1
Page 160
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 161
1.5.5 Ensure core dumps are restricted (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
A core dump is the memory of an executable program. It is generally used to determine
why a program aborted. It can also be used to glean confidential information from a core
file. The system provides the ability to set a soft limit for core dumps, but this can be
overridden by the user.
Rationale:
Setting a hard limit on core dumps prevents users from overriding the soft variable. If
core dumps are required, consider setting limits for user groups (see limits.conf(5) ).
In addition, setting the fs.suid_dumpable variable to 0 will prevent setuid programs from
dumping core.
Audit:
Run the following command and verify output matches:
# grep -Es '^(\*|\s).*hard.*core.*(\s+#.*)?$' /etc/security/limits.conf
/etc/security/limits.d/*
* hard core 0
Run the following script to verify fs.suid_dumpable = 0:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• fs.suid_dumpable is set to 0
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 162
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("fs.suid_dumpable=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 163
# systemctl is-enabled coredump.service
if enabled, masked, or disabled is returned systemd-coredump is installed
Remediation:
Add the following line to /etc/security/limits.conf or a /etc/security/limits.d/*
file:
* hard core 0
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• fs.suid_dumpable = 0
Example:
# printf "
fs.suid_dumpable = 0
" >> /etc/sysctl.d/60-fs_sysctl.conf
Run the following command to set the active kernel parameter:
# sysctl -w fs.suid_dumpable=0
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
-IF- systemd-coredump is installed:
edit /etc/systemd/coredump.conf and add/modify the following lines:
Storage=none
ProcessSizeMax=0
Run the command:
systemctl daemon-reload
Techniques / Sub-
Tactics Mitigations
techniques
Page 164
1.6 Mandatory Access Control
Page 165
1.6.1 Configure AppArmor
AppArmor provides a Mandatory Access Control (MAC) system that greatly augments
the default Discretionary Access Control (DAC) model. Under AppArmor MAC rules are
applied by file paths instead of by security contexts as in other MAC systems. As such it
does not require support in the filesystem and can be applied to network mounted
filesystems for example. AppArmor security policies define what system resources
applications can access and what privileges they can do so with. This automatically
limits the damage that the software can do to files accessible by the calling user. The
user does not need to take any action to gain this benefit. For an action to occur, both
the traditional DAC permissions must be satisfied as well as the AppArmor MAC rules.
The action will not be allowed if either one of these models does not permit the action.
In this way, AppArmor rules can only make a system's permissions more restrictive and
secure.
References:
Page 166
1.6.1.1 Ensure AppArmor is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
AppArmor provides Mandatory Access Controls.
Rationale:
Without a Mandatory Access Control system installed only the default Discretionary
Access Control system will be available.
Audit:
Verify that AppArmor is installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
apparmor apparmor-utils
Remediation:
Install AppArmor.
# apt install apparmor apparmor-utils
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 167
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 168
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure AppArmor to be enabled at boot time and verify that it has not been
overwritten by the bootloader boot parameters.
Note: This recommendation is designed around the grub bootloader, if LILO or another
bootloader is in use in your environment enact equivalent settings.
Rationale:
AppArmor must be enabled at boot time in your bootloader configuration to ensure that
the controls it provides are not overridden.
Audit:
Run the following commands to verify that all linux lines have the apparmor=1 and
security=apparmor parameters set:
Remediation:
Edit /etc/default/grub and add the apparmor=1 and security=apparmor parameters to
the GRUB_CMDLINE_LINUX= line
GRUB_CMDLINE_LINUX="apparmor=1 security=apparmor"
Run the following command to update the grub2 configuration:
# update-grub
References:
Page 169
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 170
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
AppArmor profiles define what resources applications are able to access.
Rationale:
Security configuration requirements vary from site to site. Some sites may mandate a
policy that is stricter than the default policy, which is perfectly acceptable. This item is
intended to ensure that any policies that exist on the system are activated.
Audit:
Run the following command and verify that profiles are loaded, and are in either enforce
or complain mode:
# apparmor_status | grep profiles
Review output and ensure that profiles are loaded, and in either enforce or complain
mode:
37 profiles are loaded.
35 profiles are in enforce mode.
2 profiles are in complain mode.
4 processes have profiles defined.
Run the following command and verify no processes are unconfined
# apparmor_status | grep processes
Review the output and ensure no processes are unconfined:
4 processes have profiles defined.
4 processes are in enforce mode.
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
Page 171
Remediation:
Run the following command to set all profiles to enforce mode:
# aa-enforce /etc/apparmor.d/*
OR
Run the following command to set all profiles to complain mode:
# aa-complain /etc/apparmor.d/*
Note: Any unconfined processes may need to have a profile created or activated for
them and then be restarted
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
TA0005
Page 172
1.6.1.4 Ensure all AppArmor Profiles are enforcing (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
AppArmor profiles define what resources applications are able to access.
Rationale:
Security configuration requirements vary from site to site. Some sites may mandate a
policy that is stricter than the default policy, which is perfectly acceptable. This item is
intended to ensure that any policies that exist on the system are activated.
Audit:
Run the following commands and verify that profiles are loaded and are not in complain
mode:
# apparmor_status | grep profiles
Review output and ensure that profiles are loaded, and in enforce mode:
34 profiles are loaded.
34 profiles are in enforce mode.
0 profiles are in complain mode.
2 processes have profiles defined.
Run the following command and verify that no processes are unconfined:
apparmor_status | grep processes
Review the output and ensure no processes are unconfined:
2 processes have profiles defined.
2 processes are in enforce mode.
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
Remediation:
Run the following command to set all profiles to enforce mode:
# aa-enforce /etc/apparmor.d/*
Note: Any unconfined processes may need to have a profile created or activated for
them and then be restarted
References:
Page 173
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 174
1.7 Command Line Warning Banners
Presenting a warning message prior to the normal user login may assist in the
prosecution of trespassers on the computer system. Changing some of these login
banners also has the side effect of hiding OS version information and other detailed
system information from attackers attempting to target specific exploits at a system. The
/etc/motd, /etc/issue, and /etc/issue.net files govern warning banners for standard
command line logins for both local and remote users.
Guidelines published by the US Department of Defense require that warning messages
include at least the name of the organization that owns the system, the fact that the
system is subject to monitoring and that such monitoring is in compliance with local
statutes, and that use of the system implies consent to such monitoring. It is important
that the organization's legal counsel review the content of all messages before any
system modifications are made, as these warning messages are inherently site-specific.
More information (including citations of relevant case law) can be found at
http://www.justice.gov/criminal/cybercrime/
Note: The text provided in the remediation actions for these items is intended as an
example only. Please edit to include the specific text for your organization as approved
by your legal department
Page 175
1.7.1 Ensure message of the day is configured properly
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/motd file are displayed to users after login and function as a
message of the day for authenticated users.
Unix-based systems have typically displayed information about the OS release and
patch level upon logging in to the system. This information can be useful to developers
who are developing software for a particular OS platform. If mingetty(8) supports the
following options, they display operating system information: \m - machine architecture
\r - operating system release \s - operating system name \v - operating system version
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place. Displaying OS and patch level
information in login banners also has the side effect of providing detailed system
information to attackers attempting to target specific exploits of a system. Authorized
users can easily get this information by running the " uname -a " command once they
have logged in.
Audit:
Run the following command and verify no results are returned:
# grep -Eis "(\\\v|\\\r|\\\m|\\\s|$(grep '^ID=' /etc/os-release | cut -d= -f2
| sed -e 's/"//g'))" /etc/motd
Page 176
Remediation:
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. Add or
update the message text to follow local site policy.
Example Text:
# echo "Authorized use only. All activity may be monitored and reported." >
/etc/issue.net
-- OR --
If the motd is not used, this file can be removed.
Run the following command to remove the motd file:
# rm /etc/motd
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 177
1.7.2 Ensure local login warning banner is configured properly
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue file are displayed to users prior to login for local
terminals.
Unix-based systems have typically displayed information about the OS release and
patch level upon logging in to the system. This information can be useful to developers
who are developing software for a particular OS platform. If mingetty(8) supports the
following options, they display operating system information: \m - machine architecture
\r - operating system release \s - operating system name \v - operating system version
- or the operating system's name
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place. Displaying OS and patch level
information in login banners also has the side effect of providing detailed system
information to attackers attempting to target specific exploits of a system. Authorized
users can easily get this information by running the " uname -a " command once they
have logged in.
Audit:
Run the following command and verify that the contents match site policy:
# cat /etc/issue
Run the following command and verify no results are returned:
# grep -E -i "(\\\v|\\\r|\\\m|\\\s|$(grep '^ID=' /etc/os-release | cut -d= -
f2 | sed -e 's/"//g'))" /etc/issue
Page 178
Remediation:
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. Add or
update the message text to follow local site policy.
Example Text:
# echo "Authorized use only. All activity may be monitored and reported." >
/etc/issue.net
Techniques / Sub-
Tactics Mitigations
techniques
Page 179
1.7.3 Ensure remote login warning banner is configured properly
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue.net file are displayed to users prior to login for remote
connections from configured services.
Unix-based systems have typically displayed information about the OS release and
patch level upon logging in to the system. This information can be useful to developers
who are developing software for a particular OS platform. If mingetty(8) supports the
following options, they display operating system information: \m - machine architecture
\r - operating system release \s - operating system name \v - operating system version
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place. Displaying OS and patch level
information in login banners also has the side effect of providing detailed system
information to attackers attempting to target specific exploits of a system. Authorized
users can easily get this information by running the " uname -a " command once they
have logged in.
Audit:
Run the following command and verify that the contents match site policy:
# cat /etc/issue.net
Run the following command and verify no results are returned:
# grep -E -i "(\\\v|\\\r|\\\m|\\\s|$(grep '^ID=' /etc/os-release | cut -d= -
f2 | sed -e 's/"//g'))" /etc/issue.net
Page 180
Remediation:
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. Add or
update the message text to follow local site policy.
Example Text:
# echo "Authorized use only. All activity may be monitored and reported." >
/etc/issue.net
Techniques / Sub-
Tactics Mitigations
techniques
Page 181
1.7.4 Ensure permissions on /etc/motd are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/motd file are displayed to users after login and function as a
message of the day for authenticated users.
Rationale:
If the /etc/motd file does not have the correct ownership it could be modified by
unauthorized users with incorrect or misleading information.
Audit:
Run the following command and verify that if /etc/motd exists, Access is 644 or more
restrictive, Uid and Gid are both 0/root:
# [ -e /etc/motd ] && stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/
%G)' /etc/motd
Remediation:
Run the following commands to set permissions on /etc/motd :
# chown root:root $(readlink -e /etc/motd)
# chmod u-x,go-wx $(readlink -e /etc/motd)
-- OR --
Run the following command to remove the /etc/motd file:
# rm /etc/motd
Default Value:
File doesn't exist
Additional Information:
If Message of the day is not needed, this file can be removed.
Page 182
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 183
1.7.5 Ensure permissions on /etc/issue are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue file are displayed to users prior to login for local
terminals.
Rationale:
If the /etc/issue file does not have the correct ownership it could be modified by
unauthorized users with incorrect or misleading information.
Audit:
Run the following command and verify Access is 644 or more restrictive and Uid and Gid
are both 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/ %G)' /etc/issue
Remediation:
Run the following commands to set permissions on /etc/issue:
# chown root:root $(readlink -e /etc/issue)
# chmod u-x,go-wx $(readlink -e /etc/issue)
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Page 184
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 185
1.7.6 Ensure permissions on /etc/issue.net are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The contents of the /etc/issue.net file are displayed to users prior to login for remote
connections from configured services.
Rationale:
If the /etc/issue.net file does not have the correct ownership it could be modified by
unauthorized users with incorrect or misleading information.
Audit:
Run the following command and verify Access is 644 or more restrictive and Uid and Gid
are both 0/root:
# stat -Lc 'Access: (%#a/%A) Uid: ( %u/ %U) Gid: { %g/ %G)' /etc/issue.net
Remediation:
Run the following commands to set permissions on /etc/issue.net :
# chown root:root $(readlink -e /etc/issue.net)
# chmod u-x,go-wx $(readlink -e /etc/issue.net)
Default Value:
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Page 186
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 187
1.8 GNOME Display Manager
The GNOME Display Manager (GDM) is a program that manages graphical display
servers and handles graphical user logins.
Note: If GDM is not installed on the system, this section can be skipped
Page 188
1.8.1 Ensure GNOME Display Manager is removed (Automated)
Profile Applicability:
• Level 2 - Server
Description:
The GNOME Display Manager (GDM) is a program that manages graphical display
servers and handles graphical user logins.
Rationale:
If a Graphical User Interface (GUI) is not required, it should be removed to reduce the
attack surface of the system.
Impact:
Removing the GNOME Display manager will remove the Graphical User Interface (GUI)
from the system.
Audit:
Run the following command and verify gdm3 is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' gdm3
Remediation:
Run the following command to uninstall gdm3:
# apt purge gdm3
References:
Page 189
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 190
1.8.2 Ensure GDM login banner is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
GDM is the GNOME Display Manager which handles graphical login for GNOME based
systems.
Rationale:
Warning messages inform users who are attempting to login to the system of their legal
status regarding the system and must include the name of the organization that owns
the system and any monitoring policies that are in place.
Page 191
Audit:
Run the following script to verify that the text banner on the login screen 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_output="" l_output2=""
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_gdmfile="$(grep -Prils '^\h*banner-message-enable\b' /etc/dconf/db/*.d)"
if [ -n "$l_gdmfile" ]; then
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
l_gdmprofile="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<< "$l_gdmfile")"
# Check if banner message is enabled
if grep -Pisq '^\h*banner-message-enable=true\b' "$l_gdmfile"; then
l_output="$l_output\n - The \"banner-message-enable\" option is enabled in
\"$l_gdmfile\""
else
l_output2="$l_output2\n - The \"banner-message-enable\" option is not enabled"
fi
l_lsbt="$(grep -Pios '^\h*banner-message-text=.*$' "$l_gdmfile")"
if [ -n "$l_lsbt" ]; then
l_output="$l_output\n - The \"banner-message-text\" option is set in \"$l_gdmfile\"\n
- banner-message-text is set to:\n - \"$l_lsbt\""
else
l_output2="$l_output2\n - The \"banner-message-text\" option is not set"
fi
if grep -Pq "^\h*system-db:$l_gdmprofile" /etc/dconf/profile/"$l_gdmprofile"; then
l_output="$l_output\n - The \"$l_gdmprofile\" profile exists"
else
l_output2="$l_output2\n - The \"$l_gdmprofile\" profile doesn't exist"
fi
if [ -f "/etc/dconf/db/$l_gdmprofile" ]; then
l_output="$l_output\n - The \"$l_gdmprofile\" profile exists in the dconf database"
else
l_output2="$l_output2\n - The \"$l_gdmprofile\" profile doesn't exist in the dconf
database"
fi
else
l_output2="$l_output2\n - The \"banner-message-enable\" option isn't configured"
fi
else
echo -e "\n\n - GNOME Desktop Manager isn't installed\n - Recommendation is Not
Applicable\n- Audit result:\n *** PASS ***\n"
fi
# Report results. If no failures output in l_output2, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 192
Remediation:
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:
Page 193
Run the following command to remove the gdm3 package:
# apt purge gdm3
Default Value:
disabled
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/login-banner.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Additional Information:
Additional options and sections may appear in the /etc/dconf/db/gdm.d/01-banner-
message file.
If a different GUI login service is in use, consult your documentation and apply an
equivalent banner.
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
TA0007
Page 194
1.8.3 Ensure GDM disable-user-list option is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
GDM is the GNOME Display Manager which handles graphical login for GNOME based
systems.
The disable-user-list option controls if a list of users is displayed on the login screen
Rationale:
Displaying the user list eliminates half of the Userid/Password equation that an
unauthorized person would need to log on.
Audit:
Run the following script and to verify that the disable-user-list option is enabled or
GNOME isn't installed:
Page 195
#!/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
output="" output2=""
l_gdmfile="$(grep -Pril '^\h*disable-user-list\h*=\h*true\b'
/etc/dconf/db)"
if [ -n "$l_gdmfile" ]; then
output="$output\n - The \"disable-user-list\" option is enabled in
\"$l_gdmfile\""
l_gdmprofile="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<<
"$l_gdmfile")"
if grep -Pq "^\h*system-db:$l_gdmprofile"
/etc/dconf/profile/"$l_gdmprofile"; then
output="$output\n - The \"$l_gdmprofile\" exists"
else
output2="$output2\n - The \"$l_gdmprofile\" doesn't exist"
fi
if [ -f "/etc/dconf/db/$l_gdmprofile" ]; then
output="$output\n - The \"$l_gdmprofile\" profile exists in the
dconf database"
else
output2="$output2\n - The \"$l_gdmprofile\" profile doesn't exist
in the dconf database"
fi
else
output2="$output2\n - The \"disable-user-list\" option is not
enabled"
fi
if [ -z "$output2" ]; then
echo -e "$l_pkgoutput\n- Audit result:\n *** PASS: ***\n$output\n"
else
echo -e "$l_pkgoutput\n- Audit Result:\n *** FAIL:
***\n$output2\n"
[ -n "$output" ] && echo -e "$output\n"
fi
else
echo -e "\n\n - GNOME Desktop Manager isn't installed\n -
Recommendation is Not Applicable\n- Audit result:\n *** PASS ***\n"
fi
}
Page 196
Remediation:
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:
# apt purge gdm3
Default Value:
false
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/login-userlist-
disable.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Page 197
Additional Information:
If a different GUI login service is in use and required on the system, consult your
documentation to disable displaying the user list
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
TA0007 M1028
T1087, T1087.001,
T1087.002
Page 198
1.8.4 Ensure GDM screen locks when the user is idle
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
GNOME Desktop Manager can make the screen lock automatically whenever the user
is idle for some amount of time.
# Number of seconds after the screen is blank before locking the screen
lock-delay=uint32 5
Rationale:
Setting a lock-out value reduces the window of opportunity for unauthorized user access
to another user's session that has been left unattended.
Audit:
Run the following script to verify that the screen locks when the user is idle:
Page 199
#!/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="$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\"
Page 200
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
}
Note:
Page 201
Remediation:
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.
Page 202
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/desktop-
lockscreen.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1461 TA0027
Page 203
1.8.5 Ensure GDM screen locks cannot be overridden
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
GNOME Desktop Manager can make the screen lock automatically whenever the user
is idle for some amount of time.
By using the lockdown mode in dconf, you can prevent users from changing specific
settings.
To lock down a dconf key or subpath, create a locks subdirectory in the keyfile directory.
The files inside this directory contain a list of keys or subpaths to lock. Just as with the
keyfiles, you may add any number of files to this directory.
Example Lock File:
# Lock desktop screensaver settings
/org/gnome/desktop/session/idle-delay
/org/gnome/desktop/screensaver/lock-delay
Rationale:
Setting a lock-out value reduces the window of opportunity for unauthorized user access
to another user's session that has been left unattended.
Without locking down the system settings, user settings take precedence over the
system settings.
Page 204
Audit:
Run the following script to verify that the screen lock 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 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
}
Remediation:
Run the following script to ensure screen locks can not be overridden:
Page 205
#!/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
}
Page 206
# dconf update
Note: Users must log out and back in again before the system-wide settings take effect.
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/desktop-
lockscreen.html.en
2. https://help.gnome.org/admin/system-admin-guide/stable/dconf-lockdown.html.en
3. NIST SP 800-53 Rev. 5: CM-11
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1456 TA0027
Page 207
1.8.6 Ensure GDM automatic mounting of removable media is
disabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 2 - Workstation
Description:
By default GNOME automatically mounts removable media when inserted as a
convenience to the user.
Rationale:
With automounting enabled anyone with physical access could attach a USB drive or
disc and have its contents available in system even if they lacked permissions to mount
it themselves.
Impact:
The use of portable hard drives is very common for workstation users. If your
organization allows the use of portable storage or media on workstations and physical
access controls to workstations is considered adequate there is little value add in
turning off automounting.
Audit:
Run the following script to verify automatic mounting is disabled:
Page 208
#!/usr/bin/env bash
{
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
Page 209
# 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
}
Remediation:
Run the following script to disable automatic mounting of media for all GNOME users:
Page 210
#!/usr/bin/env bash
{
l_pkgoutput="" l_output="" l_output2=""
l_gpname="local" # Set to desired dconf profile name (defaule is local)
# Check if GNOME Desktop Manager is installed. If package isn't
installed, recommendation is Not Applicable\n
# determine system's package manager
if command -v dpkg-query > /dev/null 2>&1; then
l_pq="dpkg-query -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
echo -e "$l_packageout"
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
echo -e "$l_pkgoutput"
# Look for existing settings and set variables if they exist
l_kfile="$(grep -Prils -- '^\h*automount\b' /etc/dconf/db/*.d)"
l_kfile2="$(grep -Prils -- '^\h*automount-open\b' /etc/dconf/db/*.d)"
# Set profile name based on dconf db directory ({PROFILE_NAME}.d)
if [ -f "$l_kfile" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<<
"$l_kfile")"
echo " - updating dconf profile name to \"$l_gpname\""
elif [ -f "$l_kfile2" ]; then
l_gpname="$(awk -F\/ '{split($(NF-1),a,".");print a[1]}' <<<
"$l_kfile2")"
echo " - updating dconf profile name to \"$l_gpname\""
fi
# check for consistency (Clean up configuration if needed)
if [ -f "$l_kfile" ] && [ "$(awk -F\/ '{split($(NF-1),a,".");print
a[1]}' <<< "$l_kfile")" != "$l_gpname" ]; then
sed -ri "/^\s*automount\s*=/s/^/# /" "$l_kfile"
l_kfile="/etc/dconf/db/$l_gpname.d/00-media-automount"
fi
if [ -f "$l_kfile2" ] && [ "$(awk -F\/ '{split($(NF-1),a,".");print
a[1]}' <<< "$l_kfile2")" != "$l_gpname" ]; then
sed -ri "/^\s*automount-open\s*=/s/^/# /" "$l_kfile2"
fi
[ -z "$l_kfile" ] && l_kfile="/etc/dconf/db/$l_gpname.d/00-media-
automount"
# Check if profile file exists
if grep -Pq -- "^\h*system-db:$l_gpname\b" /etc/dconf/profile/*; then
echo -e "\n - dconf database profile exists in: \"$(grep -Pl --
"^\h*system-db:$l_gpname\b" /etc/dconf/profile/*)\""
else
[ ! -f "/etc/dconf/profile/user" ] &&
l_gpfile="/etc/dconf/profile/user" || l_gpfile="/etc/dconf/profile/user2"
echo -e " - creating dconf database profile"
{
Page 211
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
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
}
OR
Run the following command to uninstall the GNOME desktop Manager package:
# apt purge gdm3
References:
1. https://access.redhat.com/solutions/20107
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Page 212
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 213
1.8.7 Ensure GDM disabling automatic mounting of removable
media is not overridden (Automated)
Profile Applicability:
• Level 1 - Server
• Level 2 - Workstation
Description:
By default GNOME automatically mounts removable media when inserted as a
convenience to the user
By using the lockdown mode in dconf, you can prevent users from changing specific
settings.
To lock down a dconf key or subpath, create a locks subdirectory in the keyfile directory.
The files inside this directory contain a list of keys or subpaths to lock. Just as with the
keyfiles, you may add any number of files to this directory.
Example Lock File:
# Lock desktop screensaver settings
/org/gnome/desktop/media-handling/automount
/org/gnome/desktop/media-handling/automount-open
Rationale:
With automounting enabled anyone with physical access could attach a USB drive or
disc and have its contents available in system even if they lacked permissions to mount
it themselves.
Impact:
The use of portable hard drives is very common for workstation users
Audit:
Run the following script to verify disable automatic mounting is locked:
Page 214
#!/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 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
}
Remediation:
Run the following script to lock disable automatic mounting of media for all GNOME
users:
Page 215
#!/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
}
Page 216
References:
1. https://help.gnome.org/admin/system-admin-guide/stable/dconf-lockdown.html.en
2. NIST SP 800-53 Rev. 5: CM-1,CM-2, CM-6, CM-7, IA-5
Techniques / Sub-
Tactics Mitigations
techniques
Page 217
1.8.8 Ensure GDM autorun-never is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The autorun-never setting allows the GNOME Desktop Display Manager to disable
autorun through GDM.
Rationale:
Malware on removable media may taking advantage of Autorun features when the
media is inserted into a system and execute.
Audit:
Run the following script to verify that autorun-never is set to true for GDM:
Page 218
#!/usr/bin/env bash
{
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:
Page 219
\"$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
}
Remediation:
Run the following script to set autorun-never to true for GDM users:
Page 220
#!/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\""
Page 221
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
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 222
1.8.9 Ensure GDM autorun-never is not overridden (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The autorun-never setting allows the GNOME Desktop Display Manager to disable
autorun through GDM.
By using the lockdown mode in dconf, you can prevent users from changing specific
settings.
To lock down a dconf key or subpath, create a locks subdirectory in the keyfile directory.
The files inside this directory contain a list of keys or subpaths to lock. Just as with the
keyfiles, you may add any number of files to this directory.
Example Lock File:
# Lock desktop media-handling settings
/org/gnome/desktop/media-handling/autorun-never
Rationale:
Malware on removable media may taking advantage of Autorun features when the
media is inserted into a system and execute.
Audit:
Run the following script to verify that autorun-never=true cannot be overridden:
Page 223
#!/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="$l_pkgoutput\n -
Package: \"$l_pn\" exists on the system\n - checking configuration"
done
# Check configuration (If applicable)
if [ -n "$l_pkgoutput" ]; then
l_output="" l_output2=""
# Look for idle-delay to determine profile in use, needed for remaining
tests
l_kfd="/etc/dconf/db/$(grep -Psril '^\h*autorun-never\b'
/etc/dconf/db/*/ | awk -F'/' '{split($(NF-1),a,".");print a[1]}').d" #set
directory of key file to be locked
if [ -d "$l_kfd" ]; then # If key file directory doesn't exist, options
can't be locked
if grep -Prisq '^\h*\/org/gnome\/desktop\/media-handling\/autorun-
never\b' "$l_kfd"; then
l_output="$l_output\n - \"autorun-never\" is locked in \"$(grep -
Pril '^\h*\/org/gnome\/desktop\/media-handling\/autorun-never\b' "$l_kfd")\""
else
l_output2="$l_output2\n - \"autorun-never\" is not locked"
fi
else
l_output2="$l_output2\n - \"autorun-never\" is not set so it can not
be locked"
fi
else
l_output="$l_output\n - GNOME Desktop Manager package is not installed
on the system\n - Recommendation is not applicable"
fi
# Report results. If no failures output in l_output2, we pass
[ -n "$l_pkgoutput" ] && echo -e "\n$l_pkgoutput"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit
failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 224
Remediation:
Run the following script to ensure that autorun-never=true cannot be overridden:
Page 225
#!/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 -Prisq '^\h*\/org/gnome\/desktop\/media-handling\/autorun-
never\b' "$l_kfd"; then
echo " - \"autorun-never\" is locked in \"$(grep -Pril
'^\h*\/org/gnome\/desktop\/media-handling\/autorun-never\b' "$l_kfd")\""
else
echo " - creating entry to lock \"autorun-never\""
[ ! -d "$l_kfd"/locks ] && echo "creating directory $l_kfd/locks"
&& mkdir "$l_kfd"/locks
{
echo -e '\n# Lock desktop media-handling autorun-never
setting'
echo '/org/gnome/desktop/media-handling/autorun-never'
} >> "$l_kfd"/locks/00-media-autorun
fi
else
echo -e " - \"autorun-never\" is not set so it can not be locked\n -
Please follow Recommendation \"Ensure GDM autorun-never is enabled\" and
follow this Recommendation again"
fi
# update dconf database
dconf update
else
echo -e " - GNOME Desktop Manager package is not installed on the
system\n - Recommendation is not applicable"
fi
}
Page 226
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 227
1.8.10 Ensure XDCMP is not enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
X Display Manager Control Protocol (XDMCP) is designed to provide authenticated
access to display management services for remote displays
Rationale:
XDMCP is inherently insecure.
Audit:
Run the following command and verify the output:
# grep -Eis '^\s*Enable\s*=\s*true' /etc/gdm3/custom.conf
Remediation:
Edit the file /etc/gdm3/custom.conf and remove the line:
Enable=true
Default Value:
false (This is denoted by no Enabled= entry in the file /etc/gdm3/custom.conf in the
[xdmcp] section
References:
Page 228
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 229
2 Services
While applying system updates and patches helps correct known vulnerabilities, one of
the best ways to protect the system against as yet unreported vulnerabilities is to
disable all services that are not required for normal system operation. This prevents the
exploitation of vulnerabilities discovered at a later date. If a service is not enabled, it
cannot be exploited. The actions in this section of the document provide guidance on
some services which can be safely disabled and under which circumstances, greatly
reducing the number of possible threats to the resulting system. Additionally, some
services which should remain enabled but with secure configuration are covered as well
as insecure service clients.
Note: This should not be considered a comprehensive list of insecure services. You
may wish to consider additions to those listed here for your environment.
Page 230
2.1 Configure Time Synchronization
It is recommended that physical systems and virtual guests lacking direct access to the
physical host's clock be configured to synchronize their time using a service such as
systemd-timesyncd, chrony, or ntp.
Note:
Page 231
2.1.1 Ensure time synchronization is in use
It is recommended that physical systems and virtual guests lacking direct access to the
physical host's clock be configured to synchronize their time using a service such as
systemd-timesyncd, chrony, or ntp.
Page 232
2.1.1.1 Ensure a single time synchronization daemon is in use
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
System time should be synchronized between all systems in an environment. This is
typically done by establishing an authoritative time server or set of servers and having
all systems synchronize their clocks to them.
Note:
Rationale:
Time synchronization is important to support time sensitive security mechanisms and
ensures log files have consistent time records across the enterprise, which aids in
forensic investigations.
Page 233
Audit:
On physical systems, and virtual systems where host based time synchronization is not
available.
One of the three time synchronization daemons should be available; chrony, systemd-
timesyncd, or ntp
Run the following script to verify that a single time synchronization daemon is available
on the system:
#!/usr/bin/env bash
{
output="" l_tsd="" l_sdtd="" chrony="" l_ntp=""
dpkg-query -W chrony > /dev/null 2>&1 && l_chrony="y"
dpkg-query -W ntp > /dev/null 2>&1 && l_ntp="y" || l_ntp=""
systemctl list-units --all --type=service | grep -q 'systemd-
timesyncd.service' && systemctl is-enabled systemd-timesyncd.service | grep -
q 'enabled' && l_sdtd="y"
if [[ "$l_chrony" = "y" && "$l_ntp" != "y" && "$l_sdtd" != "y" ]]; then
l_tsd="chrony"
output="$output\n- chrony is in use on the system"
elif [[ "$l_chrony" != "y" && "$l_ntp" = "y" && "$l_sdtd" != "y" ]]; then
l_tsd="ntp"
output="$output\n- ntp is in use on the system"
elif [[ "$l_chrony" != "y" && "$l_ntp" != "y" ]]; then
if systemctl list-units --all --type=service | grep -q 'systemd-
timesyncd.service' && systemctl is-enabled systemd-timesyncd.service | grep -
Eq '(enabled|disabled|masked)'; then
l_tsd="sdtd"
output="$output\n- systemd-timesyncd is in use on the system"
fi
else
[[ "$l_chrony" = "y" && "$l_ntp" = "y" ]] && output="$output\n- both
chrony and ntp are in use on the system"
[[ "$l_chrony" = "y" && "$l_sdtd" = "y" ]] && output="$output\n- both
chrony and systemd-timesyncd are in use on the system"
[[ "$l_ntp" = "y" && "$l_sdtd" = "y" ]] && output="$output\n- both ntp
and systemd-timesyncd are in use on the system"
fi
if [ -n "$l_tsd" ]; then
echo -e "\n- PASS:\n$output\n"
else
echo -e "\n- FAIL:\n$output\n"
fi
}
NOTE: Follow the guidance in the subsection for the time synchronization daemon
available on the system and skip the other two time synchronization daemon
subsections.
Page 234
Remediation:
On physical systems, and virtual systems where host based time synchronization is not
available.
Select one of the three time synchronization daemons; chrony (1), systemd-timesyncd
(2), or ntp (3), and following the remediation procedure for the selected daemon.
Note: enabling more than one synchronization daemon could lead to unexpected or
unreliable results:
1. chrony
2. systemd-timesyncd
Page 235
3. ntp
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 236
2.1.2 Configure chrony
chrony is a daemon which implements the Network Time Protocol (NTP) and is
designed to synchronize system clocks across a variety of systems and use a source
that is highly accurate.
chrony can be configured to be a client and/or a server.
More information on chrony can be found at: http://chrony.tuxfamily.org/.
Note:
• If ntp or systemd-timesyncd are used, chrony should be removed and this section
skipped
• Only one time synchronization method should be in use on the system
Page 237
2.1.2.1 Ensure chrony is configured with authorized timeserver
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
• server
o The server directive specifies an NTP server which can be used as a time
source. The client-server relationship is strictly hierarchical: a client might
synchronize its system time to that of the server, but the server’s system
time will never be influenced by that of a client.
o This directive can be used multiple times to specify multiple servers.
o The directive is immediately followed by either the name of the server, or
its IP address.
• pool
o The syntax of this directive is similar to that for the server directive, except
that it is used to specify a pool of NTP servers rather than a single NTP
server. The pool name is expected to resolve to multiple addresses which
might change over time.
o This directive can be used multiple times to specify multiple pools.
o All options valid in the server directive can be used in this directive too.
Rationale:
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Page 238
Audit:
IF chrony is in use on the system, run the following command to display the server
and/or pool directive:
# grep -Pr --include=*.{sources,conf} '^\h*(server|pool)\h+\H+' /etc/chrony/
Verify that at least one pool line and/or at least three server lines are returned, and the
timeserver on the returned lines follows local site policy
Output examples:
pool directive:
Page 239
Remediation:
Edit /etc/chrony/chrony.conf or a file ending in .sources in /etc/chrony/sources.d/
and add or edit server or pool lines as appropriate according to local site policy:
<[server|pool]> <[remote-server|remote-pool]>
Examples:
pool directive:
References:
Additional Information:
If pool and/or server directive(s) are set in a sources file in /etc/chrony/sources.d, the
line:
sourcedir /etc/chrony/sources.d
must be present in /etc/chrony/chrony.conf
Page 240
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 241
2.1.2.2 Ensure chrony is running as user _chrony (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The chrony package is installed with a dedicated user account _chrony. This account is
granted the access required by the chronyd service
Rationale:
The chronyd service should run with only the required privlidges
Audit:
IF chrony is in use on the system, run the following command to verify the chronyd
service is being run as the _chrony user:
# ps -ef | awk '(/[c]hronyd/ && $1!="_chrony") { print $1 }'
Nothing should be returned
Remediation:
Add or edit the user line to /etc/chrony/chrony.conf or a file ending in .conf in
/etc/chrony/conf.d/:
user _chrony
OR
If another time synchronization service is in use on the system, run the following
command to remove chrony from the system:
# apt purge chrony
Default Value:
user _chrony
References:
Page 242
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 243
2.1.2.3 Ensure chrony is enabled and running (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
chrony is a daemon for synchronizing the system clock across the network
Rationale:
chrony needs to be enabled and running in order to synchronize the system to a
timeserver.
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Audit:
IF chrony is in use on the system, run the following commands:
Run the following command to verify that the chrony service is enabled:
# systemctl is-enabled chrony.service
enabled
Run the following command to verify that the chrony service is active:
# systemctl is-active chrony.service
active
Page 244
Remediation:
IF chrony is in use on the system, run the following commands:
Run the following command to unmask chrony.service:
# systemctl unmask chrony.service
Run the following command to enable and start chrony.service:
# systemctl --now enable chrony.service
OR
If another time synchronization service is in use on the system, run the following
command to remove chrony:
# apt purge chrony
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 245
2.1.3 Configure systemd-timesyncd
systemd-timesyncd is a daemon that has been added for synchronizing the system
clock across the network. It implements an SNTP client. In contrast to NTP
implementations such as chrony or the NTP reference server this only implements a
client side, and does not bother with the full NTP complexity, focusing only on querying
time from one remote server and synchronizing the local clock to it. The daemon runs
with minimal privileges, and has been hooked up with networkd to only operate when
network connectivity is available. The daemon saves the current clock to disk every time
a new NTP sync has been acquired, and uses this to possibly correct the system clock
early at bootup, in order to accommodate for systems that lack an RTC such as the
Raspberry Pi and embedded devices, and make sure that time monotonically
progresses on these systems, even if it is not always correct. To make use of this
daemon a new system user and group "systemd-timesync" needs to be created on
installation of systemd.
The default configuration is set during compilation, so configuration is only needed
when it is necessary to deviate from those defaults. Initially, the main configuration file
in /etc/systemd/ contains commented out entries showing the defaults as a guide to the
administrator. Local overrides can be created by editing this file or by creating drop-ins,
as described below. Using drop-ins for local configuration is recommended over
modifications to the main configuration file.
In addition to the "main" configuration file, drop-in configuration snippets are read from
/usr/lib/systemd/*.conf.d/, /usr/local/lib/systemd/*.conf.d/, and
/etc/systemd/*.conf.d/. Those drop-ins have higher precedence and override the
main configuration file. Files in the *.conf.d/ configuration subdirectories are sorted by
their filename in lexicographic order, regardless of in which of the subdirectories they
reside. When multiple files specify the same option, for options which accept just a
single value, the entry in the file sorted last takes precedence, and for options which
accept a list of values, entries are collected as they occur in the sorted files.
When packages need to customize the configuration, they can install drop-ins under
/usr/. Files in /etc/ are reserved for the local administrator, who may use this logic to
override the configuration files installed by vendor packages. Drop-ins have to be used
to override package drop-ins, since the main configuration file has lower precedence. It
is recommended to prefix all filenames in those subdirectories with a two-digit number
and a dash, to simplify the ordering of the files.
To disable a configuration file supplied by the vendor, the recommended way is to place
a symlink to /dev/null in the configuration directory in /etc/, with the same filename as
the vendor configuration file.
Page 246
Note:
Page 247
2.1.3.1 Ensure systemd-timesyncd configured with authorized
timeserver (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
NTP=
FallbackNTP=
Rationale:
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Page 248
Audit:
IF systemd-timesyncd is in use on the system, run the following command:
# grep -Ph '^\h*(NTP|FallbackNTP)=\H+' /etc/systemd/timesyncd.conf
Verify that NTP=<space_separated_list_of_servers> and/or
FallbackNTP=<space_separated_list_of_servers> is returned and that the time
server(s) shown follows local site policy
Example Output:
/etc/systemd/timesyncd.conf:NTP=time.nist.gov
/etc/systemd/timesyncd.conf:FallbackNTP=time-a-g.nist.gov time-b-g.nist.gov
time-c-g.nist.gov
Page 249
Remediation:
Edit /etc/systemd/timesyncd.conf and add the NTP= and/or FallbackNTP= lines to the
[Time] section:
Example:
[Time]
NTP=time.nist.gov # Uses the generic name for NIST's time servers
-AND/OR-
FallbackNTP=time-a-g.nist.gov time-b-g.nist.gov time-c-g.nist.gov # Space
separated list of NIST time servers
Note: Servers added to these line(s) should follow local site policy. NIST servers are for
example.
Example script:
The following example script will add the example NIST time servers to
/etc/systemd/timesyncd.conf
#!/usr/bin/env bash
{
l_ntp_ts="time.nist.gov"
l_ntp_fb="time-a-g.nist.gov time-b-g.nist.gov time-c-g.nist.gov"
l_conf_file="/etc/systemd/timesyncd.conf"
if ! grep -Ph '^\h*NTP=\H+' "$l_conf_file"; then
! grep -Pqs '^\h*\[Time\]' "$l_conf_file" && echo "[Time]" >>
"$l_conf_file"
echo "NTP=$l_ntp_ts" >> "$l_conf_file"
fi
if ! grep -Ph '^\h*FallbackNTP=\H+' "$l_conf_file"; then
! grep -Pqs '^\h*\[Time\]' "$l_conf_file" && echo "[Time]" >>
"$l_conf_file"
echo "FallbackNTP=$l_ntp_fb" >> "$l_conf_file"
fi
}
Run the following command to reload the systemd-timesyncd configuration:
# systemctl try-reload-or-restart systemd-timesyncd
-OR-
If another time synchronization service is in use on the system, run the following
command to stop and mask systemd-timesyncd:
# systemctl --now mask systemd-timesyncd
Default Value:
#NTP=
#FallbackNTP=
Page 250
References:
1. https://www.freedesktop.org/software/systemd/man/timesyncd.conf.html
2. https://tf.nist.gov/tf-cgi/servers.cgi
3. NIST SP 800-53 Rev. 5: AU-7, AU-8
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 251
2.1.3.2 Ensure systemd-timesyncd is enabled and running
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
systemd-timesyncd is a daemon that has been added for synchronizing the system
clock across the network
Rationale:
systemd-timesyncd needs to be enabled and running in order to synchronize the system
to a timeserver.
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Audit:
IF systemd-timesyncd is in use on the system, run the following commands:
Run the following command to verify that the systemd-timesyncd service is enabled:
# systemctl is-enabled systemd-timesyncd.service
enabled
Run the following command to verify that the systemd-timesyncd service is active:
# systemctl is-active systemd-timesyncd.service
active
Page 252
Remediation:
IF systemd-timesyncd is in use on the system, run the following commands:
Run the following command to unmask systemd-timesyncd.service:
# systemctl unmask systemd-timesyncd.service
Run the following command to enable and start systemd-timesyncd.service:
# systemctl --now enable systemd-timesyncd.service
OR
If another time synchronization service is in use on the system, run the following
command to stop and mask systemd-timesyncd:
# systemctl --now mask systemd-timesyncd.service
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 253
2.1.4 Configure ntp
ntp is a daemon which implements the Network Time Protocol (NTP). It is designed to
synchronize system clocks across a variety of systems and use a source that is highly
accurate. More information on NTP can be found at http://www.ntp.org. ntp can be
configured to be a client and/or a server.
Note:
Page 254
2.1.4.1 Ensure ntp access control is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
ntp Access Control Commands:
restrict address [mask mask] [ippeerlimit int] [flag ...]
Page 255
One or more of the following flags may be specified:
• kod - If this flag is set when an access violation occurs, a kiss-o'-death (KoD)
packet is sent. KoD packets are rate limited to no more than one per second. If
another KoD packet occurs within one second after the last one, the packet is
dropped.
• limited - Deny service if the packet spacing violates the lower limits specified in
the discard command. A history of clients is kept using the monitoring capability
of ntpd. Thus, monitoring is always active as long as there is a restriction entry
with the limited flag.
• lowpriotrap - Declare traps set by matching hosts to be low priority. The number
of traps a server can maintain is limited (the current limit is 3). Traps are usually
assigned on a first come, first served basis, with later trap requestors being
denied service. This flag modifies the assignment algorithm by allowing low
priority traps to be overridden by later requests for normal priority traps.
• noepeer - Deny ephemeral peer requests, even if they come from an
authenticated source. Note that the ability to use a symmetric key for
authentication may be restricted to one or more IPs or subnets via the third field
of the ntp.keys file. This restriction is not enabled by default, to maintain
backward compatibility. Expect noepeer to become the default in ntp-4.4.
• nomodify - Deny ntpq and ntpdc queries which attempt to modify the state of the
server (i.e., run time reconfiguration). Queries which return information are
permitted.
• noquery - Deny ntpq and ntpdc queries. Time service is not affected.
• nopeer - Deny unauthenticated packets which would result in mobilizing a new
association. This includes broadcast and symmetric active packets when a
configured association does not exist. It also includes pool associations, so if you
want to use servers from a pool directive and also want to use nopeer by default,
you'll want a restrict source ... line as well that does not include the nopeer
directive.
• noserve - Deny all packets except ntpq and ntpdc queries.
• notrap - Decline to provide mode 6 control message trap service to matching
hosts. The trap service is a subsystem of the ntpq control message protocol
which is intended for use by remote event logging programs.
• notrust - Deny service unless the packet is cryptographically authenticated.
• ntpport - This is actually a match algorithm modifier, rather than a restriction
flag. Its presence causes the restriction entry to be matched only if the source
port in the packet is the standard NTP UDP port (123). Both ntpport and non-
ntpport may be specified. The ntpport is considered more specific and is sorted
later in the list.
Rationale:
If ntp is in use on the system, proper configuration is vital to ensuring time
synchronization is accurate.
Page 256
Audit:
IF ntp is in use on the system, run the following command to verify the restrict lines:
# grep -P -- '^\h*restrict\h+((-4\h+)?|-
6\h+)default\h+(?:[^#\n\r]+\h+)*(?!(?:\2|\3|\4|\5))(\h*\bkod\b\h*|\h*\bnomodi
fy\b\h*|\h*\bnotrap\b\h*|\h*\bnopeer\b\h*|\h*\bnoquery\b\h*)\h+(?:[^#\n\r]+\h
+)*(?!(?:\1|\3|\4|\5))(\h*\bkod\b\h*|\h*\bnomodify\b\h*|\h*\bnotrap\b\h*|\h*\
bnopeer\b\h*|\h*\bnoquery\b\h*)\h+(?:[^#\n\r]+\h+)*(?!(?:\1|\2|\4|\5))(\h*\bk
od\b\h*|\h*\bnomodify\b\h*|\h*\bnotrap\b\h*|\h*\bnopeer\b\h*|\h*\bnoquery\b\h
*)\h+(?:[^#\n\r]+\h+)*(?!(?:\1|\2|\3|\5))(\h*\bkod\b\h*|\h*\bnomodify\b\h*|\h
*\bnotrap\b\h*|\h*\bnopeer\b\h*|\h*\bnoquery\b\h*)\h+(?:[^#\n\r]+\h+)*(?!(?:\
1|\2|\3|\4))(\h*\bkod\b\h*|\h*\bnomodify\b\h*|\h*\bnotrap\b\h*|\h*\bnopeer\b\
h*|\h*\bnoquery\b\h*)\h*(?:\h+\H+\h*)*(?:\h+#.*)?$' /etc/ntp.conf
Output should be similar to:
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
Verify that the output includes two lines, and both lines include: default, kod, nomodify,
notrap, nopeer and noquery.
Note: The -4 in the first line is optional, options after default may appear in any order,
and additional options may exist.
Remediation:
Add or edit restrict lines in /etc/ntp.conf to match the following:
restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp from the system:
# apt purge ntp
Default Value:
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
References:
1. http://www.ntp.org/
2. ntp.conf(5)
3. ntpd(8)
4. NIST SP 800-53 Rev. 5: AU-8
Page 257
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 258
2.1.4.2 Ensure ntp is configured with authorized timeserver
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The various modes are determined by the command keyword and the type of the
required IP address. Addresses are classed by type as (s) a remote server or peer
(IPv4 class A, B and C), (b) the broadcast address of a local interface, (m) a multicast
address (IPv4 class D), or (r) a reference clock address (127.127.x.x).
Note: That only those options applicable to each command are listed below. Use of
options not listed may not be caught as an error, but may result in some weird and even
destructive behavior.
If the Basic Socket Interface Extensions for IPv6 (RFC-2553) is detected, support for
the IPv6 address family is generated in addition to the default support of the IPv4
address family. In a few cases, including the reslist billboard generated by ntpq or
ntpdc, IPv6 addresses are automatically generated. IPv6 addresses can be identified by
the presence of colons “:” in the address field. IPv6 addresses can be used almost
everywhere where IPv4 addresses can be used, with the exception of reference clock
addresses, which are always IPv4.
Note: In contexts where a host name is expected, a -4 qualifier preceding the host
name forces DNS resolution to the IPv4 namespace, while a -6 qualifier forces DNS
resolution to the IPv6 namespace. See IPv6 references for the equivalent classes for
that address family.
• pool - For type s addresses, this command mobilizes a persistent client mode
association with a number of remote servers. In this mode the local clock can
synchronized to the remote server, but the remote server can never be
synchronized to the local clock.
• server - For type s and r addresses, this command mobilizes a persistent client
mode association with the specified remote server or local radio clock. In this
mode the local clock can synchronized to the remote server, but the remote
server can never be synchronized to the local clock. This command should not
be used for type b or m addresses.
Rationale:
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Page 259
Audit:
IF ntp is in use on the system, run the following command to display the server and/or
pool mode:
# grep -P -- '^\h*(server|pool)\h+\H+' /etc/ntp.conf
Verify that at least one pool line and/or at least three server lines are returned, and the
timeserver on the returned lines follows local site policy
Output examples:
pool mode:
Remediation:
Edit /etc/ntp.conf and add or edit server or pool lines as appropriate according to local
site policy:
<[server|pool]> <[remote-server|remote-pool]>
Examples:
pool mode:
Page 260
References:
1. http://www.ntp.org/
2. https://tf.nist.gov/tf-cgi/servers.cgi
3. ntp.conf(5)
4. ntpd(8)
5. NIST SP 800-53 Rev. 5: AU-8
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 261
2.1.4.3 Ensure ntp is running as user ntp (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The ntp package is installed with a dedicated user account ntp. This account is granted
the access required by the ntpd daemon
Note:
• If chrony or systemd-timesyncd are used, ntp should be removed and this section
skipped
• This recommendation only applies if ntp is in use on the system
• Only one time synchronization method should be in use on the system
Rationale:
The ntpd daemon should run with only the required privlidge
Audit:
IF ntp is in use on the system run the following command to verify the ntpd daemon is
being run as the user ntp:
# ps -ef | awk '(/[n]tpd/ && $1!="ntp") { print $1 }'
Nothing should be returned
Run the following command to verify the RUNASUSER= is set to ntp in /usr/lib/ntp/ntp-
systemd-wrapper:
RUNASUSER=ntp
Page 262
Remediation:
Add or edit the following line in /usr/lib/ntp/ntp-systemd-wrapper:
RUNASUSER=ntp
Run the following command to restart ntp.servocee:
# systemctl restart ntp.service
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp from the system:
# apt purge ntp
Default Value:
user ntp
References:
1. http://www.ntp.org/
2. NIST SP 800-53 Rev. 5: AU-8
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 263
2.1.4.4 Ensure ntp is enabled and running (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
ntp is a daemon for synchronizing the system clock across the network
Rationale:
ntp needs to be enabled and running in order to synchronize the system to a timeserver.
Time synchronization is important to support time sensitive security mechanisms and to
ensure log files have consistent time records across the enterprise to aid in forensic
investigations
Audit:
IF ntp is in use on the system, run the following commands:
Run the following command to verify that the ntp service is enabled:
# systemctl is-enabled ntp.service
enabled
Run the following command to verify that the ntp service is active:
# systemctl is-active ntp.service
active
Page 264
Remediation:
IF ntp is in use on the system, run the following commands:
Run the following command to unmask ntp.service:
# systemctl unmask ntp.service
Run the following command to enable and start ntp.service:
# systemctl --now enable ntp.service
OR
If another time synchronization service is in use on the system, run the following
command to remove ntp:
# apt purge ntp
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 265
2.2 Special Purpose Services
This section describes services that are installed on systems that specifically need to
run these services. If any of these services are not required, it is recommended that
they be deleted from the system to reduce the potential attack surface. If a package is
required as a dependency, and the service is not required, the service should be
stopped and masked.
The following command can be used to stop and mask the service:
# systemctl --now mask <service_name>
Page 266
2.2.1 Ensure X Window System is not installed (Automated)
Profile Applicability:
• Level 2 - Server
Description:
The X Window System provides a Graphical User Interface (GUI) where users can have
multiple windows in which to run programs and various add on. The X Windows system
is typically used on workstations where users login, but not on servers where users
typically do not login.
Rationale:
Unless your organization specifically requires graphical login access via X Windows,
remove it to reduce the potential attack surface.
Impact:
Many Linux systems run applications which require a Java runtime. Some Linux Java
packages have a dependency on specific X Windows xorg-x11-fonts. One workaround
to avoid this dependency is to use the "headless" Java packages for your specific Java
runtime, if provided by your distribution.
Audit:
Verify X Windows System is not installed:
dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
xserver-xorg* | grep -Pi '\h+installed\b'
Nothing should be returned
Remediation:
Remove the X Windows System packages:
apt purge xserver-xorg*
References:
Page 267
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 268
2.2.2 Ensure Avahi Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Avahi is a free zeroconf implementation, including a system for multicast DNS/DNS-SD
service discovery. Avahi allows programs to publish and discover services and hosts
running on a local network with no specific configuration. For example, a user can plug
a computer into a network and Avahi automatically finds printers to print to, files to look
at and people to talk to, as well as network services running on the machine.
Rationale:
Automatic discovery of network services is not normally required for system
functionality. It is recommended to remove this package to reduce the potential attack
surface.
Audit:
Run the following command to verify avahi-daemon is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
avahi-daemon
Remediation:
Run the following commands to remove avahi-daemon:
# systemctl stop avahi-daaemon.service
# systemctl stop avahi-daemon.socket
# apt purge avahi-daemon
References:
Page 269
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 270
2.2.3 Ensure CUPS is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 2 - Workstation
Description:
The Common Unix Print System (CUPS) provides the ability to print to both local and
network printers. A system running CUPS can also accept print jobs from remote
systems and print them to local printers. It also provides a web based remote
administration capability.
Rationale:
If the system does not need to print jobs or accept print jobs from other systems, it is
recommended that CUPS be removed to reduce the potential attack surface.
Impact:
Removing CUPS will prevent printing from the system, a common task for workstation
systems.
Audit:
Run the following command to verify cups is not Installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' cups
Remediation:
Run one of the following commands to remove cups :
# apt purge cups
References:
Page 271
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 272
2.2.4 Ensure DHCP Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Dynamic Host Configuration Protocol (DHCP) is a service that allows machines to
be dynamically assigned IP addresses.
Rationale:
Unless a system is specifically set up to act as a DHCP server, it is recommended that
this package be removed to reduce the potential attack surface.
Audit:
Run the following commands to verify isc-dhcp-server is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' isc-
dhcp-server
Remediation:
Run the following command to remove isc-dhcp-server:
# apt purge isc-dhcp-server
References:
Page 273
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 274
2.2.5 Ensure LDAP server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Lightweight Directory Access Protocol (LDAP) was introduced as a replacement for
NIS/YP. It is a service that provides a method for looking up information from a central
database.
Rationale:
If the system will not need to act as an LDAP server, it is recommended that the
software be removed to reduce the potential attack surface.
Audit:
Run the following command to verify slapd is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
slapd
Remediation:
Run one of the following commands to remove slapd:
# apt purge slapd
References:
Page 275
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 276
2.2.6 Ensure NFS is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Network File System (NFS) is one of the first and most widely distributed file
systems in the UNIX environment. It provides the ability for systems to mount file
systems of other servers through the network.
Rationale:
If the system does not export NFS shares, it is recommended that the nfs-kernel-
server package be removed to reduce the remote attack surface.
Audit:
Run the following command to verify nfs is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' nfs-
kernel-server
Remediation:
Run the following command to remove nfs:
# apt purge nfs-kernel-server
References:
Page 277
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 278
2.2.7 Ensure DNS Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Domain Name System (DNS) is a hierarchical naming system that maps names to
IP addresses for computers, services and other resources connected to a network.
Rationale:
Unless a system is specifically designated to act as a DNS server, it is recommended
that the package be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify DNS server is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
bind9
Remediation:
Run the following commands to disable DNS server:
# apt purge bind9
References:
Page 279
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 280
2.2.8 Ensure FTP Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The File Transfer Protocol (FTP) provides networked computers with the ability to
transfer files.
Rationale:
FTP does not protect the confidentiality of data or authentication credentials. It is
recommended SFTP be used if file transfer is required. Unless there is a need to run
the system as a FTP server (for example, to allow anonymous downloads), it is
recommended that the package be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify vsftpd is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
vsftpd
Remediation:
Run the following command to remove vsftpd:
# apt purge vsftpd
References:
Additional Information:
Additional FTP servers also exist and should be audited.
Page 281
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 282
2.2.9 Ensure HTTP server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
HTTP or web servers provide the ability to host web site content.
Rationale:
Unless there is a need to run the system as a web server, it is recommended that the
package be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify apache2 is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
apache2
Remediation:
Run the following command to remove apache2:
# apt purge apache2
References:
Additional Information:
Several httpd servers exist and can use other service names. apache2 and nginx are
example services that provide an HTTP server. These and other services should also
be audited
Page 283
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 284
2.2.10 Ensure IMAP and POP3 server are not installed
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
dovecot-imapdand dovecot-pop3d are an open source IMAP and POP3 server for Linux
based systems.
Rationale:
Unless POP3 and/or IMAP servers are to be provided by this system, it is
recommended that the package be removed to reduce the potential attack surface.
Audit:
Run the following command to verify dovecot-imapd and dovecot-pop3d are not
installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
dovecot-imapd dovecot-pop3d
Remediation:
Run one of the following commands to remove dovecot-imapd and dovecot-pop3d:
# apt purge dovecot-imapd dovecot-pop3d
References:
Additional Information:
Several IMAP/POP3 servers exist and can use other service names. courier-imap and
cyrus-imap are example services that provide a mail server. These and other services
should also be audited.
Page 285
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 286
2.2.11 Ensure Samba is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Samba daemon allows system administrators to configure their Linux systems to
share file systems and directories with Windows desktops. Samba will advertise the file
systems and directories via the Server Message Block (SMB) protocol. Windows
desktop users will be able to mount these directories and file systems as letter drives on
their systems.
Rationale:
If there is no need to mount directories and file systems to Windows systems, then this
service should be deleted to reduce the potential attack surface.
Audit:
Run the following command to verify samba is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
samba
Remediation:
Run the following command to remove samba:
# apt purge samba
References:
Page 287
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 288
2.2.12 Ensure HTTP Proxy Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Squid is a standard proxy server used in many distributions and environments.
Rationale:
If there is no need for a proxy server, it is recommended that the squid proxy be deleted
to reduce the potential attack surface.
Audit:
Run the following command to verify squid is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
squid
Remediation:
Run the following command to remove squid:
# apt purge squid
References:
Additional Information:
Several HTTP proxy servers exist. These and other services should be checked
Page 289
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 290
2.2.13 Ensure SNMP Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Simple Network Management Protocol (SNMP) is a widely used protocol for monitoring
the health and welfare of network equipment, computer equipment and devices like
UPSs.
Net-SNMP is a suite of applications used to implement SNMPv1 (RFC 1157), SNMPv2
(RFCs 1901-1908), and SNMPv3 (RFCs 3411-3418) using both IPv4 and IPv6.
Support for SNMPv2 classic (a.k.a. "SNMPv2 historic" - RFCs 1441-1452) was dropped
with the 4.0 release of the UCD-snmp package.
The Simple Network Management Protocol (SNMP) server is used to listen for SNMP
commands from an SNMP management system, execute the commands or collect the
information and then send results back to the requesting system.
Rationale:
The SNMP server can communicate using SNMPv1, which transmits data in the clear and
does not require authentication to execute commands. SNMPv3 replaces the simple/clear
text password sharing used in SNMPv2 with more securely encoded parameters. If the
the SNMP service is not required, the snmpd package should be removed to reduce the
attack surface of the system.
Note: If SNMP is required:
• The server should be configured for SNMP v3 only. User Authentication and
Message Encryption should be configured.
• If SNMP v2 is absolutely necessary, modify the community strings' values.
Audit:
Run the following command to verify snmpd is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
snmpd
Page 291
Remediation:
Run the following command to remove snmpd:
# apt purge snmpd
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 292
2.2.14 Ensure NIS Server is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Network Information Service (NIS) (formally known as Yellow Pages) is a client-
server directory service protocol for distributing system configuration files. The NIS
server is a collection of programs that allow for the distribution of configuration files.
Rationale:
The NIS service is inherently an insecure system that has been vulnerable to DOS
attacks, buffer overflows and has poor authentication for querying NIS maps. NIS
generally has been replaced by such protocols as Lightweight Directory Access
Protocol (LDAP). It is recommended that the service be removed and other, more
secure services be used
Audit:
Run the following command to verify nis is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' nis
Remediation:
Run the following command to remove nis:
# apt purge nis
References:
Page 293
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 294
2.2.15 Ensure dnsmasq is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
dnsmasqis a lightweight tool that provides DNS caching, DNS forwarding and DHCP
(Dynamic Host Configuration Protocol) services.
Rationale:
Unless a system is specifically designated to act as a DNS caching, DNS forwarding
and/or DHCP server, it is recommended that the package be removed to reduce the
potential attack surface.
Audit:
Run one of the following commands to verify dnsmasq is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
dnsmasq
Remediation:
Run the following command to remove dnsmasq:
# apt purge dnsmasq
References:
Page 295
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 296
2.2.16 Ensure mail transfer agent is configured for local-only
mode (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Mail Transfer Agents (MTA), such as sendmail and Postfix, are used to listen for
incoming mail and transfer the messages to the appropriate user or mail server. If the
system is not intended to be a mail server, it is recommended that the MTA be
configured to only process local mail.
Rationale:
The software for all Mail Transfer Agents is complex and most have a long history of
security issues. While it is important to ensure that the system can process local mail
messages, it is not necessary to have the MTA's daemon listening on a port unless the
server is intended to be a mail server that receives and processes mail from other
systems.
Note:
Audit:
Run the following command to verify that the MTA is not listening on any non-loopback
address (127.0.0.1 or::1).
# ss -lntu | grep -P ':25\b' | grep -Pv '\h+(127\.0\.0\.1|\[?::1\]?):25\b'
Nothing should be returned
Page 297
Remediation:
Edit /etc/postfix/main.cf and add the following line to the RECEIVING MAIL section.
If the line already exists, change it to look like the line below:
inet_interfaces = loopback-only
Run the following command to restart postfix:
# systemctl restart postfix
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 298
2.2.17 Ensure rsync service is either not installed or is masked
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The rsync service can be used to synchronize files between systems over network
links.
Rationale:
The rsync service presents a security risk as the rsync protocol is unencrypted. The
rsync package should be removed or if required for dependencies, the rsync service
should be stopped and masked to reduce the attack area of the system.
Audit:
Run the following command to verify rsync is not installed:
dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' rsync
inactive
masked
Page 299
Remediation:
Run the following command to remove rsync:
# apt purge rsync
-- OR --
Run the following commands to stop and mask rsync:
# systemctl stop rsync
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 300
2.3 Service Clients
A number of insecure services exist. While disabling the servers prevents a local attack
against these services, it is advised to remove their clients unless they are required.
Note: This should not be considered a comprehensive list of insecure service clients.
You may wish to consider additions to those listed here for your environment.
Page 301
2.3.1 Ensure NIS Client is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Network Information Service (NIS), formerly known as Yellow Pages, is a client-
server directory service protocol used to distribute system configuration files. The NIS
client was used to bind a machine to an NIS server and receive the distributed
configuration files.
Rationale:
The NIS service is inherently an insecure system that has been vulnerable to DOS
attacks, buffer overflows and has poor authentication for querying NIS maps. NIS
generally has been replaced by such protocols as Lightweight Directory Access
Protocol (LDAP). It is recommended that the service be removed.
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify nis is not installed. Use the following command to provide the needed
information:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' nis
Remediation:
Uninstall nis:
# apt purge nis
References:
Page 302
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 303
2.3.2 Ensure rsh client is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The rsh-client package contains the client commands for the rsh services.
Rationale:
These legacy clients contain numerous security exposures and have been replaced with
the more secure SSH package. Even if the server is removed, it is best to ensure the
clients are also removed to prevent users from inadvertently attempting to use these
commands and therefore exposing their credentials. Note that removing the rsh-client
package removes the clients for rsh , rcp and rlogin .
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify rsh-client is not installed. Use the following command to provide the needed
information:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' rsh-
client
Remediation:
Uninstall rsh:
# apt purge rsh-client
References:
Page 304
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 305
2.3.3 Ensure talk client is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The talk software makes it possible for users to send and receive messages across
systems through a terminal session. The talk client, which allows initialization of talk
sessions, is installed by default.
Rationale:
The software presents a security risk as it uses unencrypted protocols for
communication.
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify talk is not installed. The following command may provide the needed
information:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' talk
Remediation:
Uninstall talk:
# apt purge talk
References:
Page 306
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 307
2.3.4 Ensure telnet client is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The telnet package contains the telnet client, which allows users to start connections
to other systems via the telnet protocol.
Rationale:
The telnet protocol is insecure and unencrypted. The use of an unencrypted
transmission medium could allow an unauthorized user to steal credentials. The ssh
package provides an encrypted session and stronger security and is included in most
Linux distributions.
Impact:
Many insecure service clients are used as troubleshooting tools and in testing
environments. Uninstalling them can inhibit capability to test and troubleshoot. If they
are required it is advisable to remove the clients after use to prevent accidental or
intentional misuse.
Audit:
Verify telnet is not installed. Use the following command to provide the needed
information:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
telnet
Remediation:
Uninstall telnet:
# apt purge telnet
References:
Page 308
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 309
2.3.5 Ensure LDAP client is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Lightweight Directory Access Protocol (LDAP) was introduced as a replacement for
NIS/YP. It is a service that provides a method for looking up information from a central
database.
Rationale:
If the system will not need to act as an LDAP client, it is recommended that the software
be removed to reduce the potential attack surface.
Impact:
Removing the LDAP client will prevent or inhibit using LDAP for authentication in your
environment.
Audit:
Verify that ldap-utils is not installed. Use the following command to provide the
needed information:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
ldap-utils
Remediation:
Uninstall ldap-utils:
# apt purge ldap-utils
References:
Page 310
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 311
2.3.6 Ensure RPC is not installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Remote Procedure Call (RPC) is a method for creating low level client server
applications across different system architectures. It requires an RPC compliant client
listening on a network port. The supporting package is rpcbind."
Rationale:
If RPC is not required, it is recommended that this services be removed to reduce the
remote attack surface.
Audit:
Run the following command to verify rpcbind is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
rpcbind
Remediation:
Run the following command to remove rpcbind:
# apt purge rpcbind
References:
Page 312
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 313
2.4 Ensure nonessential services are removed or masked
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
A network port is identified by its number, the associated IP address, and the type of the
communication protocol such as TCP or UDP.
A listening port is a network port on which an application or process listens on, acting as
a communication endpoint.
Each listening port can be open or closed (filtered) using a firewall. In general terms, an
open port is a network port that accepts incoming packets from remote locations.
Rationale:
Services listening on the system pose a potential risk as an attack vector. These
services should be reviewed, and if not required, the service should be stopped, and the
package containing the service should be removed. If required packages have a
dependency, the service should be stopped and masked to reduce the attack surface of
the system.
Audit:
Run the following command:
# ss -plntu
Review the output to ensure that all services listed are required on the system. If a listed
service is not required, remove the package containing the service. If the package
containing the service is required, stop and mask the service
Page 314
Remediation:
Run the following command to remove the package containing the service:
# apt purge <package_name>
OR If required packages have a dependency:
Run the following commands to stop and mask the service:
# systemctl stop <service_name>.socket
# systemctl stop <service_name>.service
# systemctl mask <service_name>.socket
# systemctl mask <service_name>.service
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 315
3 Network Configuration
This section provides guidance on for securing the network configuration of the system
through kernel parameters, access list control, and firewall settings.
Note:
Page 316
3.1 Disable unused network protocols and devices
To reduce the attack surface of a system, unused network protocols and devices should
be disabled.
The Linux kernel modules support several network protocols that are not commonly
used. If these protocols are not needed, it is recommended that they be disabled in the
kernel.
Note: This should not be considered a comprehensive list of uncommon network
protocols, you may wish to consider additions to those listed here for your environment.
Page 317
3.1.1 Ensure IPv6 status is identified (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Internet Protocol Version 6 (IPv6) is the most recent version of Internet Protocol (IP). It's
designed to supply IP addressing and additional security to support the predicted
growth of connected devices. IPv6 is based on 128-bit addressing and can support 340
undecillion addresses, which is 340 followed by 36 zeroes.
Features of IPv6
Rationale:
IETF RFC 4038 recommends that applications are built with an assumption of dual
stack. It is recommended that IPv6 be enabled and configured in accordance with
Benchmark recommendations.
If dual stack and IPv6 are not used in your environment, IPv6 may be disabled to
reduce the attack surface of the system, and recommendations pertaining to IPv6 can
be skipped.
Note: It is recommended that IPv6 be enabled and configured unless this is against
local site policy
Impact:
IETF RFC 4038 recommends that applications are built with an assumption of dual
stack.
When enabled, IPv6 will require additional configuration to reduce risk to the system.
Page 318
Audit:
Run the following to identify if IPv6 is enabled on the system:
# grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && echo -e "\n -
IPv6 is enabled\n" || echo -e "\n - IPv6 is not enabled\n"
Remediation:
Enable or disable IPv6 in accordance with system requirements and local site policy
Default Value:
IPv6 is enabled
References:
Additional Information:
Having more addresses has grown in importance with the expansion of smart devices
and connectivity. IPv6 provides more than enough globally unique IP addresses for
every networked device currently on the planet, helping ensure providers can keep pace
with the expected proliferation of IP-based devices.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 319
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 320
3.1.2 Ensure wireless interfaces are disabled (Automated)
Profile Applicability:
• Level 1 - Server
Description:
Wireless networking is used when wired networks are unavailable. Debian contains a
wireless tool kit to allow system administrators to configure and use wireless networks.
Rationale:
If wireless is not to be used, wireless devices can be disabled to reduce the potential
attack surface.
Impact:
Many if not all laptop workstations and some desktop workstations will connect via
wireless requiring these interfaces be enabled.
Audit:
Run the following script to verify no wireless interfaces are active on the system:
Page 321
#!/usr/bin/env bash
{
l_output="" l_output2=""
module_chk()
{
# Check how module will be loaded
l_loadable="$(modprobe -n -v "$l_mname")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable";
then
l_output="$l_output\n - module: \"$l_mname\" is not loadable:
\"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable:
\"$l_loadable\""
fi
# Check is the module currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
# Check if the module is deny listed
if modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mname\b";
then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in:
\"$(grep -Pl -- "^\h*blacklist\h+$l_mname\b" /etc/modprobe.d/*)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
if [ -n "$(find /sys/class/net/*/ -type d -name wireless)" ]; then
l_dname=$(for driverdir in $(find /sys/class/net/*/ -type d -name
wireless | xargs -0 dirname); do basename "$(readlink -f
"$driverdir"/device/driver/module)";done | sort -u)
for l_mname in $l_dname; do
module_chk
done
fi
# Report results. If no failures output in l_output2, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **"
if [ -z "$l_output" ]; then
echo -e "\n - System has no wireless NICs installed"
else
echo -e "\n$l_output\n"
fi
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit
failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 322
Remediation:
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
}
References:
Page 323
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 324
3.1.3 Ensure bluetooth is disabled (Automated)
Profile Applicability:
• Level 1 - Server
Description:
Bluetooth is a short-range wireless technology standard that is used for exchanging
data between devices over short distances. It employs UHF radio waves in the ISM
bands, from 2.402 GHz to 2.48 GHz. It is mainly used as an alternative to wire
connections.
Rationale:
An attacker may be able to find a way to access or corrupt your data. One example of
this type of activity is bluesnarfing, which refers to attackers using a Bluetooth
connection to steal information off of your Bluetooth device. Also, viruses or other
malicious code can take advantage of Bluetooth technology to infect other devices. If
you are infected, your data may be corrupted, compromised, stolen, or lost.
Impact:
Many personal electronic devices (PEDs) use Bluetooth technology. For example, you
may be able to operate your computer with a wireless keyboard. Disabling Bluetooth will
prevent these devices from connecting to the system.
Audit:
Run the following commands to verify that the Bluetooth service is disabled:
Run the following command to verify that the Bluetooth service is not enabled:
# systemctl is-enabled bluetooth.service | grep '^enabled'
Remediation:
Run the following commands to stop and mask the Bluetooth service
# systemctl stop bluetooth.service
# systemctl mask bluetooth.service
Note: A reboot may be required
Page 325
References:
1. https://www.cisa.gov/tips/st05-015
2. NIST SP 800-53 Rev. 5: CM-7
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 326
3.1.4 Ensure DCCP is disabled (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The Datagram Congestion Control Protocol (DCCP) is a transport layer protocol that
supports streaming media and telephony. DCCP provides a way to gain access to
congestion control, without having to do it at the application layer, but does not provide
in-sequence delivery.
Rationale:
If the protocol is not required, it is recommended that the drivers not be installed to
reduce the potential attack surface.
Audit:
Run the following script to verify the dccp module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 327
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="dccp" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 328
Remediation:
Run the following script to disable the dccp module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 329
#!/usr/bin/env bash
{
l_mname="dccp" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 330
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 331
3.1.5 Ensure SCTP is disabled (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The Stream Control Transmission Protocol (SCTP) is a transport layer protocol used to
support message oriented communication, with several streams of messages in one
connection. It serves a similar function as TCP and UDP, incorporating features of both.
It is message-oriented like UDP, and ensures reliable in-sequence transport of
messages with congestion control like TCP.
Rationale:
If the protocol is not being used, it is recommended that kernel module not be loaded,
disabling the service to reduce the potential attack surface.
Audit:
Run the following script to verify the sctp module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 332
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="sctp" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 333
Remediation:
Run the following script to disable the sctp module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 334
#!/usr/bin/env bash
{
l_mname="sctp" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 335
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 336
3.1.6 Ensure RDS is disabled (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The Reliable Datagram Sockets (RDS) protocol is a transport layer protocol designed to
provide low-latency, high-bandwidth communications between cluster nodes. It was
developed by the Oracle Corporation.
Rationale:
If the protocol is not being used, it is recommended that kernel module not be loaded,
disabling the service to reduce the potential attack surface.
Audit:
Run the following script to verify the rds module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 337
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="rds" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 338
Remediation:
Run the following script to disable the rds module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 339
#!/usr/bin/env bash
{
l_mname="rds" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
Page 340
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 341
3.1.7 Ensure TIPC is disabled (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The Transparent Inter-Process Communication (TIPC) protocol is designed to provide
communication between cluster nodes.
Rationale:
If the protocol is not being used, it is recommended that kernel module not be loaded,
disabling the service to reduce the potential attack surface.
Audit:
Run the following script to verify the tipc module is disabled:
If the module is available in the running kernel:
If the kernel module is not available on the system, or pre-compiled into the kernel:
Page 342
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_dl="" # Unset output variables
l_mname="tipc" # set module name
l_mtype="net" # set module type
l_searchloc="/lib/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf
/etc/modprobe.d/*.conf"
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_chk()
{
# Check if the module is currently loadable
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
l_output="$l_output\n - module: \"$l_mname\" is not loadable: \"$l_loadable\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is loadable: \"$l_loadable\""
fi
}
module_loaded_chk()
{
# Check if the module is currently loaded
if ! lsmod | grep "$l_mname" > /dev/null 2>&1; then
l_output="$l_output\n - module: \"$l_mname\" is not loaded"
else
l_output2="$l_output2\n - module: \"$l_mname\" is loaded"
fi
}
module_deny_chk()
{
# Check if the module is deny listed
l_dl="y"
if modprobe --showconfig | grep -Pq -- '^\h*blacklist\h+'"$l_mpname"'\b'; then
l_output="$l_output\n - module: \"$l_mname\" is deny listed in: \"$(grep -Pls --
"^\h*blacklist\h+$l_mname\b" $l_searchloc)\""
else
l_output2="$l_output2\n - module: \"$l_mname\" is not deny listed"
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
l_output3="$l_output3\n - \"$l_mdir\""
[ "$l_dl" != "y" ] && module_deny_chk
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_chk
module_loaded_chk
fi
else
l_output="$l_output\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\""
fi
done
# Report results. If no failures output in l_output2, we pass
[ -n "$l_output3" ] && echo -e "\n\n -- INFO --\n - module: \"$l_mname\" exists in:$l_output3"
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 343
Remediation:
Run the following script to disable the tipc module:
If the module is available in the running kernel:
If the kernel module is not available on the system or pre-compiled into the kernel:
• No remediation is necessary
Page 344
#!/usr/bin/env bash
{
l_mname="tipc" # set module name
l_mtype="net" # set module type
l_mpath="/lib/modules/**/kernel/$l_mtype"
l_mpname="$(tr '-' '_' <<< "$l_mname")"
l_mndir="$(tr '-' '/' <<< "$l_mname")"
module_loadable_fix()
{
# If the module is currently loadable, add "install {MODULE_NAME} /bin/false" to a file in
"/etc/modprobe.d"
l_loadable="$(modprobe -n -v "$l_mname")"
[ "$(wc -l <<< "$l_loadable")" -gt "1" ] && l_loadable="$(grep -P --
"(^\h*install|\b$l_mname)\b" <<< "$l_loadable")"
if ! grep -Pq -- '^\h*install \/bin\/(true|false)' <<< "$l_loadable"; then
echo -e "\n - setting module: \"$l_mname\" to be not loadable"
echo -e "install $l_mname /bin/false" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
module_loaded_fix()
{
# If the module is currently loaded, unload the module
if lsmod | grep "$l_mname" > /dev/null 2>&1; then
echo -e "\n - unloading module \"$l_mname\""
modprobe -r "$l_mname"
fi
}
module_deny_fix()
{
# If the module isn't deny listed, denylist the module
if ! modprobe --showconfig | grep -Pq -- "^\h*blacklist\h+$l_mpname\b"; then
echo -e "\n - deny listing \"$l_mname\""
echo -e "blacklist $l_mname" >> /etc/modprobe.d/"$l_mpname".conf
fi
}
# Check if the module exists on the system
for l_mdir in $l_mpath; do
if [ -d "$l_mdir/$l_mndir" ] && [ -n "$(ls -A $l_mdir/$l_mndir)" ]; then
echo -e "\n - module: \"$l_mname\" exists in \"$l_mdir\"\n - checking if disabled..."
module_deny_fix
if [ "$l_mdir" = "/lib/modules/$(uname -r)/kernel/$l_mtype" ]; then
module_loadable_fix
module_loaded_fix
fi
else
echo -e "\n - module: \"$l_mname\" doesn't exist in \"$l_mdir\"\n"
fi
done
echo -e "\n - remediation of module: \"$l_mname\" complete\n"
}
References:
Page 345
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 346
3.2 Network Parameters (Host Only)
The following network parameters are intended for use if the system is to act as a host
only. A system is considered host only if the system has a single interface, or has
multiple interfaces but will not be configured as a router.
Note:
Configuration files are read from directories in /etc/, /run/, /usr/local/lib/, and
/lib/, in order of precedence. Files must have the the ".conf" extension. extension.
Files in /etc/ override files with the same name in /run/, /usr/local/lib/, and /lib/.
Files in /run/ override files with the same name under /usr/.
All configuration files are sorted by their filename in lexicographic order, regardless of
which of the directories they reside in. If multiple files specify the same option, the entry
in the file with the lexicographically latest name will take precedence. Thus, the
configuration in a certain file may either be replaced completely (by placing a file with
the same name in a directory with higher priority), or individual settings might be
changed (by specifying additional settings in a file with a different name that is ordered
later).
Packages should install their configuration files in /usr/lib/ (distribution packages) or
/usr/local/lib/ (local installs). Files in /etc/ are reserved for the local administrator,
who may use this logic to override the configuration files installed by vendor packages.
It is recommended to prefix all filenames with a two-digit number and a dash, to simplify
the ordering of the files.
If the administrator wants to disable a configuration file supplied by the vendor, the
recommended way is to place a symlink to /dev/null in the configuration directory in
/etc/, with the same filename as the vendor configuration file. If the vendor
configuration file is included in the initrd image, the image has to be regenerated.
Page 347
3.2.1 Ensure packet redirect sending is disabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
ICMP Redirects are used to send routing information to other hosts. As a host itself
does not act as a router (in a host only configuration), there is no need to send
redirects.
Rationale:
An attacker could use a compromised host to send invalid ICMP redirects to other
router devices in an attempt to corrupt routing and have users access a system set up
by the attacker as opposed to a valid system.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.conf.all.send_redirects is set to 0
• net.ipv4.conf.default.send_redirects is set to 0
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 348
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.send_redirects=0" "net.ipv4.conf.default.send_redirects=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 349
Remediation:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.conf.all.send_redirects = 0
• net.ipv4.conf.default.send_redirects = 0
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.send_redirects = 1
net.ipv4.conf.default.send_redirects = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 350
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 351
3.2.2 Ensure IP forwarding is disabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The net.ipv4.ip_forward and net.ipv6.conf.all.forwarding flags are used to tell the
system whether it can forward packets or not.
Rationale:
Setting net.ipv4.ip_forward and net.ipv6.conf.all.forwarding to 0 ensures that a
system with multiple interfaces (for example, a hard proxy), will never be able to forward
packets, and therefore, never serve as a router.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.ip_forward is set to 0
• net.ipv6.conf.all.forwarding is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
conically later file, that "correct" setting will be ignored both by the script and by
the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 352
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.ip_forward=0" "net.ipv6.conf.all.forwarding=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 353
Remediation:
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.ip_forward = 0
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 file in /etc/sysctl.d/ ending in
.conf:
• net.ipv6.conf.all.forwarding = 0
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.ip_forward = 0
net.ipv6.conf.all.forwarding = 0
References:
Page 354
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 355
3.3 Network Parameters (Host and Router)
The following network parameters are intended for use on both host only and router
systems. A system acts as a router if it has at least two interfaces and is configured to
perform routing functions.
Note:
Configuration files are read from directories in /etc/, /run/, /usr/local/lib/, and
/lib/, in order of precedence. Files must have the ".conf" extension. extension. Files
in /etc/ override files with the same name in /run/, /usr/local/lib/, and /lib/. Files
in /run/ override files with the same name under /usr/.
All configuration files are sorted by their filename in lexicographic order, regardless of
which of the directories they reside in. If multiple files specify the same option, the entry
in the file with the lexicographically latest name will take precedence. Thus, the
configuration in a certain file may either be replaced completely (by placing a file with
the same name in a directory with higher priority), or individual settings might be
changed (by specifying additional settings in a file with a different name that is ordered
later).
Packages should install their configuration files in /usr/lib/ (distribution packages) or
/usr/local/lib/ (local installs). Files in /etc/ are reserved for the local administrator,
who may use this logic to override the configuration files installed by vendor packages.
It is recommended to prefix all filenames with a two-digit number and a dash, to simplify
the ordering of the files.
If the administrator wants to disable a configuration file supplied by the vendor, the
recommended way is to place a symlink to /dev/null in the configuration directory in
/etc/, with the same filename as the vendor configuration file. If the vendor
configuration file is included in the initrd image, the image has to be regenerated.
Page 356
3.3.1 Ensure source routed packets are not accepted
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
In networking, source routing allows a sender to partially or fully specify the route
packets take through a network. In contrast, non-source routed packets travel a path
determined by routers in the network. In some cases, systems may not be routable or
reachable from some locations (e.g. private addresses vs. Internet routable), and so
source routed packets would need to be used.
Rationale:
Setting net.ipv4.conf.all.accept_source_route,
net.ipv4.conf.default.accept_source_route,
net.ipv6.conf.all.accept_source_route and
net.ipv6.conf.default.accept_source_route to 0 disables the system from accepting
source routed packets. Assume this system was capable of routing packets to Internet
routable addresses on one interface and private addresses on another interface.
Assume that the private addresses were not routable to the Internet routable addresses
and vice versa. Under normal routing circumstances, an attacker from the Internet
routable addresses could not use the system as a way to reach the private address
systems. If, however, source routed packets were allowed, they could be used to gain
access to the private address systems as the route could be specified, rather than rely
on routing protocols that did not allow this routing.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.conf.all.accept_source_route is set to 0
• net.ipv4.conf.default.accept_source_route is set to 0
• net.ipv6.conf.all.accept_source_route is set to 0
• net.ipv6.conf.default.accept_source_route is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
conically later file, that "correct" setting will be ignored both by the script and by
the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 357
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.accept_source_route=0"
"net.ipv4.conf.default.accept_source_route=0" "net.ipv6.conf.all.accept_source_route=0"
"net.ipv6.conf.default.accept_source_route=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 358
Remediation:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.conf.all.accept_source_route = 0
• net.ipv4.conf.default.accept_source_route = 0
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 file in /etc/sysctl.d/ ending in
.conf:
• net.ipv6.conf.all.accept_source_route = 0
• net.ipv6.conf.default.accept_source_route = 0
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0
Page 359
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 360
3.3.2 Ensure ICMP redirects are not accepted (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
ICMP redirect messages are packets that convey routing information and tell your host
(acting as a router) to send packets via an alternate path. It is a way of allowing an
outside routing device to update your system routing tables.
Rationale:
ICMP redirect messages are packets that convey routing information and tell your host
(acting as a router) to send packets via an alternate path. It is a way of allowing an
outside routing device to update your system routing tables. By setting
net.ipv4.conf.all.accept_redirects, net.ipv4.conf.default.accept_redirects,
net.ipv6.conf.all.accept_redirects, and net.ipv6.conf.default.accept_redirects
to 0, the system will not accept any ICMP redirect messages, and therefore, won't allow
outsiders to update the system's routing tables.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.conf.all.accept_redirects is set to 0
• net.ipv4.conf.default.accept_redirects is set to 0
• net.ipv6.conf.all.accept_redirects is set to 0
• net.ipv6.conf.default.accept_redirects is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
conically later file, that "correct" setting will be ignored both by the script and by
the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 361
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.accept_redirects=0" "net.ipv4.conf.default.accept_redirects=0"
"net.ipv6.conf.all.accept_redirects=0" "net.ipv6.conf.default.accept_redirects=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 362
Remediation:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.conf.all.accept_redirects = 0
• net.ipv4.conf.default.accept_redirects = 0
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 file in /etc/sysctl.d/ ending in
.conf:
• net.ipv6.conf.all.accept_redirects = 0
• net.ipv6.conf.default.accept_redirects = 0
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.accept_redirects = 1
net.ipv4.conf.default.accept_redirects = 1
net.ipv6.conf.all.accept_redirects = 1
net.ipv6.conf.default.accept_redirects = 1
Page 363
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 364
3.3.3 Ensure secure ICMP redirects are not accepted
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Secure ICMP redirects are the same as ICMP redirects, except they come from
gateways listed on the default gateway list. It is assumed that these gateways are
known to your system, and that they are likely to be secure.
Rationale:
It is still possible for even known gateways to be compromised. Setting
net.ipv4.conf.all.secure_redirects and net.ipv4.conf.default.secure_redirects
to 0 protects the system from routing table updates by possibly compromised known
gateways.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.conf.all.secure_redirects is set to 0
• net.ipv4.conf.default.secure_redirects is set to 0
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 365
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.secure_redirects=0" "net.ipv4.conf.default.secure_redirects=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 366
Remediation:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.conf.all.secure_redirects = 0
• net.ipv4.conf.default.secure_redirects = 0
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.secure_redirects = 1
net.ipv4.conf.default.secure_redirects = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 367
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 368
3.3.4 Ensure suspicious packets are logged (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
When enabled, this feature logs packets with un-routable source addresses to the
kernel log.
Rationale:
Setting net.ipv4.conf.all.log_martians and net.ipv4.conf.default.log_martians
to 1` enables this feature. Logging these packets allows an administrator to investigate
the possibility that an attacker is sending spoofed packets to their system.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.conf.all.log_martians is set to 1
• net.ipv4.conf.default.log_martians is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 369
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.log_martians=1" "net.ipv4.conf.default.log_martians=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 370
Remediation:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.conf.all.log_martians = 1
• net.ipv4.conf.default.log_martians = 1
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.log_martians = 0
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 371
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 372
3.3.5 Ensure broadcast ICMP requests are ignored (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting net.ipv4.icmp_echo_ignore_broadcasts to 1 will cause the system to ignore all
ICMP echo and timestamp requests to broadcast and multicast addresses.
Rationale:
Accepting ICMP echo and timestamp requests with broadcast or multicast destinations
for your network could be used to trick your host into starting (or participating) in a
Smurf attack. A Smurf attack relies on an attacker sending large amounts of ICMP
broadcast messages with a spoofed source address. All hosts receiving this message
and responding would send echo-reply messages back to the spoofed address, which is
probably not routable. If many hosts respond to the packets, the amount of traffic on the
network could be significantly multiplied.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.icmp_echo_ignore_broadcasts is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 373
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.icmp_echo_ignore_broadcasts=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 374
Remediation:
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.icmp_echo_ignore_broadcasts = 1
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.default.log_martians = 0
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 375
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 376
3.3.6 Ensure bogus ICMP responses are ignored (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting net.ipv4.icmp_ignore_bogus_error_responses to 1 prevents the kernel from
logging bogus responses (RFC-1122 non-compliant) from broadcast reframes, keeping
file systems from filling up with useless log messages.
Rationale:
Some routers (and some attackers) will send responses that violate RFC-1122 and
attempt to fill up a log file system with many useless error messages.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.icmp_ignore_bogus_error_responses is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 377
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.icmp_ignore_bogus_error_responses=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 378
Remediation:
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.icmp_ignore_bogus_error_responses = 1
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.icmp_ignore_bogus_error_responses = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 379
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 380
3.3.7 Ensure Reverse Path Filtering is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Setting net.ipv4.conf.all.rp_filter and net.ipv4.conf.default.rp_filter to 1
forces the Linux kernel to utilize reverse path filtering on a received packet to determine
if the packet was valid. Essentially, with reverse path filtering, if the return packet does
not go out the same interface that the corresponding source packet came from, the
packet is dropped (and logged if log_martians is set).
Rationale:
Setting net.ipv4.conf.all.rp_filter and net.ipv4.conf.default.rp_filter to 1 is a
good way to deter attackers from sending your system bogus packets that cannot be
responded to. One instance where this feature 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.
Impact:
If you are using asymmetrical routing on your system, you will not be able to enable this
feature without breaking the routing.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.conf.all.rp_filter is set to 1
• net.ipv4.conf.default.rp_filter is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 381
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.conf.all.rp_filter=1" "net.ipv4.conf.default.rp_filter=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 382
Remediation:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.conf.all.rp_filter = 1
• net.ipv4.conf.default.rp_filter = 1
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 383
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 384
3.3.8 Ensure TCP SYN Cookies is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
When tcp_syncookies is set, the kernel will handle TCP SYN packets normally until the
half-open connection queue is full, at which time, the SYN cookie functionality kicks in.
SYN cookies work by not using the SYN queue at all. Instead, the kernel simply replies
to the SYN with a SYN|ACK, but will include a specially crafted TCP sequence number
that encodes the source and destination IP address and port number and the time the
packet was sent. A legitimate connection would send the ACK packet of the three way
handshake with the specially crafted sequence number. This allows the system to verify
that it has received a valid response to a SYN cookie and allow the connection, even
though there is no corresponding SYN in the queue.
Rationale:
Attackers use SYN flood attacks to perform a denial of service attacked on a system by
sending many SYN packets without completing the three way handshake. This will
quickly use up slots in the kernel's half-open connection queue and prevent legitimate
connections from succeeding. Setting net.ipv4.tcp_syncookies to 1 enables SYN
cookies, allowing the system to keep accepting valid connections, even if under a denial
of service attack.
Audit:
Run the following script to verify the following kernel parameter is set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv4.tcp_syncookies is set to 1
Note: kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded, the
parameter is overridden by an incorrect setting later in that file, or in a conically later file,
that "correct" setting will be ignored both by the script and by the system during a
normal kernel parameter load sequence.
Page 385
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv4.tcp_syncookies=1")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 386
Remediation:
Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv4.tcp_syncookies = 1
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv4.tcp_syncookies = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 387
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 388
3.3.9 Ensure IPv6 router advertisements are not accepted
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
This setting disables the system's ability to accept IPv6 router advertisements.
Rationale:
It is recommended that systems do not accept router advertisements as they could be
tricked into routing traffic to compromised machines. Setting hard routes within the
system (usually a single default route to a trusted router) protects the system from bad
routes. Setting net.ipv6.conf.all.accept_ra and net.ipv6.conf.default.accept_ra
to 0 disables the system's ability to accept IPv6 router advertisements.
Audit:
Run the following script to verify the following kernel parameters are set in the running
configuration and correctly loaded from a kernel parameter configuration file:
• net.ipv6.conf.all.accept_ra is set to 0
• net.ipv6.conf.default.accept_ra is set to 0
Note:
• kernel parameters are loaded by file and parameter order precedence. The
following script observes this precedence as part of the auditing procedure. The
parameters being checked may be set correctly in a file. If that file is superseded,
the parameter is overridden by an incorrect setting later in that file, or in a
conically later file, that "correct" setting will be ignored both by the script and by
the system during a normal kernel parameter load sequence.
• IPv6 kernel parameters only apply to systems where IPv6 is enabled
Page 389
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_parlist=("net.ipv6.conf.all.accept_ra=0" "net.ipv6.conf.default.accept_ra=0")
l_ufwscf="$([ -f /etc/default/ufw ] && awk -F= '/^\s*IPT_SYSCTL=/ {print $2}'
/etc/default/ufw)"
kernel_parameter_chk()
{
l_krp="$(sysctl "$l_kpname" | awk -F= '{print $2}' | xargs)" # Check running configuration
if [ "$l_krp" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_krp\" in the running
configuration"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_krp\" in the running
configuration and should have a value of: \"$l_kpvalue\""
fi
unset A_out; declare -A A_out # Check durable setting (files)
while read -r l_out; do
if [ -n "$l_out" ]; then
if [[ $l_out =~ ^\s*# ]]; then
l_file="${l_out//# /}"
else
l_kpar="$(awk -F= '{print $1}' <<< "$l_out" | xargs)"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_file")
fi
fi
done < <(/usr/lib/systemd/systemd-sysctl --cat-config | grep -Po
'^\h*([^#\n\r]+|#\h*\/[^#\n\r\h]+\.conf\b)')
if [ -n "$l_ufwscf" ]; then # Account for systems with UFW (Not covered by systemd-sysctl -
-cat-config)
l_kpar="$(grep -Po "^\h*$l_kpname\b" "$l_ufwscf" | xargs)"
l_kpar="${l_kpar//\//.}"
[ "$l_kpar" = "$l_kpname" ] && A_out+=(["$l_kpar"]="$l_ufwscf")
fi
if (( ${#A_out[@]} > 0 )); then # Assess output from files and generate output
while IFS="=" read -r l_fkpname l_fkpvalue; do
l_fkpname="${l_fkpname// /}"; l_fkpvalue="${l_fkpvalue// /}"
if [ "$l_fkpvalue" = "$l_kpvalue" ]; then
l_output="$l_output\n - \"$l_kpname\" is correctly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\"\n"
else
l_output2="$l_output2\n - \"$l_kpname\" is incorrectly set to \"$l_fkpvalue\" in
\"$(printf '%s' "${A_out[@]}")\" and should have a value of: \"$l_kpvalue\"\n"
fi
done < <(grep -Po -- "^\h*$l_kpname\h*=\h*\H+" "${A_out[@]}")
else
l_output2="$l_output2\n - \"$l_kpname\" is not set in an included file\n ** Note:
\"$l_kpname\" May be set in a file that's ignored by load procedure **\n"
fi
}
while IFS="=" read -r l_kpname l_kpvalue; do # Assess and check parameters
l_kpname="${l_kpname// /}"; l_kpvalue="${l_kpvalue// /}"
if ! grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable && grep -q '^net.ipv6.' <<<
"$l_kpname"; then
l_output="$l_output\n - IPv6 is disabled on the system, \"$l_kpname\" is not applicable"
else
kernel_parameter_chk
fi
done < <(printf '%s\n' "${a_parlist[@]}")
if [ -z "$l_output2" ]; then # Provide output from checks
echo -e "\n- Audit Result:\n ** PASS **\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "\n- Correctly set:\n$l_output\n"
fi
}
Page 390
Remediation:
-IF- IPv6 is enabled on the system:
Set the following parameters in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in
.conf:
• net.ipv6.conf.all.accept_ra = 0
• net.ipv6.conf.default.accept_ra = 0
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
}
Note: If these settings appear in a conically later file, or later in the same file, these
settings will be overwritten
Default Value:
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.default.accept_ra = 1
References:
Additional Information:
On systems with Uncomplicated Firewall, additional settings may be configured in
/etc/ufw/sysctl.conf
Page 391
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 392
3.4 Firewall Configuration
A firewall is a set of rules. When a data packet moves into or out of a protected network
space, its contents (in particular, information about its origin, target, and the protocol it
plans to use) are tested against the firewall rules to see if it should be allowed through
To provide a Host Based Firewall, the Linux kernel includes support for:
• Netfilter - A set of hooks inside the Linux kernel that allows kernel modules to
register callback functions with the network stack. A registered callback function
is then called back for every packet that traverses the respective hook within the
network stack. Includes the ip_tables, ip6_tables, arp_tables, and ebtables kernel
modules. These modules are some of the significant parts of the Netfilter hook
system.
• nftables - A subsystem of the Linux kernel providing filtering and classification of
network packets/datagrams/frames. nftables is supposed to replace certain parts
of Netfilter, while keeping and reusing most of it. nftables utilizes the building
blocks of the Netfilter infrastructure, such as the existing hooks into the
networking stack, connection tracking system, userspace queueing component,
and logging subsystem. Is available in Linux kernels 3.13 and newer.
In order to configure firewall rules for Netfilter or nftables, a firewall utility needs to be
installed. Guidance has been included for the following firewall utilities:
Note:
• Only one method should be used to configure a firewall on the system. Use of
more than one method could produce unexpected results
• This section is intended only to ensure the resulting firewall rules are in place, not
how they are configured
Page 393
3.4.1 Configure UncomplicatedFirewall
If nftables or iptables are being used in your environment, please follow the
guidance in their respective section and pass-over the guidance in this section.
Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to
be easy to use.
Note:
Page 394
3.4.1.1 Ensure ufw is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Uncomplicated Firewall (ufw) is a frontend for iptables and is particularly well-suited
for host-based firewalls. ufw provides a framework for managing netfilter, as well as a
command-line interface for manipulating the firewall
Rationale:
A firewall utility is required to configure the Linux kernel's netfilter framework via the
iptables or nftables back-end.
The Linux kernel's netfilter framework host-based firewall can protect against threats
originating from within a corporate network to include malicious mobile code and poorly
configured software on a host.
Note: Only one firewall utility should be installed and configured. UFW is dependent on
the iptables package
Audit:
Run the following command to verify that Uncomplicated Firewall (UFW) is installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' ufw
Remediation:
Run the following command to install Uncomplicated Firewall (UFW):
apt install ufw
References:
Page 395
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 396
3.4.1.2 Ensure iptables-persistent is not installed with ufw
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The iptables-persistent is a boot-time loader for netfilter rules, iptables plugin
Rationale:
Running both ufw and the services included in the iptables-persistent package may lead
to conflict
Audit:
Run the following command to verify that the iptables-persistent package is not
installed:
dpkg-query -s iptables-persistent
Remediation:
Run the following command to remove the iptables-persistent package:
# apt purge iptables-persistent
References:
Page 397
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 398
3.4.1.3 Ensure ufw service is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
UncomplicatedFirewall (ufw) is a frontend for iptables. ufw provides a framework for
managing netfilter, as well as a command-line and available graphical user interface for
manipulating the firewall.
Note:
• When running ufw enable or starting ufw via its initscript, ufw will flush its chains.
This is required so ufw can maintain a consistent state, but it may drop existing
connections (eg ssh). ufw does support adding rules before enabling the firewall.
• Run the following command before running ufw enable.
• The rules will still be flushed, but the ssh port will be open after enabling the
firewall. Please note that once ufw is 'enabled', ufw will not flush the chains when
adding or removing rules (but will when modifying a rule or changing the default
policy)
• By default, ufw will prompt when enabling the firewall while running under ssh.
This can be disabled by using ufw --force enable
Rationale:
The ufw service must be enabled and running in order for ufw to protect the system
Impact:
Changing firewall settings while connected over network can result in being locked out
of the system.
Page 399
Audit:
Run the following command to verify that the ufw daemon is enabled:
# systemctl is-enabled ufw.service
enabled
Run the following command to verify that the ufw daemon is active:
# systemctl is-active ufw
active
Run the following command to verify ufw is active
# ufw status
Status: active
Remediation:
Run the following command to unmask the ufw daemon:
# systemctl unmask ufw.service
Run the following command to enable and start the ufw daemon:
# systemctl --now enable ufw.service
active
Run the following command to enable ufw:
# ufw enable
References:
1. http://manpages.ubuntu.com/manpages/precise/en/man8/ufw.8.html
2. NIST SP 800-53 Rev. 5: SC-7
Page 400
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 401
3.4.1.4 Ensure ufw loopback traffic is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network (127.0.0.0/8 for IPv4 and ::1/128 for IPv6).
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
(127.0.0.0/8 for IPv4 and ::1/128 for IPv6) traffic should be seen, all other interfaces
should ignore traffic on this network as an anti-spoofing measure.
Audit:
Run the following commands and verify output includes the listed rules in order:
# ufw status verbose
To Action From
-- ------ ----
Anywhere on lo ALLOW IN Anywhere
Anywhere DENY IN 127.0.0.0/8
Anywhere (v6) on lo ALLOW IN Anywhere (v6)
Anywhere (v6) DENY IN ::1
Remediation:
Run the following commands to implement the loopback rules:
# ufw allow in on lo
# ufw allow out on lo
# ufw deny in from 127.0.0.0/8
# ufw deny in from ::1
References:
Page 402
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 403
3.4.1.5 Ensure ufw outbound connections are configured
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound connections.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system.
• Unlike iptables, when a new outbound rule is added, ufw automatically takes care
of associated established connections, so no rules for the latter kind are required.
Rationale:
If rules are not in place for new outbound connections all packets will be dropped by the
default policy preventing network usage.
Audit:
Run the following command and verify all rules for new outbound connections match
site policy:
# ufw status numbered
Remediation:
Configure ufw in accordance with site policy. The following commands will implement a
policy to allow all outbound connections on all interfaces:
# ufw allow out on all
References:
Page 404
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 405
3.4.1.6 Ensure ufw firewall rules exist for all open ports
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Services and ports can be accepted or explicitly rejected.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• The remediation command opens up the port to traffic from all sources. Consult
ufw documentation and set any restrictions in compliance with site policy
Rationale:
To reduce the attack surface of a system, all services and ports should be blocked
unless required.
• Any ports that have been opened on non-loopback addresses need firewall rules
to govern traffic.
• Without a firewall rule configured for open ports, the default firewall policy will
drop all packets to these ports.
• Required ports should have a firewall rule created to allow approved connections
in accordance with local site policy.
• Unapproved ports should have an explicit deny rule created.
Page 406
Audit:
Run the following script to verify a firewall rule exists for all open ports:
#!/usr/bin/env bash
{
unset a_ufwout;unset a_openports
while read -r l_ufwport; do
[ -n "$l_ufwport" ] && a_ufwout+=("$l_ufwport")
done < <(ufw status verbose | grep -Po '^\h*\d+\b' | sort -u)
while read -r l_openport; do
[ -n "$l_openport" ] && a_openports+=("$l_openport")
done < <(ss -tuln | awk '($5!~/%lo:/ && $5!~/127.0.0.1:/ &&
$5!~/\[?::1\]?:/) {split($5, a, ":"); print a[2]}' | sort -u)
a_diff=("$(printf '%s\n' "${a_openports[@]}" "${a_ufwout[@]}"
"${a_ufwout[@]}" | sort | uniq -u)")
if [[ -n "${a_diff[*]}" ]]; then
echo -e "\n- Audit Result:\n ** FAIL **\n- The following port(s) don't
have a rule in UFW: $(printf '%s\n' \\n"${a_diff[*]}")\n- End List"
else
echo -e "\n - Audit Passed -\n- All open ports have a rule in UFW\n"
fi
}
Remediation:
For each port identified in the audit which does not have a firewall rule, evaluate the
service listening on the port and add a rule for accepting or denying inbound
connections in accordance with local site policy:
Examples:
# ufw allow in <port>/<tcp or udp protocol>
References:
Page 407
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 408
3.4.1.7 Ensure ufw default deny firewall policy (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
A default deny policy on connections ensures that any unconfigured network usage will
be rejected.
Note: Any port or protocol without a explicit allow before the default deny will be
blocked
Rationale:
With a default accept policy the firewall will accept any packet that is not configured to
be denied. It is easier to white list acceptable usage than to black list unacceptable
usage.
Impact:
Any port and protocol not explicitly allowed will be blocked. The following rules should
be considered before applying the default deny.
ufw allow git
ufw allow in http
ufw allow out http <- required for apt to connect to repository
ufw allow in https
ufw allow out https
ufw allow out 53
ufw logging on
Audit:
Run the following command and verify that the default policy for incoming , outgoing ,
and routed directions is deny , reject , or disabled:
# ufw status verbose | grep Default:
Example output:
Default: deny (incoming), deny (outgoing), disabled (routed)
Page 409
Remediation:
Run the following commands to implement a default deny policy:
# ufw default deny incoming
# ufw default deny outgoing
# ufw default deny routed
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 410
3.4.2 Configure nftables
• This section broadly assumes starting with an empty nftables firewall ruleset
(established by flushing the rules with nft flush ruleset).
• Remediation steps included only affect the live system, you will also need to
configure your default firewall configuration to apply on boot.
• Configuration of a live systems firewall directly over a remote connection will
often result in being locked out. It is advised to have a known good firewall
configuration set to run on boot and to configure an entire firewall structure in a
script that is then run and tested before saving to boot.
The following will implement the firewall rules of this section and open ICMP, IGMP, and
port 22(ssh) from anywhere. Opening the ports for ICMP, IGMP, and port 22(ssh) needs
to be updated in accordance with local site policy. Allow port 22(ssh) needs to be
updated to only allow systems requiring ssh connectivity to connect, as per site
policy.
Save the script bellow as /etc/nftables.rules
Page 411
#!/sbin/nft -f
# Base chain for hook output named output (Filters outbount network
packets)
chain output {
type filter hook output priority 0; policy drop;
# Ensure outbound and established connections are configured
ip protocol tcp ct state established,related,new accept
ip protocol udp ct state established,related,new accept
ip protocol icmp ct state established,related,new accept
}
}
Run the following command to load the file into nftables
Page 412
# nft -f /etc/nftables.rules
All changes in the nftables subsections are temporary.
To make these changes permanent:
Run the following command to create the nftables.rules file
nft list ruleset > /etc/nftables.rules
Add the following line to /etc/nftables.conf
include "/etc/nftables.rules"
Page 413
3.4.2.1 Ensure nftables is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables provides a new in-kernel packet classification framework that is based on a
network-specific Virtual Machine (VM) and a new nft userspace command line tool.
nftables reuses the existing Netfilter subsystems such as the existing hook
infrastructure, the connection tracking system, NAT, userspace queuing and logging
subsystem.
Notes:
Rationale:
nftables is a subsystem of the Linux kernel that can protect against threats originating
from within a corporate network to include malicious mobile code and poorly configured
software on a host.
Audit:
Run the following command to verify that nftables is installed:
# dpkg-query -s nftables | grep 'Status: install ok installed'
Remediation:
Run the following command to install nftables:
# apt install nftables
References:
Page 414
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 415
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to
be easy to use.
Rationale:
Running both the nftables service and ufw may lead to conflict and unexpected results.
Audit:
Run the following commands to verify that ufw is either not installed or inactive. Only
one of the following needs to pass.
Run the following command to verify that ufw is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' ufw
Status: inactive
# systemctl is-enabled ufw.service
masked
Page 416
Remediation:
Run one of the following to either remove ufw or disable ufw and mask ufw.service:
Run the following command to remove ufw:
# apt purge ufw
-OR-
Run the following commands to disable ufw and mask ufw.service:
# ufw disable
# systemctl stop ufw.service
# systemctl mask ufw.service
Note: ufw disable needs to be run before systemctl mask ufw.service in order to
correctly disable UFW
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 417
3.4.2.3 Ensure iptables are flushed with nftables (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables is a replacement for iptables, ip6tables, ebtables and arptables
Rationale:
It is possible to mix iptables and nftables. However, this increases complexity and also
the chance to introduce errors. For simplicity flush out all iptables rules, and ensure it is
not loaded
Audit:
Run the following commands to ensure no iptables rules exist
For iptables:
# iptables -L
No rules should be returned
For ip6tables:
# ip6tables -L
No rules should be returned
Remediation:
Run the following commands to flush iptables:
For iptables:
# iptables -F
For ip6tables:
# ip6tables -F
References:
Page 418
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 419
3.4.2.4 Ensure a nftables table exists (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Tables hold chains. Each table only has one address family and only applies to packets
of this family. Tables can have one of five families.
Rationale:
nftables doesn't have any default tables. Without a table being build, nftables will not
filter network traffic.
Impact:
Adding rules to a running nftables can cause loss of connectivity to the system
Audit:
Run the following command to verify that a nftables table exists:
# nft list tables
Return should include a list of nftables:
Example:
table inet filter
Remediation:
Run the following command to create a table in nftables
# nft create table inet <table name>
Example:
# nft create table inet filter
References:
Page 420
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 421
3.4.2.5 Ensure nftables base chains exist (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Chains are containers for rules. They exist in two kinds, base chains and regular chains.
A base chain is an entry point for packets from the networking stack, a regular chain
may be used as jump target and is used for better rule organization.
Rationale:
If a base chain doesn't exist with a hook for input, forward, and delete, packets that
would flow through those chains will not be touched by nftables.
Impact:
If configuring nftables over ssh, creating a base chain with a policy of drop will cause
loss of connectivity.
Ensure that a rule allowing ssh has been added to the base chain prior to setting the
base chain's policy to drop
Audit:
Run the following commands and verify that base chains exist for INPUT.
# nft list ruleset | grep 'hook input'
Page 422
Remediation:
Run the following command to create the base chains:
# nft create chain inet <table name> <base chain name> { 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 \;
}
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 423
3.4.2.6 Ensure nftables loopback traffic is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
traffic should be seen, all other interfaces should ignore traffic on this network as an
anti-spoofing measure.
Audit:
Run the following commands to verify that the loopback interface is configured:
Run the following command to verify the loopback interface is configured to accept
network traffic:
# nft list ruleset | awk '/hook input/,/}/' | grep 'iif "lo" accept'
Example output:
iif "lo" accept
Run the following command to verify network traffic from an iPv4 loopback interface is
configured to drop:
# nft list ruleset | awk '/hook input/,/}/' | grep 'ip saddr'
Example output:
ip saddr 127.0.0.0/8 counter packets 0 bytes 0 drop
-IF- IPv6 is enabled on the system:
Run the following command to verify network traffic from an iPv6 loopback interface is
configured to drop:
# nft list ruleset | awk '/hook input/,/}/' | grep 'ip6 saddr'
Example output:
ip6 saddr ::1 counter packets 0 bytes 0 drop
Page 424
Remediation:
Run the following commands to implement the loopback rules:
# nft add rule inet filter input iif lo accept
# nft create rule inet filter input ip saddr 127.0.0.0/8 counter drop
-IF- IPv6 is enabled on the system:
Run the following command to implement the IPv6 loopback rule:
# nft add rule inet filter input ip6 saddr ::1 counter drop
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 425
3.4.2.7 Ensure nftables outbound and established connections
are configured (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound, and established connections
Rationale:
If rules are not in place for new outbound, and established connections all packets will
be dropped by the default policy preventing network usage.
Audit:
Run the following commands and verify all rules for established incoming connections
match site policy: site policy:
# nft list ruleset | awk '/hook input/,/}/' | grep -E 'ip protocol
(tcp|udp|icmp) ct state'
Output should be similar to:
ip protocol tcp ct state established accept
ip protocol udp ct state established accept
ip protocol icmp ct state established accept
Run the folllowing command and verify all rules for new and established outbound
connections match site policy
# nft list ruleset | awk '/hook output/,/}/' | grep -E 'ip protocol
(tcp|udp|icmp) ct state'
Output should be similar to:
ip protocol tcp ct state established,related,new accept
ip protocol udp ct state established,related,new accept
ip protocol icmp ct state established,related,new accept
Page 426
Remediation:
Configure nftables in accordance with site policy. The following commands will
implement a policy to allow all outbound connections and all established connections:
# nft add rule inet filter input ip protocol tcp ct state established accept
# nft add rule inet filter input ip protocol udp ct state established accept
# nft add rule inet filter input ip protocol icmp ct state established accept
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 427
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 428
3.4.2.8 Ensure nftables default deny firewall policy (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Base chain policy is the default verdict that will be applied to packets reaching the end
of the chain.
Rationale:
There are two policies: accept (Default) and drop. If the policy is set to accept, the
firewall will accept any packet that is not configured to be denied and the packet will
continue transversing the network stack.
It is easier to white list acceptable usage than to black list unacceptable usage.
Note: Changing firewall settings while connected over network can result in being
locked out of the system.
Impact:
If configuring nftables over ssh, creating a base chain with a policy of drop will cause
loss of connectivity.
Ensure that a rule allowing ssh has been added to the base chain prior to setting the
base chain's policy to drop
Audit:
Run the following commands and verify that base chains contain a policy of DROP.
# nft list ruleset | grep 'hook input'
Page 429
Remediation:
Run the following command for the base chains with the input, forward, and output
hooks to implement a default DROP policy:
# nft chain <table family> <table name> <chain name> { policy drop \; }
Example:
# nft chain inet filter input { policy drop \; }
Default Value:
accept
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 430
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 431
3.4.2.9 Ensure nftables service is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The nftables service allows for the loading of nftables rulesets during boot, or starting on
the nftables service
Rationale:
The nftables service restores the nftables rules from the rules files referenced in the
/etc/nftables.conf file during boot or the starting of the nftables service
Audit:
Run the following command and verify that the nftables service is enabled:
# systemctl is-enabled nftables
enabled
Remediation:
Run the following command to enable the nftables service:
# systemctl enable nftables
References:
Page 432
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 433
3.4.2.10 Ensure nftables rules are permanent (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables is a subsystem of the Linux kernel providing filtering and classification of
network packets/datagrams/frames.
The nftables service reads the /etc/nftables.conf file for a nftables file or files to
include in the nftables ruleset.
A nftables ruleset containing the input, forward, and output base chains allow network
traffic to be filtered.
Rationale:
Changes made to nftables ruleset only affect the live system, you will also need to
configure the nftables ruleset to apply on boot
Audit:
Run the following commands to verify that input, forward, and output base chains are
configured to be applied to a nftables ruleset on boot:
Run the following command to verify the input base chain:
# [ -n "$(grep -E '^\s*include' /etc/nftables.conf)" ] && awk '/hook
input/,/}/' $(awk '$1 ~ /^\s*include/ { gsub("\"","",$2);print $2 }'
/etc/nftables.conf)
Output should be similar to:
Page 434
type filter hook input priority 0; policy drop;
Page 435
Remediation:
Edit the /etc/nftables.conf file and un-comment or add a line with include <Absolute
path to nftables rules file> for each nftables file you want included in the nftables
ruleset on boot
Example:
# vi /etc/nftables.conf
Add the line:
include "/etc/nftables.rules"
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 436
3.4.3 Configure iptables
Page 437
3.4.3.1 Configure iptables software
This section provides guidance for installing, enabling, removing, and disabling software
packages necessary for using IPTables as the method for configuring and maintaining a
Host Based Firewall on the system.
Note: Using more than one method to configure and maintain a Host Based Firewall can
cause unexpected results. If FirewallD or NFTables are being used for configuration and
maintenance, this section should be skipped and the guidance in their respective
section followed.
Page 438
3.4.3.1.1 Ensure iptables packages are installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
iptables is a utility program that allows a system administrator to configure the tables
provided by the Linux kernel firewall, implemented as different Netfilter modules, and
the chains and rules it stores. Different kernel modules and programs are used for
different protocols; iptables applies to IPv4, ip6tables to IPv6, arptables to ARP, and
ebtables to Ethernet frames.
Rationale:
A method of configuring and maintaining firewall rules is necessary to configure a Host
Based Firewall.
Audit:
Run the following command to verify that iptables and iptables-persistent are
installed:
# apt list iptables iptables-persistent | grep installed
iptables-persistent/<version> [installed,automatic]
iptables/<version> [installed,automatic]
Remediation:
Run the following command to install iptables and iptables-persistent
# apt install iptables iptables-persistent
References:
Page 439
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 440
3.4.3.1.2 Ensure nftables is not installed with iptables
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
nftables is a subsystem of the Linux kernel providing filtering and classification of
network packets/datagrams/frames and is the successor to iptables.
Rationale:
Running both iptables and nftables may lead to conflict.
Audit:
Run the following commend to verify that nftables is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
nftables
Remediation:
Run the following command to remove nftables:
# apt purge nftables
References:
Page 441
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 442
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Uncomplicated Firewall (UFW) is a program for managing a netfilter firewall designed to
be easy to use.
Rationale:
Running iptables.persistent with ufw enabled may lead to conflict and unexpected
results.
Audit:
Run the following commands to verify that ufw is either not installed or disabled. Only
one of the following needs to pass.
Run the following command to verify that ufw is not installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n' ufw
Status: inactive
Run the following commands to verify that the ufw service is masked:
# systemctl is-enabled ufw
masked
Page 443
Remediation:
Run one of the following commands to either remove ufw or stop and mask ufw
Run the following command to remove ufw:
# apt purge ufw
-OR-
Run the following commands to disable ufw:
# ufw disable
# systemctl stop ufw
# systemctl mask ufw
Note: ufw disable needs to be run before systemctl mask ufw in order to correctly
disable UFW
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 444
3.4.3.2 Configure IPv4 iptables
Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the
Linux kernel. Several different tables may be defined. Each table contains a number of
built-in chains and may also contain user-defined chains.
Each chain is a list of rules which can match a set of packets. Each rule specifies what
to do with a packet that matches. This is called a 'target', which may be a jump to a
user-defined chain in the same table.
Note: This section broadly assumes starting with an empty IPtables firewall ruleset
(established by flushing the rules with iptables -F). Remediation steps included only
affect the live system, you will also need to configure your default firewall configuration
to apply on boot. Configuration of a live systems firewall directly over a remote
connection will often result in being locked out. It is advised to have a known good
firewall configuration set to run on boot and to configure an entire firewall structure in a
script that is then run and tested before saving to boot. The following script will
implement the firewall rules of this section and open port 22(ssh) from anywhere:
#!/bin/bash
Page 445
3.4.3.2.1 Ensure iptables default deny firewall policy (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
A default deny all policy on connections ensures that any unconfigured network usage
will be rejected.
Notes:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
With a default accept policy the firewall will accept any packet that is not configured to
be denied. It is easier to white list acceptable usage than to black list unacceptable
usage.
Audit:
Run the following command and verify that the policy for the INPUT , OUTPUT , and
FORWARD chains is DROP or REJECT :
# iptables -L -n
Remediation:
Run the following commands to implement a default DROP policy:
# iptables -P INPUT DROP
# iptables -P OUTPUT DROP
# iptables -P FORWARD DROP
References:
Page 446
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 447
3.4.3.2.2 Ensure iptables loopback traffic is configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network (127.0.0.0/8).
Notes:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
(127.0.0.0/8) traffic should be seen, all other interfaces should ignore traffic on this
network as an anti-spoofing measure.
Audit:
Run the following commands and verify output includes the listed rules in order (packet
and byte counts may differ):
# iptables -L INPUT -v -n
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source
destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 127.0.0.0/8 0.0.0.0/0
# iptables -L OUTPUT -v -n
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source
destination
0 0 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
Page 448
Remediation:
Run the following commands to implement the loopback rules:
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A OUTPUT -o lo -j ACCEPT
# iptables -A INPUT -s 127.0.0.0/8 -j DROP
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 449
3.4.3.2.3 Ensure iptables outbound and established connections
are configured (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound, and established connections.
Notes:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
If rules are not in place for new outbound, and established connections all packets will
be dropped by the default policy preventing network usage.
Audit:
Run the following command and verify all rules for new outbound, and established
connections match site policy:
# iptables -L -v -n
Remediation:
Configure iptables in accordance with site policy. The following commands will
implement a policy to allow all outbound connections and all established connections:
# iptables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -p icmp -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
# iptables -A INPUT -p udp -m state --state ESTABLISHED -j ACCEPT
# iptables -A INPUT -p icmp -m state --state ESTABLISHED -j ACCEPT
References:
Page 450
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 451
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Any ports that have been opened on non-loopback addresses need firewall rules to
govern traffic.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
• The remediation command opens up the port to traffic from all sources. Consult
iptables documentation and set any restrictions in compliance with site policy
Rationale:
Without a firewall rule configured for open ports default firewall policy will drop all
packets to these ports.
Page 452
Audit:
Run the following command to determine open ports:
# ss -4tuln
Verify all open ports listening on non-localhost addresses have at least one firewall rule.
The last line identified by the "tcp dpt:22 state NEW" identifies it as a firewall rule for
new connections on tcp port 22.
Remediation:
For each port identified in the audit which does not have a firewall rule establish a
proper rule for accepting inbound connections:
# iptables -A INPUT -p <protocol> --dport <port> -m state --state NEW -j
ACCEPT
References:
Page 453
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 454
3.4.3.3 Configure IPv6 ip6tables
Ip6tables is used to set up, maintain, and inspect the tables of IPv6 packet filter rules in
the Linux kernel. Several different tables may be defined. Each table contains a number
of built-in chains and may also contain user-defined chains. Each chain is a list of rules
which can match a set of packets. Each rule specifies what to do with a packet that
matches. This is called a `target', which may be a jump to a user-defined chain in the
same table.
If IPv6 in enabled on the system, the ip6tables should be configured.
Note: This section broadly assumes starting with an empty ip6tables firewall ruleset
(established by flushing the rules with ip6tables -F). Remediation steps included only
affect the live system, you will also need to configure your default firewall configuration
to apply on boot. Configuration of a live systems firewall directly over a remote
connection will often result in being locked out. It is advised to have a known good
firewall configuration set to run on boot and to configure an entire firewall structure in a
script that is then run and tested before saving to boot.
The following script will implement the firewall rules of this section and open port
22(ssh) from anywhere:
#!/bin/bash
Page 455
3.4.3.3.1 Ensure ip6tables default deny firewall policy
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
A default deny all policy on connections ensures that any unconfigured network usage
will be rejected.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
With a default accept policy the firewall will accept any packet that is not configured to
be denied. It is easier to white list acceptable usage than to black list unacceptable
usage.
Page 456
Audit:
Run the following command and verify that the policy for the INPUT, OUTPUT, and
FORWARD chains is DROP or REJECT:
# ip6tables -L -n
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Remediation:
IF IPv6 is enabled on your system:
Run the following commands to implement a default DROP policy:
# ip6tables -P INPUT DROP
# ip6tables -P OUTPUT DROP
# ip6tables -P FORWARD DROP
References:
Page 457
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 458
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the loopback interface to accept traffic. Configure all other interfaces to deny
traffic to the loopback network (::1).
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
Loopback traffic is generated between processes on machine and is typically critical to
operation of the system. The loopback interface is the only place that loopback network
(::1) traffic should be seen, all other interfaces should ignore traffic on this network as
an anti-spoofing measure.
Page 459
Audit:
Run the following commands and verify output includes the listed rules in order (packet
and byte counts may differ):
# ip6tables -L INPUT -v -n
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source
destination
0 0 ACCEPT all lo * ::/0 ::/0
0 0 DROP all * * ::1 ::/0
# ip6tables -L OUTPUT -v -n
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source
destination
0 0 ACCEPT all * lo ::/0 ::/0
-OR-
Verify IPv6 is disabled:
Run the following script. Output will confirm if IPv6 is enabled on the system.
#!/usr/bin/bash
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Remediation:
Run the following commands to implement the loopback rules:
# ip6tables -A INPUT -i lo -j ACCEPT
# ip6tables -A OUTPUT -o lo -j ACCEPT
# ip6tables -A INPUT -s ::1 -j DROP
References:
Page 460
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 461
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure the firewall rules for new outbound, and established IPv6 connections.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
Rationale:
If rules are not in place for new outbound, and established connections all packets will
be dropped by the default policy preventing network usage.
Audit:
Run the following command and verify all rules for new outbound, and established
connections match site policy:
# ip6tables -L -v -n
-OR-
Verify IPv6 is disabled:_
Run the following script. Output will confirm if IPv6 is enabled on the system.
#!/usr/bin/bash
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Page 462
Remediation:
Configure iptables in accordance with site policy. The following commands will
implement a policy to allow all outbound connections and all established connections:
# ip6tables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
# ip6tables -A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT
# ip6tables -A OUTPUT -p icmp -m state --state NEW,ESTABLISHED -j ACCEPT
# ip6tables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT
# ip6tables -A INPUT -p udp -m state --state ESTABLISHED -j ACCEPT
# ip6tables -A INPUT -p icmp -m state --state ESTABLISHED -j ACCEPT
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 463
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Any ports that have been opened on non-loopback addresses need firewall rules to
govern traffic.
Note:
• Changing firewall settings while connected over network can result in being
locked out of the system
• Remediation will only affect the active system firewall, be sure to configure the
default policy in your firewall management to apply on boot as well
• The remediation command opens up the port to traffic from all sources. Consult
iptables documentation and set any restrictions in compliance with site policy
Rationale:
Without a firewall rule configured for open ports default firewall policy will drop all
packets to these ports.
Page 464
Audit:
Run the following command to determine open ports:
# ss -6tuln
{
if grep -Pqs '^\h*0\b' /sys/module/ipv6/parameters/disable; then
echo -e " - IPv6 is enabled on the system"
else
echo -e " - IPv6 is not enabled on the system"
fi
}
Page 465
Remediation:
For each port identified in the audit which does not have a firewall rule establish a
proper rule for accepting inbound connections:
# ip6tables -A INPUT -p <protocol> --dport <port> -m state --state NEW -j
ACCEPT
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 466
4 Access, Authentication and Authorization
Page 467
4.1 Configure time-based job schedulers
cron is a time-based job scheduler used to schedule jobs, commands or shell scripts, to
run periodically at fixed times, dates, or intervals.
atprovides the ability to execute a command or shell script at a specified date and
hour, or after a given interval of time.
Note:
• Other methods exist for scheduling jobs, such as systemd timers. If another
method is used, it should be secured in accordance with local site policy
• systemd timers are systemd unit files whose name ends in .timer that control
.service files or events
o Timers can be used as an alternative to cron and at
o Timers have built-in support for calendar time events, monotonic time
events, and can be run asynchronously
• If cron and at are not installed, this section can be skipped
Page 468
4.1.1 Ensure cron daemon is enabled and active (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The cron daemon is used to execute batch jobs on the system.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
While there may not be user jobs that need to be run on the system, the system does
have maintenance jobs that may include security monitoring that have to run, and cron
is used to execute them.
Audit:
Run the following command to verify cron is enabled:
# systemctl is-enabled cron
enabled
Run the following command to verify that cron is active:
# systemctl is-active cron
active
Remediation:
Run the following command to enable and start cron:
# systemctl unmask cron
# systemctl --now enable cron
References:
Page 469
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 470
4.1.2 Ensure permissions on /etc/crontab are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/crontab file is used by cron to control its own jobs. The commands in this
item make sure that root is the user and group owner of the file and that only the owner
can access the file.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
This file contains information on what system jobs are run by cron. Write access to
these files could provide unprivileged users with the ability to elevate their privileges.
Read access to these files could provide users with the ability to gain insight on system
jobs that run on the system and could provide them a way to gain unauthorized
privileged access.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other :
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/crontab
Remediation:
Run the following commands to set ownership and permissions on /etc/crontab :
# chown root:root /etc/crontab
# chmod og-rwx /etc/crontab
Default Value:
Access: (644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
References:
Page 471
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 472
4.1.3 Ensure permissions on /etc/cron.hourly are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
This directory contains system cron jobs that need to run on an hourly basis. The files in
this directory cannot be manipulated by the crontab command, but are instead edited
by system administrators using a text editor. The commands below restrict read/write
and search access to user and group root, preventing regular users from accessing this
directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.hourly/
Remediation:
Run the following commands to set ownership and permissions on the
/etc/cron.hourly directory:
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Page 473
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 474
4.1.4 Ensure permissions on /etc/cron.daily are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.daily directory contains system cron jobs that need to run on a daily
basis. The files in this directory cannot be manipulated by the crontab command, but
are instead edited by system administrators using a text editor. The commands below
restrict read/write and search access to user and group root, preventing regular users
from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.daily/
Remediation:
Run the following commands to set ownership and permissions on the /etc/cron.daily
directory:
# chown root:root /etc/cron.daily/
# chmod og-rwx /etc/cron.daily/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Page 475
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 476
4.1.5 Ensure permissions on /etc/cron.weekly are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.weekly directory contains system cron jobs that need to run on a weekly
basis. The files in this directory cannot be manipulated by the crontab command, but
are instead edited by system administrators using a text editor. The commands below
restrict read/write and search access to user and group root, preventing regular users
from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.weekly/
Remediation:
Run the following commands to set ownership and permissions on the
/etc/cron.weekly directory:
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Page 477
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 478
4.1.6 Ensure permissions on /etc/cron.monthly are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.monthly directory contains system cron jobs that need to run on a
monthly basis. The files in this directory cannot be manipulated by the crontab
command, but are instead edited by system administrators using a text editor. The
commands below restrict read/write and search access to user and group root,
preventing regular users from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.monthly/
Remediation:
Run the following commands to set ownership and permissions on the
/etc/cron.monthly directory:
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Page 479
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 480
4.1.7 Ensure permissions on /etc/cron.d are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/cron.d directory contains system cron jobs that need to run in a similar
manner to the hourly, daily weekly and monthly jobs from /etc/crontab, but require
more granular control as to when they run. The files in this directory cannot be
manipulated by the crontab command, but are instead edited by system administrators
using a text editor. The commands below restrict read/write and search access to user
and group root, preventing regular users from accessing this directory.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be secured
in accordance with local site policy
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this
directory could give an unprivileged user insight in how to gain elevated privileges or
circumvent auditing controls.
Audit:
Run the following command and verify Uid and Gid are both 0/root and Access does
not grant permissions to group or other:
# stat -Lc 'Access: (%a/%A) Uid: ( %u/ %U) Gid: ( %g/ %G)' /etc/cron.d/
Remediation:
Run the following commands to set ownership and permissions on the /etc/cron.d
directory:
# chown root:root /etc/cron.d/
# chmod og-rwx /etc/cron.d/
Default Value:
Access: (755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Page 481
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 482
4.1.8 Ensure cron is restricted to authorized users (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure /etc/cron.allow to allow specific users to use this service. If
/etc/cron.allow does not exist, then /etc/cron.deny is checked. Any user not
specifically defined in this file is allowed to use cron. By removing the file, only users in
/etc/cron.allow are allowed to use cron.
Note:
• Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, cron should be removed, and the alternate method should be
secured in accordance with local site policy
• Even though a given user is not listed in cron.allow, cron jobs can still be run as
that user
• The cron.allow file only controls administrative access to the crontab command
for scheduling and modifying cron jobs
Rationale:
On many systems, only the system administrator is authorized to schedule cron jobs.
Using the cron.allow file to control who can run cron jobs enforces this policy. It is
easier to manage an allow list than a deny list. In a deny list, you could potentially add a
user ID to the system and forget to add it to the deny files.
Audit:
Run the following script to verify:
• /etc/cron.deny does not exist
• /etc/cron.allow does exist
• /etc/cron.allow is mode 0640 or more restrictive
• /etc/cron.allow is owned by the user root
• /etc/cron.allow is group owned by the group crontab
-OR-
• cron is not installed on the system
Page 483
#!/usr/bin/env bash
{
l_output="" l_output2=""
if dpkg-query -W cron > /dev/null 2>&1; then
l_file="/etc/cron.allow"
[ -e /etc/cron.deny ] && l_output2="$l_output2\n - cron.deny exists"
if [ ! -e /etc/cron.allow ]; then
l_output2="$l_output2\n - cron.allow doesn't exist"
else
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_output2="$l_output2\n - \"$l_file\" is mode: \"$l_mode\"
(should be mode: \"$l_maxperm\" or more restrictive)"
else
l_output="$l_output\n - \"$l_file\" is correctly set to mode:
\"$l_mode\""
fi
if [ "$l_fown" != "root" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by user
\"$l_fown\" (should be owned by \"root\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by
user: \"$l_fown\""
fi
if [ "$l_fgroup" != "crontab" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by group:
\"$l_fgroup\" (should be owned by group: \"crontab\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by
group: \"$l_fgroup\""
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
fi
else
l_output="$l_output\n - cron is not installed on the system"
fi
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit
failure:$l_output2\n"
fi
}
Page 484
Remediation:
Run the following script to:
#!/usr/bin/env bash
{
if dpkg-query -W cron > /dev/null 2>&1; then
l_file="/etc/cron.allow"
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ -e /etc/cron.deny ]; then
echo -e " - Removing \"/etc/cron.deny\""
rm -f /etc/cron.deny
fi
if [ ! -e /etc/cron.allow ]; then
echo -e " - creating \"$l_file\""
touch "$l_file"
fi
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
echo -e " - Removing excessive permissions from \"$l_file\""
chmod u-x,g-wx,o-rwx "$l_file"
fi
if [ "$l_fown" != "root" ]; then
echo -e " - Changing owner on \"$l_file\" from: \"$l_fown\" to:
\"root\""
chown root "$l_file"
fi
if [ "$l_fgroup" != "crontab" ]; then
echo -e " - Changing group owner on \"$l_file\" from:
\"$l_fgroup\" to: \"crontab\""
chgrp crontab "$l_file"
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
else
echo -e "- cron is not installed on the system, no remediation
required\n"
fi
}
References:
Page 485
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 486
4.1.9 Ensure at is restricted to authorized users (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Configure /etc/at.allow to allow specific users to use this service. If /etc/at.allow
does not exist, then /etc/at.deny is checked. Any user not specifically defined in this
file is allowed to use at. By removing the file, only users in /etc/at.allow are allowed
to use at.
Note: Other methods, such as systemd timers, exist for scheduling jobs. If another
method is used, at should be removed, and the alternate method should be secured in
accordance with local site policy
Rationale:
On many systems, only the system administrator is authorized to schedule at jobs.
Using the at.allow file to control who can run at jobs enforces this policy. It is easier to
manage an allow list than a deny list. In a deny list, you could potentially add a user ID
to the system and forget to add it to the deny files.
Audit:
Run the following script to verify:
• /etc/at.deny does not exist
• /etc/at.allow does exist
• /etc/at.allow is mode 0640 or more restrictive
• /etc/at.allow is owned by the user root
• /etc/at.allow is group owned by the group root
-OR-
• at is not installed on the system
Page 487
#!/usr/bin/env bash
{
l_output="" l_output2=""
if dpkg-query -W at > /dev/null 2>&1; then
l_file="/etc/at.allow"
[ -e /etc/at.deny ] && l_output2="$l_output2\n - at.deny exists"
if [ ! -e /etc/at.allow ]; then
l_output2="$l_output2\n - at.allow doesn't exist"
else
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_output2="$l_output2\n - \"$l_file\" is mode: \"$l_mode\"
(should be mode: \"$l_maxperm\" or more restrictive)"
else
l_output="$l_output\n - \"$l_file\" is correctly set to mode:
\"$l_mode\""
fi
if [ "$l_fown" != "root" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by user
\"$l_fown\" (should be owned by \"root\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by
user: \"$l_fown\""
fi
if [ "$l_fgroup" != "root" ]; then
l_output2="$l_output2\n - \"$l_file\" is owned by group:
\"$l_fgroup\" (should be owned by group: \"root\")"
else
l_output="$l_output\n - \"$l_file\" is correctly owned by
group: \"$l_fgroup\""
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
fi
else
l_output="$l_output\n - at is not installed on the system"
fi
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - Reason(s) for audit
failure:$l_output2\n"
fi
}
Page 488
Remediation:
Run the following script to:
#!/usr/bin/env bash
{
if dpkg-query -W at > /dev/null 2>&1; then
l_file="/etc/at.allow"
l_mask='0137'
l_maxperm="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ -e /etc/at.deny ]; then
echo -e " - Removing \"/etc/at.deny\""
rm -f /etc/at.deny
fi
if [ ! -e /etc/at.allow ]; then
echo -e " - creating \"$l_file\""
touch "$l_file"
fi
while read l_mode l_fown l_fgroup; do
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
echo -e " - Removing excessive permissions from \"$l_file\""
chmod u-x,g-wx,o-rwx "$l_file"
fi
if [ "$l_fown" != "root" ]; then
echo -e " - Changing owner on \"$l_file\" from: \"$l_fown\" to:
\"root\""
chown root "$l_file"
fi
if [ "$l_fgroup" != "root" ]; then
echo -e " - Changing group owner on \"$l_file\" from:
\"$l_fgroup\" to: \"root\""
chgrp root "$l_file"
fi
done < <(stat -Lc '%#a %U %G' "$l_file")
else
echo -e "- cron is not installed on the system, no remediation
required\n"
fi
}
References:
Page 489
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 490
4.2 Configure SSH Server
SSH is a secure, encrypted replacement for common login services such as telnet,
ftp, rlogin, rsh, and rcp. It is strongly recommended that sites abandon older clear-
text login protocols and use SSH to prevent session hijacking and sniffing of sensitive
data off the network.
Note:
• The recommendations in this section only apply if the SSH daemon is installed
on the system, if remote access is not required the SSH daemon can be
removed and this section skipped.
• The following openSSH daemon configuration options, Include and Match, may
cause the audits in this section's recommendations to report incorrectly. It is
recommended that these options only be used if they're needed and fully
understood. If these options are configured in accordance with local site policy,
they should be accounted for when following the recommendations in this
section.
• The default Include location is the /etc/ssh/sshd_config.d directory. This
default has been accounted for in this section. If a file has an additional Include
that isn't this default location, the files should be reviewed to verify that the
recommended setting is not being over-ridden.
• The audits of the running configuration in this section are run in the context of the
root user, the local host name, and the local host's IP address. If a Match block
exists that matches one of these criteria, the output of the audit will be from the
match block. The respective matched criteria should be replaced with a non-
matching substitution.
• Once all configuration changes have been made to /etc/ssh/sshd_config or any
included configuration files, the sshd configuration must be reloaded
• Include:
o Include the specified configuration file(s).
o Multiple pathnames may be specified and each pathname may contain
glob(7) wildcards.
o Files without absolute paths are assumed to be in /etc/ssh.
o An Include directive may appear inside a Match block to perform
conditional inclusion.
Page 491
• Match:
o Introduces a conditional block.
o If all of the criteria on the Match line are satisfied, the keywords on the
following lines override those set in the global section of the config file,
until either another Match line or the end of the file.
o If a keyword appears in multiple Match blocks that are satisfied, only the
first instance of the keyword is applied.
o The arguments to Match are one or more criteria-pattern pairs or the
single token All which matches all criteria. The available criteria are User,
Group, Host, LocalAddress, LocalPort, RDomain, and Address (with
RDomain representing the rdomain(4) on which the connection was
received).
o The match patterns may consist of single entries or comma-separated lists
and may use the wildcard and negation operators described in the
PATTERNS section of ssh_config(5).
o The patterns in an Address criteria may additionally contain addresses to
match in CIDR address/masklen format, such as 192.0.2.0/24 or
2001:db8::/32. Note that the mask length provided must be consistent with
the address - it is an error to specify a mask length that is too long for the
address or one with bits set in this host portion of the address. For
example, 192.0.2.0/33 and 192.0.2.0/8, respectively.
o Only a subset of keywords may be used on the lines following a Match
keyword.
o Available keywords are: AcceptEnv, AllowAgentForwarding, AllowGroups,
AllowStreamLocalForwarding, AllowTcpForwarding, AllowUsers,
AuthenticationMethods, AuthorizedKeysCommand,
AuthorizedKeysCommandUser, AuthorizedKeysFile,
AuthorizedPrincipalsCommand, AuthorizedPrincipalsCommandUser,
AuthorizedPrincipalsFile, Banner, ChrootDirectory,
ClientAliveCountMax, ClientAliveInterval, DenyGroups, DenyUsers,
ForceCommand, GatewayPorts, GSSAPIAuthentication,
HostbasedAcceptedKeyTypes, HostbasedAuthentication,
HostbasedUsesNameFromPacketOnly, Include, IPQoS,
KbdInteractiveAuthentication, KerberosAuthentication, LogLevel,
MaxAuthTries, MaxSessions, PasswordAuthentication,
PermitEmptyPasswords, PermitListen, PermitOpen, PermitRootLogin,
PermitTTY, PermitTunnel, PermitUserRC, PubkeyAcceptedKeyTypes,
PubkeyAuthentication, RekeyLimit, RevokedKeys, RDomain, SetEnv,
StreamLocalBindMask, StreamLocalBindUnlink, TrustedUserCAKeys,
X11DisplayOffset, X11Forwarding and X11UseLocalhost.
Page 492
4.2.1 Ensure permissions on /etc/ssh/sshd_config are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The file /etc/ssh/sshd_config, and files ending in .conf in the /etc/ssh/sshd_config.d
directory, contain configuration specifications for sshd.
Rationale:
configuration specifications for sshd need to be protected from unauthorized changes by
non-privileged users.
Page 493
Audit:
Run the following script and verify /etc/ssh/sshd_config and files ending in .conf in
the /etc/ssh/sshd_config.d directory are:
#!/usr/bin/env bash
{
l_output="" l_output2=""
unset a_sshdfiles && a_sshdfiles=()
[ -e "/etc/ssh/sshd_config" ] && a_sshdfiles+=("$(stat -Lc '%n^%#a^%U^%G'
"/etc/ssh/sshd_config")")
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_sshdfiles+=("$(stat -Lc '%n^%#a^%U^%G'
"$l_file")")
done < <(find /etc/ssh/sshd_config.d -type f \( -perm /077 -o ! -user
root -o ! -group root \) -print0)
if (( ${#a_sshdfiles[@]} != 0 )); then
perm_mask='0177'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
while IFS="^" read -r l_file l_mode l_user l_group; do
l_out2=""
[ $(( $l_mode & $perm_mask )) -gt 0 ] && l_out2="$l_out2\n - Is
mode: \"$l_mode\" should be: \"$maxperm\" or more restrictive"
[ "$l_user" != "root" ] && l_out2="$l_out2\n - Is owned by
\"$l_user\" should be owned by \"root\""
[ "$l_group" != "root" ] && l_out2="$l_out2\n - Is group owned by
\"$l_user\" should be group owned by \"root\""
if [ -n "$l_out2" ]; then
l_output2="$l_output2\n - File: \"$l_file\":$l_out2"
else
l_output="$l_output\n - File: \"$l_file\":\n - Correct: mode
($l_mode), owner ($l_user), and group owner ($l_group) configured"
fi
done <<< "$(printf '%s\n' "${a_sshdfiles[@]}")"
fi
unset a_sshdfiles
# If l_output2 is empty, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n *** PASS ***\n- * Correctly set *
:\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit
failure * :\n$l_output2\n"
[ -n "$l_output" ] && echo -e " - * Correctly set * :\n$l_output\n"
fi
}
Page 494
Remediation:
Run the following script to set ownership and permissions on /etc/ssh/sshd_config
and files ending in .conf in the /etc/ssh/sshd_config.d directory:
#!/usr/bin/env bash
{
chmod u-x,og-rwx /etc/ssh/sshd_config
chown root:root /etc/ssh/sshd_config
while IFS= read -r -d $'\0' l_file; do
if [ -e "$l_file" ]; then
chmod u-x,og-rwx "$l_file"
chown root:root "$l_file"
fi
done < <(find /etc/ssh/sshd_config.d -type f -print0)
}
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 495
4.2.2 Ensure permissions on SSH private host key files are
configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
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
Page 496
Audit:
Run the following script to verify SSH private host key files are mode 0600 or more
restrictive, owned be the root user, and owned by the group root or group designated to
own openSSH private keys:
#!/usr/bin/env bash
{
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)" # Get gid of
group
[ -n "$l_skgid" ] && l_agroup="(root|$l_skgn)" || l_agroup="root"
unset a_skarr && a_skarr=() # Clear and initialize array
while IFS= read -r -d $'\0' l_file; do # Loop to populate array
if grep -Pq ':\h+OpenSSH\h+private\h+key\b' <<< "$(file "$l_file")"; then
a_skarr+=("$(stat -Lc '%n^%#a^%U^%G^%g' "$l_file")")
fi
done < <(find -L /etc/ssh -xdev -type f -print0)
while IFS="^" read -r l_file l_mode l_owner l_group l_gid; do
echo "File: \"$l_file\" Mode: \"$l_mode\" Owner: \"$l_owner\" Group: \"$l_group\"
GID: \"$l_gid\""
l_out2=""
[ "$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_out2="$l_out2\n - Mode: \"$l_mode\" should be mode: \"$l_maxperm\" or more
restrictive"
fi
if [ "$l_owner" != "root" ]; then
l_out2="$l_out2\n - Owned by: \"$l_owner\" should be owned by \"root\""
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_out2="$l_out2\n - Owned by group \"$l_group\" should be group owned by:
\"${l_agroup//|/ or }\""
fi
if [ -n "$l_out2" ]; then
l_output2="$l_output2\n - File: \"$l_file\"$l_out2"
else
l_output="$l_output\n - File: \"$l_file\"\n - Correct: mode ($l_mode), owner
($l_owner), and group owner ($l_group) configured"
fi
done <<< "$(printf '%s\n' "${a_skarr[@]}")"
unset a_skarr
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n *** PASS ***\n- * Correctly set * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure *
:\n$l_output2\n"
[ -n "$l_output" ] && echo -e " - * Correctly set * :\n$l_output\n"
fi
}
Page 497
Remediation:
Run the following script to set mode, ownership, and group on the private SSH host key
files:
#!/usr/bin/env bash
{
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)" # Get gid of
group
if [ -n "$l_skgid" ]; then
l_agroup="(root|$l_skgn)" && l_sgroup="$l_skgn" && l_mfix="u-x,g-wx,o-rwx"
else
l_agroup="root" && l_sgroup="root" && l_mfix="u-x,go-rwx"
fi
unset a_skarr && a_skarr=() # Clear and initialize array
while IFS= read -r -d $'\0' l_file; do # Loop to populate array
if grep -Pq ':\h+OpenSSH\h+private\h+key\b' <<< "$(file "$l_file")"; then
a_skarr+=("$(stat -Lc '%n^%#a^%U^%G^%g' "$l_file")")
fi
done < <(find -L /etc/ssh -xdev -type f -print0)
while IFS="^" read -r l_file l_mode l_owner l_group l_gid; do
l_out2=""
[ "$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_out2="$l_out2\n - Mode: \"$l_mode\" should be mode: \"$l_maxperm\" or more
restrictive\n - Revoking excess permissions"
chmod "$l_mfix" "$l_file"
fi
if [ "$l_owner" != "root" ]; then
l_out2="$l_out2\n - Owned by: \"$l_owner\" should be owned by \"root\"\n -
Changing ownership to \"root\""
chown root "$l_file"
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_out2="$l_out2\n - Owned by group \"$l_group\" should be group owned by:
\"${l_agroup//|/ or }\"\n - Changing group ownership to \"$l_sgroup\""
chgrp "$l_sgroup" "$l_file"
fi
[ -n "$l_out2" ] && l_output2="$l_output2\n - File: \"$l_file\"$l_out2"
done <<< "$(printf '%s\n' "${a_skarr[@]}")"
unset a_skarr
if [ -z "$l_output2" ]; then
echo -e "\n- No access changes required\n"
else
echo -e "\n- Remediation results:\n$l_output2\n"
fi
}
References:
Page 498
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 499
4.2.3 Ensure permissions on SSH public host key files are
configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
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.
Page 500
Audit:
Run the following command and verify Access does not grant write or execute
permissions to group or other for all returned files:
Run the following script to verify SSH public host key files are mode 0644 or more
restrictive, owned be the root user, and owned be the root group:
#!/usr/bin/env bash
{
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
)
}
Page 501
Remediation:
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 " - File: \"$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 " - File: \"$l_file\" is owned by: \"$l_owner\" changing
owner to \"root\""
chown root "$l_file"
fi
if [ "$l_group" != "root" ]; then
echo -e " - File: \"$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
References:
Page 502
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 503
4.2.4 Ensure SSH access is limited (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
There are several options available to limit which users and group can access the
system via SSH. It is recommended that at least one of the following options be
leveraged:
• AllowUsers:
o The AllowUsers variable gives the system administrator the option of
allowing specific users to ssh into the system. The list consists of space
separated user names. Numeric user IDs are not recognized with this
variable. If a system administrator wants to restrict user access further by
only allowing the allowed users to log in from a particular host, the entry
can be specified in the form of user@host.
• AllowGroups:
o The AllowGroups variable gives the system administrator the option of
allowing specific groups of users to ssh into the system. The list consists
of space separated group names. Numeric group IDs are not recognized
with this variable.
• DenyUsers:
o The DenyUsers variable gives the system administrator the option of
denying specific users to ssh into the system. The list consists of space
separated user names. Numeric user IDs are not recognized with this
variable. If a system administrator wants to restrict user access further by
specifically denying a user's access from a particular host, the entry can
be specified in the form of user@host.
• DenyGroups:
o The DenyGroups variable gives the system administrator the option of
denying specific groups of users to ssh into the system. The list consists of
space separated group names. Numeric group IDs are not recognized
with this variable.
Rationale:
Restricting which users can remotely access the system via SSH will help ensure that
only authorized users access the system.
Page 504
Audit:
Run the following commands and verify the output:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -Pi
'^\h*(allow|deny)(users|groups)\h+\H+(\h+.*)?$'
AllowUsers <userlist>
OR
AllowGroups <grouplist>
OR
DenyUsers <userlist>
OR
DenyGroups <grouplist>
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location. If
the Include location is not the default, /etc/ssh/sshd_config.d/*.conf, the audit will
need to be modified to account for the Include location used.
Default Value:
None
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: AC-3. MP-2
Page 505
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 506
4.2.5 Ensure SSH LogLevel is appropriate (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
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.
VERBOSElevel 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.
Audit:
Run the following command and verify that output matches loglevel VERBOSE or
loglevel INFO:
Page 507
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
LogLevel VERBOSE
OR
LogLevel INFO
Note: First occurrence of an option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Default Value:
LogLevel INFO
References:
1. https://www.ssh.com/ssh/sshd_config/
2. NIST SP 800-53 Rev. 5: AU-3, AU-12, SI-5
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 508
4.2.6 Ensure SSH PAM is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The UsePAM directive enables the Pluggable Authentication Module (PAM) interface. If
set to yes this will enable PAM authentication using ChallengeResponseAuthentication
and PasswordAuthentication directives in addition to PAM account and session module
processing for all authentication types.
Rationale:
When usePAM is set to yes, PAM runs through account and session types properly. This
is important if you want to restrict access to services based off of IP, time or other
factors of the account. Additionally, you can make sure users inherit certain
environment variables on login or disallow access to the server
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -i usepam
Verify the output matches:
usepam yes
Run the following command:
# grep -Pis '^\h*UsePAM\h+"?no"?\b' /etc/ssh/sshd_config
/etc/ssh/ssh_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
are used in your environment, those locations should be checked for the correct
configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
UsePAM yes
Note: First occurrence of a option takes precedence. If Include locations are enabled,
used, and order of precedence is understood in your environment, the entry may be
created in a file in Include location.
Page 509
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 510
4.2.7 Ensure SSH root login is disabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The PermitRootLogin parameter specifies if the root user can log in using SSH. The
default is prohibit-password.
Rationale:
Disallowing root logins over SSH requires system admins to authenticate using their
own individual account, then escalating to root. This limits opportunity for non-
repudiation and provides a clear audit trail in the event of a security incident.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep permitrootlogin
Verify the output matches:
permitrootlogin no
Run the following command:
# grep -Pis '^\h*PermitRootLogin\h+"?(yes|prohibit-password|forced-commands-
only)"?\b' /etc/ssh/sshd_config /etc/ssh/ssh_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
and/or Match set statements are used in your environment, those locations should be
checked for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
PermitRootLogin no
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Default Value:
PermitRootLogin without-password
Page 511
References:
1. SSHD_CONFIG(5)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 512
4.2.8 Ensure SSH HostbasedAuthentication is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The HostbasedAuthentication parameter specifies if authentication is allowed through
trusted hosts via the user of .rhosts, or /etc/hosts.equiv, along with successful public
key client host authentication.
Rationale:
Even though the .rhosts files are ineffective if support is disabled in /etc/pam.conf,
disabling the ability to use .rhosts files in SSH provides an additional layer of
protection.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep hostbasedauthentication
Verify the output matches:
hostbasedauthentication no
Run the following command:
# grep -Pis '^\h*HostbasedAuthentication\h+"?yes"?\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
and/or Match set statements are used in your environment, those locations should be
checked for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
HostbasedAuthentication no
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Page 513
Default Value:
HostbasedAuthentication no
References:
1. SSHD_CONFIG(5)
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1042
T1078.003
Page 514
4.2.9 Ensure SSH PermitEmptyPasswords is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The PermitEmptyPasswords parameter specifies if the SSH server allows login to
accounts with empty password strings.
Rationale:
Disallowing remote shell access to accounts that have an empty password reduces the
probability of unauthorized access to the system.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep permitemptypasswords
Verify the output matches:
permitemptypasswords no
Run the following command and verify the output:
# grep -Pis '^\h*PermitEmptyPasswords\h+"?yes\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
and/or Match set statements are used in your environment, those locations should be
checked for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
PermitEmptyPasswords no
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Page 515
Default Value:
PermitEmptyPasswords no
References:
1. SSHD_CONFIG(5)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 516
4.2.10 Ensure SSH PermitUserEnvironment is disabled
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The PermitUserEnvironment option allows users to present environment options to the
SSH daemon.
Rationale:
Permitting users the ability to set environment variables through the SSH daemon could
potentially allow users to bypass security controls (e.g. setting an execution path that
has SSH executing trojan'd programs)
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep permituserenvironment
Verify the output matches:
permituserenvironment no
Run the following command and verify the output:
# grep -Pis '^\h*PermitUserEnvironment\h+"?yes"?\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
are used in your environment, those locations should be checked for the correct
configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
PermitUserEnvironment no
Note: First occurrence of a option takes precedence. If Include locations are enabled,
used, and order of precedence is understood in your environment, the entry may be
created in a file in Include location.
Page 517
Default Value:
PermitUserEnvironment no
References:
1. SSHD_CONFIG(5)
Techniques / Sub-
Tactics Mitigations
techniques
Page 518
4.2.11 Ensure SSH IgnoreRhosts is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The IgnoreRhosts parameter specifies that .rhosts and .shosts files will not be used in
RhostsRSAAuthentication or HostbasedAuthentication.
Rationale:
Setting this parameter forces users to enter a password when authenticating with SSH.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep ignorerhosts
Verify the output matches:
ignorerhosts yes
Run the following command:
# grep -Pis '^\h*ignorerhosts\h+"?no"?\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
and/or Match set statements are used in your environment, those locations should be
checked for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
IgnoreRhosts yes
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Default Value:
IgnoreRhosts yes
Page 519
References:
1. SSHD_CONFIG(5)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1027
T1078.003
Page 520
4.2.12 Ensure SSH X11 forwarding is disabled (Automated)
Profile Applicability:
• Level 1 - Workstation
• Level 2 - Server
Description:
The X11Forwarding parameter provides the ability to tunnel X11 traffic through the
connection to enable remote graphic connections.
Rationale:
Disable X11 forwarding unless there is an operational requirement to use X11
applications directly. There is a small risk that the remote X11 servers of users who are
logged in via SSH with X11 forwarding could be compromised by other users on the
X11 server. Note that even if X11 forwarding is disabled, users can always install their
own forwarders.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -i x11forwarding
Verify the output matches:
x11forwarding no
Run the following command:
# grep -Pis '^\h*x11forwarding\h+"?yes"?\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing is returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf
and/or Match set statements are used in your environment, those locations should be
checked for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
X11Forwarding no
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Page 521
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 522
4.2.13 Ensure only strong Ciphers are used (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
This variable limits the ciphers that SSH can use during communication.
Note:
Rationale:
Weak ciphers that are used for authentication to the cryptographic module cannot be
relied upon to provide confidentiality or integrity, and system data may be compromised.
• The Triple DES ciphers, as used in SSH, have a birthday bound of approximately
four billion blocks, which makes it easier for remote attackers to obtain clear text
data via a birthday attack against a long-duration encrypted session, aka a
"Sweet32" attack.
• Error handling in the SSH protocol; Client and Server, when using a block cipher
algorithm in Cipher Block Chaining (CBC) mode, makes it easier for remote
attackers to recover certain plain text data from an arbitrary block of cipher text in
an SSH session via unknown vectors.
Page 523
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep ciphers
Verify that output does not contain any of the following weak ciphers:
3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
rijndael-cbc@lysator.liu.se
Remediation:
Edit the /etc/ssh/sshd_config file add/modify the Ciphers line to contain a comma
separated list of the site approved ciphers above any Include entries:
Example:
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-
gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
Note: First occurrence of a option takes precedence. If Include locations are enabled,
used, and order of precedence is understood in your environment, the entry may be
created in a file in Include location.
Default Value:
Ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-
gcm@openssh.com,aes256-gcm@openssh.com
References:
1. https://nvd.nist.gov/vuln/detail/CVE-2016-2183
2. https://www.openssh.com/txt/cbc.adv
3. https://nvd.nist.gov/vuln/detail/CVE-2008-5161
4. https://www.openssh.com/txt/cbc.adv
5. SSHD_CONFIG(5)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 524
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 525
4.2.14 Ensure only strong MAC algorithms are used (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
This variable limits the types of MAC algorithms that SSH can use during
communication.
Notes:
Rationale:
MD5 and 96-bit MAC algorithms are considered weak and have been shown to increase
exploitability in SSH downgrade attacks. Weak algorithms continue to have a great deal
of attention as a weak spot that can be exploited with expanded computing power. An
attacker that breaks the algorithm could take advantage of a MiTM position to decrypt
the SSH tunnel and capture credentials and information.
Page 526
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -i "MACs"
Verify that output does not contain any of the listed weak MAC algorithms:
hmac-md5
hmac-md5-96
hmac-ripemd160
hmac-sha1
hmac-sha1-96
umac-64@openssh.com
hmac-md5-etm@openssh.com
hmac-md5-96-etm@openssh.com
hmac-ripemd160-etm@openssh.com
hmac-sha1-etm@openssh.com
hmac-sha1-96-etm@openssh.com
umac-64-etm@openssh.com
Remediation:
Edit the /etc/ssh/sshd_config file and add/modify the MACs line to contain a comma
separated list of the site approved MACs above any Include entries:
Example:
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-
512,hmac-sha2-256,umac-128-etm@openssh.com,umac-128@openssh.com
Note: First occurrence of a option takes precedence. If Include locations are enabled,
used, and order of precedence is understood in your environment, the entry may be
created in a file in Include location.
Default Value:
MACs umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-
etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-
etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-
256,hmac-sha2-512,hmac-sha1
References:
Page 527
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 528
4.2.15 Ensure only strong Key Exchange algorithms are used
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Key exchange is any method in cryptography by which cryptographic keys are
exchanged between two parties, allowing use of a cryptographic algorithm. If the sender
and receiver wish to exchange encrypted messages, each must be equipped to encrypt
messages to be sent and decrypt messages received
Notes:
• Kex algorithms have a higher preference the earlier they appear in the list
• Some organizations may have stricter requirements for approved Key exchange
algorithms
• Ensure that Key exchange algorithms used are in compliance with site policy
• The only Key Exchange Algorithms currently FIPS 140-2 approved are:
o ecdh-sha2-nistp256
o ecdh-sha2-nistp384
o ecdh-sha2-nistp521
o diffie-hellman-group-exchange-sha256
o diffie-hellman-group16-sha512
o diffie-hellman-group18-sha512
o diffie-hellman-group14-sha256
Rationale:
Key exchange methods that are considered weak should be removed. A key exchange
method may be weak because too few bits are used, or the hashing algorithm is
considered too weak. Using weak algorithms could expose connections to man-in-the-
middle attacks
Page 529
Audit:
Run the following command and verify that output does not contain any of the listed
weak Key Exchange algorithms:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep kexalgorithms
Weak Key Exchange Algorithms:
diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group-exchange-sha1
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf and/or
Match set statements are used in your environment, those locations should be checked
for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file add/modify the KexAlgorithms line to contain a comma
separated list of the site approved key exchange algorithms above any Include entries:
Example:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-
group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-
sha512,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-
hellman-group-exchange-sha256
Note: First occurrence of a option takes precedence. If Include locations are enabled,
used, and order of precedence is understood in your environment, the entry may be
created in a file in Include location.
Default Value:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-
nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-
sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-
group14-sha256
References:
Page 530
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 531
4.2.16 Ensure SSH AllowTcpForwarding is disabled (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
SSH port forwarding is a mechanism in SSH for tunneling application ports from the
client to the server, or servers to clients. It can be used for adding encryption to legacy
applications, going through firewalls, and some system administrators and IT
professionals use it for opening backdoors into the internal network from their home
machines.
Rationale:
Leaving port forwarding enabled can expose the organization to security risks and
backdoors.
SSH connections are protected with strong encryption. This makes their contents
invisible to most deployed network monitoring and traffic filtering solutions. This
invisibility carries considerable risk potential if it is used for malicious purposes such as
data exfiltration. Cybercriminals or malware could exploit SSH to hide their unauthorized
communications, or to exfiltrate stolen data from the target network.
Impact:
SSH tunnels are widely used in many corporate environments. In some environments
the applications themselves may have very limited native support for security. By
utilizing tunneling, compliance with SOX, HIPAA, PCI-DSS, and other standards can be
achieved without having to modify the applications.
Page 532
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -i allowtcpforwarding
Verify the output matches:
allowtcpforwarding no
Run the following command:
# grep -Pis '^\h*AllowTcpForwarding\h+"?yes\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf and/or
Match set statements are used in your environment, those locations should be checked
for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
AllowTcpForwarding no
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Default Value:
AllowTcpForwarding yes
References:
1. https://www.ssh.com/ssh/tunneling/example
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Techniques / Sub-
Tactics Mitigations
techniques
Page 533
4.2.17 Ensure SSH warning banner is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The Banner parameter specifies a file whose contents must be sent to the remote user
before authentication is permitted. By default, no banner is displayed.
Rationale:
Banners are used to warn connecting users of the particular site's policy regarding
connection. Presenting a warning message prior to the normal user login may assist the
prosecution of trespassers on the computer system.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep banner
Verify the output matches:
banner /etc/issue.net
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
Banner /etc/issue.net
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 534
4.2.18 Ensure SSH MaxAuthTries is set to 4 or less (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The MaxAuthTries parameter specifies the maximum number of authentication attempts
permitted per connection. When the login failure count reaches half the number, error
messages will be written to the syslog file detailing the login failure.
Rationale:
Setting the MaxAuthTries parameter to a low number will minimize the risk of successful
brute force attacks to the SSH server. While the recommended setting is 4, set the
number based on site policy.
Audit:
Run the following command and verify that output MaxAuthTries is 4 or less:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep maxauthtries
maxauthtries 4
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf and/or
Match set statements are used in your environment, those locations should be checked
for the correct configuration as well.
Run the following command and verify that the output:
# grep -Pis '^\h*maxauthtries\h+"?([5-9]|[1-9][0-9]+)\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing is returned
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
MaxAuthTries 4
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Default Value:
MaxAuthTries 6
Page 535
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: AU-3
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1110, T1110.001,
TA0006 M1036
T1110.003
Page 536
4.2.19 Ensure SSH MaxStartups is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The MaxStartups parameter specifies the maximum number of concurrent
unauthenticated connections to the SSH daemon.
Rationale:
To protect a system from denial of service due to a large number of pending
authentication connection attempts, use the rate limiting function of MaxStartups to
protect availability of sshd logins and prevent overwhelming the daemon.
Audit:
Run the following command:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -i maxstartups
Verify that output MaxStartups is 10:30:60 or more restrictive:
maxstartups 10:30:60
Run the following command and verify the output:
# grep -Pis '^\h*maxstartups\h+"?(((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]+)))\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Nothing should be returned.
Note: If Include locations besides, or in addition to /etc/ssh/sshd_config.d/*.conf and/or
Match set statements are used in your environment, those locations should be checked
for the correct configuration as well.
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
MaxStartups 10:30:60
Note: First occurrence of a option takes precedence. If Include locations are enabled,
used, and order of precedence is understood in your environment, the entry may be
created in a file in Include location.
Page 537
Default Value:
MaxStartups 10:30:100
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 538
4.2.20 Ensure SSH LoginGraceTime is set to one minute or less
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The LoginGraceTime parameter specifies the time allowed for successful authentication
to the SSH server. The longer the Grace period is the more open unauthenticated
connections can exist. Like other session controls in this session the Grace Period
should be limited to appropriate organizational limits to ensure the service is available
for needed access.
Rationale:
Setting the LoginGraceTime parameter to a low number will minimize the risk of
successful brute force attacks to the SSH server. It will also limit the number of
concurrent unauthenticated connections While the recommended setting is 60 seconds
(1 Minute), set the number based on site policy.
Audit:
Run the following command and verify that output LoginGraceTime is between 1 and 60
seconds or 1m:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep logingracetime
logingracetime 60
Run the following command and verify the output:
# grep -Pis '^\h*LoginGraceTime\h+"?(0|6[1-9]|[7-9][0-9]|[1-9][0-9][0-
9]+|[^1]m)\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf
Page 539
Remediation:
Edit the /etc/ssh/sshd_config file to set the parameter above any Include entries as
follows:
LoginGraceTime 60
Note: First occurrence of a option takes precedence, Match set statements
withstanding. If Include locations are enabled, used, and order of precedence is
understood in your environment, the entry may be created in a file in Include location.
Default Value:
LoginGraceTime 120
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-6
Techniques / Sub-
Tactics Mitigations
techniques
T1110, T1110.001,
TA0006 M1036
T1110.003, T1110.004
Page 540
4.2.21 Ensure SSH MaxSessions is set to 10 or less (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The MaxSessions parameter specifies the maximum number of open sessions permitted
from a given connection.
Rationale:
To protect a system from denial of service due to a large number of concurrent
sessions, use the rate limiting function of MaxSessions to protect availability of sshd
logins and prevent overwhelming the daemon.
Audit:
Run the following command and verify that output MaxSessions is 10 or less:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep -i maxsessions
maxsessions 10
Run the following command and verify the output:
grep -Pis '^\h*MaxSessions\h+"?(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)\b'
/etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf
Page 541
References:
1. SSHD_CONFIG(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Techniques / Sub-
Tactics Mitigations
techniques
Page 542
4.2.22 Ensure SSH Idle Timeout Interval is configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Note: To clarify, the two settings described below are only meant for idle connections
from a protocol perspective and are not meant to check if the user is active or not. An
idle user does not mean an idle connection. SSH does not and never had, intentionally,
the capability to drop idle users. In SSH versions before 8.2p1 there was a bug that
caused these values to behave in such a manner that they were abused to disconnect
idle users. This bug has been resolved in 8.2p1 and thus it can no longer be abused
disconnect idle users.
The two options ClientAliveInterval and ClientAliveCountMax control the timeout of
SSH sessions. Taken directly from man 5 sshd_config:
Page 543
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.
Audit:
Run the following commands and verify ClientAliveInterval is greater than zero:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep clientaliveinterval
Example output:
clientaliveinterval 15
Run the following command and verify ClientAliveCountMax is greater than zero:
# sshd -T -C user=root -C host="$(hostname)" -C addr="$(grep $(hostname)
/etc/hosts | awk '{print $1}')" | grep clientalivecountmax
Example output:
clientalivecountmax 3
Run the following command:
# grep -Pis '^\h*ClientAliveCountMax\h+"?0\b' /etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Page 544
Default Value:
ClientAliveInterval 0
ClientAliveCountMax 3
References:
1. https://man.openbsd.org/sshd_config
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Additional Information:
https://bugzilla.redhat.com/show_bug.cgi?id=1873547
https://github.com/openssh/openssh-portable/blob/V_8_9/serverloop.c#L137
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0001 M1026
T1078.002, T1078.003
Page 545
4.3 Configure privilege escalation
There are various tools which allows a permitted user to execute a command as the
superuser or another user, as specified by the security policy.
sudo
sudo documentation
The invoking user's real (not effective) user ID is used to determine the user name with
which to query the security policy.
sudo supports a plug-in architecture for security policies and input/output logging. Third
parties can develop and distribute their own policy and I/O logging plug-ins to work
seamlessly with the sudo front end. The default security policy is sudoers, which is
configured via the file /etc/sudoers and any entries in /etc/sudoers.d.
pkexec
pkexec documentation
pkexec allows an authorized user to execute PROGRAM as another user. If username
is not specified, then the program will be executed as the administrative super user,
root.
Page 546
4.3.1 Ensure sudo is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo allows a permitted user to execute a command as the superuser or another user,
as specified by the security policy. The invoking user's real (not effective) user ID is
used to determine the user name with which to query the security policy.
Rationale:
sudo supports a plug-in architecture for security policies and input/output logging. Third
parties can develop and distribute their own policy and I/O logging plug-ins to work
seamlessly with the sudo front end. The default security policy is sudoers, which is
configured via the file /etc/sudoers and any entries in /etc/sudoers.d.
The security policy determines what privileges, if any, a user has to run sudo. The policy
may require that users authenticate themselves with a password or another
authentication mechanism. If authentication is required, sudo will exit if the user's
password is not entered within a configurable time limit. This limit is policy-specific.
Audit:
Run the following command to verify that either sudo or sudo-ldap is installed:
# dpkg-query -W sudo sudo-ldap > /dev/null 2>&1 && dpkg-query -W -
f='${binary:Package}\t${Status}\t${db:Status-Status}\n' sudo sudo-ldap | awk
'($4=="installed" && $NF=="installed") {print "\n""PASS:""\n""Package
""\""$1"\""" is installed""\n"}' || echo -e "\nFAIL:\nneither \"sudo\" or
\"sudo-ldap\" package is installed\n"
Remediation:
First determine is LDAP functionality is required. If so, then install sudo-ldap, else install
sudo.
Example:
# apt install sudo
References:
1. SUDO(8)
2. NIST SP 800-53 Rev. 5: AC-2, AC-6
Page 547
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 548
4.3.2 Ensure sudo commands use pty (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo can be configured to run only from a pseudo terminal (pseudo-pty).
Rationale:
Attackers can run a malicious program using sudo which would fork a background
process that remains even when the main program has finished executing.
Impact:
WARNING: Editing the sudo configuration incorrectly can cause sudo to stop
functioning. Always use visudo to modify sudo configuration files.
Audit:
Verify that sudo can only run other commands from a pseudo terminal.
Run the following command:
# grep -rPi '^\h*Defaults\h+([^#\n\r]+,)?use_pty(,\h*\h+\h*)*\h*(#.*)?$'
/etc/sudoers*
Verify the output matches:
/etc/sudoers:Defaults use_pty
Remediation:
Edit the file /etc/sudoers with visudo or a file in /etc/sudoers.d/ with visudo -f <PATH
TO FILE> and add the following line:
Defaults use_pty
Note:
• sudo will read each file in /etc/sudoers.d, skipping file names that end in ~ or
contain a . character to avoid causing problems with package manager or editor
temporary/backup files.
• Files are parsed in sorted lexical order. That is, /etc/sudoers.d/01_first will be
parsed before /etc/sudoers.d/10_second.
• Be aware that because the sorting is lexical, not numeric,
/etc/sudoers.d/1_whoops would be loaded after /etc/sudoers.d/10_second.
• Using a consistent number of leading zeroes in the file names can be used to
avoid such problems.
Page 549
References:
1. SUDO(8)
2. VISUDO(8)
3. sudoers(5)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 550
4.3.3 Ensure sudo log file exists (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo can use a custom log file
Rationale:
A sudo log file simplifies auditing of sudo commands
Impact:
WARNING: Editing the sudo configuration incorrectly can cause sudo to stop
functioning. Always use visudo to modify sudo configuration files.
Audit:
Run the following command to verify that sudo has a custom log file configured:
# grep -rPsi
"^\h*Defaults\h+([^#]+,\h*)?logfile\h*=\h*(\"|\')?\H+(\"|\')?(,\h*\H+\h*)*\h*
(#.*)?$" /etc/sudoers*
Verify the output matches:
Defaults logfile="/var/log/sudo.log"
Remediation:
Edit the file /etc/sudoers or a file in /etc/sudoers.d/ with visudo or visudo -f <PATH
TO FILE> and add the following line:
Example:
Defaults logfile="/var/log/sudo.log"
Note:
• sudo will read each file in /etc/sudoers.d, skipping file names that end in ~ or
contain a . character to avoid causing problems with package manager or editor
temporary/backup files.
• Files are parsed in sorted lexical order. That is, /etc/sudoers.d/01_first will be
parsed before /etc/sudoers.d/10_second.
• Be aware that because the sorting is lexical, not numeric,
/etc/sudoers.d/1_whoops would be loaded after /etc/sudoers.d/10_second.
• Using a consistent number of leading zeroes in the file names can be used to
avoid such problems.
Page 551
References:
1. SUDO(8)
2. VISUDO(8)
3. sudoers(5)
Additional Information:
visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the
sudoers file against multiple simultaneous edits, provides basic sanity checks, and
checks for parse errors. If the sudoers file is currently being edited you will receive a
message to try again later.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 552
4.3.4 Ensure users must provide password for privilege escalation
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must be configured so that users must provide a password for
privilege escalation.
Rationale:
Without (re-)authentication, users may access resources or perform tasks for which they
do not have authorization.
When operating systems provide the capability to escalate a functional capability, it is
critical the user (re-)authenticate.
Impact:
This will prevent automated processes from being able to elevate privileges.
Audit:
Note: If passwords are not being used for authentication, this is not applicable.
Verify the operating system requires users to supply a password for privilege escalation.
Check the configuration of the /etc/sudoers and /etc/sudoers.d/* files with the
following command:
# grep -r "^[^#].*NOPASSWD" /etc/sudoers*
If any line is found refer to the remediation procedure below.
Remediation:
Based on the outcome of the audit procedure, use visudo -f <PATH TO FILE> to edit
the relevant sudoers file.
Remove any line with occurrences of NOPASSWD tags in the file.
References:
Page 553
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 554
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The operating system must be configured so that users must re-authenticate for
privilege escalation.
Rationale:
Without re-authentication, users may access resources or perform tasks for which they
do not have authorization.
When operating systems provide the capability to escalate a functional capability, it is
critical the user re-authenticate.
Audit:
Verify the operating system requires users to re-authenticate for privilege escalation.
Check the configuration of the /etc/sudoers and /etc/sudoers.d/* files with the
following command:
# grep -r "^[^#].*\!authenticate" /etc/sudoers*
If any line is found with a !authenticate tag, refer to the remediation procedure below.
Remediation:
Configure the operating system to require users to reauthenticate for privilege
escalation.
Based on the outcome of the audit procedure, use visudo -f <PATH TO FILE> to edit
the relevant sudoers file.
Remove any occurrences of !authenticate tags in the file(s).
References:
Page 555
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 556
4.3.6 Ensure sudo authentication timeout is configured correctly
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
sudo caches used credentials for a default of 15 minutes. This is for ease of use when
there are multiple administrative tasks to perform. The timeout can be modified to suit
local security policies.
This default is distribution specific. See audit section for further information.
Rationale:
Setting a timeout value reduces the window of opportunity for unauthorized privileged
access to another user.
Audit:
Ensure that the caching timeout is no more than 15 minutes.
Example:
# grep -roP "timestamp_timeout=\K[0-9]*" /etc/sudoers*
If there is no timestamp_timeout configured in /etc/sudoers* then the default is 15
minutes. This default can be checked with:
# sudo -V | grep "Authentication timestamp timeout:"
NOTE: A value of -1 means that the timeout is disabled. Depending on the
configuration of the timestamp_type, this could mean for all terminals / processes of that
user and not just that one single terminal session.
Page 557
Remediation:
If the currently configured timeout is larger than 15 minutes, edit the file listed in the
audit section with visudo -f <PATH TO FILE> 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 it's 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
References:
1. https://www.sudo.ws/man/1.9.0/sudoers.man.html
2. NIST SP 800-53 Rev. 5: AC-6
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 558
4.3.7 Ensure access to the su command is restricted (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The su command allows a user to run a command or shell as another user. The
program has been superseded by sudo, which allows for more granular control over
privileged access. Normally, the su command can be executed by any user. By
uncommenting the pam_wheel.so statement in /etc/pam.d/su, the su command will only
allow users in a specific groups to execute su. This group should be empty to reinforce
the use of sudo for privileged access.
Rationale:
Restricting the use of su , and using sudo in its place, provides system administrators
better control of the escalation of user privileges to execute privileged commands. The
sudo utility also provides a better logging and audit mechanism, as it can log each
command executed via sudo , whereas su can only record that a user executed the su
program.
Audit:
Run the following command:
# grep -Pi
'^\h*auth\h+(?:required|requisite)\h+pam_wheel\.so\h+(?:[^#\n\r]+\h+)?((?!\2)
(use_uid\b|group=\H+\b))\h+(?:[^#\n\r]+\h+)?((?!\1)(use_uid\b|group=\H+\b))(\
h+.*)?$' /etc/pam.d/su
Verify the output matches:
auth required pam_wheel.so use_uid group=<group_name>
Run the following command and verify that the group specified in <group_name> contains
no users:
# grep <group_name> /etc/group
Verify the output does not contain any users in the relevant group:
<group_name>:x:<GID>:
Page 559
Remediation:
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
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 560
4.4 Configure PAM
• As of this writing, the management of PAM via pam-auth-update does not offer all
the required functionality implemented by the benchmark. As such, the usage of
pam-auth-update is not recommended at present.
Page 561
4.4.1 Ensure password creation requirements are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The pam_pwquality.so module checks the strength of passwords. It performs checks
such as making sure a password is not a dictionary word, it is a certain length, contains
a mix of characters (e.g. alphabet, numeric, other) and more.
The following options are set in the /etc/security/pwquality.conf file:
• Password Length:
o - password must be 14 characters or more
minlen = 14
• Password complexity:
o minclass = 4 - The minimum number of required classes of characters for
the new password (digits, uppercase, lowercase, others)
OR
Rationale:
Strong passwords protect systems from being hacked through brute force methods.
Page 562
Audit:
Verify password creation requirements conform to organization policy.
Password length
Option 1
Run the following command:
# grep '^\s*minclass\s*' /etc/security/pwquality.conf
Verify the output matches:
minclass = 4
Option 2
Run the following command:
# grep -E '^\s*[duol]credit\s*' /etc/security/pwquality.conf
Verify the output matches:
dcredit = -1
ucredit = -1
lcredit = -1
ocredit = -1
pam_pwquality.so enabled
Page 563
Remediation:
The following setting is a recommend example policy. Alter these values to conform to
your own organization's password policies.
Run the following command to install the pam_pwquality module:
# apt install libpam-pwquality
Edit the file /etc/security/pwquality.conf and add or modify the following line for
password length to conform to site policy:
minlen = 14
Edit the file /etc/security/pwquality.conf and add or modify the following line for
password complexity to conform to site policy:
Option 1
minclass = 4
Option 2
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
Edit the /etc/pam.d/common-password file to include pam_pwquality.so and to conform
to site policy:
password requisite pam_pwquality.so retry=3
References:
Additional Information:
Additional module options may be set, recommendation requirements only cover
including try_first_pass and minlen set to 14 or more.
NOTE: As of this writing it is not possible to customize the maximum number of retries
for the creation of a password within recommended methods. The command pam-auth-
update is used to manage certain PAM configurations via profiles, such as
/etc/pam.d/common-password. Making a manual change to this file will cause pam-auth-
update to overwrite it on the next run and is thus against recommendations.
Alternatively, pam_pwquality (via /etc/security/pwquality.conf) fully supports the
configuration of the maximum number of retries for a password change with the
configuration entry retry = XXX. The issue is that the template /usr/share/pam-
configs/pwquality contains retry=3 which will override any retry setting in
/etc/security/pwquality.conf as PAM entries takes precedence. This template file
should not be modified as any package update will overwrite the change. Thus it is not
possible, in any recommended way, to modify password retries.
Page 564
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003
Page 565
4.4.2 Ensure lockout for failed password attempts is configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Lock out users after n unsuccessful consecutive login attempts. The first sets of
changes are made to the PAM configuration files. The second set of changes are
applied to the program specific PAM configuration file. The second set of changes must
be applied to each program that will lock out users. Check the documentation for each
secondary program for instructions on how to configure them to work with PAM.
• deny=n - n represents the number of failed attempts before the account is locked
• unlock_time=n - n represents the number of seconds before the account is
unlocked
• audit - Will log the user name into the system log if the user is not found.
• silent - Don't print informative messages. Set the lockout number and unlock time
in accordance with local site policy.
Rationale:
Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute
force password attacks against your systems.
Page 566
Audit:
Verify password lockouts are configured. These settings are commonly configured with
the pam_tally2.so modules found in /etc/pam.d/common-auth:
Run the following command to verify that pam_tally2.so includes deny= exists and is set
to 5 or less in /etc/pam.d/common-auth:
# grep 'pam_tally2' /etc/pam.d/common-auth
Example output:
auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900
Run the following command to verify the pam_deny.so module and pam_tally2.so
modules are included in /etc/pam.d/common-account:
# grep -E 'pam_(tally2|deny)\.so' /etc/pam.d/common-account
Remediation:
Edit the /etc/pam.d/common-auth file and add the auth line below:
auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900
Edit the /etc/pam.d/common-account file and add the account lines bellow:
account requisite pam_deny.so
account required pam_tally2.so
References:
Additional Information:
• Add pam_tally2 to the account section account required pam_tally2.so for the
counter to reset to 0 when using sudo
• Use of the "audit" keyword may log credentials in the case of user error during
authentication. This risk should be evaluated in the context of the site policies of
your organization.
• If a user has been locked out because they have reached the maximum
consecutive failure count defined by deny= in the pam_tally2.so module, the user
can be unlocked by issuing the command /sbin/pam_tally2 -u <username> --
reset. This command sets the failed count to 0, effectively unlocking the user.
Page 567
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1110, T1110.001,
TA0006 M1027
T1110.003
Page 568
4.4.3 Ensure password reuse is limited (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/security/opasswd file stores the users' old passwords and can be checked to
ensure that users are not recycling recent passwords.
Rationale:
Forcing users not to reuse their past 5 passwords make it less likely that an attacker will
be able to guess the password.
Audit:
Run the following command to verify the following in /etc/pam.d/common-password:
# grep -P --
'^\h*password\h+([^#\n\r]+\h+)?(pam_pwhistory\.so|pam_unix\.so)\b'
/etc/pam.d/common-password
Page 569
Remediation:
NOTE: Pay special attention to the configuration. Incorrect configuration can cause
system lock outs or unexpected behavior. This is example configuration. You
configuration may differ based on previous changes to the files.
Edit the /etc/pam.d/common-password file to include:
Example:
password required pam_pwhistory.so remember=5
password [success=1 default=ignore] pam_unix.so obscure
sha512 use_authtok
References:
1. https://manpages.ubuntu.com/manpages/focal/man8/pam_pwhistory.8.html
2. https://bugs.launchpad.net/ubuntu/+source/pam/+bug/1989731
3. NIST SP 800-53 Rev. 5: AC-2, IA-5
Additional Information:
Changes only apply to accounts configured on the local system.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 570
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
TA0005 M1028
T1078.004, T1110,
T1110.004
Page 571
4.4.4 Ensure strong password hashing algorithm is configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Hash functions behave as one-way functions by using mathematical operations that are
extremely difficult and cumbersome to revert
When a user is created, the password is run through a one-way hashing algorithm
before being stored. When the user logs in, the password sent is run through the same
one-way hashing algorithm and compared to the hash connected with the provided
username. If the hashed password and the stored hash match, the login is valid.
Rationale:
The SHA512 hashing algorithm provides stronger hashing than previous available
algorithms like MD5, thus providing additional protection to the system by increasing the
level of effort for an attacker to successfully determine passwords.
Audit:
Run the following command to verify that pam_unix.so includes sha512 in
/etc/pam.d/common-password:
# grep -Pi --
'^\h*password\h+[^#\n\r]+\h+pam_unix.so([^#\n\r]+\h+)?(sha512|yescrypt)\b'
/etc/pam.d/common-password
Example Output
password [success=1 default=ignore] pam_unix.so obscure sha512
use_authtok
Run the following command to verify that ENCRYPT_METHOD is set to SHA512 in
/etc/login.defs:
Page 572
Remediation:
Note:
Edit the /etc/pam.d/common-password file and ensure that sha512 is included and the
pam_unix.so success line:
Example:
password [success=1 default=ignore] pam_unix.so obscure sha512
use_authtok
Edit /etc/login.defs and ensure that ENCRYPT_METHOD is set to SHA512.
ENCRYPT_METHOD SHA512
Default Value:
sha512
References:
Additional Information:
Additional module options may be set, recommendation only covers those listed here.
yescrypt has been included in the audit commands. This hashing algorithm is not
currently supported, but it will be acceptable as an alternative to sha512 if future updates
enable its support.
Page 573
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 574
4.4.5 Ensure all current passwords uses the configured hashing
algorithm (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Currently used passwords with out of date hashing algorithms may pose a security risk
to the system.
Rationale:
In use passwords should always match the configured hashing algorithm for the system.
Impact:
If the administrator forces a password change, this could cause a large spike in CPU
usage if a large number of users change their password during the same time.
Audit:
Run the following script to get a list of users that are not using the currently configured
hashing algorithm:
#!/usr/bin/env bash
{
declare -A HASH_MAP=( ["y"]="yescrypt" ["1"]="md5" ["2"]="blowfish"
["5"]="SHA256" ["6"]="SHA512" ["g"]="gost-yescrypt" )
CONFIGURED_HASH=$(sed -n "s/^\s*ENCRYPT_METHOD\s*\(.*\)\s*$/\1/p"
/etc/login.defs)
Page 575
Remediation:
If the administrator wishes to force an immediate change on all users as per the output
of the audit, execute:
#!/usr/bin/env bash
{
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
awk -F: -v UID_MIN="${UID_MIN}" '( $3 >= UID_MIN && $1 != "nfsnobody" ) {
print $1 }' /etc/passwd | xargs -n 1 chage -d 0
}
NOTE: This could cause significant temporary CPU load on the system if a large
number of users reset their passwords at the same time.
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 576
4.5 User Accounts and Environment
This section provides guidance on setting up secure defaults for system and user
accounts and their environment.
Page 577
4.5.1 Set Shadow Password Suite Parameters
While a majority of the password control parameters have been moved to PAM, some
parameters are still available through the shadow password suite. Any changes made to
/etc/login.defs will only be applied if the usermod command is used. If user IDs are
added a different way, use the chage command to effect changes to individual user IDs.
Page 578
4.5.1.1 Ensure minimum days between password changes is
configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The PASS_MIN_DAYS parameter in /etc/login.defs allows an administrator to prevent
users from changing their password until a minimum number of days have passed since
the last time the user changed their password. It is recommended that PASS_MIN_DAYS
parameter be set to 1 or more days.
Rationale:
By restricting the frequency of password changes, an administrator can prevent users
from repeatedly changing their password in an attempt to circumvent password reuse
controls.
Audit:
Run the following command and verify PASS_MIN_DAYS conforms to site policy (no less
than 1 day):
# grep PASS_MIN_DAYS /etc/login.defs
PASS_MIN_DAYS 1
Run the following command and Review list of users and PAS_MIN_DAYS to Verify that
all users' PAS_MIN_DAYS conforms to site policy (no less than 1 day):
# awk -F : '(/^[^:]+:[^!*]/ && $4 < 1){print $1 " " $4}' /etc/shadow
Remediation:
Set the PASS_MIN_DAYS parameter to 1 in /etc/login.defs:
PASS_MIN_DAYS 1
Modify user parameters for all users with a password set to match:
# chage --mindays 1 <user>
Default Value:
PASS_MIN_DAYS 0
Page 579
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 580
4.5.1.2 Ensure password expiration is 365 days or less
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The PASS_MAX_DAYS parameter in /etc/login.defs allows an administrator to force
passwords to expire once they reach a defined age.
Rationale:
The window of opportunity for an attacker to leverage compromised credentials or
successfully compromise credentials via an online brute force attack is limited by the
age of the password. Therefore, reducing the maximum age of a password also reduces
an attacker's window of opportunity. It is recommended that the PASS_MAX_DAYS
parameter does not exceed 365 days and is greater than the value of PASS_MIN_DAYS.
Audit:
Run the following command and verify PASS_MAX_DAYS conforms to site policy, does not
exceed 365 days, and is greater than PASS_MIN_DAYS:
# grep PASS_MAX_DAYS /etc/login.defs
PASS_MAX_DAYS 365
Run the following command and Review list of users and PASS_MAX_DAYS to verify that all
users' PASS_MAX_DAYS conforms to site policy, does not exceed 365 days, and is no less
than PASS_MIN_DAYS
# awk -F: '(/^[^:]+:[^!*]/ && ($5>365 || $5~/([0-1]|-1|\s*)/)){print $1 " "
$5}' /etc/shadow
Remediation:
Set the PASS_MAX_DAYS parameter to conform to site policy in /etc/login.defs :
PASS_MAX_DAYS 365
Modify user parameters for all users with a password set to match:
# chage --maxdays 365 <user>
Default Value:
PASS_MAX_DAYS 99999
Page 581
References:
1. https://www.cisecurity.org/white-papers/cis-password-policy-guide/
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Additional Information:
A value of -1 will disable password expiration
The password expiration must be greater than the minimum days between
password changes or users will be unable to change their password
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 582
4.5.1.3 Ensure password expiration warning days is 7 or more
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The PASS_WARN_AGE parameter in /etc/login.defs allows an administrator to notify
users that their password will expire in a defined number of days. It is recommended
that the PASS_WARN_AGE parameter be set to 7 or more days.
Rationale:
Providing an advance warning that a password will be expiring gives users time to think
of a secure password. Users caught unaware may choose a simple password or write it
down where it may be discovered.
Audit:
Run the following command and verify PASS_WARN_AGE conforms to site policy (No less
than 7 days):
# grep PASS_WARN_AGE /etc/login.defs
PASS_WARN_AGE 7
Verify all users with a password have their number of days of warning before password
expires set to 7 or more:
Run the following command and Review list of users and PASS_WARN_AGE to verify that all
users' PASS_WARN_AGE conforms to site policy (No less than 7 days):
# awk -F: '(/^[^:]+:[^!*]/ && $6<7){print $1 " " $6}' /etc/shadow
Remediation:
Set the PASS_WARN_AGE parameter to 7 in /etc/login.defs:
PASS_WARN_AGE 7
Modify user parameters for all users with a password set to match:
# chage --warndays 7 <user>
Default Value:
PASS_WARN_AGE 7
Page 583
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 584
4.5.1.4 Ensure inactive password lock is 30 days or less
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
User accounts that have been inactive for over a given period of time can be
automatically disabled. It is recommended that accounts that are inactive for 30 days
after password expiration be disabled.
Rationale:
Inactive accounts pose a threat to system security since the users are not logging in to
notice failed login attempts or other anomalies.
Audit:
Run the following command and verify INACTIVE conforms to site policy (no more than
30 days):
# useradd -D | grep INACTIVE
INACTIVE=30
Verify all users with a password have Password inactive no more than 30 days after
password expires:
Run the following command and Review list of users and INACTIVE to verify that all
users' INACTIVE conforms to site policy (no more than 30 days):
# awk -F: '(/^[^:]+:[^!*]/ && ($7~/(\s*|-1)/ || $7>30)){print $1 " " $7}'
/etc/shadow
Remediation:
Run the following command to set the default password inactivity period to 30 days:
# useradd -D -f 30
Modify user parameters for all users with a password set to match:
# chage --inactive 30 <user>
Default Value:
INACTIVE=-1
Page 585
Additional Information:
A value of -1 would disable this setting
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.002,
TA0001 M1027
T1078.003
Page 586
4.5.1.5 Ensure all users last password change date is in the past
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
All users should have a password change date in the past.
Rationale:
If a users recorded password change date is in the future then they could bypass any
set password expiration.
Audit:
Run the following script to verify all users last password change was in the past:
#!/usr/bin/env bash
{
l_output2=""
while read -r l_user; do
l_change="$(chage --list $l_user | awk -F: '($1 ~
/^\s*Last\s+password\s+change/ && $2 !~ /never/){print $2}' | xargs)"
if [[ "$(date -d "$l_change" +%s)" -gt "$(date +%s)" ]]; then
l_output2="$l_output2\n - User: \"$l_user\" last password change is
in the future \"$l_change\""
fi
done < <(awk -F: '($2 ~ /^[^*!xX\n\r][^\n\r]+/){print $1}' /etc/shadow)
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - All user password changes
are in the past \n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit
failure * :$l_output2\n"
fi
}
Remediation:
Investigate any users with a password change date in the future and correct them.
Locking the account, expiring the password, or resetting the password manually may be
appropriate.
References:
Page 587
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
T1078.002, T1078.003,
T1078.004, T1110, TA0006 M1027
T1110.001, T1110.002,
T1110.003, T1110.004
Page 588
4.5.1.6 Ensure the number of changed characters in a new
password is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The pwquality difok option sets the number of characters in a password that must not
be present in the old password.
Rationale:
Use of a complex password helps to increase the time and resources required to
compromise the password. Password complexity, or strength, is a measure of the
effectiveness of a password in resisting attempts at guessing and brute-force attacks.
Password complexity is one factor of several that determines how long it takes to crack
a password. The more complex the password, the greater the number of possible
combinations that need to be tested before the password is compromised.
Audit:
Run the following command to verify that the difok option in
/etc/security/pwquality.conf is set to 2 or more:
# grep -P '^\h*difok\h*=\h*([2-9]|[1-9][0-9]+)\b'
/etc/security/pwquality.conf
difok = 2
Remediation:
Edit or add the following line in /etc/security/pwquality.conf to a value of 2 or more:
difok = 2
Default Value:
difok = 1
References:
Page 589
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 590
4.5.1.7 Ensure preventing the use of dictionary words for
passwords is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The pwquality dictcheck option sets whether to check for the words from the cracklib
dictionary.
Rationale:
If the operating system allows the user to select passwords based on dictionary words,
this increases the chances of password compromise by increasing the opportunity for
successful guesses, and brute-force attacks.
Audit:
Run the following command to verify that the dictcheck option in
/etc/security/pwquality.conf is not set to 0:
dictcheck = 1
Remediation:
Edit or add the following line in /etc/security/pwquality.conf to a value of 1:
dictcheck = 1
Default Value:
dictcheck = 1
References:
Page 591
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 592
4.5.2 Ensure system accounts are secured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
There are a number of accounts provided with most distributions that are used to
manage applications and are not intended to provide an interactive shell.
Rationale:
It is important to make sure that accounts that are not being used by regular users are
prevented from being used to provide an interactive shell. By default, most distributions
set the password field for these accounts to an invalid string, but it is also recommended
that the shell field in the password file be set to the nologin shell. This prevents the
account from potentially being used to run any commands.
Page 593
Audit:
Run the following script to verify all local system accounts:
#!/usr/bin/env bash
{
l_output="" l_output2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed
-rn '/^\//{s,/,\\\\/,g;p}' | paste -s -d '|' - ))$"
a_users=(); a_ulock=() # initialize arrays
while read -r l_user; do # Populate array with system accounts that have a
valid login shell
a_users+=("$l_user")
done < <(awk -v pat="$l_valid_shells" -F:
'($1!~/(root|sync|shutdown|halt|^\+)/ && $3<'"$(awk '/^\s*UID_MIN/{print $2}'
/etc/login.defs)"' && $(NF) ~ pat) { print $1 }' /etc/passwd)
while read -r l_ulock; do # Populate array with system accounts that
aren't locked
a_ulock+=("$l_ulock")
done < <(awk -v pat="$l_valid_shells" -F: '($1!~/(root|^\+)/ && $2!~/LK?/
&& $3<'"$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)"' && $(NF) ~ pat) {
print $1 }' /etc/passwd)
if ! (( ${#a_users[@]} > 0 )); then
l_output="$l_output\n - local system accounts login is disabled"
else
l_output2="$l_output2\n - There are \"$(printf '%s'
"${#a_users[@]}")\" system accounts with login enabled\n - List of
accounts:\n$(printf '%s\n' "${a_users[@]:0:$l_limit}")\n - end of list\n"
fi
if ! (( ${#a_ulock[@]} > 0 )); then
l_output="$l_output\n - local system accounts are locked"
else
l_output2="$l_output2\n - There are \"$(printf '%s'
"${#a_ulock[@]}")\" system accounts that are not locked\n - List of
accounts:\n$(printf '%s\n' "${a_ulock[@]:0:$l_limit}")\n - end of list\n"
fi
unset a_users; unset a_ulock # Remove arrays
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured *
:\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit
failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "- * Correctly configured *
:\n$l_output\n"
fi
}
Page 594
Note:
• The root, sync, shutdown, and halt users are exempted from requiring a non-
login shell
• root is exempt from being locked
Remediation:
Set the shell for any accounts returned by the audit to nologin:
# usermod -s $(which nologin) <user>
Lock any non root accounts returned by the audit:
# usermod -L <user>
The following script will:
• Set the shell for any accounts returned by the audit to nologin
• Lock any non root system accounts returned by the audit:
#!/usr/bin/env bash
{
l_output="" l_output2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed
-rn '/^\//{s,/,\\\\/,g;p}' | paste -s -d '|' - ))$"
a_users=(); a_ulock=() # initialize arrays
while read -r l_user; do # change system accounts that have a valid login
shell to nolog shell
echo -e " - System account \"$l_user\" has a valid logon shell,
changing shell to \"$(which nologin)\""
usermod -s "$(which nologin)" "$l_user"
done < <(awk -v pat="$l_valid_shells" -F:
'($1!~/(root|sync|shutdown|halt|^\+)/ && $3<'"$(awk '/^\s*UID_MIN/{print $2}'
/etc/login.defs)"' && $(NF) ~ pat) { print $1 }' /etc/passwd)
while read -r l_ulock; do # Lock system accounts that aren't locked
echo -e " - System account \"$l_ulock\" is not locked, locking account"
usermod -L "$l_ulock"
done < <(awk -v pat="$l_valid_shells" -F: '($1!~/(root|^\+)/ && $2!~/LK?/
&& $3<'"$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)"' && $(NF) ~ pat) {
print $1 }' /etc/passwd)
}
References:
Page 595
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1026
T1078.003
Page 596
4.5.3 Ensure default group for the root account is GID 0
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The usermod command can be used to specify which group the root user belongs to.
This affects permissions of files that are created by the root user.
Rationale:
Using GID 0 for the root account helps prevent root -owned files from accidentally
becoming accessible to non-privileged users.
Audit:
Run the following command and verify the result is 0 :
# grep "^root:" /etc/passwd | cut -f4 -d:
0
Remediation:
Run the following command to set the root user default group to GID 0 :
# usermod -g 0 root
References:
Page 597
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 598
4.5.4 Ensure default user umask is 027 or more restrictive
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The user file-creation mode mask (umask) is use to determine the file permission for
newly created directories and files. In Linux, the default permissions for any newly
created directory is 0777 (rwxrwxrwx), and for any newly created file it is 0666 (rw-rw-
rw-). The umask modifies the default Linux permissions by restricting (masking) these
permissions. The umask is not simply subtracted, but is processed bitwise. Bits set in the
umask are cleared in the resulting file mode.
• Octal (Numeric) Value - Represented by either three or four digits. ie umask 0027
or umask 027. If a four digit umask is used, the first digit is ignored. The remaining
three digits effect the resulting permissions for user, group, and world/other
respectively.
• Symbolic Value - Represented by a comma separated list for User u, group g,
and world/other o. The permissions listed are not masked by umask. ie a umask
set by umask u=rwx,g=rx,o= is the Symbolic equivalent of the Octal umask 027.
This umask would set a newly created directory with file mode drwxr-x--- and a
newly created file with file mode rw-r-----.
• pam_umask module:
o will set the umask according to the system default in /etc/login.defs and
user settings, solving the problem of different umask settings with different
shells, display managers, remote sessions etc.
o umask=<mask> value in the /etc/login.defs file is interpreted as Octal
o Setting USERGROUPS_ENAB to yes in /etc/login.defs (default):
▪ will enable setting of the umask group bits to be the same as owner
bits. (examples: 022 -> 002, 077 -> 007) for non-root users, if the
uid is the same as gid, and username is the same as the primary
group name
▪ userdel will remove the user's group if it contains no more
members, and useradd will create by default a group with the name
of the user
Page 599
• System Wide Shell Configuration File:
o /etc/profile - used to set system wide environmental variables on users
shells. The variables are sometimes the same ones that are in the
.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
o /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.
o /etc/bash.bashrc - System wide version of .bashrc. 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/bash.bashrc
Rationale:
Setting a very secure default value for umask ensures that users make a conscious
choice about their file permissions. A default umask setting of 077 causes files and
directories created by users to not be readable by any other user on the system. A
umask of 027 would make files and directories readable by users in the same Unix group,
while a umask of 022 would make files readable by every user on the system.
Impact:
Setting USERGROUPS_ENAB no in /etc/login.defs may change the expected behavior of
useradd and userdel.
Page 600
Audit:
Run the following to verify:
Run the following script to verify that a default user umask is set enforcing a newly
created directories's permissions to be 750 (drwxr-x---), and a newly created file's
permissions be 640 (rw-r-----), or more restrictive:
#!/bin/bash
passing=""
grep -Eiq '^\s*UMASK\s+(0[0-7][2-7]7|[0-7][2-7]7)\b' /etc/login.defs && grep
-Eqi '^\s*USERGROUPS_ENAB\s*"?no"?\b' /etc/login.defs && grep -Eq
'^\s*session\s+(optional|requisite|required)\s+pam_umask\.so\b'
/etc/pam.d/common-session && passing=true
grep -REiq '^\s*UMASK\s+\s*(0[0-7][2-7]7|[0-7][2-
7]7|u=(r?|w?|x?)(r?|w?|x?)(r?|w?|x?),g=(r?x?|x?r?),o=)\b' /etc/profile*
/etc/bash.bashrc* && passing=true
[ "$passing" = true ] && echo "Default user umask is set"
Verify output is: "Default user umask is set"
Run the following to verify that no less restrictive system wide umask is set:
# 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/bash.bashrc*
Page 601
Remediation:
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/bash.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 /etc/pam.d/common-session and add or edit the following:
session optional pam_umask.so
OR
Configure umask in one of the following files:
Example: /etc/profile.d/set_umask.sh
umask 027
Note: this method only applies to bash and shell. If other shells are supported on the
system, it is recommended that their configuration files also are checked.
Default Value:
UMASK 022
References:
1. pam_umask(8)
2. NIST SP 800-53 Rev. 5: AC-3, MP-2
Page 602
Additional Information:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 603
4.5.5 Ensure default user shell timeout is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
TMOUT is an environmental setting that determines the timeout of a shell in seconds.
Rationale:
Setting a timeout value reduces the window of opportunity for unauthorized user access
to another user's shell session that has been left unattended. It also ends the inactive
session and releases the resources associated with that session.
Page 604
Audit:
Run the following script to verify TMOUT is configured:
Page 605
#!/usr/bin/env bash
{
l_output="" l_output2=""
l_tmv_max="900"
l_searchloc="/etc/bashrc /etc/bash.bashrc /etc/profile /etc/profile.d/*.sh"
a_tmofile=()
while read -r l_file; do
[ -e "$l_file" ] && a_tmofile+=("$(readlink -f $l_file)")
done < <(grep -PRils '^\h*([^#\n\r]+\h+)?TMOUT=\d+\b' $l_searchloc)
if ! (( ${#a_tmofile[@]} > 0 )); then
l_output2="$l_output2\n - TMOUT is not set"
elif (( ${#a_tmofile[@]} > 1 )); then
l_output2="$l_output2\n - TMOUT is set in multiple locations.\n - List of files where
TMOUT is set:\n$(printf '%s\n' "${a_tmofile[@]}")\n - end of list\n"
else
for l_file in ${a_tmofile[@]}; do
if (( "$(grep -Pci '^\h*([^#\n\r]+\h+)?TMOUT=\d+' "$l_file")" > 1 )); then
l_output2="$l_output2\n - TMOUT is set multiple times in \"$l_file\""
else
l_tmv="$(grep -Pi '^\h*([^#\n\r]+\h+)?TMOUT=\d+' "$l_file" | grep -Po '\d+')"
if (( "$l_tmv" > "$l_tmv_max" )); then
l_output2="$l_output\n - TMOUT is \"$l_tmv\" in \"$l_file\"\n - Should be
\"$l_tmv_max\" or less and not \"0\""
else
l_output="$l_output\n- TMOUT is correctly set to \"$l_tmv\" in \"$l_file\""
if grep -Piq '^\h*([^#\n\r]+\h+)?readonly\h+TMOUT\b' "$l_file"; then
l_output="$l_output\n- TMOUT is correctly set to \"readonly\" in \"$l_file\""
else
l_output2="$l_output2\n- TMOUT is not set to \"readonly\""
fi
if grep -Piq '^(\h*|\h*[^#\n\r]+\h*;\h*)export\h+TMOUT\b' "$l_file"; then
l_output="$l_output\n- TMOUT is correctly set to \"export\" in \"$l_file\""
else
l_output2="$l_output2\n- TMOUT is not set to \"export\""
fi
fi
fi
done
fi
unset a_tmofile # Remove array
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "- * Correctly configured * :\n$l_output\n"
fi
}
Page 606
Remediation:
Review /etc/bash.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:
• Be configured once, as multiple lines, or a single line, in one and only one of the
following locations:
o A file in the /etc/profile.d/ directory ending in .sh
o /etc/profile
o /etc/bash.bashrc
• Not exceed 900
• Not be equal to 0
References:
Additional Information:
The audit and remediation in this recommendation apply to bash and shell. If other
shells are supported on the system, it is recommended that their configuration files are
also checked
Other methods of setting a timeout exist not covered here
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 607
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1026
T1078.002, T1078.003
Page 608
4.5.6 Ensure nologin is not listed in /etc/shells (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
/etc/shells is a text file which contains the full pathnames of valid login shells. This file
is consulted by chsh and available to be queried by other programs.
Be aware that there are programs which consult this file to find out if a user is a normal
user; for example, FTP daemons traditionally disallow access to users with shells not
included in this file.
Rationale:
A user can use chsh to change their configured shell.
If a user has a shell configured that isn't in in /etc/shells, then the system assumes
that they're somehow restricted. In the case of chsh it means that the user cannot
change that value.
Other programs might query that list and apply similar restrictions.
By putting nologin in /etc/shells, any user that has nologin as its shell is considered
a full, unrestricted user. This is not the expected behavior for nologin.
Audit:
Run the following command to verify that nologin is not listed in the /etc/shells file:
# grep '/nologin\b' /etc/shells
Nothing should be returned
Remediation:
Edit /etc/shells and remove any lines that include nologin
References:
1. shells(5)
2. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5
Page 609
4.5.7 Ensure maximum number of same consecutive characters
in a password is configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The pwquality maxrepeat option sets the maximum number of allowed same
consecutive characters in a new password.
Rationale:
Use of a complex password helps to increase the time and resources required to
compromise the password. Password complexity, or strength, is a measure of the
effectiveness of a password in resisting attempts at guessing and brute-force attacks.
Password complexity is one factor of several that determines how long it takes to crack
a password. The more complex the password, the greater the number of possible
combinations that need to be tested before the password is compromised.
Audit:
Run the following command to verify that the maxrepeat option in
/etc/security/pwquality.conf is set to 3 or less, and not 0:
maxrepeat = 3
Note: The check is disabled if the value is 0
Remediation:
Edit or add the following line in /etc/security/pwquality.conf to a value of 3 or less
and not 0:
maxrepeat = 3
Default Value:
maxrepeat = 0
References:
Page 610
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 611
5 Logging and Auditing
The items in this section describe how to configure logging, log monitoring, and
auditing, using tools included in most distributions.
It is recommended that rsyslog be used for logging (with logwatch providing
summarization) and auditd be used for auditing (with aureport providing
summarization) to automatically monitor logs for intrusion attempts and other suspicious
system behavior.
In addition to the local log files created by the steps in this section, it is also
recommended that sites collect copies of their system logs on a secure, centralized log
server via an encrypted connection. Not only does centralized logging help sites
correlate events that may be occurring on multiple systems, but having a second copy
of the system log information may be critical after a system compromise where the
attacker has modified the local log files on the affected system(s). If a log correlation
system is deployed, configure it to process the logs described in this section.
Because it is often necessary to correlate log information from many different systems
(particularly after a security incident) it is recommended that the time be synchronized
among systems and devices connected to the local network.
It is important that all logs described in this section be monitored on a regular basis and
correlated to determine trends. A seemingly innocuous entry in one log could be more
significant when compared to an entry in another log.
Note on log file permissions: There really isn't a "one size fits all" solution to the
permissions on log files. Many sites utilize group permissions so that administrators who
are in a defined security group, such as "wheel" do not have to elevate privileges to root
in order to read log files. Also, if a third party log aggregation tool is used, it may need to
have group permissions to read the log files, which is preferable to having it run setuid
to root. Therefore, there are two remediation and audit steps for log file permissions.
One is for systems that do not have a secured group method implemented that only
permits root to read the log files (root:root 600). The other is for sites that do have
such a setup and are designated as root:securegrp 640 where securegrp is the
defined security group (in some cases wheel).
Page 612
5.1 Configure Logging
• Ensure transport layer security is implemented between the client and the log
server.
• Ensure that logs are rotated as per the environment requirements.
• Ensure all locally generated logs have the appropriate permissions.
• Ensure all security logs are sent to a remote log server.
• Ensure the required events are logged.
What is covered
This section will cover the minimum best practices for the usage of either rsyslog or
journald. The recommendations are written such that each is wholly independent of
each other and only one is implemented.
Page 613
5.1.1 Configure journald
Page 614
5.1.1.1 Ensure journald is configured to send logs to a remote log
host
Page 615
5.1.1.1.1 Ensure systemd-journal-remote is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald (via systemd-journal-remote) supports the ability to send log events it gathers
to a remote log host or to receive messages from remote hosts, thus enabling
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.
Audit:
Run the following command to verify systemd-journal-remote is installed.
Run the following command:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
systemd-journal-remote
Remediation:
Run the following command to install systemd-journal-remote:
# apt install systemd-journal-remote
References:
Page 616
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 617
5.1.1.1.2 Ensure systemd-journal-remote is configured (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald (via systemd-journal-remote) supports the ability to send log events it gathers
to a remote log host or to receive messages from remote hosts, thus enabling
centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker
gains root access on the local system, they could tamper with or remove log data that is
stored on the local system.
Audit:
Verify systemd-journal-remote is configured.
Run the following command:
# grep -P "^ *URL=|^ *ServerKeyFile=|^ *ServerCertificateFile=|^
*TrustedCertificateFile=" /etc/systemd/journal-upload.conf
Verify the output matches per your environments certificate locations and the URL of
the log server. Example:
URL=192.168.50.42
ServerKeyFile=/etc/ssl/private/journal-upload.pem
ServerCertificateFile=/etc/ssl/certs/journal-upload.pem
TrustedCertificateFile=/etc/ssl/ca/trusted.pem
Remediation:
Edit the /etc/systemd/journal-upload.conf file and ensure the following lines are set
per your environment:
URL=192.168.50.42
ServerKeyFile=/etc/ssl/private/journal-upload.pem
ServerCertificateFile=/etc/ssl/certs/journal-upload.pem
TrustedCertificateFile=/etc/ssl/ca/trusted.pem
Restart the service:
# systemctl restart systemd-journal-upload
References:
Page 618
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 619
5.1.1.1.3 Ensure systemd-journal-remote is enabled (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald (via systemd-journal-remote) supports the ability to send log events it gathers
to a remote log host or to receive messages from remote hosts, thus enabling
centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker
gains root access on the local system, they could tamper with or remove log data that is
stored on the local system.
Audit:
Verify systemd-journal-remote is enabled.
Run the following command:
# systemctl is-enabled systemd-journal-upload.service
Verify the output matches:
enabled
Remediation:
Run the following command to enable systemd-journal-remote:
# systemctl --now enable systemd-journal-upload.service
References:
Page 620
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 621
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald supports the ability to receive messages from remote hosts, thus acting as a
log server. Clients should not receive data from other hosts.
Note:
Rationale:
If a client is configured to also receive data, thus turning it into a server, the client
system is acting outside it's operational boundary.
Audit:
Run the following command to verify systemd-journal-remote.socket is not enabled:
# systemctl is-enabled systemd-journal-remote.socket
Verify the output matches:
disabled
Remediation:
Run the following command to disable systemd-journal-remote.socket:
# systemctl --now disable systemd-journal-remote.socket
References:
Page 622
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 623
5.1.1.2 Ensure journald service is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Ensure that the systemd-journald service is enabled to allow capturing of logging
events.
Rationale:
If the systemd-journald service is not enabled to start on boot, the system will not
capture logging events.
Audit:
Run the following command to verify systemd-journald is enabled:
# systemctl is-enabled systemd-journald.service
Verify the output matches:
static
Remediation:
By default the systemd-journald service does not have an [Install] section and thus
cannot be enabled / disabled. It is meant to be referenced as Requires or Wants by other
unit files. As such, if the status of systemd-journald is not static, investigate why.
References:
Page 624
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 625
5.1.1.3 Ensure journald is configured to compress large log files
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The journald system includes the capability of compressing overly large files to avoid
filling up the system with logs or making the logs unmanageably large.
Rationale:
Uncompressed large files may unexpectedly fill a filesystem leading to resource
unavailability. Compressing logs prior to write can prevent sudden, unexpected
filesystem impacts.
Audit:
Run the following command to verify that large files will be compressed:
# grep -Psi '^\h*Compress\h*=\h*yes\b' /etc/systemd/journald.conf
/etc/systemd/journald.conf.d/*
Verify the output matches:
Compress=yes
Remediation:
Edit the /etc/systemd/journald.conf file or a file ending in .conf in
/etc/systemd/journald.conf.d/ and add the following line:
Compress=yes
Restart the service:
# systemctl restart systemd-journald
References:
Page 626
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.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 627
5.1.1.4 Ensure journald is configured to write logfiles to persistent
disk (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Data from journald may be stored in volatile memory or persisted locally on the server.
Logs in memory will be lost upon a system reboot. By persisting logs to local disk on the
server they are protected from loss due to a reboot.
Rationale:
Writing log data to disk will provide the ability to forensically reconstruct events which
may have impacted the operations or security of a system even after a system crash or
reboot.
Audit:
Run the following command to verify that logs are persisted to disk:
# grep -Psi '^\h*Storage\h*=\h*persistent\b' /etc/systemd/journald.conf
/etc/systemd/journald.conf.d/*
Verify the output matches:
Storage=persistent
Remediation:
Edit the /etc/systemd/journald.conf file or a file ending in .conf in
/etc/systemd/journald.conf.d/ and add the following line:
Storage=persistent
Restart the service:
# systemctl restart systemd-journald
References:
Page 628
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.
Note: a bug in systemd versions prior to v243 caused an error at the unmounting of
/var/log (and thus, /var) if Storage=persistent is set in /etc/systemd/journald.conf.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 629
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Data from journald should be kept in the confines of the service and not forwarded on
to other services.
Rationale:
IF journald is the method for capturing logs, all logs of the system should be handled by
journald and not forwarded to other logging mechanisms.
Audit:
IF journald is the method for capturing logs
Run the following command to verify that logs are not forwarded to rsyslog:
# grep -Psi '^\h*ForwardToSyslog\h*=\h*yes\b` /etc/systemd/journald.conf
/etc/systemd/journald.conf.d/*
Verify that there is no output.
Remediation:
Edit the /etc/systemd/journald.conf file and files in /etc/systemd/journald.conf.d/
and ensure that ForwardToSyslog=yes is removed.
Restart the service:
# systemctl restart systemd-journald
References:
Page 630
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 631
5.1.1.6 Ensure journald log rotation is configured per site policy
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald includes the capability of rotating log files regularly to avoid filling up the
system with logs or making the logs unmanageably large. The file
/etc/systemd/journald.conf is the configuration file used to specify how logs
generated by Journald should be rotated.
Rationale:
By keeping the log files smaller and more manageable, a system administrator can
easily archive these files to another system and spend less time looking through
inordinately large log files.
Audit:
Review /etc/systemd/journald.conf, and files in /etc/systemd/journald.conf.d/, and
verify logs are rotated according to site policy. The specific parameters for log rotation
are:
SystemMaxUse=
SystemKeepFree=
RuntimeMaxUse=
RuntimeKeepFree=
MaxFileSec=
Remediation:
Review /etc/systemd/journald.conf and verify logs are rotated according to site
policy. The settings should be carefully understood as there are specific edge cases
and prioritization of parameters.
The specific parameters for log rotation are:
SystemMaxUse=
SystemKeepFree=
RuntimeMaxUse=
RuntimeKeepFree=
MaxFileSec=
References:
Page 632
Additional Information:
See man 5 journald.conf for detailed information regarding the parameters in use.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 633
5.1.1.7 Ensure journald default file permissions configured
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Journald will create logfiles that do not already exist on the system. This setting controls
what permissions will be applied to these newly created files.
Rationale:
It is important to ensure that log files have the correct permissions to ensure that
sensitive data is archived and protected.
Audit:
First see if there is an override file /etc/tmpfiles.d/systemd.conf. If so, this file will
override all default settings as defined in /usr/lib/tmpfiles.d/systemd.conf and
should be inspected.
If there is no override file, inspect the default /usr/lib/tmpfiles.d/systemd.conf
against the site specific requirements.
Ensure that file permissions are 0640.
Should a site policy dictate less restrictive permissions, ensure to follow said policy.
NOTE: More restrictive permissions such as 0600 is implicitly sufficient.
Remediation:
If the default configuration is not appropriate for the site specific requirements, copy
/usr/lib/tmpfiles.d/systemd.conf to /etc/tmpfiles.d/systemd.conf and modify as
required. Requirements is either 0640 or site policy if that is less restrictive.
References:
Additional Information:
See man 5 tmpfiles.d for detailed information on the permission sets for the relevant
log files. Further information with examples can be found at
https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
Page 634
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 635
5.1.2 Configure rsyslog
The rsyslog software package may be used instead of the default journald logging
mechanism.
Note: This section only applies if rsyslog is the chosen method for client side logging.
Do not apply this section if journald is used.
Page 636
5.1.2.1 Ensure rsyslog is installed (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The rsyslog software is recommended in environments where journald does not meet
operation requirements.
Rationale:
The security enhancements of rsyslog such as connection-oriented (i.e. TCP)
transmission of logs, the option to log to database formats, and the encryption of log
data en route to a central logging server) justify installing and configuring the package.
Audit:
Run the following command to verify rsyslog is installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
rsyslog
Remediation:
Run the following command to install rsyslog:
# apt install rsyslog
References:
Page 637
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 638
5.1.2.2 Ensure rsyslog service is enabled (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Once the rsyslog package is installed, ensure that the service is enabled.
Rationale:
If the rsyslog service is not enabled to start on boot, the system will not capture logging
events.
Audit:
Run the following command to verify rsyslog is enabled:
# systemctl is-enabled rsyslog
Verify the output matches:
enabled
Remediation:
Run the following command to enable rsyslog:
# systemctl --now enable rsyslog
References:
Page 639
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 640
5.1.2.3 Ensure journald is configured to send logs to rsyslog
(Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Data from journald may be stored in volatile memory or persisted locally on the server.
Utilities exist to accept remote export of journald logs, however, use of the RSyslog
service provides a consistent means of log collection and export.
Rationale:
IF RSyslog is the preferred method for capturing logs, all logs of the system should be
sent to it for further processing.
Audit:
IF RSyslog is the preferred method for capturing logs
Review /etc/systemd/journald.conf and verify that logs are forwarded to rsyslog.
# grep ^\s*ForwardToSyslog /etc/systemd/journald.conf
Verify the output matches:
ForwardToSyslog=yes
Remediation:
Edit the /etc/systemd/journald.conf file and add the following line:
ForwardToSyslog=yes
Restart the service:
# systemctl restart rsyslog
References:
Page 641
Additional Information:
As noted in the journald man pages, journald logs may be exported to rsyslog either
through the process mentioned here, or through a facility like systemd-
journald.service. There are trade-offs involved in each implementation, where
ForwardToSyslog will immediately capture all events (and forward to an external log
server, if properly configured), but may not capture all boot-up activities. Mechanisms
such as systemd-journald.service, on the other hand, will record bootup events, but
may delay sending the information to rsyslog, leading to the potential for log
manipulation prior to export. Be aware of the limitations of all tools employed to secure
a system.
The main configuration file /etc/systemd/journald.conf is read before any of the
custom *.conf files. If there are custom configurations present, they override the main
configuration parameters
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 642
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 643
5.1.2.4 Ensure rsyslog default file permissions are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
RSyslog will create logfiles that do not already exist on the system. This setting controls
what permissions will be applied to these newly created files.
Rationale:
It is important to ensure that log files have the correct permissions to ensure that
sensitive data is archived and protected.
Impact:
The systems global umask could override, but only making the file permissions stricter,
what is configured in RSyslog with the FileCreateMode directive. RSyslog also has it's
own $umask directive that can alter the intended file creation mode. In addition,
consideration should be given to how FileCreateMode is used.
Thus it is critical to ensure that the intended file creation mode is not overridden with
less restrictive settings in /etc/rsyslog.conf, /etc/rsyslog.d/*conf files and that
FileCreateMode is set before any file is created.
Audit:
Run the following command:
# grep ^\$FileCreateMode /etc/rsyslog.conf /etc/rsyslog.d/*.conf
Verify the output matches:
$FileCreateMode 0640
Should a site policy dictate less restrictive permissions, ensure to follow said policy.
NOTE: More restrictive permissions such as 0600 is implicitly sufficient.
Page 644
Remediation:
Edit either /etc/rsyslog.conf or a dedicated .conf file in /etc/rsyslog.d/ and set
$FileCreateMode to 0640 or more restrictive:
$FileCreateMode 0640
Restart the service:
# systemctl restart rsyslog
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 645
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 646
5.1.2.5 Ensure logging is configured (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files specifies rules for logging and
which files are to be used to log certain classes of messages.
Rationale:
A great deal of important security-related information is sent via rsyslog (e.g.,
successful and failed su attempts, failed login attempts, root login attempts, etc.).
Audit:
Review the contents of /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files to ensure
appropriate logging is set. In addition, run the following command and verify that the log
files are logging information as expected:
# ls -l /var/log/
Page 647
Remediation:
Edit the following lines in the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files as
appropriate for your environment.
NOTE: The below configuration is shown for example purposes only. Due care should
be given to how the organization wish to store log data.
*.emerg :omusrmsg:*
auth,authpriv.* /var/log/secure
mail.* -/var/log/mail
mail.info -/var/log/mail.info
mail.warning -/var/log/mail.warn
mail.err /var/log/mail.err
cron.* /var/log/cron
*.=warning;*.=err -/var/log/warn
*.crit /var/log/warn
*.*;mail.none;news.none -/var/log/messages
local0,local1.* -/var/log/localmessages
local2,local3.* -/var/log/localmessages
local4,local5.* -/var/log/localmessages
local6,local7.* -/var/log/localmessages
Run the following command to reload the rsyslogd configuration:
# systemctl restart rsyslog
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 648
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 649
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host (Manual)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
RSyslog supports the ability to send log events it gathers to a remote log host or to
receive messages from remote hosts, thus enabling 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.
Audit:
Review the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and verify that logs are
sent to a central host (where loghost.example.com is the name of your central log host):
Old format
# grep -E '^\s*([^#]+\s+)?action\(([^#]+\s+)?\btarget=\"?[^#"]+\"?\b'
/etc/rsyslog.conf /etc/rsyslog.d/*.conf
Output should include target=<FQDN or IP of remote loghost>, for example:
*.* action(type="omfwd" target="loghost.example.com" port="514"
protocol="tcp"
Page 650
Remediation:
Edit the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and add the following line
(where loghost.example.com is the name of your central log host). The target directive
may either be a fully qualified domain name or an IP address.
*.* action(type="omfwd" target="192.168.2.100" port="514" protocol="tcp"
action.resumeRetryCount="100"
queue.type="LinkedList" queue.size="1000")
Run the following command to reload the rsyslogd configuration:
# systemctl restart rsyslog
References:
Additional Information:
In addition, see the RSyslog documentation for implementation details of TLS.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 651
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
RSyslog supports the ability to receive messages from remote hosts, thus acting as a
log server. Clients should not receive data from other hosts.
Rationale:
If a client is configured to also receive data, thus turning it into a server, the client
system is acting outside it's operational boundary.
Audit:
Review the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and verify that the
system is not configured to accept incoming logs.
Old format
Page 652
Remediation:
Should there be any active log server configuration found in the auditing section, modify
those files and remove the specific lines highlighted by the audit. Ensure none of the
following entries are present in any of /etc/rsyslog.conf or /etc/rsyslog.d/*.conf.
Old format
$ModLoad imtcp
$InputTCPServerRun
New format
module(load="imtcp")
input(type="imtcp" port="514")
Restart the service:
# systemctl restart rsyslog
References:
Page 653
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 654
5.1.3 Ensure all logfiles have appropriate access configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Log files stored in /var/log/ contain logged information from many services on the
system and potentially from other logged hosts as well.
Rationale:
It is important that log files have the correct permissions to ensure that sensitive data is
protected and that only the appropriate users / groups have access to them.
Audit:
Run the following script to verify that files in /var/log/ have appropriate permissions
and ownership:
Page 655
#!/usr/bin/env bash
{
l_op2="" l_output2=""
l_uidmin="$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)"
file_test_chk()
{
l_op2=""
if [ $(( $l_mode & $perm_mask )) -gt 0 ]; then
l_op2="$l_op2\n - Mode: \"$l_mode\" should be \"$maxperm\" or more
restrictive"
fi
if [[ ! "$l_user" =~ $l_auser ]]; then
l_op2="$l_op2\n - Owned by: \"$l_user\" and should be owned by
\"${l_auser//|/ or }\""
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_op2="$l_op2\n - Group owned by: \"$l_group\" and should be group
owned by \"${l_agroup//|/ or }\""
fi
[ -n "$l_op2" ] && l_output2="$l_output2\n - File: \"$l_fname\"
is:$l_op2\n"
}
unset a_file && a_file=() # clear and initialize array
# Loop to create array with stat of files that could possibly fail one of
the audits
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_file+=("$(stat -Lc '%n^%#a^%U^%u^%G^%g'
"$l_file")")
done < <(find -L /var/log -type f \( -perm /0137 -o ! -user root -o ! -
group root \) -print0)
while IFS="^" read -r l_fname l_mode l_user l_uid l_group l_gid; do
l_bname="$(basename "$l_fname")"
case "$l_bname" in
lastlog | lastlog.* | wtmp | wtmp.* | wtmp-* | btmp | btmp.* | btmp-
* | README)
perm_mask='0113'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|utmp)"
file_test_chk
;;
secure | auth.log | syslog | messages)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
file_test_chk
;;
SSSD | sssd)
perm_mask='0117'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="(root|SSSD)"
l_agroup="(root|SSSD)"
file_test_chk
;;
gdm | gdm3)
Page 656
perm_mask='0117'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|gdm|gdm3)"
file_test_chk
;;
*.journal | *.journal~)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|systemd-journal)"
file_test_chk
;;
*)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
if [ "$l_uid" -lt "$l_uidmin" ] && [ -z "$(awk -v grp="$l_group"
-F: '$1==grp {print $4}' /etc/group)" ]; then
if [[ ! "$l_user" =~ $l_auser ]]; then
l_auser="(root|syslog|$l_user)"
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_tst=""
while l_out3="" read -r l_duid; do
[ "$l_duid" -ge "$l_uidmin" ] && l_tst=failed
done <<< "$(awk -F: '$4=='"$l_gid"' {print $3}'
/etc/passwd)"
[ "$l_tst" != "failed" ] && l_agroup="(root|adm|$l_group)"
fi
fi
file_test_chk
;;
esac
done <<< "$(printf '%s\n' "${a_file[@]}")"
unset a_file # Clear array
# If all files passed, then we pass
if [ -z "$l_output2" ]; 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$l_output2"
fi
}
Remediation:
Run the following script to update permissions and ownership on files in /var/log.
Although the script is not destructive, ensure that the output is captured in the event that
the remediation causes issues.
Page 657
#!/usr/bin/env bash
{
l_op2="" l_output2=""
l_uidmin="$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)"
file_test_fix()
{
l_op2=""
l_fuser="root"
l_fgroup="root"
if [ $(( $l_mode & $perm_mask )) -gt 0 ]; then
l_op2="$l_op2\n - Mode: \"$l_mode\" should be \"$maxperm\" or more
restrictive\n - Removing excess permissions"
chmod "$l_rperms" "$l_fname"
fi
if [[ ! "$l_user" =~ $l_auser ]]; then
l_op2="$l_op2\n - Owned by: \"$l_user\" and should be owned by
\"${l_auser//|/ or }\"\n - Changing ownership to: \"$l_fuser\""
chown "$l_fuser" "$l_fname"
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_op2="$l_op2\n - Group owned by: \"$l_group\" and should be group owned by
\"${l_agroup//|/ or }\"\n - Changing group ownership to: \"$l_fgroup\""
chgrp "$l_fgroup" "$l_fname"
fi
[ -n "$l_op2" ] && l_output2="$l_output2\n - File: \"$l_fname\" is:$l_op2\n"
}
unset a_file && a_file=() # clear and initialize array
# Loop to create array with stat of files that could possibly fail one of the
audits
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_file+=("$(stat -Lc '%n^%#a^%U^%u^%G^%g' "$l_file")")
done < <(find -L /var/log -type f \( -perm /0137 -o ! -user root -o ! -group root
\) -print0)
while IFS="^" read -r l_fname l_mode l_user l_uid l_group l_gid; do
l_bname="$(basename "$l_fname")"
case "$l_bname" in
lastlog | lastlog.* | wtmp | wtmp.* | wtmp-* | btmp | btmp.* | btmp-* |
README)
perm_mask='0113'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="ug-x,o-wx"
l_auser="root"
l_agroup="(root|utmp)"
file_test_fix
;;
secure | auth.log | syslog | messages)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="u-x,g-wx,o-rwx"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
file_test_fix
;;
SSSD | sssd)
perm_mask='0117'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="ug-x,o-rwx"
l_auser="(root|SSSD)"
l_agroup="(root|SSSD)"
file_test_fix
;;
gdm | gdm3)
Page 658
perm_mask='0117'
l_rperms="ug-x,o-rwx"
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_auser="root"
l_agroup="(root|gdm|gdm3)"
file_test_fix
;;
*.journal | *.journal~)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="u-x,g-wx,o-rwx"
l_auser="root"
l_agroup="(root|systemd-journal)"
file_test_fix
;;
*)
perm_mask='0137'
maxperm="$( printf '%o' $(( 0777 & ~$perm_mask)) )"
l_rperms="u-x,g-wx,o-rwx"
l_auser="(root|syslog)"
l_agroup="(root|adm)"
if [ "$l_uid" -lt "$l_uidmin" ] && [ -z "$(awk -v grp="$l_group" -F:
'$1==grp {print $4}' /etc/group)" ]; then
if [[ ! "$l_user" =~ $l_auser ]]; then
l_auser="(root|syslog|$l_user)"
fi
if [[ ! "$l_group" =~ $l_agroup ]]; then
l_tst=""
while l_out3="" read -r l_duid; do
[ "$l_duid" -ge "$l_uidmin" ] && l_tst=failed
done <<< "$(awk -F: '$4=='"$l_gid"' {print $3}' /etc/passwd)"
[ "$l_tst" != "failed" ] && l_agroup="(root|adm|$l_group)"
fi
fi
file_test_fix
;;
esac
done <<< "$(printf '%s\n' "${a_file[@]}")"
unset a_file # Clear array
# If all files passed, then we report no changes
if [ -z "$l_output2" ]; then
echo -e "- All files in \"/var/log/\" have appropriate permissions and
ownership\n - No changes required\n"
else
# print report of changes
echo -e "\n$l_output2"
fi
}
Note: You may also need to change the configuration for your logging software or
services for any logs that had incorrect permissions.
If there are services that log to other locations, ensure that those log files have the
appropriate access configured.
References:
Page 659
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 660
5.2 Configure System Accounting (auditd)
The Linux Auditing System operates on a set of rules that collects certain types of
system activity to facilitate incident investigation, detect unauthorized access or
modification of data. By default events will be logged to /var/log/audit/audit.log,
which can be configured in /etc/audit/auditd.conf.
The following types of audit rules can be specified:
• On the command line using the auditctl utility. These rules are not persistent
across reboots.
• In /etc/audit/audit.rules. These rules have to be merged and loaded before
they are active.
Notes:
• For 64 bit systems that have arch as a rule parameter, you will need two rules:
one for 64 bit and one for 32 bit systems calls. For 32 bit systems, only one rule
is needed.
• If the auditing system is configured to be locked (-e 2), a system reboot will be
required in order to load any changes.
• Key names are optional on the rules and will not be used as a compliance
auditing. The usage of key names is highly recommended as it facilitates
organization and searching, as such, all remediation steps will have key names
supplied.
• It is best practice to store the rules, in number prepended files, in
/etc/audit/rules.d/. Rules must end in a .rules suffix. This then requires the
use of augenrules to merge all the rules into /etc/audit/audit.rules based on
their alphabetical (lexical) sort order. All benchmark recommendations follow this
best practice for remediation, specifically using the prefix of 50 which is center
weighed if all rule sets make use of the number prepending naming convention.
• Your system may have been customized to change the default UID_MIN. All
samples output uses 1000, but this value will not be used in compliance auditing.
To confirm the UID_MIN for your system, run the following command: awk
'/^\s*UID_MIN/{print $2}' /etc/login.defs
Page 661
Normalization
The Audit system normalizes some entries, so when you look at the sample output keep
in mind that:
• With regards to users whose login UID is not set, the values -1 / unset /
4294967295 are equivalent and normalized to -1.
• When comparing field types and both sides of the comparison is valid fields
types, such aseuid!=uid, then the auditing system may normalize such that the
output is uid!=euid.
• Some parts of the rule may be rearranged whilst others are dependant on
previous syntax. For example, the following two statements are the same:
The recommendations in this section implement auditing policies that not only produces
large quantities of logged data, but may also negatively impact system performance.
Capacity planning is critical in order not to adversely impact production environments.
Page 662
5.2.1 Ensure auditing is enabled
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Page 663
5.2.1.1 Ensure auditd is installed (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
auditd is the userspace component to the Linux Auditing System. It's responsible for
writing audit records to the disk
Rationale:
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Audit:
Run the following command and verify auditd and audispd-plugins are installed:
# dpkg-query -W -f='${binary:Package}\t${Status}\t${db:Status-Status}\n'
auditd
Remediation:
Run the following command to Install auditd
# apt install auditd
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 664
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 665
5.2.1.2 Ensure auditd service is enabled and active (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Turn on the auditd daemon to record system events.
Rationale:
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Audit:
Run the following command to verify auditd is enabled:
# systemctl is-enabled auditd
enabled
Verify result is "enabled".
Run the following command to verify auditd is active:
# systemctl is-active auditd
active
Verify result is active
Remediation:
Run the following command to enable and start auditd:
# systemctl --now enable auditd
References:
Page 666
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 667
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Configure grub2 so that processes that are capable of being audited can be audited
even if they start up prior to auditd startup.
Rationale:
Audit events need to be captured on processes that start up prior to auditd , so that
potential malicious activity cannot go undetected.
Audit:
Run the following command:
# find -L /boot -type f -name 'grub.cfg' -exec grep -Ph -- '^\h*linux\b' {} +
| grep -v 'audit=1'
Nothing should be returned.
Remediation:
Edit /etc/default/grub and add audit=1 to GRUB_CMDLINE_LINUX:
Example:
GRUB_CMDLINE_LINUX="audit=1"
Run the following command to update the grub2 configuration:
# update-grub
Additional Information:
This recommendation is designed around the grub2 bootloader, if another bootloader is
in use in your environment enact equivalent settings.
Page 668
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 669
5.2.1.4 Ensure audit_backlog_limit is sufficient (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
In the kernel-level audit subsystem, a socket buffer queue is used to hold audit events.
Whenever a new audit event is received, it is logged and prepared to be added to this
queue.
The kernel boot parameter audit_backlog_limit=N, with N representing the amount of
messages, will ensure that a queue cannot grow beyond a certain size. If an audit event
is logged which would grow the queue beyond this limit, then a failure occurs and is
handled according to the system configuration
Rationale:
If an audit event is logged which would grow the queue beyond the
audit_backlog_limit, then a failure occurs, auditd records will be lost, and potential
malicious activity could go undetected.
Audit:
Run the following command and verify the audit_backlog_limit= parameter is set:
# find -L /boot -type f -name 'grub.cfg' -exec grep -Ph -- '^\h*linux\b' {} +
| grep -Pv 'audit_backlog_limit=\d+\b'
Nothing should be returned.
Remediation:
Edit /etc/default/grub and add audit_backlog_limit=N to GRUB_CMDLINE_LINUX.
The recommended size for N is 8192 or larger.
Example:
GRUB_CMDLINE_LINUX="audit_backlog_limit=8192"
Run the following command to update the grub2 configuration:
# update-grub
Default Value:
if audit_backlog_limit is not set, the system defaults to audit_backlog_limit=64
References:
Page 670
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 671
5.2.2 Configure Data Retention
When auditing, it is important to carefully configure the storage requirements for audit
logs. By default, auditd will max out the log files at 5MB and retain only 4 copies of
them. Older versions will be deleted. It is possible on a system that the 20 MBs of audit
logs may fill up the system causing loss of audit data. While the recommendations here
provide guidance, check your site policy for audit storage requirements.
Page 672
5.2.2.1 Ensure audit log storage size is configured (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Configure the maximum size of the audit log file. Once the log reaches the maximum
size, it will be rotated and a new log file will be started.
Rationale:
It is important that an appropriate size is determined for log files so that they do not
impact the system and audit data is not lost.
Audit:
Run the following command and ensure output is in compliance with site policy:
# grep -Po -- '^\h*max_log_file\h*=\h*\d+\b' /etc/audit/auditd.conf
max_log_file = <MB>
Remediation:
Set the following parameter in /etc/audit/auditd.conf in accordance with site policy:
max_log_file = <MB>
Default Value:
max_log_file = 8
References:
Additional Information:
The max_log_file parameter is measured in megabytes.
Other methods of log rotation may be appropriate based on site policy. One example is
time-based rotation strategies which don't have native support in auditd configurations.
Manual audit of custom configurations should be evaluated for effectiveness and
completeness.
Page 673
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 674
5.2.2.2 Ensure audit logs are not automatically deleted
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The max_log_file_action setting determines how to handle the audit log file reaching
the max file size. A value of keep_logs will rotate the logs but never delete old logs.
Rationale:
In high security contexts, the benefits of maintaining a long audit history exceed the cost
of storing the audit history.
Audit:
Run the following command and verify output matches:
# grep max_log_file_action /etc/audit/auditd.conf
max_log_file_action = keep_logs
Remediation:
Set the following parameter in /etc/audit/auditd.conf:
max_log_file_action = keep_logs
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 675
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 676
5.2.2.3 Ensure system is disabled when audit logs are full
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The auditd daemon can be configured to halt the system when the audit logs are full.
The admin_space_left_action parameter tells the system what action to take when the
system has detected that it is low on disk space. Valid values are ignore, syslog,
suspend, single, and halt.
Rationale:
In high security contexts, the risk of detecting unauthorized access or nonrepudiation
exceeds the benefit of the system's availability.
Impact:
If the admin_space_left_action parameter is set to halt the audit daemon will
shutdown the system when the disk partition containing the audit logs becomes full.
Page 677
Audit:
Run the following commands and verify output matches:
# grep space_left_action /etc/audit/auditd.conf
space_left_action = email
# grep action_mail_acct /etc/audit/auditd.conf
action_mail_acct = root
Run the following command and verify the output is either halt or single:
# grep -E 'admin_space_left_action\s*=\s*(halt|single)'
/etc/audit/auditd.conf
admin_space_left_action = <halt|single>
Remediation:
Set the following parameters in /etc/audit/auditd.conf:
space_left_action = email
action_mail_acct = root
set admin_space_left_action to either halt or single in /etc/audit/auditd.conf.
Example:
admin_space_left_action = halt
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 678
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 679
5.2.3 Configure auditd rules
The Audit system operates on a set of rules that define what is to be captured in the log
files.
The following types of Audit rules can be specified:
• Control rules: Allow the Audit system's behavior and some of its configuration to
be modified.
• File system rules: Allow the auditing of access to a particular file or a directory.
(Also known as file watches)
• System call rules: Allow logging of system calls that any specified program
makes.
• on the command line using the auditctl utility. Note that these rules are not
persistent across reboots.
• in a file ending in .rules in the /etc/audit/audit.d/ directory.
Page 680
5.2.3.1 Ensure changes to system administration scope (sudoers)
is collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor scope changes for system administrators. If the system has been properly
configured to force system administrators to log in as themselves first and then use the
sudo command to execute privileged commands, it is possible to monitor changes in
scope. The file /etc/sudoers, or files in /etc/sudoers.d, will be written to when the
file(s) or related attributes have changed. The audit records will be tagged with the
identifier "scope".
Rationale:
Changes in the /etc/sudoers and /etc/sudoers.d files can indicate that an
unauthorized change has been made to the scope of system administrator activity.
Page 681
Audit:
On disk configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor scope changes for system administrators.
Example:
# printf "
-w /etc/sudoers -p wa -k scope
-w /etc/sudoers.d -p wa -k scope
" >> /etc/audit/rules.d/50-scope.rules
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
References:
Page 682
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 683
5.2.3.2 Ensure actions as another user are always logged
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
sudo provides users with temporary elevated privileges to perform operations, either as
the superuser or another user.
Rationale:
Creating an audit log of users with temporary elevated privileges and the operation(s)
they performed is essential to reporting. Administrators will want to correlate the events
written to the audit trail with the records written to sudo's logfile to verify if unauthorized
commands have been executed.
Page 684
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# awk '/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&(/ -C *euid!=uid/||/ -C *uid!=euid/) \
&&/ -S *execve/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Verify the output matches:
-a always,exit -F arch=b64 -C euid!=uid -F auid!=unset -S execve -k
user_emulation
-a always,exit -F arch=b32 -C euid!=uid -F auid!=unset -S execve -k
user_emulation
Running configuration
Run the following command to check loaded rules:
# auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&(/ -C *euid!=uid/||/ -C *uid!=euid/) \
&&/ -S *execve/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
Verify the output matches:
-a always,exit -F arch=b64 -S execve -C uid!=euid -F auid!=-1 -F
key=user_emulation
-a always,exit -F arch=b32 -S execve -C uid!=euid -F auid!=-1 -F
key=user_emulation
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 685
Remediation:
Create audit rules
Example:
# printf "
-a always,exit -F arch=b64 -C euid!=uid -F auid!=unset -S execve -k
user_emulation
-a always,exit -F arch=b32 -C euid!=uid -F auid!=unset -S execve -k
user_emulation
" >> /etc/audit/rules.d/50-user_emulation.rules
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
Page 686
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 687
5.2.3.3 Ensure events that modify the sudo log file are collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the sudo log file. If the system has been properly configured to disable the use
of the su command and force all administrators to have to log in first and then use sudo
to execute privileged commands, then all administrator commands will be logged to
/var/log/sudo.log . Any time a command is executed, an audit event will be triggered
as the /var/log/sudo.log file will be opened for write and the executed administration
command will be written to the log.
Rationale:
Changes in /var/log/sudo.log indicate that an administrator has executed a command
or the log file itself has been tampered with. Administrators will want to correlate the
events written to the audit trail with the records written to /var/log/sudo.log to verify if
unauthorized commands have been executed.
Page 688
Audit:
On disk configuration
Page 689
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor events that modify the sudo log file.
Example:
# {
SUDO_LOG_FILE=$(grep -r logfile /etc/sudoers* | sed -e 's/.*logfile=//;s/,?
.*//' -e 's/"//g')
[ -n "${SUDO_LOG_FILE}" ] && printf "
-w ${SUDO_LOG_FILE} -p wa -k sudo_log_file
" >> /etc/audit/rules.d/50-sudo.rules || printf "ERROR: Variable
'SUDO_LOG_FILE_ESCAPED' is unset.\n"
}
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
Page 690
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 691
5.2.3.4 Ensure events that modify date and time information are
collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Capture events where the system date and/or time has been modified. The parameters
in this section are set to determine if the;
system calls have been executed. Further, ensure to write an audit record to the
configured audit log file upon exit, tagging the records with a unique identifier such as
"time-change".
Rationale:
Unexpected changes in system date and/or time could be a sign of malicious activity on
the system.
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
awk '/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&/ -S/ \
&&(/adjtimex/ \
||/settimeofday/ \
||/clock_settime/ ) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Page 692
-a always,exit -F arch=b64 -S adjtimex,settimeofday,clock_settime -k time-
change
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime -k time-
change
-w /etc/localtime -p wa -k time-change
Running configuration
Run the following command to check loaded rules:
# {
auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&/ -S/ \
&&(/adjtimex/ \
||/settimeofday/ \
||/clock_settime/ ) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
In addition, also audit for the stime system call rule. For example:
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime,stime -k
time-change
Page 693
Remediation:
Create audit rules
Example:
# printf "
-a always,exit -F arch=b64 -S adjtimex,settimeofday,clock_settime -k time-
change
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime -k time-
change
-w /etc/localtime -p wa -k time-change
" >> /etc/audit/rules.d/50-time-change.rules
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64. In
addition, add stime to the system call audit. Example:
-a always,exit -F arch=b32 -S adjtimex,settimeofday,clock_settime,stime -k
time-change
References:
Page 694
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 695
5.2.3.5 Ensure events that modify the system's network
environment are collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Record changes to network environment files or system calls. The below parameters
monitors the following system calls, and write an audit event on system call exit:
Rationale:
Monitoring sethostname and setdomainname will identify potential unauthorized changes
to host and domain name of a system. The changing of these names could potentially
break security parameters that are set based on those names. The /etc/hosts file is
monitored for changes that can indicate an unauthorized intruder is trying to change
machine associations with IP addresses and trick users and processes into connecting
to unintended machines. Monitoring /etc/issue and /etc/issue.net is important, as
intruders could put disinformation into those files and trick users into providing
information to the intruder. Monitoring /etc/network is important as it can show if
network interfaces or scripts are being modified in a way that can lead to the machine
becoming unavailable or compromised. All audit records should have a relevant tag
associated with them.
Page 696
Audit:
64 Bit systems
On disk configuration
Run the following commands to check the on disk rules:
# awk '/^ *-a *always,exit/ \
&&/ -F *arch=b(32|64)/ \
&&/ -S/ \
&&(/sethostname/ \
||/setdomainname/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Page 697
-a always,exit -F arch=b64 -S sethostname,setdomainname -F key=system-locale
-a always,exit -F arch=b32 -S sethostname,setdomainname -F key=system-locale
-w /etc/issue -p wa -k system-locale
-w /etc/issue.net -p wa -k system-locale
-w /etc/hosts -p wa -k system-locale
-w /etc/networks -p wa -k system-locale
-w /etc/network/ -p wa -k system-locale
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64
Remediation:
Create audit rules
Example:
# printf "
-a always,exit -F arch=b64 -S sethostname,setdomainname -k system-locale
-a always,exit -F arch=b32 -S sethostname,setdomainname -k system-locale
-w /etc/issue -p wa -k system-locale
-w /etc/issue.net -p wa -k system-locale
-w /etc/hosts -p wa -k system-locale
-w /etc/networks -p wa -k system-locale
-w /etc/network/ -p wa -k system-locale
" >> /etc/audit/rules.d/50-system_locale.rules
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 698
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 699
5.2.3.6 Ensure use of privileged commands are collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor privileged programs, those that have the setuid and/or setgid bit set on
execution, to determine if unprivileged users are running these commands.
Rationale:
Execution of privileged commands by non-privileged users could be an indication of
someone trying to gain unauthorized access to the system.
Impact:
Both the audit and remediation section of this recommendation will traverse all mounted
file systems that is not mounted with either noexec or nosuid mount options. If there are
large file systems without these mount options, such traversal will be significantly
detrimental to the performance of the system.
Before running either the audit or remediation section, inspect the output of the following
command to determine exactly which file systems will be traversed:
# findmnt -n -l -k -it $(awk '/nodev/ { print $2 }' /proc/filesystems | paste
-sd,) | grep -Pv "noexec|nosuid"
To exclude a particular file system due to adverse performance impacts, update the
audit and remediation sections by adding a sufficiently unique string to the grep
statement. The above command can be used to test the modified exclusions.
Page 700
Audit:
On disk configuration
If there are any special mount points that are not visible by default from findmnt as per
the above audit, said file systems would have to be manually audited.
Page 701
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor the use of privileged commands.
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
AUDIT_RULE_FILE="/etc/audit/rules.d/50-privileged.rules"
NEW_DATA=()
for PARTITION in $(findmnt -n -l -k -it $(awk '/nodev/ { print $2 }'
/proc/filesystems | paste -sd,) | grep -Pv "noexec|nosuid" | awk '{print
$1}'); do
readarray -t DATA < <(find "${PARTITION}" -xdev -perm /6000 -type f | awk
-v UID_MIN=${UID_MIN} '{print "-a always,exit -F path=" $1 " -F perm=x -F
auid>="UID_MIN" -F auid!=unset -k privileged" }')
for ENTRY in "${DATA[@]}"; do
NEW_DATA+=("${ENTRY}")
done
done
readarray &> /dev/null -t OLD_DATA < "${AUDIT_RULE_FILE}"
COMBINED_DATA=( "${OLD_DATA[@]}" "${NEW_DATA[@]}" )
printf '%s\n' "${COMBINED_DATA[@]}" | sort -u > "${AUDIT_RULE_FILE}"
}
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
Special mount points
If there are any special mount points that are not visible by default from just scanning /,
change the PARTITION variable to the appropriate partition and re-run the remediation.
References:
Page 702
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
NIST SP 800-53 Rev. 5:
• AU-3
• AU-3(1)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 703
5.2.3.7 Ensure unsuccessful file access attempts are collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor for unsuccessful attempts to access files. The following parameters are
associated with system calls that control files:
• creation - creat
• opening - open , openat
• truncation - truncate , ftruncate
An audit log record will only be written if all of the following criteria is met for the user
when trying to access a file:
Rationale:
Failed attempts to open, create or truncate files could be an indication that an individual
or process is trying to gain unauthorized access to the system.
Page 704
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&(/ -F *exit=-EACCES/||/ -F *exit=-EPERM/) \
&&/ -S/ \
&&/creat/ \
&&/open/ \
&&/truncate/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output includes:
-a always,exit -F arch=b64 -S creat,open,openat,truncate,ftruncate -F exit=-
EACCES -F auid>=1000 -F auid!=unset -k access
-a always,exit -F arch=b64 -S creat,open,openat,truncate,ftruncate -F exit=-
EPERM -F auid>=1000 -F auid!=unset -k access
-a always,exit -F arch=b32 -S creat,open,openat,truncate,ftruncate -F exit=-
EACCES -F auid>=1000 -F auid!=unset -k access
-a always,exit -F arch=b32 -S creat,open,openat,truncate,ftruncate -F exit=-
EPERM -F auid>=1000 -F auid!=unset -k access
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&(/ -F *exit=-EACCES/||/ -F *exit=-EPERM/) \
&&/ -S/ \
&&/creat/ \
&&/open/ \
&&/truncate/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output includes:
Page 705
-a always,exit -F arch=b64 -S open,truncate,ftruncate,creat,openat -F exit=-
EACCES -F auid>=1000 -F auid!=-1 -F key=access
-a always,exit -F arch=b64 -S open,truncate,ftruncate,creat,openat -F exit=-
EPERM -F auid>=1000 -F auid!=-1 -F key=access
-a always,exit -F arch=b32 -S open,truncate,ftruncate,creat,openat -F exit=-
EACCES -F auid>=1000 -F auid!=-1 -F key=access
-a always,exit -F arch=b32 -S open,truncate,ftruncate,creat,openat -F exit=-
EPERM -F auid>=1000 -F auid!=-1 -F key=access
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S creat,open,openat,truncate,ftruncate -F exit=-
EACCES -F auid>=${UID_MIN} -F auid!=unset -k access
-a always,exit -F arch=b64 -S creat,open,openat,truncate,ftruncate -F exit=-
EPERM -F auid>=${UID_MIN} -F auid!=unset -k access
-a always,exit -F arch=b32 -S creat,open,openat,truncate,ftruncate -F exit=-
EACCES -F auid>=${UID_MIN} -F auid!=unset -k access
-a always,exit -F arch=b32 -S creat,open,openat,truncate,ftruncate -F exit=-
EPERM -F auid>=${UID_MIN} -F auid!=unset -k access
" >> /etc/audit/rules.d/50-access.rules || printf "ERROR: Variable 'UID_MIN'
is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 706
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 707
5.2.3.8 Ensure events that modify user/group information are
collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Record events affecting the modification of user or group information, including that of
passwords and old passwords if in use.
The parameters in this section will watch the files to see if they have been opened for
write or have had attribute changes (e.g. permissions) and tag them with the identifier
"identity" in the audit log file.
Rationale:
Unexpected changes to these files could be an indication that the system has been
compromised and that an unauthorized user is attempting to hide their activities or
compromise additional accounts.
Page 708
Audit:
On disk configuration
Page 709
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor events that modify user/group information.
Example:
# printf "
-w /etc/group -p wa -k identity
-w /etc/passwd -p wa -k identity
-w /etc/gshadow -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/security/opasswd -p wa -k identity
" >> /etc/audit/rules.d/50-identity.rules
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
Page 710
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 711
5.2.3.9 Ensure discretionary access control permission
modification events are collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor changes to file permissions, attributes, ownership and group. The parameters in
this section track changes for system calls that affect file permissions and attributes.
The following commands and system calls effect the permissions, ownership and
various attributes of files.
• chmod
• fchmod
• fchmodat
• chown
• fchown
• fchownat
• lchown
• setxattr
• lsetxattr
• fsetxattr
• removexattr
• lremovexattr
• fremovexattr
In all cases, an audit record will only be written for non-system user ids and will ignore
Daemon events. All audit records will be tagged with the identifier "perm_mod."
Rationale:
Monitoring for changes in file attributes could alert a system administrator to activity that
could indicate intruder activity or policy violation.
Page 712
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -S/ \
&&/ -F *auid>=${UID_MIN}/ \
&&(/chmod/||/fchmod/||/fchmodat/ \
||/chown/||/fchown/||/fchownat/||/lchown/ \
||/setxattr/||/lsetxattr/||/fsetxattr/ \
||/removexattr/||/lremovexattr/||/fremovexattr/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat -F auid>=1000 -F
auid!=unset -F key=perm_mod
-a always,exit -F arch=b64 -S chown,fchown,lchown,fchownat -F auid>=1000 -F
auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=1000 -F
auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F auid>=1000 -F
auid!=unset -F key=perm_mod
-a always,exit -F arch=b64 -S
setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=1000 -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S
setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=1000 -F auid!=unset -F key=perm_mod
Running configuration
Run the following command to check loaded rules:
Page 713
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -S/ \
&&/ -F *auid>=${UID_MIN}/ \
&&(/chmod/||/fchmod/||/fchmodat/ \
||/chown/||/fchown/||/fchownat/||/lchown/ \
||/setxattr/||/lsetxattr/||/fsetxattr/ \
||/removexattr/||/lremovexattr/||/fremovexattr/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat -F auid>=1000 -F auid!=-1
-F key=perm_mod
-a always,exit -F arch=b64 -S chown,fchown,lchown,fchownat -F auid>=1000 -F
auid!=-1 -F key=perm_mod
-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=1000 -F auid!=-1
-F key=perm_mod
-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F auid>=1000 -F
auid!=-1 -F key=perm_mod
-a always,exit -F arch=b64 -S
setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=1000 -F auid!=-1 -F key=perm_mod
-a always,exit -F arch=b32 -S
setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=1000 -F auid!=-1 -F key=perm_mod
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 714
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat -F auid>=${UID_MIN} -F
auid!=unset -F key=perm_mod
-a always,exit -F arch=b64 -S chown,fchown,lchown,fchownat -F
auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=${UID_MIN} -F
auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F
auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b64 -S
setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
-a always,exit -F arch=b32 -S
setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F
auid>=${UID_MIN} -F auid!=unset -F key=perm_mod
" >> /etc/audit/rules.d/50-perm_mod.rules || printf "ERROR: Variable
'UID_MIN' is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 715
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 716
5.2.3.10 Ensure successful file system mounts are collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the use of the mount system call. The mount (and umount ) system call controls
the mounting and unmounting of file systems. The parameters below configure the
system to create an audit record when the mount system call is used by a non-
privileged user
Rationale:
It is highly unusual for a non privileged user to mount file systems to the system. While
tracking mount commands gives the system administrator evidence that external media
may have been mounted (based on a review of the source of the mount and confirming
it's an external media type), it does not conclusively indicate that data was exported to
the media. System administrators who wish to determine if data were exported, would
also have to track successful open, creat and truncate system calls requiring write
access to a file under the mount point of the external media file system. This could give
a fair indication that a write occurred. The only way to truly prove it, would be to track
successful writes to the external media. Tracking write system calls could quickly fill up
the audit log and is not recommended. Recommendations on configuration options to
track data export to media is beyond the scope of this document.
Page 717
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&/mount/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F arch=b64 -S mount -F auid>=1000 -F auid!=unset -k mounts
-a always,exit -F arch=b32 -S mount -F auid>=1000 -F auid!=unset -k mounts
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&/mount/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F arch=b64 -S mount -F auid>=1000 -F auid!=-1 -F key=mounts
-a always,exit -F arch=b32 -S mount -F auid>=1000 -F auid!=-1 -F key=mounts
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 718
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b32 -S mount -F auid>=$UID_MIN -F auid!=unset -k
mounts
-a always,exit -F arch=b64 -S mount -F auid>=$UID_MIN -F auid!=unset -k
mounts
" >> /etc/audit/rules.d/50-mounts.rules || printf "ERROR: Variable 'UID_MIN'
is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 719
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
NIST SP 800-53 Rev. 5:
• CM-6
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 720
5.2.3.11 Ensure session initiation information is collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor session initiation events. The parameters in this section track changes to the
files associated with session events.
Page 721
Audit:
On disk configuration
Page 722
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor session initiation information.
Example:
# printf "
-w /var/run/utmp -p wa -k session
-w /var/log/wtmp -p wa -k session
-w /var/log/btmp -p wa -k session
" >> /etc/audit/rules.d/50-session.rules
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
Page 723
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 724
5.2.3.12 Ensure login and logout events are collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor login and logout events. The parameters below track changes to files
associated with login/logout events.
Rationale:
Monitoring login/logout events could provide a system administrator with information
associated with brute force attacks against user logins.
Page 725
Audit:
On disk configuration
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor login and logout events.
Example:
# printf "
-w /var/log/lastlog -p wa -k logins
-w /var/run/faillock -p wa -k logins
" >> /etc/audit/rules.d/50-login.rules
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
References:
Page 726
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
NIST SP 800-53 Rev. 5:
• AU-3
• AU-3(1)
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 727
5.2.3.13 Ensure file deletion events by users are collected
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the use of system calls associated with the deletion or renaming of files and file
attributes. This configuration statement sets up monitoring for:
Rationale:
Monitoring these calls from non-privileged users could provide a system administrator
with evidence that inappropriate removal of files and file attributes associated with
protected files is occurring. While this audit option will look at all events, system
administrators will want to look for specific privileged files that are being deleted or
altered.
Page 728
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&(/unlink/||/rename/||/unlinkat/||/renameat/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F auid>=1000 -
F auid!=unset -k delete
-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F auid>=1000 -
F auid!=unset -k delete
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -S/ \
&&(/unlink/||/rename/||/unlinkat/||/renameat/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F arch=b64 -S rename,unlink,unlinkat,renameat -F auid>=1000 -
F auid!=-1 -F key=delete
-a always,exit -F arch=b32 -S unlink,rename,unlinkat,renameat -F auid>=1000 -
F auid!=-1 -F key=delete
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 729
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S rename,unlink,unlinkat,renameat -F
auid>=${UID_MIN} -F auid!=unset -F key=delete
-a always,exit -F arch=b32 -S rename,unlink,unlinkat,renameat -F
auid>=${UID_MIN} -F auid!=unset -F key=delete
" >> /etc/audit/rules.d/50-delete.rules || printf "ERROR: Variable 'UID_MIN'
is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 730
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 731
5.2.3.14 Ensure events that modify the system's Mandatory
Access Controls are collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor AppArmor, an implementation of mandatory access controls. The parameters
below monitor any write access (potential additional, deletion or modification of files in
the directory) or attribute changes to the /etc/apparmor/ and /etc/apparmor.d/
directories.
Note: If a different Mandatory Access Control method is used, changes to the
corresponding directories should be audited.
Rationale:
Changes to files in the /etc/apparmor/ and /etc/apparmor.d/ directories could indicate
that an unauthorized user is attempting to modify access controls and change security
contexts, leading to a compromise of the system.
Page 732
Audit:
On disk configuration
Page 733
Remediation:
Edit or create a file in the /etc/audit/rules.d/ directory, ending in .rules extension,
with the relevant rules to monitor events that modify the system's Mandatory Access
Controls.
Example:
# printf "
-w /etc/apparmor/ -p wa -k MAC-policy
-w /etc/apparmor.d/ -p wa -k MAC-policy
" >> /etc/audit/rules.d/50-MAC-policy.rules
Merge and load the rules into active configuration:
# augenrules --load
Check if reboot is required.
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot
required to load rules\n"; fi
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
Page 734
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 735
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the chcon command.
Rationale:
The chcon command is used to change file security context. Without generating audit
records that are specific to the security and mission needs of the organization, it would
be difficult to establish, correlate, and investigate the events relating to an incident or
identify those responsible for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 736
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chcon/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F path=/usr/bin/chcon -F perm=x -F auid>=1000 -F auid!=unset
-k perm_chng
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chcon/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -S all -F path=/usr/bin/chcon -F perm=x -F auid>=1000 -F
auid!=-1 -F key=perm_chng
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 737
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/bin/chcon -F perm=x -F auid>=${UID_MIN} -F
auid!=unset -k perm_chng
" >> /etc/audit/rules.d/50-perm_chng.rules || printf "ERROR: Variable
'UID_MIN' is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 738
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 739
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the setfacl command
Rationale:
This utility sets Access Control Lists (ACLs) of files and directories. Without generating
audit records that are specific to the security and mission needs of the organization, it
would be difficult to establish, correlate, and investigate the events relating to an
incident or identify those responsible for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 740
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/setfacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules ||
printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F path=/usr/bin/setfacl -F perm=x -F auid>=1000 -F
auid!=unset -k perm_chng
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/setfacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -S all -F path=/usr/bin/setfacl -F perm=x -F auid>=1000 -F
auid!=-1 -F key=perm_chng
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 741
Remediation:
Create audit rules
64 Bit systems
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/bin/setfacl -F perm=x -F auid>=${UID_MIN} -F
auid!=unset -k perm_chng
" >> /etc/audit/rules.d/50-perm_chng.rules || printf "ERROR: Variable
'UID_MIN' is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 742
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 743
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the chacl command.
chacl is an IRIX-compatibility command, and is maintained for those users who are
familiar with its use from either XFS or IRIX.
Rationale:
chacl changes the ACL(s) for a file or directory. Without generating audit records that
are specific to the security and mission needs of the organization, it would be difficult to
establish, correlate, and investigate the events relating to an incident or identify those
responsible for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 744
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F path=/usr/bin/chacl -F perm=x -F auid>=1000 -F auid!=unset
-k perm_chng
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/bin\/chacl/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -S all -F path=/usr/bin/chacl -F perm=x -F auid>=1000 -F
auid!=-1 -F key=perm_chng
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 745
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/bin/chacl -F perm=x -F auid>=${UID_MIN} -F
auid!=unset -k perm_chng
" >> /etc/audit/rules.d/50-perm_chng.rules || printf "ERROR: Variable
'UID_MIN' is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 746
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 747
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The operating system must generate audit records for successful/unsuccessful uses of
the usermod command.
Rationale:
The usermod command modifies the system account files to reflect the changes that are
specified on the command line. Without generating audit records that are specific to the
security and mission needs of the organization, it would be difficult to establish,
correlate, and investigate the events relating to an incident or identify those responsible
for one.
Audit records can be generated from various components within the information system
(e.g., module or policy filter).
Page 748
Audit:
64 Bit systems
On disk configuration
Run the following command to check the on disk rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/sbin\/usermod/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" /etc/audit/rules.d/*.rules \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -F path=/usr/sbin/usermod -F perm=x -F auid>=1000 -F
auid!=unset -k usermod
Running configuration
Run the following command to check loaded rules:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && auditctl -l | awk "/^ *-a *always,exit/ \
&&(/ -F *auid!=unset/||/ -F *auid!=-1/||/ -F *auid!=4294967295/) \
&&/ -F *auid>=${UID_MIN}/ \
&&/ -F *perm=x/ \
&&/ -F *path=\/usr\/sbin\/usermod/ \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)" \
|| printf "ERROR: Variable 'UID_MIN' is unset.\n"
}
Verify the output matches:
-a always,exit -S all -F path=/usr/sbin/usermod -F perm=x -F auid>=1000 -F
auid!=-1 -F key=usermod
32 Bit systems
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
Page 749
Remediation:
Create audit rules
64 Bit systems
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F path=/usr/sbin/usermod -F perm=x -F auid>=${UID_MIN} -F
auid!=unset -k usermod
" >> /etc/audit/rules.d/50-usermod.rules || printf "ERROR: Variable 'UID_MIN'
is unset.\n"
}
Load audit rules
Follow the same procedures as for 64 bit systems and ignore any entries with b64.
References:
Page 750
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 751
5.2.3.19 Ensure kernel module loading unloading and
modification is collected (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Monitor the loading and unloading of kernel modules. All the loading / listing /
dependency checking of modules is done by kmod via symbolic links.
The following system calls control loading and unloading of modules:
Any execution of the loading and unloading module programs and system calls will
trigger an audit record with an identifier of modules.
Rationale:
Monitoring the use of all the various ways to manipulate kernel modules could provide
system administrators with evidence that an unauthorized change was made to a kernel
module, possibly compromising the security of the system.
Page 752
Audit:
64 Bit systems
On disk configuration
Run the following commands to check the on disk rules:
# {
awk '/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F auid!=unset/||/ -F auid!=-1/||/ -F auid!=4294967295/) \
&&/ -S/ \
&&(/init_module/ \
||/finit_module/ \
||/delete_module/ \
||/create_module/ \
||/query_module/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)' /etc/audit/rules.d/*.rules
Page 753
# {
auditctl -l | awk '/^ *-a *always,exit/ \
&&/ -F *arch=b[2346]{2}/ \
&&(/ -F auid!=unset/||/ -F auid!=-1/||/ -F auid!=4294967295/) \
&&/ -S/ \
&&(/init_module/ \
||/finit_module/ \
||/delete_module/ \
||/create_module/ \
||/query_module/) \
&&(/ key= *[!-~]* *$/||/ -k *[!-~]* *$/)'
Page 754
Remediation:
Create audit rules
Example:
# {
UID_MIN=$(awk '/^\s*UID_MIN/{print $2}' /etc/login.defs)
[ -n "${UID_MIN}" ] && printf "
-a always,exit -F arch=b64 -S
init_module,finit_module,delete_module,create_module,query_module -F
auid>=${UID_MIN} -F auid!=unset -k kernel_modules
-a always,exit -F path=/usr/bin/kmod -F perm=x -F auid>=${UID_MIN} -F
auid!=unset -k kernel_modules
" >> /etc/audit/rules.d/50-kernel_modules.rules || printf "ERROR: Variable
'UID_MIN' is unset.\n"
}
Load audit rules
References:
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
System call structure
For performance (man 7 audit.rules) reasons it is preferable to have all the system
calls on one line. However, your configuration may have them on one line each or some
other combination. This is important to understand for both the auditing and remediation
sections as the examples given are optimized for performance as per the man page.
Page 755
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 756
5.2.3.20 Ensure the audit configuration is immutable (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Set system audit so that audit rules cannot be modified with auditctl . Setting the flag
"-e 2" forces audit to be put in immutable mode. Audit changes can only be made on
system reboot.
Note: This setting will require the system to be rebooted to update the active auditd
configuration settings.
Rationale:
In immutable mode, unauthorized users cannot execute changes to the audit system to
potentially hide malicious activity and then put the audit rules back. Users would most
likely notice a system reboot and that could alert administrators of an attempt to make
unauthorized audit changes.
Audit:
Run the following command and verify output matches:
# grep -Ph -- '^\h*-e\h+2\b' /etc/audit/rules.d/*.rules | tail -1
-e 2
Page 757
Remediation:
Edit or create the file /etc/audit/rules.d/99-finalize.rules and add the line -e 2 at
the end of the file:
Example:
# printf -- "-e 2
" >> /etc/audit/rules.d/99-finalize.rules
Load audit rules
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 758
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 759
5.2.3.21 Ensure the running and on disk configuration is the same
(Manual)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The Audit system have both on disk and running configuration. It is possible for these
configuration settings to differ.
Note: Due to the limitations of augenrules and auditctl, it is not absolutely guaranteed
that loading the rule sets via augenrules --load will result in all rules being loaded or
even that the user will be informed if there was a problem loading the rules.
Rationale:
Configuration differences between what is currently running and what is on disk could
cause unexpected problems or may give a false impression of compliance
requirements.
Audit:
Merged rule sets
# augenrules --check
/usr/sbin/augenrules: No change
Should there be any drift, run augenrules --load to merge and load all rules.
Remediation:
If the rules are not aligned across all three () areas, run the following command to
merge and load all rules:
# augenrules --load
Check if reboot is required.
if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then echo "Reboot required
to load rules"; fi
References:
Page 760
Additional Information:
Potential reboot required
If the auditing configuration is locked (-e 2), then augenrules will not warn in any way
that rules could not be loaded into the running configuration. A system reboot will be
required to load the rules into the running configuration.
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Page 761
5.2.4 Configure auditd file access
Without the capability to restrict which roles and individuals can select which events are
audited, unauthorized personnel may be able to prevent the auditing of critical events.
Page 762
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit log files contain information about the system and system activity.
Rationale:
Access to audit records can reveal system and configuration data to attackers,
potentially compromising its confidentiality.
Audit:
Run the following command to verify audit log files have mode 0640 or less permissive:
# [ -f /etc/audit/auditd.conf ] && find "$(dirname $(awk -F "="
'/^\s*log_file/ {print $2}' /etc/audit/auditd.conf | xargs))" -type f -perm
/0137 -exec stat -Lc "%n %#a" {} +
Nothing should be returned
Remediation:
Run the following command to remove more permissive mode than 0640 from audit log
files:
# [ -f /etc/audit/auditd.conf ] && find "$(dirname $(awk -F "="
'/^\s*log_file/ {print $2}' /etc/audit/auditd.conf | xargs))" -type f -perm
/0137 -exec chmod u-x,g-wx,o-rwx {} +
References:
Page 763
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 764
5.2.4.2 Ensure only authorized users own audit log files
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit log files contain information about the system and system activity.
Rationale:
Access to audit records can reveal system and configuration data to attackers,
potentially compromising its confidentiality.
Audit:
Run the following command to verify audit log files are owned by the root user:
# [ -f /etc/audit/auditd.conf ] && find "$(dirname $(awk -F "="
'/^\s*log_file/ {print $2}' /etc/audit/auditd.conf | xargs))" -type f ! -user
root -exec stat -Lc "%n %U" {} +
Nothing should be returned
Remediation:
Run the following command to configure the audit log files to be owned by the root
user:
# [ -f /etc/audit/auditd.conf ] && find "$(dirname $(awk -F "="
'/^\s*log_file/ {print $2}' /etc/audit/auditd.conf | xargs))" -type f ! -user
root -exec chown root {} +
References:
Page 765
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 766
5.2.4.3 Ensure only authorized groups are assigned ownership of
audit log files (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit log files contain information about the system and system activity.
Rationale:
Access to audit records can reveal system and configuration data to attackers,
potentially compromising its confidentiality.
Audit:
Run the following command to verify log_group parameter is set to either adm or root in
/etc/audit/auditd.conf:
{
if [ -e /etc/audit/auditd.conf ]; then
l_fpath="$(dirname "$(awk -F "=" '/^\s*log_file/ {print $2}'
/etc/audit/auditd.conf | xargs)")"
find -L "$l_fpath" -not -path "$l_fpath"/lost+found -type f \( ! -group
root -a ! -group adm \) -exec ls -l {} +
fi
}
Nothing should be returned
Page 767
Remediation:
Run the following command to configure the audit log files to be group owned by adm:
# find $(dirname $(awk -F"=" '/^\s*log_file/ {print $2}'
/etc/audit/auditd.conf | xargs)) -type f \( ! -group adm -a ! -group root \)
-exec chgrp adm {} +
Run the following command to set the log_group parameter in the audit configuration
file to log_group = adm:
# sed -ri 's/^\s*#?\s*log_group\s*=\s*\S+(\s*#.*)?.*$/log_group = adm\1/'
/etc/audit/auditd.conf
Run the following command to restart the audit daemon to reload the configuration file:
# systemctl restart auditd
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 768
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
The audit log directory contains audit log files.
Rationale:
Audit information includes all information including: audit records, audit settings and
audit reports. This information is needed to successfully audit system activity. This
information must be protected from unauthorized modification or deletion. If this
information were to be compromised, forensic analysis and discovery of the true source
of potentially malicious system activity is impossible to achieve.
Audit:
Run the following command to verify that the audit log directory has a mode of 0750 or
less permissive:
# stat -Lc "%n %a" "$(dirname $( awk -F"=" '/^\s*log_file/ {print $2}'
/etc/audit/auditd.conf))" | grep -Pv -- '^\h*\H+\h+([0,5,7][0,5]0)'
Nothing should be returned
Remediation:
Run the following command to configure the audit log directory to have a mode of
"0750" or less permissive:
# chmod g-w,o-rwx "$(dirname $(awk -F"=" '/^\s*log_file/ {print $2}'
/etc/audit/auditd.conf))"
Default Value:
750
References:
Page 769
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 770
5.2.4.5 Ensure audit configuration files are 640 or more restrictive
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit configuration files control auditd and what events are audited.
Rationale:
Access to the audit configuration files could allow unauthorized personnel to prevent the
auditing of critical events.
Misconfigured audit configuration files may prevent the auditing of critical events or
impact the system's performance by overwhelming the audit log. Misconfiguration of the
audit configuration files may also make it more difficult to establish and investigate
events relating to an incident.
Audit:
Run the following command to verify that the audit configuration files have mode 640 or
more restrictive and are owned by the root user and root group:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) -exec stat
-Lc "%n %a" {} + | grep -Pv -- '^\h*\H+\h*([0,2,4,6][0,4]0)\h*$'
Nothing should be returned
Remediation:
Run the following command to remove more permissive mode than 0640 from the audit
configuration files:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) -exec
chmod u-x,g-wx,o-rwx {} +
References:
Page 771
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 772
5.2.4.6 Ensure audit configuration files are owned by root
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit configuration files control auditd and what events are audited.
Rationale:
Access to the audit configuration files could allow unauthorized personnel to prevent the
auditing of critical events.
Misconfigured audit configuration files may prevent the auditing of critical events or
impact the system's performance by overwhelming the audit log. Misconfiguration of the
audit configuration files may also make it more difficult to establish and investigate
events relating to an incident.
Audit:
Run the following command to verify that the audit configuration files have mode 640 or
more restrictive and are owned by the root user and root group:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) ! -user
root
Nothing should be returned
Remediation:
Run the following command to change ownership to root user:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) ! -user
root -exec chown root {} +
References:
Page 773
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 774
5.2.4.7 Ensure audit configuration files belong to group root
(Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit configuration files control auditd and what events are audited.
Rationale:
Access to the audit configuration files could allow unauthorized personnel to prevent the
auditing of critical events.
Misconfigured audit configuration files may prevent the auditing of critical events or
impact the system's performance by overwhelming the audit log. Misconfiguration of the
audit configuration files may also make it more difficult to establish and investigate
events relating to an incident.
Audit:
Run the following command to verify that the audit configuration files have mode 640 or
more restrictive and are owned by the root user and root group:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) ! -group
root
Nothing should be returned
Remediation:
Run the following command to change group to root:
# find /etc/audit/ -type f \( -name '*.conf' -o -name '*.rules' \) ! -group
root -exec chgrp root {} +
References:
Page 775
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 776
5.2.4.8 Ensure audit tools are 755 or more restrictive (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting audit information includes identifying and protecting the tools used to view
and manipulate log data. Protecting audit tools is necessary to prevent unauthorized
operation on audit information.
Audit:
Run the following command to verify the audit tools have mode 755 or more restrictive,
are owned by the root user and group root:
# stat -c "%n %a" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace
/sbin/auditd /sbin/augenrules | grep -Pv -- '^\h*\H+\h+([0-
7][0,1,4,5][0,1,4,5])\h*$'
Nothing should be returned
Remediation:
Run the following command to remove more permissive mode from the audit tools:
# chmod go-w /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace
/sbin/auditd /sbin/augenrules
References:
Page 777
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 778
5.2.4.9 Ensure audit tools are owned by root (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting audit information includes identifying and protecting the tools used to view
and manipulate log data. Protecting audit tools is necessary to prevent unauthorized
operation on audit information.
Audit:
Run the following command to verify the audit tools have mode 755 or more restrictive,
are owned by the root user and group root:
# stat -c "%n %U" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace
/sbin/auditd /sbin/augenrules | grep -Pv -- '^\h*\H+\h+root\h*$'
Nothing should be returned
Remediation:
Run the following command to change the owner of the audit tools to the root user:
# chown root /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace
/sbin/auditd /sbin/augenrules
References:
Page 779
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 780
5.2.4.10 Ensure audit tools belong to group root (Automated)
Profile Applicability:
• Level 2 - Server
• Level 2 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting audit information includes identifying and protecting the tools used to view
and manipulate log data. Protecting audit tools is necessary to prevent unauthorized
operation on audit information.
Audit:
Run the following command to verify the audit tools have mode 755 or more restrictive,
are owned by the root user and group root:
# stat -c "%n %a %U %G" /sbin/auditctl /sbin/aureport /sbin/ausearch
/sbin/autrace /sbin/auditd /sbin/augenrules | grep -Pv -- '^\h*\H+\h+([0-
7][0,1,4,5][0,1,4,5])\h+root\h+root\h*$'
Nothing should be returned
Remediation:
Run the following command to remove more permissive mode from the audit tools:
# chmod go-w /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace
/sbin/auditd /sbin/augenrules
Run the following command to change owner and group of the audit tools to root user
and group:
# chown root:root /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace
/sbin/auditd /sbin/augenrules
References:
Page 781
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 782
5.2.4.11 Ensure cryptographic mechanisms are used to protect
the integrity of audit tools (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Audit tools include, but are not limited to, vendor-provided and open source audit tools
needed to successfully view and manipulate audit information system activity and
records. Audit tools include custom queries and report generators.
Rationale:
Protecting the integrity of the tools used for auditing purposes is a critical step toward
ensuring the integrity of audit information. Audit information includes all information
(e.g., audit records, audit settings, and audit reports) needed to successfully audit
information system activity.
Attackers may replace the audit tools or inject code into the existing tools with the
purpose of providing the capability to hide or erase system activity from the audit logs.
Audit tools should be cryptographically signed in order to provide the capability to
identify when the audit tools have been modified, manipulated, or replaced. An example
is a checksum hash of the file or files.
Audit:
Verify that Advanced Intrusion Detection Environment (AIDE) is properly configured .
Run the following command to verify that AIDE is configured to use cryptographic
mechanisms to protect the integrity of audit tools:
# grep -Ps -- '(\/sbin\/(audit|au)\H*\b)' /etc/aide.conf /etc/aide/aide.conf
/etc/aide.conf.d/*.conf /etc/aide/aide.conf.d/*
Verify the output includes:
/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
Page 783
Remediation:
Add or update the following selection lines for to a file ending in .conf in the
/etc/aide/aide.conf.d/ or to /etc/aide/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
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 784
6 System Maintenance
Recommendations in this section are intended as maintenance and are intended to be
checked on a frequent basis to ensure system stability. Many recommendations do not
have quick remediations and require investigation into the cause and best fix available
and may indicate an attempted breach of system security.
Page 785
6.1 System File Permissions
This section provides guidance on securing aspects of system files and directories.
Page 786
6.1.1 Ensure permissions on /etc/passwd are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/passwd file contains user account information that is used by many system
utilities and therefore must be readable for these utilities to operate.
Rationale:
It is critical to ensure that the /etc/passwd file is protected from unauthorized write
access. Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/passwd is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/passwd:
# chmod u-x,go-wx /etc/passwd
# chown root:root /etc/passwd
Default Value:
/etc/passwd 644 0/root 0/root
References:
Page 787
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 788
6.1.2 Ensure permissions on /etc/passwd- are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/passwd- file contains backup user account information.
Rationale:
It is critical to ensure that the /etc/passwd- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/passwd- is mode 644 or more restrictive, Uid
is 0/root and Gid is 0/root:
# stat -Lc "%n %a %u/%U %g/%G" /etc/passwd-
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/passwd-:
# chmod u-x,go-wx /etc/passwd-
# chown root:root /etc/passwd-
Default Value:
/etc/passwd- 644 0/root 0/root
References:
Page 789
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 790
6.1.3 Ensure permissions on /etc/group are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/group file contains a list of all the valid groups defined in the system. The
command below allows read/write access for root and read access for everyone else.
Rationale:
The /etc/group file needs to be protected from unauthorized changes by non-privileged
users, but needs to be readable as this information is used with many non-privileged
programs.
Audit:
Run the following command to verify /etc/group is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/group:
# chmod u-x,go-wx /etc/group
# chown root:root /etc/group
Default Value:
/etc/group 644 0/root 0/root
References:
Page 791
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 792
6.1.4 Ensure permissions on /etc/group- are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/group- file contains a backup list of all the valid groups defined in the system.
Rationale:
It is critical to ensure that the /etc/group- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/group- is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/group-:
# chmod u-x,go-wx /etc/group-
# chown root:root /etc/group-
Default Value:
/etc/group- 644 0/root 0/root
References:
Page 793
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 794
6.1.5 Ensure permissions on /etc/shadow are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/shadow file is used to store the information about user accounts that is critical
to the security of those accounts, such as the hashed password and other security
information.
Rationale:
If attackers can gain read access to the /etc/shadow file, they can easily run a
password cracking program against the hashed password to break it. Other security
information that is stored in the /etc/shadow file (such as expiration) could also be
useful to subvert the user accounts.
Audit:
Run the following command to verify /etc/shadow is mode 640 or more restrictive, Uid is
0/root and Gid is 0/root:
Remediation:
Run one of the following commands to set ownership of /etc/shadow to root and group
to either root or shadow:
# chown root:shadow /etc/shadow
-OR-
# chown root:root /etc/shadow
Run the following command to remove excess permissions form /etc/shadow:
# chmod u-x,g-wx,o-rwx /etc/shadow
Default Value:
/etc/shadow 640 0/root 42/shadow
Page 795
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 796
6.1.6 Ensure permissions on /etc/shadow- are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/shadow- file is used to store backup information about user accounts that is
critical to the security of those accounts, such as the hashed password and other
security information.
Rationale:
It is critical to ensure that the /etc/shadow- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/shadow- is mode 640 or more restrictive, Uid
is 0/root and Gid is 0/root:
# stat -Lc "%n %a %u/%U %g/%G" /etc/shadow-
Example:
/etc/shadow 640 0/root 42/shadow-
Remediation:
Run one of the following commands to set ownership of /etc/shadow- to root and
group to either root or shadow:
# chown root:shadow /etc/shadow-
-OR-
# chown root:root /etc/shadow-
Run the following command to remove excess permissions form /etc/shadow-:
# chmod u-x,g-wx,o-rwx /etc/shadow-
Default Value:
/etc/shadow- 640 0/root 42/shadow
References:
Page 797
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 798
6.1.7 Ensure permissions on /etc/gshadow are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/gshadow file is used to store the information about groups that is critical to the
security of those accounts, such as the hashed password and other security
information.
Rationale:
If attackers can gain read access to the /etc/gshadow file, they can easily run a
password cracking program against the hashed password to break it. Other security
information that is stored in the /etc/gshadow file (such as group administrators) could
also be useful to subvert the group.
Audit:
Run the following command to verify /etc/gshadow is mode 640 or more restrictive, Uid
is 0/root and Gid is 0/root:
# stat -Lc "%n %a %u/%U %g/%G" /etc/gshadow
Example:
/etc/gshadow 640 0/root 42/gshadow
Remediation:
Run one of the following commands to set ownership of /etc/gshadow to root and
group to either root or shadow:
# chown root:shadow /etc/gshadow
-OR-
# chown root:root /etc/gshadow
Run the following command to remove excess permissions form /etc/gshadow:
# chmod u-x,g-wx,o-rwx /etc/gshadow
Default Value:
/etc/gshadow 640 0/root 42/shadow
Page 799
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 800
6.1.8 Ensure permissions on /etc/gshadow- are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The /etc/gshadow- file is used to store backup information about groups that is critical
to the security of those accounts, such as the hashed password and other security
information.
Rationale:
It is critical to ensure that the /etc/gshadow- file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/gshadow- is mode 640 or more restrictive, Uid
is 0/root and Gid is 0/root:
# stat -Lc "%n %a %u/%U %g/%G" /etc/gshadow-
Example:
/etc/gshadow- 640 0/root 42/shadow
Remediation:
Run one of the following commands to set ownership of /etc/gshadow- to root and
group to either root or shadow:
# chown root:shadow /etc/gshadow-
-OR-
# chown root:root /etc/gshadow-
Run the following command to remove excess permissions form /etc/gshadow-:
# chmod u-x,g-wx,o-rwx /etc/gshadow-
Default Value:
/etc/gshadow- 640 0/root 42/shadow
References:
Page 801
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 802
6.1.9 Ensure permissions on /etc/shells are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
/etc/shells is a text file which contains the full pathnames of valid login shells. This file
is consulted by chsh and available to be queried by other programs.
Rationale:
It is critical to ensure that the /etc/shells file is protected from unauthorized access.
Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following command to verify /etc/shells is mode 644 or more restrictive, Uid is
0/root and Gid is 0/root:
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/shells:
# chmod u-x,go-wx /etc/shells
# chown root:root /etc/shells
References:
Additional Information:
/etc/shells 644 0/root 0/root
Page 803
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 804
6.1.10 Ensure permissions on /etc/opasswd are configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
/etc/security/opasswd and it's backup /etc/security/opasswd.old hold user's
previous passwords if pam_unix or pam_pwhistory is in use on the system
Rationale:
It is critical to ensure that /etc/security/opasswd is protected from unauthorized
access. Although it is protected by default, the file permissions could be changed either
inadvertently or through malicious actions.
Audit:
Run the following commands to verify /etc/security/opasswd and
/etc/security/opasswd.old are mode 600 or more restrictive, Uid is 0/root and Gid is
0/root if they exist:
Page 805
Remediation:
Run the following commands to remove excess permissions, set owner, and set group
on /etc/security/opasswd and /etc/security/opasswd.old is they exist:
# [ -e "/etc/security/opasswd" ] && chmod u-x,go-rwx /etc/security/opasswd
# [ -e "/etc/security/opasswd" ] && chown root:root /etc/security/opasswd
# [ -e "/etc/security/opasswd.old" ] && chmod u-x,go-rwx
/etc/security/opasswd.old
# [ -e "/etc/security/opasswd.old" ] && chown root:root
/etc/security/opasswd.old
References:
Additional Information:
/etc/security/opasswd 600 0/root 0/root
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 806
6.1.11 Ensure world writable files and directories are secured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
World writable files are the least secure. Data in world-writable files can be modified and
compromised by any user on the system. World writable files may also indicate an
incorrectly written script or program that could potentially be the cause of a larger
compromise to the system's integrity. See the chmod(2) man page for more information.
Setting the sticky bit on world writable directories prevents users from deleting or
renaming files in that directory that are not owned by them.
Rationale:
Data in world-writable files can be modified and compromised by any user on the
system. World writable files may also indicate an incorrectly written script or program
that could potentially be the cause of a larger compromise to the system's integrity.
This feature prevents the ability to delete or rename files in world writable directories
(such as /tmp ) that are owned by another user.
Page 807
Audit:
Run the following script to verify:
#!/usr/bin/env bash
{
l_output="" l_output2=""
l_smask='01000'
a_path=(); a_arr=(); a_file=(); a_dir=() # Initialize arrays
a_path=(! -path "/run/user/*" -a ! -path "/proc/*" -a ! -path "*/containerd/*" -a ! -path
"*/kubelet/pods/*" -a ! -path "/sys/kernel/security/apparmor/*" -a ! -path "/snap/*" -a ! -path
"/sys/fs/cgroup/memory/*")
while read -r l_bfs; do
a_path+=( -a ! -path ""$l_bfs"/*")
done < <(findmnt -Dkerno fstype,target | awk '$1 ~ /^\s*(nfs|proc|smb)/ {print $2}')
# Populate array with files that will possibly fail one of the audits
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_arr+=("$(stat -Lc '%n^%#a' "$l_file")")
done < <(find / \( "${a_path[@]}" \) \( -type f -o -type d \) -perm -0002 -print0 2>/dev/null)
while IFS="^" read -r l_fname l_mode; do # Test files in the array
[ -f "$l_fname" ] && a_file+=("$l_fname") # Add WR files
if [ -d "$l_fname" ]; then # Add directories w/o sticky bit
[ ! $(( $l_mode & $l_smask )) -gt 0 ] && a_dir+=("$l_fname")
fi
done < <(printf '%s\n' "${a_arr[@]}")
if ! (( ${#a_file[@]} > 0 )); then
l_output="$l_output\n - No world writable files exist on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_file[@]}")\" World writable files
on the system.\n - The following is a list of World writable files:\n$(printf '%s\n'
"${a_file[@]}")\n - end of list\n"
fi
if ! (( ${#a_dir[@]} > 0 )); then
l_output="$l_output\n - Sticky bit is set on world writable directories on the local
filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_dir[@]}")\" World writable
directories without the sticky bit on the system.\n - The following is a list of World writable
directories without the sticky bit:\n$(printf '%s\n' "${a_dir[@]}")\n - end of list\n"
fi
unset a_path; unset a_arr; unset a_file; unset a_dir # Remove arrays
# If l_output2 is empty, we pass
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "- * Correctly configured * :\n$l_output\n"
fi
}
Note: On systems with a large number of files and/or directories, this audit may be a
long running process
Page 808
Remediation:
#!/usr/bin/env bash
{
l_smask='01000'
a_path=(); a_arr=() # Initialize array
a_path=(! -path "/run/user/*" -a ! -path "/proc/*" -a ! -path "*/containerd/*" -a ! -path
"*/kubelet/pods/*" -a ! -path "/sys/kernel/security/apparmor/*" -a ! -path "/snap/*" -a ! -path
"/sys/fs/cgroup/memory/*")
while read -r l_bfs; do
a_path+=( -a ! -path ""$l_bfs"/*")
done < <(findmnt -Dkerno fstype,target | awk '$1 ~ /^\s*(nfs|proc|smb)/ {print $2}')
# Populate array with files
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_arr+=("$(stat -Lc '%n^%#a' "$l_file")")
done < <(find / \( "${a_path[@]}" \) \( -type f -o -type d \) -perm -0002 -print0 2>/dev/null)
while IFS="^" read -r l_fname l_mode; do # Test files in the array
if [ -f "$l_fname" ]; then # Remove excess permissions from WW files
echo -e " - File: \"$l_fname\" is mode: \"$l_mode\"\n - removing write permission on
\"$l_fname\" from \"other\""
chmod o-w "$l_fname"
fi
if [ -d "$l_fname" ]; then
if [ ! $(( $l_mode & $l_smask )) -gt 0 ]; then # Add sticky bit
echo -e " - Directory: \"$l_fname\" is mode: \"$l_mode\" and doesn't have the sticky
bit set\n - Adding the sticky bit"
chmod a+t "$l_fname"
fi
fi
done < <(printf '%s\n' "${a_arr[@]}")
unset a_path; unset a_arr # Remove array
}
References:
Page 809
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 810
6.1.12 Ensure no unowned or ungrouped files or directories exist
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Administrators may delete users or groups from the system and neglect to remove all
files and/or directories owned by those users or groups.
Rationale:
A new user or group who is assigned a deleted user's user ID or group ID may then end
up "owning" a deleted user or group's files, and thus have more access on the system
than was intended.
Page 811
Audit:
Run the following script to verify no unowned or ungrouped files or directories exist:
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_path=(); a_arr=(); a_nouser=(); a_nogroup=() # Initialize arrays
a_path=(! -path "/run/user/*" -a ! -path "/proc/*" -a ! -path "*/containerd/*" -a ! -path
"*/kubelet/pods/*")
while read -r l_bfs; do
a_path+=( -a ! -path ""$l_bfs"/*")
done < <(findmnt -Dkerno fstype,target | awk '$1 ~ /^\s*(nfs|proc|smb)/ {print $2}')
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_arr+=("$(stat -Lc '%n^%U^%G' "$l_file")") && echo "Adding: $l_file"
done < <(find / \( "${a_path[@]}" \) \( -type f -o -type d \) \( -nouser -o -nogroup \) -
print0 2> /dev/null)
while IFS="^" read -r l_fname l_user l_group; do # Test files in the array
[ "$l_user" = "UNKNOWN" ] && a_nouser+=("$l_fname")
[ "$l_group" = "UNKNOWN" ] && a_nogroup+=("$l_fname")
done <<< "$(printf '%s\n' "${a_arr[@]}")"
if ! (( ${#a_nouser[@]} > 0 )); then
l_output="$l_output\n - No unowned files or directories exist on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_nouser[@]}")\" unowned files or
directories on the system.\n - The following is a list of unowned files and/or
directories:\n$(printf '%s\n' "${a_nouser[@]}")\n - end of list"
fi
if ! (( ${#a_nogroup[@]} > 0 )); then
l_output="$l_output\n - No ungrouped files or directories exist on the local filesystem."
else
l_output2="$l_output2\n - There are \"$(printf '%s' "${#a_nogroup[@]}")\" ungrouped files
or directories on the system.\n - The following is a list of ungrouped files and/or
directories:\n$(printf '%s\n' "${a_nogroup[@]}")\n - end of list"
fi
unset a_path; unset a_arr ; unset a_nouser; unset a_nogroup # Remove arrays
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "\n- * Correctly configured * :\n$l_output\n"
fi
}
Note: On systems with a large number of files and/or directories, this audit may be a
long running process
Remediation:
Remove or set ownership and group ownership of these files and/or directories to an
active user on the system as appropriate.
References:
Page 812
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 813
6.1.13 Ensure SUID and SGID files are reviewed (Manual)
Profile Applicability:
• Level 1 - Workstation
• Level 1 - Server
Description:
The owner of a file can set the file's permissions to run with the owner's or group's
permissions, even if the user running the program is not the owner or a member of the
group. The most common reason for a SUID or SGID program is to enable users to
perform functions (such as changing their password) that require root privileges.
Rationale:
There are valid reasons for SUID and SGID programs, but it is important to identify and
review such programs to ensure they are legitimate. Review the files returned by the
action in the audit section and check to see if system binaries have a different
checksum than what from the package. This is an indication that the binary may have
been replaced.
Page 814
Audit:
Run the following script to generate a list of SUID and SGID files:
#!/usr/bin/env bash
{
l_output="" l_output2=""
a_arr=(); a_suid=(); a_sgid=() # initialize arrays
# Populate array with files that will possibly fail one of the audits
while read -r l_mpname; do
while IFS= read -r -d $'\0' l_file; do
[ -e "$l_file" ] && a_arr+=("$(stat -Lc '%n^%#a' "$l_file")")
done < <(find "$l_mpname" -xdev -not -path "/run/user/*" -type f \( -
perm -2000 -o -perm -4000 \) -print0)
done <<< "$(findmnt -Derno target)"
# Test files in the array
while IFS="^" read -r l_fname l_mode; do
if [ -f "$l_fname" ]; then
l_suid_mask="04000"; l_sgid_mask="02000"
[ $(( $l_mode & $l_suid_mask )) -gt 0 ] && a_suid+=("$l_fname")
[ $(( $l_mode & $l_sgid_mask )) -gt 0 ] && a_sgid+=("$l_fname")
fi
done <<< "$(printf '%s\n' "${a_arr[@]}")"
if ! (( ${#a_suid[@]} > 0 )); then
l_output="$l_output\n - There are no SUID files exist on the system"
else
l_output2="$l_output2\n - List of \"$(printf '%s' "${#a_suid[@]}")\"
SUID executable files:\n$(printf '%s\n' "${a_suid[@]}")\n - end of list -\n"
fi
if ! (( ${#a_sgid[@]} > 0 )); then
l_output="$l_output\n - There are no SGID files exist on the system"
else
l_output2="$l_output2\n - List of \"$(printf '%s' "${#a_sgid[@]}")\"
SGID executable files:\n$(printf '%s\n' "${a_sgid[@]}")\n - end of list -\n"
fi
[ -n "$l_output2" ] && l_output2="$l_output2\n- Review the preceding
list(s) of SUID and/or SGID files to\n- ensure that no rogue programs have
been introduced onto the system.\n"
unset a_arr; unset a_suid; unset a_sgid # Remove arrays
# If l_output2 is empty, Nothing to report
if [ -z "$l_output2" ]; then
echo -e "\n- Audit Result:\n$l_output\n"
else
echo -e "\n- Audit Result:\n$l_output2\n"
[ -n "$l_output" ] && echo -e "$l_output\n"
fi
}
Note: on systems with a large number of files, this may be a long running process
Remediation:
Ensure that no rogue SUID or 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.
Page 815
References:
1. NIST SP 800-53 Rev. 5: CM-1, CM-2, CM-6, CM-7, IA-5, AC-3, MP-2
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 816
6.2 Local User and Group Settings
This section provides guidance on securing aspects of the local users and groups.
Note: The recommendations in this section check local users and groups. Any users or
groups from other sources such as LDAP will not be audited. In a domain environment
similar checks should be performed against domain users and groups.
Page 817
6.2.1 Ensure accounts in /etc/passwd use shadowed passwords
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Local accounts can uses shadowed passwords. With shadowed passwords, the
passwords are saved in shadow password file, /etc/shadow, encrypted by a salted one-
way hash. Accounts with a shadowed password have an x in the second field in
/etc/passwd.
Rationale:
The /etc/passwd file also contains information like user ID's and group ID's that are
used by many system programs. Therefore, the /etc/passwd file must remain world
readable. In spite of encoding the password with a randomly-generated one-way hash
function, an attacker could still break the system if they got access to the /etc/passwd
file. This can be mitigated by using shadowed passwords, thus moving the passwords in
the /etc/passwd file to /etc/shadow. The /etc/shadow file is set so only root will be able
to read and write. This helps mitigate the risk of an attacker gaining access to the
encoded passwords with which to perform a dictionary attack.
Note:
• All accounts must have passwords or be locked to prevent the account from
being used by an unauthorized user.
• A user account with an empty second field in /etc/passwd allows the account to
be logged into by providing only the username.
Audit:
Run the following command and verify that no output is returned:
# awk -F: '($2 != "x" ) { print $1 " is not set to shadowed passwords "}'
/etc/passwd
Remediation:
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.
Page 818
References:
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 819
6.2.2 Ensure /etc/shadow password fields are not empty
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
An account with an empty password field means that anybody may log in as that user
without providing a password.
Rationale:
All accounts must have passwords or be locked to prevent the account from being used
by an unauthorized user.
Audit:
Run the following command and verify that no output is returned:
# awk -F: '($2 == "" ) { print $1 " does not have a password "}' /etc/shadow
Remediation:
If any accounts in the /etc/shadow file do not have a password, run the following
command to lock the account until it can be determined why it does not have a
password:
# passwd -l <username>
Also, check to see if the account is logged in and investigate what it is being used for to
determine if it needs to be forced off.
References:
Page 820
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0003 M1027
T1078.003
Page 821
6.2.3 Ensure all groups in /etc/passwd exist in /etc/group
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Over time, system administration errors and changes can lead to groups being defined
in /etc/passwd but not in /etc/group .
Rationale:
Groups defined in the /etc/passwd file but not in the /etc/group file pose a threat to
system security since group permissions are not properly managed.
Audit:
Run the following script and verify no results are returned:
#!/bin/bash
Remediation:
Analyze the output of the Audit step above and perform the appropriate action to correct
any discrepancies found.
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 822
6.2.4 Ensure shadow group is empty (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The shadow group allows system programs which require access the ability to read the
/etc/shadow file. No users should be assigned to the shadow group.
Rationale:
Any users assigned to the shadow group would be granted read access to the
/etc/shadow file. If attackers can gain read access to the /etc/shadow file, they can
easily run a password cracking program against the hashed passwords to break them.
Other security information that is stored in the /etc/shadow file (such as expiration)
could also be useful to subvert additional user accounts.
Audit:
Run the following commands and verify no results are returned:
# awk -F: '($1=="shadow") {print $NF}' /etc/group
# awk -F: -v GID="$(awk -F: '($1=="shadow") {print $3}' /etc/group)"
'($4==GID) {print $1}' /etc/passwd
Remediation:
Run the following command to remove all users from the shadow group
# sed -ri 's/(^shadow:[^:]*:[^:]*:)([^:]+$)/\1/' /etc/group
Change the primary group of any users with shadow as their primary group.
# usermod -g <primary group> <user>
References:
Page 823
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 824
6.2.5 Ensure no duplicate UIDs exist (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the useradd program will not let you create a duplicate User ID (UID), it is
possible for an administrator to manually edit the /etc/passwd file and change the UID
field.
Rationale:
Users must be assigned unique UIDs for accountability and to ensure appropriate
access protections.
Audit:
Run the following script and verify no results are returned:
#!/bin/bash
Remediation:
Based on the results of the audit script, establish unique UIDs and review all files owned
by the shared UIDs to determine which UID they are supposed to belong to.
References:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1027
T1078.003
Page 825
6.2.6 Ensure no duplicate GIDs exist (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the groupadd program will not let you create a duplicate Group ID (GID), it is
possible for an administrator to manually edit the /etc/group file and change the GID
field.
Rationale:
User groups must be assigned unique GIDs for accountability and to ensure appropriate
access protections.
Audit:
Run the following script and verify no results are returned:
#!/bin/bash
Remediation:
Based on the results of the audit script, establish unique GIDs and review all files
owned by the shared GID to determine which group they are supposed to belong to.
References:
Additional Information:
You can also use the grpck command to check for other inconsistencies in the
/etc/group file.
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0005 M1027
T1078.003
Page 826
6.2.7 Ensure no duplicate user names exist (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the useradd program will not let you create a duplicate user name, it is
possible for an administrator to manually edit the /etc/passwd file and change the user
name.
Rationale:
If a user is assigned a duplicate user name, it will create and have access to files with
the first UID for that username in /etc/passwd . For example, if "test4" has a UID of
1000 and a subsequent "test4" entry has a UID of 2000, logging in as "test4" will use
UID 1000. Effectively, the UID is shared, which is a security problem.
Audit:
Run the following script and verify no results are returned:
#!/bin/bash
Remediation:
Based on the results of the audit script, establish unique user names for the users. File
ownerships will automatically reflect the change as long as the users have unique UIDs.
References:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0004 M1027
T1078.003
Page 827
6.2.8 Ensure no duplicate group names exist (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
Although the groupadd program will not let you create a duplicate group name, it is
possible for an administrator to manually edit the /etc/group file and change the group
name.
Rationale:
If a group is assigned a duplicate group name, it will create and have access to files
with the first GID for that group in /etc/group . Effectively, the GID is shared, which is a
security problem.
Audit:
Run the following script and verify no results are returned:
#!/bin/bash
Remediation:
Based on the results of the audit script, establish unique names for the user groups. File
group ownerships will automatically reflect the change as long as the groups have
unique GIDs.
References:
Techniques / Sub-
Tactics Mitigations
techniques
T1078, T1078.001,
TA0004 M1027
T1078.003
Page 828
6.2.9 Ensure root PATH Integrity (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
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.
Audit:
Run the following script and verify no results are returned:
#!/bin/bash
Remediation:
Correct or justify any items discovered in the Audit step.
References:
Page 829
MITRE ATT&CK Mappings:
Techniques / Sub-
Tactics Mitigations
techniques
Page 830
6.2.10 Ensure root is the only UID 0 account (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
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.
Audit:
Run the following command and verify that only "root" is returned:
# awk -F: '($3 == 0) { print $1 }' /etc/passwd
root
Remediation:
Remove any users other than root with UID 0 or assign them a new UID if appropriate.
References:
Techniques / Sub-
Tactics Mitigations
techniques
Page 831
6.2.11 Ensure local interactive user home directories are
configured (Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
The user home directory is space defined for the particular user to set local environment
variables and to store personal files. While the system administrator can establish
secure permissions for users' home directories, the users can easily override these.
Users can be defined in /etc/passwd without a home directory or with a home directory
that does not actually exist.
Rationale:
Since the user is accountable for files stored in the user home directory, the user must
be the owner of the directory. Group or world-writable user home directories may enable
malicious users to steal or modify other users' data or to gain another user's system
privileges. If the user's home directory does not exist or is unassigned, the user will be
placed in "/" and will not be able to write any files or have local environment variables
set.
Page 832
Audit:
Run the following script to Ensure:
#!/usr/bin/env bash
{
l_output="" l_output2="" l_heout2="" l_hoout2="" l_haout2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn
'/^\//{s,/,\\\\/,g;p}' | paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }'
/etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
[ "$l_asize " -gt "10000" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local interactive
users found on the system\n - This may be a long running check\n"
while read -r l_user l_home; do
if [ -d "$l_home" ]; then
l_mask='0027'
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read -r l_own l_mode; do
[ "$l_user" != "$l_own" ] && l_hoout2="$l_hoout2\n - User: \"$l_user\" Home
\"$l_home\" is owned by: \"$l_own\""
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_haout2="$l_haout2\n - User: \"$l_user\" Home \"$l_home\" is mode: \"$l_mode\"
should be mode: \"$l_max\" or more restrictive"
fi
done <<< "$(stat -Lc '%U %#a' "$l_home")"
else
l_heout2="$l_heout2\n - User: \"$l_user\" Home \"$l_home\" Doesn't exist"
fi
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
[ -z "$l_heout2" ] && l_output="$l_output\n - home directories exist" ||
l_output2="$l_output2$l_heout2"
[ -z "$l_hoout2" ] && l_output="$l_output\n - own their home directory" ||
l_output2="$l_output2$l_hoout2"
[ -z "$l_haout2" ] && l_output="$l_output\n - home directories are mode: \"$l_max\" or more
restrictive" || l_output2="$l_output2$l_haout2"
[ -n "$l_output" ] && l_output=" - All local interactive users:$l_output"
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured * :\n$l_output"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit failure * :\n$l_output2"
[ -n "$l_output" ] && echo -e "\n- * Correctly configured * :\n$l_output"
fi
}
Page 833
Remediation:
If a local interactive users' home directory is undefined and/or doesn't exist, follow local
site policy and perform one of the following:
#!/usr/bin/env bash
{
l_output2=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn
'/^\//{s,/,\\\\/,g;p}' | paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }'
/etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
[ "$l_asize " -gt "10000" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local interactive
users found on the system\n - This may be a long running process\n"
while read -r l_user l_home; do
if [ -d "$l_home" ]; then
l_mask='0027'
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
while read -r l_own l_mode; do
if [ "$l_user" != "$l_own" ]; then
l_output2="$l_output2\n - User: \"$l_user\" Home \"$l_home\" is owned by:
\"$l_own\"\n - changing ownership to: \"$l_user\"\n"
chown "$l_user" "$l_home"
fi
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_output2="$l_output2\n - User: \"$l_user\" Home \"$l_home\" is mode: \"$l_mode\"
should be mode: \"$l_max\" or more restrictive\n - removing excess permissions\n"
chmod g-w,o-rwx "$l_home"
fi
done <<< "$(stat -Lc '%U %#a' "$l_home")"
else
l_output2="$l_output2\n - User: \"$l_user\" Home \"$l_home\" Doesn't exist\n - Please
create a home in accordance with local site policy"
fi
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e " - No modification needed to local interactive users home directories"
else
echo -e "\n$l_output2"
fi
}
References:
Page 834
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
Page 835
6.2.12 Ensure local interactive user dot files access is configured
(Automated)
Profile Applicability:
• Level 1 - Server
• Level 1 - Workstation
Description:
While the system administrator can establish secure permissions for users' "dot" files,
the users can easily override these.
• .forward file specifies an email address to forward the user's mail to.
• .rhost file provides the "remote authentication" database for the rcp, rlogin, and
rsh commands and the rcmd() function. These files bypass the standard
password-based user authentication mechanism. They specify remote hosts and
users that are considered trusted (i.e. are allowed to access the local system
without supplying a password)
• .netrc file contains data for logging into a remote host or passing authentication
to an API.
• .bash_history file keeps track of the user’s last 500 commands.
Rationale:
User configuration files with excessive or incorrect access may enable malicious users
to steal or modify other users' data or to gain another user's system privileges.
Audit:
Run the following script to verify local interactive user dot files:
Note: If a .netrc file is required, and follows local site policy, it should have permissions
of 600 or more restrictive.
Page 836
#!/usr/bin/env bash
{
l_output="" l_output2="" l_output3="" l_output4=""
l_bf="" l_df="" l_nf="" l_hf=""
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed
-rn '/^\//{s,/,\\\\/,g;p}' | paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home
location
[[ -n "$l_epu" && -n "$l_eph" ]] && a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " "
$(NF-1) }' /etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users
before proceeding
l_maxsize="1000" # Maximun number of local interactive users before
warning (Default 1,000)
[ "$l_asize " -gt "$l_maxsize" ] && echo -e "\n ** INFO **\n -
\"$l_asize\" Local interactive users found on the system\n - This may be a
long running check\n"
file_access_chk()
{
l_facout2=""
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
l_facout2="$l_facout2\n - File: \"$l_hdfile\" is mode: \"$l_mode\"
and should be mode: \"$l_max\" or more restrictive"
fi
if [[ ! "$l_owner" =~ ($l_user) ]]; then
l_facout2="$l_facout2\n - File: \"$l_hdfile\" owned by:
\"$l_owner\" and should be owned by \"${l_user//|/ or }\""
fi
if [[ ! "$l_gowner" =~ ($l_group) ]]; then
l_facout2="$l_facout2\n - File: \"$l_hdfile\" group owned by:
\"$l_gowner\" and should be group owned by \"${l_group//|/ or }\""
fi
}
while read -r l_user l_home; do
l_fe="" l_nout2="" l_nout3="" l_dfout2="" l_hdout2="" l_bhout2=""
if [ -d "$l_home" ]; then
l_group="$(id -gn "$l_user" | xargs)"
l_group="${l_group// /|}"
while IFS= read -r -d $'\0' l_hdfile; do
while read -r l_mode l_owner l_gowner; do
case "$(basename "$l_hdfile")" in
.forward | .rhost )
l_fe="Y" && l_bf="Y"
l_dfout2="$l_dfout2\n - File: \"$l_hdfile\" exists" ;;
.netrc )
l_mask='0177'
file_access_chk
if [ -n "$l_facout2" ]; then
l_fe="Y" && l_nf="Y"
l_nout2="$l_facout2"
else
l_nout3=" - File: \"$l_hdfile\" exists"
fi ;;
Page 837
.bash_history )
l_mask='0177'
file_access_chk
if [ -n "$l_facout2" ]; then
l_fe="Y" && l_hf="Y"
l_bhout2="$l_facout2"
fi ;;
* )
l_mask='0133'
file_access_chk
if [ -n "$l_facout2" ]; then
l_fe="Y" && l_df="Y"
l_hdout2="$l_facout2"
fi ;;
esac
done <<< "$(stat -Lc '%#a %U %G' "$l_hdfile")"
done < <(find "$l_home" -xdev -type f -name '.*' -print0)
fi
if [ "$l_fe" = "Y" ]; then
l_output2="$l_output2\n - User: \"$l_user\" Home Directory:
\"$l_home\""
[ -n "$l_dfout2" ] && l_output2="$l_output2$l_dfout2"
[ -n "$l_nout2" ] && l_output2="$l_output2$l_nout2"
[ -n "$l_bhout2" ] && l_output2="$l_output2$l_bhout2"
[ -n "$l_hdout2" ] && l_output2="$l_output2$l_hdout2"
fi
[ -n "$l_nout3" ] && l_output3="$l_output3\n - User: \"$l_user\" Home
Directory: \"$l_home\"\n$l_nout3"
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
unset a_uarr # Remove array
[ -n "$l_output3" ] && l_output3=" - ** Warning **\n - \".netrc\" files
should be removed unless deemed necessary\n and in accordance with local
site policy:$l_output3"
[ -z "$l_bf" ] && l_output="$l_output\n - \".forward\" or \".rhost\"
files"
[ -z "$l_nf" ] && l_output="$l_output\n - \".netrc\" files with
incorrect access configured"
[ -z "$l_hf" ] && l_output="$l_output\n - \".bash_history\" files with
incorrect access configured"
[ -z "$l_df" ] && l_output="$l_output\n - \"dot\" files with incorrect
access configured"
[ -n "$l_output" ] && l_output=" - No local interactive users home
directories contain:$l_output"
echo -e "$l_output4"
if [ -z "$l_output2" ]; then # If l_output2 is empty, we pass
echo -e "\n- Audit Result:\n ** PASS **\n - * Correctly configured *
:\n$l_output\n"
echo -e "$l_output3\n"
else
echo -e "\n- Audit Result:\n ** FAIL **\n - * Reasons for audit
failure * :\n$l_output2\n"
echo -e "$l_output3\n"
[ -n "$l_output" ] && echo -e "- * Correctly configured *
:\n$l_output\n"
fi
}
Page 838
Remediation:
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:
Page 839
#!/usr/bin/env bash
{
l_valid_shells="^($( awk -F\/ '$NF != "nologin" {print}' /etc/shells | sed -rn
'/^\//{s,/,\\\\/,g;p}' | paste -s -d '|' - ))$"
unset a_uarr && a_uarr=() # Clear and initialize array
while read -r l_epu l_eph; do # Populate array with users and user home location
[[ -n "$l_epu" && -n "$l_eph" ]] && a_uarr+=("$l_epu $l_eph")
done <<< "$(awk -v pat="$l_valid_shells" -F: '$(NF) ~ pat { print $1 " " $(NF-1) }'
/etc/passwd)"
l_asize="${#a_uarr[@]}" # Here if we want to look at number of users before proceeding
l_maxsize="1000" # Maximum number of local interactive users before warning (Default 1,000)
[ "$l_asize " -gt "$l_maxsize" ] && echo -e "\n ** INFO **\n - \"$l_asize\" Local
interactive users found on the system\n - This may be a long running check\n"
file_access_fix()
{
l_facout2=""
l_max="$( printf '%o' $(( 0777 & ~$l_mask)) )"
if [ $(( $l_mode & $l_mask )) -gt 0 ]; then
echo -e " - File: \"$l_hdfile\" is mode: \"$l_mode\" and should be mode: \"$l_max\" or
more restrictive\n - Changing to mode \"$l_max\""
chmod "$l_chp" "$l_hdfile"
fi
if [[ ! "$l_owner" =~ ($l_user) ]]; then
echo -e " - File: \"$l_hdfile\" owned by: \"$l_owner\" and should be owned by
\"${l_user//|/ or }\"\n - Changing ownership to \"$l_user\""
chown "$l_user" "$l_hdfile"
fi
if [[ ! "$l_gowner" =~ ($l_group) ]]; then
echo -e " - File: \"$l_hdfile\" group owned by: \"$l_gowner\" and should be group owned
by \"${l_group//|/ or }\"\n - Changing group ownership to \"$l_group\""
chgrp "$l_group" "$l_hdfile"
fi
}
while read -r l_user l_home; do
if [ -d "$l_home" ]; then
echo -e "\n - Checking user: \"$l_user\" home directory: \"$l_home\""
l_group="$(id -gn "$l_user" | xargs)"
l_group="${l_group// /|}"
while IFS= read -r -d $'\0' l_hdfile; do
while read -r l_mode l_owner l_gowner; do
case "$(basename "$l_hdfile")" in
.forward | .rhost )
echo -e " - File: \"$l_hdfile\" exists\n - Please investigate and
manually delete \"$l_hdfile\""
;;
.netrc )
l_mask='0177'
l_chp="u-x,go-rwx"
file_access_fix ;;
.bash_history )
l_mask='0177'
l_chp="u-x,go-rwx"
file_access_fix ;;
* )
l_mask='0133'
l_chp="u-x,go-wx"
file_access_fix ;;
esac
done <<< "$(stat -Lc '%#a %U %G' "$l_hdfile")"
done < <(find "$l_home" -xdev -type f -name '.*' -print0)
fi
done <<< "$(printf '%s\n' "${a_uarr[@]}")"
unset a_uarr # Remove array
}
References:
Page 840
CIS Controls:
Controls
Control IG 1 IG 2 IG 3
Version
Techniques / Sub-
Tactics Mitigations
techniques
T1222, T1222.001,
T1222.002, T1552, TA0005 M1022
T1552.003, T1552.004
Page 841
Appendix: Summary Table
CIS Benchmark Recommendation Set
Correctly
Yes No
1 Initial Setup
Page 842
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 843
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 844
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 845
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 846
CIS Benchmark Recommendation Set
Correctly
Yes No
2 Services
Page 847
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 848
CIS Benchmark Recommendation Set
Correctly
Yes No
3 Network Configuration
Page 849
CIS Benchmark Recommendation Set
Correctly
Yes No
3.4.1.6 Ensure ufw firewall rules exist for all open ports
(Automated)
Page 850
CIS Benchmark Recommendation Set
Correctly
Yes No
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
(Automated)
Page 851
CIS Benchmark Recommendation Set
Correctly
Yes No
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
(Automated)
Page 852
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 853
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 854
CIS Benchmark Recommendation Set
Correctly
Yes No
4.5.1.5 Ensure all users last password change date is in the past
(Automated)
Page 855
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 856
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 857
CIS Benchmark Recommendation Set
Correctly
Yes No
5.2.3.3 Ensure events that modify the sudo log file are collected
(Automated)
5.2.3.4 Ensure events that modify date and time information are
collected (Automated)
Page 858
CIS Benchmark Recommendation Set
Correctly
Yes No
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
(Automated)
Page 859
CIS Benchmark Recommendation Set
Correctly
Yes No
6 System Maintenance
Page 860
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 861
CIS Benchmark Recommendation Set
Correctly
Yes No
Page 862
Appendix: CIS Controls v7 IG 1 Mapped
Recommendations
Recommendation Set
Correctly
Yes No
1.1.2.1 Ensure /tmp is a separate partition
1.1.2.2 Ensure nodev option set on /tmp partition
1.1.2.3 Ensure noexec option set on /tmp partition
1.1.2.4 Ensure nosuid option set on /tmp partition
1.1.3.1 Ensure separate partition exists for /var
1.1.3.2 Ensure nodev option set on /var partition
1.1.3.3 Ensure nosuid option set on /var partition
1.1.4.1 Ensure separate partition exists for /var/tmp
1.1.4.2 Ensure nodev option set on /var/tmp partition
1.1.4.3 Ensure noexec option set on /var/tmp partition
1.1.4.4 Ensure nosuid option set on /var/tmp partition
1.1.5.2 Ensure nodev option set on /var/log partition
1.1.5.3 Ensure noexec option set on /var/log partition
1.1.5.4 Ensure nosuid option set on /var/log partition
1.1.6.2 Ensure nodev option set on /var/log/audit partition
1.1.6.3 Ensure noexec option set on /var/log/audit partition
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
1.1.7.1 Ensure separate partition exists for /home
1.1.7.2 Ensure nodev option set on /home partition
1.1.7.3 Ensure nosuid option set on /home partition
1.1.8.1 Ensure nodev option set on /dev/shm partition
1.1.8.2 Ensure noexec option set on /dev/shm partition
1.1.8.3 Ensure nosuid option set on /dev/shm partition
1.1.9 Disable Automounting
1.1.10 Disable USB Storage
1.3.1 Ensure updates, patches, and additional security
software are installed
Page 863
Recommendation Set
Correctly
Yes No
1.3.2 Ensure package manager repositories are configured
1.3.3 Ensure GPG keys are configured
1.4.2 Ensure permissions on bootloader config are configured
1.6.1.1 Ensure AppArmor is installed
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode
1.6.1.4 Ensure all AppArmor Profiles are enforcing
1.7.4 Ensure permissions on /etc/motd are configured
1.7.5 Ensure permissions on /etc/issue are configured
1.7.6 Ensure permissions on /etc/issue.net are configured
1.8.4 Ensure GDM screen locks when the user is idle
1.8.5 Ensure GDM screen locks cannot be overridden
1.8.6 Ensure GDM automatic mounting of removable media is
disabled
1.8.8 Ensure GDM autorun-never is enabled
1.8.9 Ensure GDM autorun-never is not overridden
2.2.1 Ensure X Window System is not installed
2.3.1 Ensure NIS Client is not installed
3.3.4 Ensure suspicious packets are logged
3.4.1.1 Ensure ufw is installed
3.4.1.2 Ensure iptables-persistent is not installed with ufw
3.4.1.3 Ensure ufw service is enabled
3.4.1.4 Ensure ufw loopback traffic is configured
3.4.1.5 Ensure ufw outbound connections are configured
3.4.1.6 Ensure ufw firewall rules exist for all open ports
3.4.1.7 Ensure ufw default deny firewall policy
3.4.2.1 Ensure nftables is installed
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
3.4.2.3 Ensure iptables are flushed with nftables
3.4.2.4 Ensure a nftables table exists
Page 864
Recommendation Set
Correctly
Yes No
3.4.2.5 Ensure nftables base chains exist
3.4.2.6 Ensure nftables loopback traffic is configured
3.4.2.7 Ensure nftables outbound and established connections
are configured
3.4.2.8 Ensure nftables default deny firewall policy
3.4.2.9 Ensure nftables service is enabled
3.4.2.10 Ensure nftables rules are permanent
3.4.3.1.1 Ensure iptables packages are installed
3.4.3.1.2 Ensure nftables is not installed with iptables
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
3.4.3.2.1 Ensure iptables default deny firewall policy
3.4.3.2.2 Ensure iptables loopback traffic is configured
3.4.3.2.3 Ensure iptables outbound and established connections
are configured
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
3.4.3.3.1 Ensure ip6tables default deny firewall policy
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
4.1.2 Ensure permissions on /etc/crontab are configured
4.1.3 Ensure permissions on /etc/cron.hourly are configured
4.1.4 Ensure permissions on /etc/cron.daily are configured
4.1.5 Ensure permissions on /etc/cron.weekly are configured
4.1.6 Ensure permissions on /etc/cron.monthly are configured
4.1.7 Ensure permissions on /etc/cron.d are configured
4.1.8 Ensure cron is restricted to authorized users
4.1.9 Ensure at is restricted to authorized users
4.2.1 Ensure permissions on /etc/ssh/sshd_config are
configured
4.2.2 Ensure permissions on SSH private host key files are
configured
Page 865
Recommendation Set
Correctly
Yes No
4.2.3 Ensure permissions on SSH public host key files are
configured
4.2.4 Ensure SSH access is limited
4.2.5 Ensure SSH LogLevel is appropriate
4.2.7 Ensure SSH root login is disabled
4.2.19 Ensure SSH MaxStartups is configured
4.3.1 Ensure sudo is installed
4.3.2 Ensure sudo commands use pty
4.3.4 Ensure users must provide password for privilege
escalation
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally
4.3.6 Ensure sudo authentication timeout is configured
correctly
4.3.7 Ensure access to the su command is restricted
4.5.2 Ensure system accounts are secured
4.5.3 Ensure default group for the root account is GID 0
4.5.4 Ensure default user umask is 027 or more restrictive
4.5.5 Ensure default user shell timeout is configured
5.1.1.1.1 Ensure systemd-journal-remote is installed
5.1.1.1.2 Ensure systemd-journal-remote is configured
5.1.1.1.3 Ensure systemd-journal-remote is enabled
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client
5.1.1.2 Ensure journald service is enabled
5.1.1.3 Ensure journald is configured to compress large log files
5.1.1.4 Ensure journald is configured to write logfiles to
persistent disk
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
5.1.1.6 Ensure journald log rotation is configured per site policy
5.1.1.7 Ensure journald default file permissions configured
5.1.2.1 Ensure rsyslog is installed
5.1.2.2 Ensure rsyslog service is enabled
Page 866
Recommendation Set
Correctly
Yes No
5.1.2.3 Ensure journald is configured to send logs to rsyslog
5.1.2.4 Ensure rsyslog default file permissions are configured
5.1.2.5 Ensure logging is configured
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client
5.1.3 Ensure all logfiles have appropriate access configured
5.2.1.1 Ensure auditd is installed
5.2.1.2 Ensure auditd service is enabled and active
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled
5.2.1.4 Ensure audit_backlog_limit is sufficient
5.2.3.6 Ensure use of privileged commands are collected
5.2.3.12 Ensure login and logout events are collected
5.2.3.13 Ensure file deletion events by users are collected
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded
5.2.3.19 Ensure kernel module loading unloading and modification
is collected
5.2.3.20 Ensure the audit configuration is immutable
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
5.2.4.2 Ensure only authorized users own audit log files
5.2.4.3 Ensure only authorized groups are assigned ownership
of audit log files
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
5.2.4.5 Ensure audit configuration files are 640 or more
restrictive
Page 867
Recommendation Set
Correctly
Yes No
5.2.4.6 Ensure audit configuration files are owned by root
5.2.4.7 Ensure audit configuration files belong to group root
5.2.4.8 Ensure audit tools are 755 or more restrictive
5.2.4.9 Ensure audit tools are owned by root
5.2.4.10 Ensure audit tools belong to group root
6.1.1 Ensure permissions on /etc/passwd are configured
6.1.2 Ensure permissions on /etc/passwd- are configured
6.1.3 Ensure permissions on /etc/group are configured
6.1.4 Ensure permissions on /etc/group- are configured
6.1.5 Ensure permissions on /etc/shadow are configured
6.1.6 Ensure permissions on /etc/shadow- are configured
6.1.7 Ensure permissions on /etc/gshadow are configured
6.1.8 Ensure permissions on /etc/gshadow- are configured
6.1.9 Ensure permissions on /etc/shells are configured
6.1.10 Ensure permissions on /etc/opasswd are configured
6.1.11 Ensure world writable files and directories are secured
6.1.12 Ensure no unowned or ungrouped files or directories
exist
6.1.13 Ensure SUID and SGID files are reviewed
6.2.4 Ensure shadow group is empty
6.2.11 Ensure local interactive user home directories are
configured
6.2.12 Ensure local interactive user dot files access is
configured
Page 868
Appendix: CIS Controls v7 IG 2 Mapped
Recommendations
Recommendation Set
Correctly
Yes No
1.1.1.1 Ensure mounting of cramfs filesystems is disabled
1.1.1.2 Ensure mounting of freevxfs filesystems is disabled
1.1.1.3 Ensure mounting of jffs2 filesystems is disabled
1.1.1.4 Ensure mounting of hfs filesystems is disabled
1.1.1.5 Ensure mounting of hfsplus filesystems is disabled
1.1.1.6 Ensure mounting of squashfs filesystems is disabled
1.1.1.7 Ensure mounting of udf filesystems is disabled
1.1.2.1 Ensure /tmp is a separate partition
1.1.2.2 Ensure nodev option set on /tmp partition
1.1.2.3 Ensure noexec option set on /tmp partition
1.1.2.4 Ensure nosuid option set on /tmp partition
1.1.3.1 Ensure separate partition exists for /var
1.1.3.2 Ensure nodev option set on /var partition
1.1.3.3 Ensure nosuid option set on /var partition
1.1.4.1 Ensure separate partition exists for /var/tmp
1.1.4.2 Ensure nodev option set on /var/tmp partition
1.1.4.3 Ensure noexec option set on /var/tmp partition
1.1.4.4 Ensure nosuid option set on /var/tmp partition
1.1.5.1 Ensure separate partition exists for /var/log
1.1.5.2 Ensure nodev option set on /var/log partition
1.1.5.3 Ensure noexec option set on /var/log partition
1.1.5.4 Ensure nosuid option set on /var/log partition
1.1.6.1 Ensure separate partition exists for /var/log/audit
1.1.6.2 Ensure nodev option set on /var/log/audit partition
1.1.6.3 Ensure noexec option set on /var/log/audit partition
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
1.1.7.1 Ensure separate partition exists for /home
Page 869
Recommendation Set
Correctly
Yes No
1.1.7.2 Ensure nodev option set on /home partition
1.1.7.3 Ensure nosuid option set on /home partition
1.1.8.1 Ensure nodev option set on /dev/shm partition
1.1.8.2 Ensure noexec option set on /dev/shm partition
1.1.8.3 Ensure nosuid option set on /dev/shm partition
1.1.9 Disable Automounting
1.1.10 Disable USB Storage
1.3.1 Ensure updates, patches, and additional security
software are installed
1.3.2 Ensure package manager repositories are configured
1.3.3 Ensure GPG keys are configured
1.4.1 Ensure bootloader password is set
1.4.2 Ensure permissions on bootloader config are configured
1.4.3 Ensure authentication required for single user mode
1.5.2 Ensure address space layout randomization (ASLR) is
enabled
1.5.3 Ensure ptrace_scope is restricted
1.5.4 Ensure Automatic Error Reporting is not enabled
1.6.1.1 Ensure AppArmor is installed
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode
1.6.1.4 Ensure all AppArmor Profiles are enforcing
1.7.4 Ensure permissions on /etc/motd are configured
1.7.5 Ensure permissions on /etc/issue are configured
1.7.6 Ensure permissions on /etc/issue.net are configured
1.8.1 Ensure GNOME Display Manager is removed
1.8.4 Ensure GDM screen locks when the user is idle
1.8.5 Ensure GDM screen locks cannot be overridden
1.8.6 Ensure GDM automatic mounting of removable media is
disabled
1.8.8 Ensure GDM autorun-never is enabled
Page 870
Recommendation Set
Correctly
Yes No
1.8.9 Ensure GDM autorun-never is not overridden
1.8.10 Ensure XDCMP is not enabled
2.1.1.1 Ensure a single time synchronization daemon is in use
2.1.2.1 Ensure chrony is configured with authorized timeserver
2.1.2.2 Ensure chrony is running as user _chrony
2.1.2.3 Ensure chrony is enabled and running
2.1.3.1 Ensure systemd-timesyncd configured with authorized
timeserver
2.1.3.2 Ensure systemd-timesyncd is enabled and running
2.1.4.1 Ensure ntp access control is configured
2.1.4.2 Ensure ntp is configured with authorized timeserver
2.1.4.3 Ensure ntp is running as user ntp
2.1.4.4 Ensure ntp is enabled and running
2.2.1 Ensure X Window System is not installed
2.2.2 Ensure Avahi Server is not installed
2.2.3 Ensure CUPS is not installed
2.2.4 Ensure DHCP Server is not installed
2.2.5 Ensure LDAP server is not installed
2.2.6 Ensure NFS is not installed
2.2.7 Ensure DNS Server is not installed
2.2.8 Ensure FTP Server is not installed
2.2.9 Ensure HTTP server is not installed
2.2.10 Ensure IMAP and POP3 server are not installed
2.2.11 Ensure Samba is not installed
2.2.12 Ensure HTTP Proxy Server is not installed
2.2.13 Ensure SNMP Server is not installed
2.2.14 Ensure NIS Server is not installed
2.2.15 Ensure dnsmasq is not installed
2.2.16 Ensure mail transfer agent is configured for local-only
mode
2.2.17 Ensure rsync service is either not installed or is masked
2.3.1 Ensure NIS Client is not installed
Page 871
Recommendation Set
Correctly
Yes No
2.3.2 Ensure rsh client is not installed
2.3.3 Ensure talk client is not installed
2.3.4 Ensure telnet client is not installed
2.3.5 Ensure LDAP client is not installed
2.3.6 Ensure RPC is not installed
2.4 Ensure nonessential services are removed or masked
3.1.1 Ensure IPv6 status is identified
3.1.3 Ensure bluetooth is disabled
3.1.4 Ensure DCCP is disabled
3.1.5 Ensure SCTP is disabled
3.1.6 Ensure RDS is disabled
3.1.7 Ensure TIPC is disabled
3.2.1 Ensure packet redirect sending is disabled
3.2.2 Ensure IP forwarding is disabled
3.3.1 Ensure source routed packets are not accepted
3.3.2 Ensure ICMP redirects are not accepted
3.3.3 Ensure secure ICMP redirects are not accepted
3.3.4 Ensure suspicious packets are logged
3.3.5 Ensure broadcast ICMP requests are ignored
3.3.6 Ensure bogus ICMP responses are ignored
3.3.7 Ensure Reverse Path Filtering is enabled
3.3.8 Ensure TCP SYN Cookies is enabled
3.3.9 Ensure IPv6 router advertisements are not accepted
3.4.1.1 Ensure ufw is installed
3.4.1.2 Ensure iptables-persistent is not installed with ufw
3.4.1.3 Ensure ufw service is enabled
3.4.1.4 Ensure ufw loopback traffic is configured
3.4.1.5 Ensure ufw outbound connections are configured
3.4.1.6 Ensure ufw firewall rules exist for all open ports
3.4.1.7 Ensure ufw default deny firewall policy
3.4.2.1 Ensure nftables is installed
Page 872
Recommendation Set
Correctly
Yes No
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
3.4.2.3 Ensure iptables are flushed with nftables
3.4.2.4 Ensure a nftables table exists
3.4.2.5 Ensure nftables base chains exist
3.4.2.6 Ensure nftables loopback traffic is configured
3.4.2.7 Ensure nftables outbound and established connections
are configured
3.4.2.8 Ensure nftables default deny firewall policy
3.4.2.9 Ensure nftables service is enabled
3.4.2.10 Ensure nftables rules are permanent
3.4.3.1.1 Ensure iptables packages are installed
3.4.3.1.2 Ensure nftables is not installed with iptables
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
3.4.3.2.1 Ensure iptables default deny firewall policy
3.4.3.2.2 Ensure iptables loopback traffic is configured
3.4.3.2.3 Ensure iptables outbound and established connections
are configured
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
3.4.3.3.1 Ensure ip6tables default deny firewall policy
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
4.1.2 Ensure permissions on /etc/crontab are configured
4.1.3 Ensure permissions on /etc/cron.hourly are configured
4.1.4 Ensure permissions on /etc/cron.daily are configured
4.1.5 Ensure permissions on /etc/cron.weekly are configured
4.1.6 Ensure permissions on /etc/cron.monthly are configured
4.1.7 Ensure permissions on /etc/cron.d are configured
4.1.8 Ensure cron is restricted to authorized users
4.1.9 Ensure at is restricted to authorized users
Page 873
Recommendation Set
Correctly
Yes No
4.2.1 Ensure permissions on /etc/ssh/sshd_config are
configured
4.2.2 Ensure permissions on SSH private host key files are
configured
4.2.3 Ensure permissions on SSH public host key files are
configured
4.2.4 Ensure SSH access is limited
4.2.5 Ensure SSH LogLevel is appropriate
4.2.6 Ensure SSH PAM is enabled
4.2.7 Ensure SSH root login is disabled
4.2.9 Ensure SSH PermitEmptyPasswords is disabled
4.2.11 Ensure SSH IgnoreRhosts is enabled
4.2.12 Ensure SSH X11 forwarding is disabled
4.2.13 Ensure only strong Ciphers are used
4.2.14 Ensure only strong MAC algorithms are used
4.2.15 Ensure only strong Key Exchange algorithms are used
4.2.19 Ensure SSH MaxStartups is configured
4.3.1 Ensure sudo is installed
4.3.2 Ensure sudo commands use pty
4.3.3 Ensure sudo log file exists
4.3.4 Ensure users must provide password for privilege
escalation
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally
4.3.6 Ensure sudo authentication timeout is configured
correctly
4.3.7 Ensure access to the su command is restricted
4.4.1 Ensure password creation requirements are configured
4.4.2 Ensure lockout for failed password attempts is configured
4.4.3 Ensure password reuse is limited
4.4.4 Ensure strong password hashing algorithm is configured
4.4.5 Ensure all current passwords uses the configured
hashing algorithm
Page 874
Recommendation Set
Correctly
Yes No
4.5.1.1 Ensure minimum days between password changes is
configured
4.5.1.2 Ensure password expiration is 365 days or less
4.5.1.3 Ensure password expiration warning days is 7 or more
4.5.1.4 Ensure inactive password lock is 30 days or less
4.5.1.5 Ensure all users last password change date is in the past
4.5.1.6 Ensure the number of changed characters in a new
password is configured
4.5.1.7 Ensure preventing the use of dictionary words for
passwords is configured
4.5.2 Ensure system accounts are secured
4.5.3 Ensure default group for the root account is GID 0
4.5.4 Ensure default user umask is 027 or more restrictive
4.5.5 Ensure default user shell timeout is configured
4.5.7 Ensure maximum number of same consecutive
characters in a password is configured
5.1.1.1.1 Ensure systemd-journal-remote is installed
5.1.1.1.2 Ensure systemd-journal-remote is configured
5.1.1.1.3 Ensure systemd-journal-remote is enabled
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client
5.1.1.2 Ensure journald service is enabled
5.1.1.3 Ensure journald is configured to compress large log files
5.1.1.4 Ensure journald is configured to write logfiles to
persistent disk
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
5.1.1.6 Ensure journald log rotation is configured per site policy
5.1.1.7 Ensure journald default file permissions configured
5.1.2.1 Ensure rsyslog is installed
5.1.2.2 Ensure rsyslog service is enabled
5.1.2.3 Ensure journald is configured to send logs to rsyslog
5.1.2.4 Ensure rsyslog default file permissions are configured
5.1.2.5 Ensure logging is configured
Page 875
Recommendation Set
Correctly
Yes No
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client
5.1.3 Ensure all logfiles have appropriate access configured
5.2.1.1 Ensure auditd is installed
5.2.1.2 Ensure auditd service is enabled and active
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled
5.2.1.4 Ensure audit_backlog_limit is sufficient
5.2.2.1 Ensure audit log storage size is configured
5.2.2.2 Ensure audit logs are not automatically deleted
5.2.2.3 Ensure system is disabled when audit logs are full
5.2.3.1 Ensure changes to system administration scope
(sudoers) is collected
5.2.3.2 Ensure actions as another user are always logged
5.2.3.3 Ensure events that modify the sudo log file are collected
5.2.3.4 Ensure events that modify date and time information are
collected
5.2.3.5 Ensure events that modify the system's network
environment are collected
5.2.3.6 Ensure use of privileged commands are collected
5.2.3.8 Ensure events that modify user/group information are
collected
5.2.3.9 Ensure discretionary access control permission
modification events are collected
5.2.3.10 Ensure successful file system mounts are collected
5.2.3.11 Ensure session initiation information is collected
5.2.3.12 Ensure login and logout events are collected
5.2.3.13 Ensure file deletion events by users are collected
5.2.3.14 Ensure events that modify the system's Mandatory
Access Controls are collected
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded
Page 876
Recommendation Set
Correctly
Yes No
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded
5.2.3.19 Ensure kernel module loading unloading and modification
is collected
5.2.3.20 Ensure the audit configuration is immutable
5.2.3.21 Ensure the running and on disk configuration is the same
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
5.2.4.2 Ensure only authorized users own audit log files
5.2.4.3 Ensure only authorized groups are assigned ownership
of audit log files
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
5.2.4.5 Ensure audit configuration files are 640 or more
restrictive
5.2.4.6 Ensure audit configuration files are owned by root
5.2.4.7 Ensure audit configuration files belong to group root
5.2.4.8 Ensure audit tools are 755 or more restrictive
5.2.4.9 Ensure audit tools are owned by root
5.2.4.10 Ensure audit tools belong to group root
6.1.1 Ensure permissions on /etc/passwd are configured
6.1.2 Ensure permissions on /etc/passwd- are configured
6.1.3 Ensure permissions on /etc/group are configured
6.1.4 Ensure permissions on /etc/group- are configured
6.1.5 Ensure permissions on /etc/shadow are configured
6.1.6 Ensure permissions on /etc/shadow- are configured
6.1.7 Ensure permissions on /etc/gshadow are configured
6.1.8 Ensure permissions on /etc/gshadow- are configured
6.1.9 Ensure permissions on /etc/shells are configured
6.1.10 Ensure permissions on /etc/opasswd are configured
6.1.11 Ensure world writable files and directories are secured
Page 877
Recommendation Set
Correctly
Yes No
6.1.12 Ensure no unowned or ungrouped files or directories
exist
6.1.13 Ensure SUID and SGID files are reviewed
6.2.1 Ensure accounts in /etc/passwd use shadowed
passwords
6.2.2 Ensure /etc/shadow password fields are not empty
6.2.4 Ensure shadow group is empty
6.2.11 Ensure local interactive user home directories are
configured
6.2.12 Ensure local interactive user dot files access is
configured
Page 878
Appendix: CIS Controls v7 IG 3 Mapped
Recommendations
Recommendation Set
Correctly
Yes No
1.1.1.1 Ensure mounting of cramfs filesystems is disabled
1.1.1.2 Ensure mounting of freevxfs filesystems is disabled
1.1.1.3 Ensure mounting of jffs2 filesystems is disabled
1.1.1.4 Ensure mounting of hfs filesystems is disabled
1.1.1.5 Ensure mounting of hfsplus filesystems is disabled
1.1.1.6 Ensure mounting of squashfs filesystems is disabled
1.1.1.7 Ensure mounting of udf filesystems is disabled
1.1.2.1 Ensure /tmp is a separate partition
1.1.2.2 Ensure nodev option set on /tmp partition
1.1.2.3 Ensure noexec option set on /tmp partition
1.1.2.4 Ensure nosuid option set on /tmp partition
1.1.3.1 Ensure separate partition exists for /var
1.1.3.2 Ensure nodev option set on /var partition
1.1.3.3 Ensure nosuid option set on /var partition
1.1.4.1 Ensure separate partition exists for /var/tmp
1.1.4.2 Ensure nodev option set on /var/tmp partition
1.1.4.3 Ensure noexec option set on /var/tmp partition
1.1.4.4 Ensure nosuid option set on /var/tmp partition
1.1.5.1 Ensure separate partition exists for /var/log
1.1.5.2 Ensure nodev option set on /var/log partition
1.1.5.3 Ensure noexec option set on /var/log partition
1.1.5.4 Ensure nosuid option set on /var/log partition
1.1.6.1 Ensure separate partition exists for /var/log/audit
1.1.6.2 Ensure nodev option set on /var/log/audit partition
1.1.6.3 Ensure noexec option set on /var/log/audit partition
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
1.1.7.1 Ensure separate partition exists for /home
Page 879
Recommendation Set
Correctly
Yes No
1.1.7.2 Ensure nodev option set on /home partition
1.1.7.3 Ensure nosuid option set on /home partition
1.1.8.1 Ensure nodev option set on /dev/shm partition
1.1.8.2 Ensure noexec option set on /dev/shm partition
1.1.8.3 Ensure nosuid option set on /dev/shm partition
1.1.9 Disable Automounting
1.1.10 Disable USB Storage
1.2.1 Ensure AIDE is installed
1.2.2 Ensure filesystem integrity is regularly checked
1.3.1 Ensure updates, patches, and additional security
software are installed
1.3.2 Ensure package manager repositories are configured
1.3.3 Ensure GPG keys are configured
1.4.1 Ensure bootloader password is set
1.4.2 Ensure permissions on bootloader config are configured
1.4.3 Ensure authentication required for single user mode
1.5.1 Ensure prelink is not installed
1.5.2 Ensure address space layout randomization (ASLR) is
enabled
1.5.3 Ensure ptrace_scope is restricted
1.5.4 Ensure Automatic Error Reporting is not enabled
1.6.1.1 Ensure AppArmor is installed
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode
1.6.1.4 Ensure all AppArmor Profiles are enforcing
1.7.4 Ensure permissions on /etc/motd are configured
1.7.5 Ensure permissions on /etc/issue are configured
1.7.6 Ensure permissions on /etc/issue.net are configured
1.8.1 Ensure GNOME Display Manager is removed
1.8.4 Ensure GDM screen locks when the user is idle
Page 880
Recommendation Set
Correctly
Yes No
1.8.5 Ensure GDM screen locks cannot be overridden
1.8.6 Ensure GDM automatic mounting of removable media is
disabled
1.8.8 Ensure GDM autorun-never is enabled
1.8.9 Ensure GDM autorun-never is not overridden
1.8.10 Ensure XDCMP is not enabled
2.1.1.1 Ensure a single time synchronization daemon is in use
2.1.2.1 Ensure chrony is configured with authorized timeserver
2.1.2.2 Ensure chrony is running as user _chrony
2.1.2.3 Ensure chrony is enabled and running
2.1.3.1 Ensure systemd-timesyncd configured with authorized
timeserver
2.1.3.2 Ensure systemd-timesyncd is enabled and running
2.1.4.1 Ensure ntp access control is configured
2.1.4.2 Ensure ntp is configured with authorized timeserver
2.1.4.3 Ensure ntp is running as user ntp
2.1.4.4 Ensure ntp is enabled and running
2.2.1 Ensure X Window System is not installed
2.2.2 Ensure Avahi Server is not installed
2.2.3 Ensure CUPS is not installed
2.2.4 Ensure DHCP Server is not installed
2.2.5 Ensure LDAP server is not installed
2.2.6 Ensure NFS is not installed
2.2.7 Ensure DNS Server is not installed
2.2.8 Ensure FTP Server is not installed
2.2.9 Ensure HTTP server is not installed
2.2.10 Ensure IMAP and POP3 server are not installed
2.2.11 Ensure Samba is not installed
2.2.12 Ensure HTTP Proxy Server is not installed
2.2.13 Ensure SNMP Server is not installed
2.2.14 Ensure NIS Server is not installed
2.2.15 Ensure dnsmasq is not installed
Page 881
Recommendation Set
Correctly
Yes No
2.2.16 Ensure mail transfer agent is configured for local-only
mode
2.2.17 Ensure rsync service is either not installed or is masked
2.3.1 Ensure NIS Client is not installed
2.3.2 Ensure rsh client is not installed
2.3.3 Ensure talk client is not installed
2.3.4 Ensure telnet client is not installed
2.3.5 Ensure LDAP client is not installed
2.3.6 Ensure RPC is not installed
2.4 Ensure nonessential services are removed or masked
3.1.1 Ensure IPv6 status is identified
3.1.2 Ensure wireless interfaces are disabled
3.1.3 Ensure bluetooth is disabled
3.1.4 Ensure DCCP is disabled
3.1.5 Ensure SCTP is disabled
3.1.6 Ensure RDS is disabled
3.1.7 Ensure TIPC is disabled
3.2.1 Ensure packet redirect sending is disabled
3.2.2 Ensure IP forwarding is disabled
3.3.1 Ensure source routed packets are not accepted
3.3.2 Ensure ICMP redirects are not accepted
3.3.3 Ensure secure ICMP redirects are not accepted
3.3.4 Ensure suspicious packets are logged
3.3.5 Ensure broadcast ICMP requests are ignored
3.3.6 Ensure bogus ICMP responses are ignored
3.3.7 Ensure Reverse Path Filtering is enabled
3.3.8 Ensure TCP SYN Cookies is enabled
3.3.9 Ensure IPv6 router advertisements are not accepted
3.4.1.1 Ensure ufw is installed
3.4.1.2 Ensure iptables-persistent is not installed with ufw
3.4.1.3 Ensure ufw service is enabled
Page 882
Recommendation Set
Correctly
Yes No
3.4.1.4 Ensure ufw loopback traffic is configured
3.4.1.5 Ensure ufw outbound connections are configured
3.4.1.6 Ensure ufw firewall rules exist for all open ports
3.4.1.7 Ensure ufw default deny firewall policy
3.4.2.1 Ensure nftables is installed
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
3.4.2.3 Ensure iptables are flushed with nftables
3.4.2.4 Ensure a nftables table exists
3.4.2.5 Ensure nftables base chains exist
3.4.2.6 Ensure nftables loopback traffic is configured
3.4.2.7 Ensure nftables outbound and established connections
are configured
3.4.2.8 Ensure nftables default deny firewall policy
3.4.2.9 Ensure nftables service is enabled
3.4.2.10 Ensure nftables rules are permanent
3.4.3.1.1 Ensure iptables packages are installed
3.4.3.1.2 Ensure nftables is not installed with iptables
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
3.4.3.2.1 Ensure iptables default deny firewall policy
3.4.3.2.2 Ensure iptables loopback traffic is configured
3.4.3.2.3 Ensure iptables outbound and established connections
are configured
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
3.4.3.3.1 Ensure ip6tables default deny firewall policy
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
4.1.2 Ensure permissions on /etc/crontab are configured
4.1.3 Ensure permissions on /etc/cron.hourly are configured
4.1.4 Ensure permissions on /etc/cron.daily are configured
4.1.5 Ensure permissions on /etc/cron.weekly are configured
Page 883
Recommendation Set
Correctly
Yes No
4.1.6 Ensure permissions on /etc/cron.monthly are configured
4.1.7 Ensure permissions on /etc/cron.d are configured
4.1.8 Ensure cron is restricted to authorized users
4.1.9 Ensure at is restricted to authorized users
4.2.1 Ensure permissions on /etc/ssh/sshd_config are
configured
4.2.2 Ensure permissions on SSH private host key files are
configured
4.2.3 Ensure permissions on SSH public host key files are
configured
4.2.4 Ensure SSH access is limited
4.2.5 Ensure SSH LogLevel is appropriate
4.2.6 Ensure SSH PAM is enabled
4.2.7 Ensure SSH root login is disabled
4.2.9 Ensure SSH PermitEmptyPasswords is disabled
4.2.11 Ensure SSH IgnoreRhosts is enabled
4.2.12 Ensure SSH X11 forwarding is disabled
4.2.13 Ensure only strong Ciphers are used
4.2.14 Ensure only strong MAC algorithms are used
4.2.15 Ensure only strong Key Exchange algorithms are used
4.2.18 Ensure SSH MaxAuthTries is set to 4 or less
4.2.19 Ensure SSH MaxStartups is configured
4.3.1 Ensure sudo is installed
4.3.2 Ensure sudo commands use pty
4.3.3 Ensure sudo log file exists
4.3.4 Ensure users must provide password for privilege
escalation
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally
4.3.6 Ensure sudo authentication timeout is configured
correctly
4.3.7 Ensure access to the su command is restricted
4.4.1 Ensure password creation requirements are configured
Page 884
Recommendation Set
Correctly
Yes No
4.4.2 Ensure lockout for failed password attempts is configured
4.4.3 Ensure password reuse is limited
4.4.4 Ensure strong password hashing algorithm is configured
4.4.5 Ensure all current passwords uses the configured
hashing algorithm
4.5.1.1 Ensure minimum days between password changes is
configured
4.5.1.2 Ensure password expiration is 365 days or less
4.5.1.3 Ensure password expiration warning days is 7 or more
4.5.1.4 Ensure inactive password lock is 30 days or less
4.5.1.5 Ensure all users last password change date is in the past
4.5.1.6 Ensure the number of changed characters in a new
password is configured
4.5.1.7 Ensure preventing the use of dictionary words for
passwords is configured
4.5.2 Ensure system accounts are secured
4.5.3 Ensure default group for the root account is GID 0
4.5.4 Ensure default user umask is 027 or more restrictive
4.5.5 Ensure default user shell timeout is configured
4.5.7 Ensure maximum number of same consecutive
characters in a password is configured
5.1.1.1.1 Ensure systemd-journal-remote is installed
5.1.1.1.2 Ensure systemd-journal-remote is configured
5.1.1.1.3 Ensure systemd-journal-remote is enabled
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client
5.1.1.2 Ensure journald service is enabled
5.1.1.3 Ensure journald is configured to compress large log files
5.1.1.4 Ensure journald is configured to write logfiles to
persistent disk
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
5.1.1.6 Ensure journald log rotation is configured per site policy
5.1.1.7 Ensure journald default file permissions configured
Page 885
Recommendation Set
Correctly
Yes No
5.1.2.1 Ensure rsyslog is installed
5.1.2.2 Ensure rsyslog service is enabled
5.1.2.3 Ensure journald is configured to send logs to rsyslog
5.1.2.4 Ensure rsyslog default file permissions are configured
5.1.2.5 Ensure logging is configured
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client
5.1.3 Ensure all logfiles have appropriate access configured
5.2.1.1 Ensure auditd is installed
5.2.1.2 Ensure auditd service is enabled and active
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled
5.2.1.4 Ensure audit_backlog_limit is sufficient
5.2.2.1 Ensure audit log storage size is configured
5.2.2.2 Ensure audit logs are not automatically deleted
5.2.2.3 Ensure system is disabled when audit logs are full
5.2.3.1 Ensure changes to system administration scope
(sudoers) is collected
5.2.3.2 Ensure actions as another user are always logged
5.2.3.3 Ensure events that modify the sudo log file are collected
5.2.3.4 Ensure events that modify date and time information are
collected
5.2.3.5 Ensure events that modify the system's network
environment are collected
5.2.3.6 Ensure use of privileged commands are collected
5.2.3.7 Ensure unsuccessful file access attempts are collected
5.2.3.8 Ensure events that modify user/group information are
collected
5.2.3.9 Ensure discretionary access control permission
modification events are collected
5.2.3.10 Ensure successful file system mounts are collected
Page 886
Recommendation Set
Correctly
Yes No
5.2.3.11 Ensure session initiation information is collected
5.2.3.12 Ensure login and logout events are collected
5.2.3.13 Ensure file deletion events by users are collected
5.2.3.14 Ensure events that modify the system's Mandatory
Access Controls are collected
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded
5.2.3.19 Ensure kernel module loading unloading and modification
is collected
5.2.3.20 Ensure the audit configuration is immutable
5.2.3.21 Ensure the running and on disk configuration is the same
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
5.2.4.2 Ensure only authorized users own audit log files
5.2.4.3 Ensure only authorized groups are assigned ownership
of audit log files
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
5.2.4.5 Ensure audit configuration files are 640 or more
restrictive
5.2.4.6 Ensure audit configuration files are owned by root
5.2.4.7 Ensure audit configuration files belong to group root
5.2.4.8 Ensure audit tools are 755 or more restrictive
5.2.4.9 Ensure audit tools are owned by root
5.2.4.10 Ensure audit tools belong to group root
6.1.1 Ensure permissions on /etc/passwd are configured
6.1.2 Ensure permissions on /etc/passwd- are configured
6.1.3 Ensure permissions on /etc/group are configured
6.1.4 Ensure permissions on /etc/group- are configured
Page 887
Recommendation Set
Correctly
Yes No
6.1.5 Ensure permissions on /etc/shadow are configured
6.1.6 Ensure permissions on /etc/shadow- are configured
6.1.7 Ensure permissions on /etc/gshadow are configured
6.1.8 Ensure permissions on /etc/gshadow- are configured
6.1.9 Ensure permissions on /etc/shells are configured
6.1.10 Ensure permissions on /etc/opasswd are configured
6.1.11 Ensure world writable files and directories are secured
6.1.12 Ensure no unowned or ungrouped files or directories
exist
6.1.13 Ensure SUID and SGID files are reviewed
6.2.1 Ensure accounts in /etc/passwd use shadowed
passwords
6.2.2 Ensure /etc/shadow password fields are not empty
6.2.4 Ensure shadow group is empty
6.2.11 Ensure local interactive user home directories are
configured
6.2.12 Ensure local interactive user dot files access is
configured
Page 888
Appendix: CIS Controls v7 Unmapped
Recommendations
Recommendation Set
Correctly
Yes No
1.5.5 Ensure core dumps are restricted
1.7.1 Ensure message of the day is configured properly
1.7.2 Ensure local login warning banner is configured properly
1.7.3 Ensure remote login warning banner is configured
properly
1.8.2 Ensure GDM login banner is configured
1.8.3 Ensure GDM disable-user-list option is enabled
1.8.7 Ensure GDM disabling automatic mounting of removable
media is not overridden
4.1.1 Ensure cron daemon is enabled and active
4.2.8 Ensure SSH HostbasedAuthentication is disabled
4.2.10 Ensure SSH PermitUserEnvironment is disabled
4.2.16 Ensure SSH AllowTcpForwarding is disabled
4.2.17 Ensure SSH warning banner is configured
4.2.20 Ensure SSH LoginGraceTime is set to one minute or less
4.2.21 Ensure SSH MaxSessions is set to 10 or less
4.2.22 Ensure SSH Idle Timeout Interval is configured
4.5.6 Ensure nologin is not listed in /etc/shells
5.2.4.11 Ensure cryptographic mechanisms are used to protect
the integrity of audit tools
6.2.3 Ensure all groups in /etc/passwd exist in /etc/group
6.2.5 Ensure no duplicate UIDs exist
6.2.6 Ensure no duplicate GIDs exist
6.2.7 Ensure no duplicate user names exist
6.2.8 Ensure no duplicate group names exist
6.2.9 Ensure root PATH Integrity
6.2.10 Ensure root is the only UID 0 account
Page 889
Page 890
Appendix: CIS Controls v8 IG 1 Mapped
Recommendations
Recommendation Set
Correctly
Yes No
1.1.2.1 Ensure /tmp is a separate partition
1.1.2.2 Ensure nodev option set on /tmp partition
1.1.2.3 Ensure noexec option set on /tmp partition
1.1.2.4 Ensure nosuid option set on /tmp partition
1.1.3.1 Ensure separate partition exists for /var
1.1.3.2 Ensure nodev option set on /var partition
1.1.3.3 Ensure nosuid option set on /var partition
1.1.4.1 Ensure separate partition exists for /var/tmp
1.1.4.2 Ensure nodev option set on /var/tmp partition
1.1.4.3 Ensure noexec option set on /var/tmp partition
1.1.4.4 Ensure nosuid option set on /var/tmp partition
1.1.5.1 Ensure separate partition exists for /var/log
1.1.5.2 Ensure nodev option set on /var/log partition
1.1.5.3 Ensure noexec option set on /var/log partition
1.1.5.4 Ensure nosuid option set on /var/log partition
1.1.6.1 Ensure separate partition exists for /var/log/audit
1.1.6.2 Ensure nodev option set on /var/log/audit partition
1.1.6.3 Ensure noexec option set on /var/log/audit partition
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
1.1.7.1 Ensure separate partition exists for /home
1.1.7.2 Ensure nodev option set on /home partition
1.1.7.3 Ensure nosuid option set on /home partition
1.1.8.1 Ensure nodev option set on /dev/shm partition
1.1.8.2 Ensure noexec option set on /dev/shm partition
1.1.8.3 Ensure nosuid option set on /dev/shm partition
1.1.9 Disable Automounting
1.1.10 Disable USB Storage
Page 891
Recommendation Set
Correctly
Yes No
1.3.1 Ensure updates, patches, and additional security
software are installed
1.3.2 Ensure package manager repositories are configured
1.3.3 Ensure GPG keys are configured
1.4.1 Ensure bootloader password is set
1.4.2 Ensure permissions on bootloader config are configured
1.4.3 Ensure authentication required for single user mode
1.6.1.1 Ensure AppArmor is installed
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode
1.6.1.4 Ensure all AppArmor Profiles are enforcing
1.7.4 Ensure permissions on /etc/motd are configured
1.7.5 Ensure permissions on /etc/issue are configured
1.7.6 Ensure permissions on /etc/issue.net are configured
1.8.4 Ensure GDM screen locks when the user is idle
1.8.5 Ensure GDM screen locks cannot be overridden
1.8.6 Ensure GDM automatic mounting of removable media is
disabled
1.8.8 Ensure GDM autorun-never is enabled
1.8.9 Ensure GDM autorun-never is not overridden
3.4.1.1 Ensure ufw is installed
3.4.1.2 Ensure iptables-persistent is not installed with ufw
3.4.1.3 Ensure ufw service is enabled
3.4.1.4 Ensure ufw loopback traffic is configured
3.4.1.5 Ensure ufw outbound connections are configured
3.4.1.6 Ensure ufw firewall rules exist for all open ports
3.4.1.7 Ensure ufw default deny firewall policy
3.4.2.1 Ensure nftables is installed
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
3.4.2.3 Ensure iptables are flushed with nftables
Page 892
Recommendation Set
Correctly
Yes No
3.4.2.4 Ensure a nftables table exists
3.4.2.5 Ensure nftables base chains exist
3.4.2.6 Ensure nftables loopback traffic is configured
3.4.2.7 Ensure nftables outbound and established connections
are configured
3.4.2.8 Ensure nftables default deny firewall policy
3.4.2.9 Ensure nftables service is enabled
3.4.2.10 Ensure nftables rules are permanent
3.4.3.1.1 Ensure iptables packages are installed
3.4.3.1.2 Ensure nftables is not installed with iptables
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
3.4.3.2.1 Ensure iptables default deny firewall policy
3.4.3.2.2 Ensure iptables loopback traffic is configured
3.4.3.2.3 Ensure iptables outbound and established connections
are configured
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
3.4.3.3.1 Ensure ip6tables default deny firewall policy
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
4.1.2 Ensure permissions on /etc/crontab are configured
4.1.3 Ensure permissions on /etc/cron.hourly are configured
4.1.4 Ensure permissions on /etc/cron.daily are configured
4.1.5 Ensure permissions on /etc/cron.weekly are configured
4.1.6 Ensure permissions on /etc/cron.monthly are configured
4.1.7 Ensure permissions on /etc/cron.d are configured
4.1.8 Ensure cron is restricted to authorized users
4.1.9 Ensure at is restricted to authorized users
4.2.1 Ensure permissions on /etc/ssh/sshd_config are
configured
4.2.2 Ensure permissions on SSH private host key files are
configured
Page 893
Recommendation Set
Correctly
Yes No
4.2.3 Ensure permissions on SSH public host key files are
configured
4.2.4 Ensure SSH access is limited
4.2.5 Ensure SSH LogLevel is appropriate
4.2.6 Ensure SSH PAM is enabled
4.2.7 Ensure SSH root login is disabled
4.2.9 Ensure SSH PermitEmptyPasswords is disabled
4.2.11 Ensure SSH IgnoreRhosts is enabled
4.2.19 Ensure SSH MaxStartups is configured
4.3.1 Ensure sudo is installed
4.3.2 Ensure sudo commands use pty
4.3.4 Ensure users must provide password for privilege
escalation
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally
4.3.6 Ensure sudo authentication timeout is configured
correctly
4.3.7 Ensure access to the su command is restricted
4.4.1 Ensure password creation requirements are configured
4.4.3 Ensure password reuse is limited
4.5.1.1 Ensure minimum days between password changes is
configured
4.5.1.2 Ensure password expiration is 365 days or less
4.5.1.3 Ensure password expiration warning days is 7 or more
4.5.1.4 Ensure inactive password lock is 30 days or less
4.5.1.5 Ensure all users last password change date is in the past
4.5.1.6 Ensure the number of changed characters in a new
password is configured
4.5.1.7 Ensure preventing the use of dictionary words for
passwords is configured
4.5.2 Ensure system accounts are secured
4.5.3 Ensure default group for the root account is GID 0
4.5.4 Ensure default user umask is 027 or more restrictive
Page 894
Recommendation Set
Correctly
Yes No
4.5.5 Ensure default user shell timeout is configured
4.5.7 Ensure maximum number of same consecutive
characters in a password is configured
5.1.1.1.1 Ensure systemd-journal-remote is installed
5.1.1.1.2 Ensure systemd-journal-remote is configured
5.1.1.1.3 Ensure systemd-journal-remote is enabled
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client
5.1.1.2 Ensure journald service is enabled
5.1.1.3 Ensure journald is configured to compress large log files
5.1.1.4 Ensure journald is configured to write logfiles to
persistent disk
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
5.1.1.6 Ensure journald log rotation is configured per site policy
5.1.1.7 Ensure journald default file permissions configured
5.1.2.1 Ensure rsyslog is installed
5.1.2.2 Ensure rsyslog service is enabled
5.1.2.3 Ensure journald is configured to send logs to rsyslog
5.1.2.4 Ensure rsyslog default file permissions are configured
5.1.2.5 Ensure logging is configured
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client
5.1.3 Ensure all logfiles have appropriate access configured
5.2.1.2 Ensure auditd service is enabled and active
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled
5.2.1.4 Ensure audit_backlog_limit is sufficient
5.2.2.1 Ensure audit log storage size is configured
5.2.2.2 Ensure audit logs are not automatically deleted
5.2.2.3 Ensure system is disabled when audit logs are full
Page 895
Recommendation Set
Correctly
Yes No
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded
5.2.3.20 Ensure the audit configuration is immutable
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
5.2.4.2 Ensure only authorized users own audit log files
5.2.4.3 Ensure only authorized groups are assigned ownership
of audit log files
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
5.2.4.5 Ensure audit configuration files are 640 or more
restrictive
5.2.4.6 Ensure audit configuration files are owned by root
5.2.4.7 Ensure audit configuration files belong to group root
5.2.4.8 Ensure audit tools are 755 or more restrictive
5.2.4.9 Ensure audit tools are owned by root
5.2.4.10 Ensure audit tools belong to group root
6.1.1 Ensure permissions on /etc/passwd are configured
6.1.2 Ensure permissions on /etc/passwd- are configured
6.1.3 Ensure permissions on /etc/group are configured
6.1.4 Ensure permissions on /etc/group- are configured
6.1.5 Ensure permissions on /etc/shadow are configured
6.1.6 Ensure permissions on /etc/shadow- are configured
6.1.7 Ensure permissions on /etc/gshadow are configured
6.1.8 Ensure permissions on /etc/gshadow- are configured
6.1.9 Ensure permissions on /etc/shells are configured
6.1.10 Ensure permissions on /etc/opasswd are configured
6.1.11 Ensure world writable files and directories are secured
Page 896
Recommendation Set
Correctly
Yes No
6.1.12 Ensure no unowned or ungrouped files or directories
exist
6.1.13 Ensure SUID and SGID files are reviewed
6.2.2 Ensure /etc/shadow password fields are not empty
6.2.4 Ensure shadow group is empty
6.2.11 Ensure local interactive user home directories are
configured
6.2.12 Ensure local interactive user dot files access is
configured
Page 897
Appendix: CIS Controls v8 IG 2 Mapped
Recommendations
Recommendation Set
Correctly
Yes No
1.1.1.1 Ensure mounting of cramfs filesystems is disabled
1.1.1.2 Ensure mounting of freevxfs filesystems is disabled
1.1.1.3 Ensure mounting of jffs2 filesystems is disabled
1.1.1.4 Ensure mounting of hfs filesystems is disabled
1.1.1.5 Ensure mounting of hfsplus filesystems is disabled
1.1.1.6 Ensure mounting of squashfs filesystems is disabled
1.1.1.7 Ensure mounting of udf filesystems is disabled
1.1.2.1 Ensure /tmp is a separate partition
1.1.2.2 Ensure nodev option set on /tmp partition
1.1.2.3 Ensure noexec option set on /tmp partition
1.1.2.4 Ensure nosuid option set on /tmp partition
1.1.3.1 Ensure separate partition exists for /var
1.1.3.2 Ensure nodev option set on /var partition
1.1.3.3 Ensure nosuid option set on /var partition
1.1.4.1 Ensure separate partition exists for /var/tmp
1.1.4.2 Ensure nodev option set on /var/tmp partition
1.1.4.3 Ensure noexec option set on /var/tmp partition
1.1.4.4 Ensure nosuid option set on /var/tmp partition
1.1.5.1 Ensure separate partition exists for /var/log
1.1.5.2 Ensure nodev option set on /var/log partition
1.1.5.3 Ensure noexec option set on /var/log partition
1.1.5.4 Ensure nosuid option set on /var/log partition
1.1.6.1 Ensure separate partition exists for /var/log/audit
1.1.6.2 Ensure nodev option set on /var/log/audit partition
1.1.6.3 Ensure noexec option set on /var/log/audit partition
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
1.1.7.1 Ensure separate partition exists for /home
Page 898
Recommendation Set
Correctly
Yes No
1.1.7.2 Ensure nodev option set on /home partition
1.1.7.3 Ensure nosuid option set on /home partition
1.1.8.1 Ensure nodev option set on /dev/shm partition
1.1.8.2 Ensure noexec option set on /dev/shm partition
1.1.8.3 Ensure nosuid option set on /dev/shm partition
1.1.9 Disable Automounting
1.1.10 Disable USB Storage
1.2.2 Ensure filesystem integrity is regularly checked
1.3.1 Ensure updates, patches, and additional security
software are installed
1.3.2 Ensure package manager repositories are configured
1.3.3 Ensure GPG keys are configured
1.4.1 Ensure bootloader password is set
1.4.2 Ensure permissions on bootloader config are configured
1.4.3 Ensure authentication required for single user mode
1.5.2 Ensure address space layout randomization (ASLR) is
enabled
1.5.3 Ensure ptrace_scope is restricted
1.5.4 Ensure Automatic Error Reporting is not enabled
1.6.1.1 Ensure AppArmor is installed
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode
1.6.1.4 Ensure all AppArmor Profiles are enforcing
1.7.4 Ensure permissions on /etc/motd are configured
1.7.5 Ensure permissions on /etc/issue are configured
1.7.6 Ensure permissions on /etc/issue.net are configured
1.8.1 Ensure GNOME Display Manager is removed
1.8.4 Ensure GDM screen locks when the user is idle
1.8.5 Ensure GDM screen locks cannot be overridden
1.8.6 Ensure GDM automatic mounting of removable media is
disabled
Page 899
Recommendation Set
Correctly
Yes No
1.8.8 Ensure GDM autorun-never is enabled
1.8.9 Ensure GDM autorun-never is not overridden
1.8.10 Ensure XDCMP is not enabled
2.1.1.1 Ensure a single time synchronization daemon is in use
2.1.2.1 Ensure chrony is configured with authorized timeserver
2.1.2.2 Ensure chrony is running as user _chrony
2.1.2.3 Ensure chrony is enabled and running
2.1.3.1 Ensure systemd-timesyncd configured with authorized
timeserver
2.1.3.2 Ensure systemd-timesyncd is enabled and running
2.1.4.1 Ensure ntp access control is configured
2.1.4.2 Ensure ntp is configured with authorized timeserver
2.1.4.3 Ensure ntp is running as user ntp
2.1.4.4 Ensure ntp is enabled and running
2.2.1 Ensure X Window System is not installed
2.2.2 Ensure Avahi Server is not installed
2.2.3 Ensure CUPS is not installed
2.2.4 Ensure DHCP Server is not installed
2.2.5 Ensure LDAP server is not installed
2.2.6 Ensure NFS is not installed
2.2.7 Ensure DNS Server is not installed
2.2.8 Ensure FTP Server is not installed
2.2.9 Ensure HTTP server is not installed
2.2.10 Ensure IMAP and POP3 server are not installed
2.2.11 Ensure Samba is not installed
2.2.12 Ensure HTTP Proxy Server is not installed
2.2.13 Ensure SNMP Server is not installed
2.2.14 Ensure NIS Server is not installed
2.2.15 Ensure dnsmasq is not installed
2.2.16 Ensure mail transfer agent is configured for local-only
mode
2.2.17 Ensure rsync service is either not installed or is masked
Page 900
Recommendation Set
Correctly
Yes No
2.3.1 Ensure NIS Client is not installed
2.3.2 Ensure rsh client is not installed
2.3.3 Ensure talk client is not installed
2.3.4 Ensure telnet client is not installed
2.3.5 Ensure LDAP client is not installed
2.3.6 Ensure RPC is not installed
2.4 Ensure nonessential services are removed or masked
3.1.1 Ensure IPv6 status is identified
3.1.2 Ensure wireless interfaces are disabled
3.1.3 Ensure bluetooth is disabled
3.1.4 Ensure DCCP is disabled
3.1.5 Ensure SCTP is disabled
3.1.6 Ensure RDS is disabled
3.1.7 Ensure TIPC is disabled
3.2.1 Ensure packet redirect sending is disabled
3.2.2 Ensure IP forwarding is disabled
3.3.1 Ensure source routed packets are not accepted
3.3.2 Ensure ICMP redirects are not accepted
3.3.3 Ensure secure ICMP redirects are not accepted
3.3.4 Ensure suspicious packets are logged
3.3.5 Ensure broadcast ICMP requests are ignored
3.3.6 Ensure bogus ICMP responses are ignored
3.3.7 Ensure Reverse Path Filtering is enabled
3.3.8 Ensure TCP SYN Cookies is enabled
3.3.9 Ensure IPv6 router advertisements are not accepted
3.4.1.1 Ensure ufw is installed
3.4.1.2 Ensure iptables-persistent is not installed with ufw
3.4.1.3 Ensure ufw service is enabled
3.4.1.4 Ensure ufw loopback traffic is configured
3.4.1.5 Ensure ufw outbound connections are configured
3.4.1.6 Ensure ufw firewall rules exist for all open ports
Page 901
Recommendation Set
Correctly
Yes No
3.4.1.7 Ensure ufw default deny firewall policy
3.4.2.1 Ensure nftables is installed
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
3.4.2.3 Ensure iptables are flushed with nftables
3.4.2.4 Ensure a nftables table exists
3.4.2.5 Ensure nftables base chains exist
3.4.2.6 Ensure nftables loopback traffic is configured
3.4.2.7 Ensure nftables outbound and established connections
are configured
3.4.2.8 Ensure nftables default deny firewall policy
3.4.2.9 Ensure nftables service is enabled
3.4.2.10 Ensure nftables rules are permanent
3.4.3.1.1 Ensure iptables packages are installed
3.4.3.1.2 Ensure nftables is not installed with iptables
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
3.4.3.2.1 Ensure iptables default deny firewall policy
3.4.3.2.2 Ensure iptables loopback traffic is configured
3.4.3.2.3 Ensure iptables outbound and established connections
are configured
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
3.4.3.3.1 Ensure ip6tables default deny firewall policy
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
4.1.2 Ensure permissions on /etc/crontab are configured
4.1.3 Ensure permissions on /etc/cron.hourly are configured
4.1.4 Ensure permissions on /etc/cron.daily are configured
4.1.5 Ensure permissions on /etc/cron.weekly are configured
4.1.6 Ensure permissions on /etc/cron.monthly are configured
4.1.7 Ensure permissions on /etc/cron.d are configured
4.1.8 Ensure cron is restricted to authorized users
Page 902
Recommendation Set
Correctly
Yes No
4.1.9 Ensure at is restricted to authorized users
4.2.1 Ensure permissions on /etc/ssh/sshd_config are
configured
4.2.2 Ensure permissions on SSH private host key files are
configured
4.2.3 Ensure permissions on SSH public host key files are
configured
4.2.4 Ensure SSH access is limited
4.2.5 Ensure SSH LogLevel is appropriate
4.2.6 Ensure SSH PAM is enabled
4.2.7 Ensure SSH root login is disabled
4.2.9 Ensure SSH PermitEmptyPasswords is disabled
4.2.11 Ensure SSH IgnoreRhosts is enabled
4.2.12 Ensure SSH X11 forwarding is disabled
4.2.13 Ensure only strong Ciphers are used
4.2.14 Ensure only strong MAC algorithms are used
4.2.15 Ensure only strong Key Exchange algorithms are used
4.2.18 Ensure SSH MaxAuthTries is set to 4 or less
4.2.19 Ensure SSH MaxStartups is configured
4.3.1 Ensure sudo is installed
4.3.2 Ensure sudo commands use pty
4.3.3 Ensure sudo log file exists
4.3.4 Ensure users must provide password for privilege
escalation
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally
4.3.6 Ensure sudo authentication timeout is configured
correctly
4.3.7 Ensure access to the su command is restricted
4.4.1 Ensure password creation requirements are configured
4.4.3 Ensure password reuse is limited
4.4.4 Ensure strong password hashing algorithm is configured
Page 903
Recommendation Set
Correctly
Yes No
4.4.5 Ensure all current passwords uses the configured
hashing algorithm
4.5.1.1 Ensure minimum days between password changes is
configured
4.5.1.2 Ensure password expiration is 365 days or less
4.5.1.3 Ensure password expiration warning days is 7 or more
4.5.1.4 Ensure inactive password lock is 30 days or less
4.5.1.5 Ensure all users last password change date is in the past
4.5.1.6 Ensure the number of changed characters in a new
password is configured
4.5.1.7 Ensure preventing the use of dictionary words for
passwords is configured
4.5.2 Ensure system accounts are secured
4.5.3 Ensure default group for the root account is GID 0
4.5.4 Ensure default user umask is 027 or more restrictive
4.5.5 Ensure default user shell timeout is configured
4.5.7 Ensure maximum number of same consecutive
characters in a password is configured
5.1.1.1.1 Ensure systemd-journal-remote is installed
5.1.1.1.2 Ensure systemd-journal-remote is configured
5.1.1.1.3 Ensure systemd-journal-remote is enabled
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client
5.1.1.2 Ensure journald service is enabled
5.1.1.3 Ensure journald is configured to compress large log files
5.1.1.4 Ensure journald is configured to write logfiles to
persistent disk
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
5.1.1.6 Ensure journald log rotation is configured per site policy
5.1.1.7 Ensure journald default file permissions configured
5.1.2.1 Ensure rsyslog is installed
5.1.2.2 Ensure rsyslog service is enabled
5.1.2.3 Ensure journald is configured to send logs to rsyslog
Page 904
Recommendation Set
Correctly
Yes No
5.1.2.4 Ensure rsyslog default file permissions are configured
5.1.2.5 Ensure logging is configured
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client
5.1.3 Ensure all logfiles have appropriate access configured
5.2.1.1 Ensure auditd is installed
5.2.1.2 Ensure auditd service is enabled and active
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled
5.2.1.4 Ensure audit_backlog_limit is sufficient
5.2.2.1 Ensure audit log storage size is configured
5.2.2.2 Ensure audit logs are not automatically deleted
5.2.2.3 Ensure system is disabled when audit logs are full
5.2.3.1 Ensure changes to system administration scope
(sudoers) is collected
5.2.3.2 Ensure actions as another user are always logged
5.2.3.3 Ensure events that modify the sudo log file are collected
5.2.3.4 Ensure events that modify date and time information are
collected
5.2.3.5 Ensure events that modify the system's network
environment are collected
5.2.3.6 Ensure use of privileged commands are collected
5.2.3.7 Ensure unsuccessful file access attempts are collected
5.2.3.8 Ensure events that modify user/group information are
collected
5.2.3.9 Ensure discretionary access control permission
modification events are collected
5.2.3.10 Ensure successful file system mounts are collected
5.2.3.11 Ensure session initiation information is collected
5.2.3.12 Ensure login and logout events are collected
5.2.3.13 Ensure file deletion events by users are collected
Page 905
Recommendation Set
Correctly
Yes No
5.2.3.14 Ensure events that modify the system's Mandatory
Access Controls are collected
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded
5.2.3.19 Ensure kernel module loading unloading and modification
is collected
5.2.3.20 Ensure the audit configuration is immutable
5.2.3.21 Ensure the running and on disk configuration is the same
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
5.2.4.2 Ensure only authorized users own audit log files
5.2.4.3 Ensure only authorized groups are assigned ownership
of audit log files
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
5.2.4.5 Ensure audit configuration files are 640 or more
restrictive
5.2.4.6 Ensure audit configuration files are owned by root
5.2.4.7 Ensure audit configuration files belong to group root
5.2.4.8 Ensure audit tools are 755 or more restrictive
5.2.4.9 Ensure audit tools are owned by root
5.2.4.10 Ensure audit tools belong to group root
6.1.1 Ensure permissions on /etc/passwd are configured
6.1.2 Ensure permissions on /etc/passwd- are configured
6.1.3 Ensure permissions on /etc/group are configured
6.1.4 Ensure permissions on /etc/group- are configured
6.1.5 Ensure permissions on /etc/shadow are configured
6.1.6 Ensure permissions on /etc/shadow- are configured
6.1.7 Ensure permissions on /etc/gshadow are configured
Page 906
Recommendation Set
Correctly
Yes No
6.1.8 Ensure permissions on /etc/gshadow- are configured
6.1.9 Ensure permissions on /etc/shells are configured
6.1.10 Ensure permissions on /etc/opasswd are configured
6.1.11 Ensure world writable files and directories are secured
6.1.12 Ensure no unowned or ungrouped files or directories
exist
6.1.13 Ensure SUID and SGID files are reviewed
6.2.1 Ensure accounts in /etc/passwd use shadowed
passwords
6.2.2 Ensure /etc/shadow password fields are not empty
6.2.4 Ensure shadow group is empty
6.2.11 Ensure local interactive user home directories are
configured
6.2.12 Ensure local interactive user dot files access is
configured
Page 907
Appendix: CIS Controls v8 IG 3 Mapped
Recommendations
Recommendation Set
Correctly
Yes No
1.1.1.1 Ensure mounting of cramfs filesystems is disabled
1.1.1.2 Ensure mounting of freevxfs filesystems is disabled
1.1.1.3 Ensure mounting of jffs2 filesystems is disabled
1.1.1.4 Ensure mounting of hfs filesystems is disabled
1.1.1.5 Ensure mounting of hfsplus filesystems is disabled
1.1.1.6 Ensure mounting of squashfs filesystems is disabled
1.1.1.7 Ensure mounting of udf filesystems is disabled
1.1.2.1 Ensure /tmp is a separate partition
1.1.2.2 Ensure nodev option set on /tmp partition
1.1.2.3 Ensure noexec option set on /tmp partition
1.1.2.4 Ensure nosuid option set on /tmp partition
1.1.3.1 Ensure separate partition exists for /var
1.1.3.2 Ensure nodev option set on /var partition
1.1.3.3 Ensure nosuid option set on /var partition
1.1.4.1 Ensure separate partition exists for /var/tmp
1.1.4.2 Ensure nodev option set on /var/tmp partition
1.1.4.3 Ensure noexec option set on /var/tmp partition
1.1.4.4 Ensure nosuid option set on /var/tmp partition
1.1.5.1 Ensure separate partition exists for /var/log
1.1.5.2 Ensure nodev option set on /var/log partition
1.1.5.3 Ensure noexec option set on /var/log partition
1.1.5.4 Ensure nosuid option set on /var/log partition
1.1.6.1 Ensure separate partition exists for /var/log/audit
1.1.6.2 Ensure nodev option set on /var/log/audit partition
1.1.6.3 Ensure noexec option set on /var/log/audit partition
1.1.6.4 Ensure nosuid option set on /var/log/audit partition
1.1.7.1 Ensure separate partition exists for /home
Page 908
Recommendation Set
Correctly
Yes No
1.1.7.2 Ensure nodev option set on /home partition
1.1.7.3 Ensure nosuid option set on /home partition
1.1.8.1 Ensure nodev option set on /dev/shm partition
1.1.8.2 Ensure noexec option set on /dev/shm partition
1.1.8.3 Ensure nosuid option set on /dev/shm partition
1.1.9 Disable Automounting
1.1.10 Disable USB Storage
1.2.1 Ensure AIDE is installed
1.2.2 Ensure filesystem integrity is regularly checked
1.3.1 Ensure updates, patches, and additional security
software are installed
1.3.2 Ensure package manager repositories are configured
1.3.3 Ensure GPG keys are configured
1.4.1 Ensure bootloader password is set
1.4.2 Ensure permissions on bootloader config are configured
1.4.3 Ensure authentication required for single user mode
1.5.1 Ensure prelink is not installed
1.5.2 Ensure address space layout randomization (ASLR) is
enabled
1.5.3 Ensure ptrace_scope is restricted
1.5.4 Ensure Automatic Error Reporting is not enabled
1.6.1.1 Ensure AppArmor is installed
1.6.1.2 Ensure AppArmor is enabled in the bootloader
configuration
1.6.1.3 Ensure all AppArmor Profiles are in enforce or complain
mode
1.6.1.4 Ensure all AppArmor Profiles are enforcing
1.7.4 Ensure permissions on /etc/motd are configured
1.7.5 Ensure permissions on /etc/issue are configured
1.7.6 Ensure permissions on /etc/issue.net are configured
1.8.1 Ensure GNOME Display Manager is removed
1.8.4 Ensure GDM screen locks when the user is idle
Page 909
Recommendation Set
Correctly
Yes No
1.8.5 Ensure GDM screen locks cannot be overridden
1.8.6 Ensure GDM automatic mounting of removable media is
disabled
1.8.8 Ensure GDM autorun-never is enabled
1.8.9 Ensure GDM autorun-never is not overridden
1.8.10 Ensure XDCMP is not enabled
2.1.1.1 Ensure a single time synchronization daemon is in use
2.1.2.1 Ensure chrony is configured with authorized timeserver
2.1.2.2 Ensure chrony is running as user _chrony
2.1.2.3 Ensure chrony is enabled and running
2.1.3.1 Ensure systemd-timesyncd configured with authorized
timeserver
2.1.3.2 Ensure systemd-timesyncd is enabled and running
2.1.4.1 Ensure ntp access control is configured
2.1.4.2 Ensure ntp is configured with authorized timeserver
2.1.4.3 Ensure ntp is running as user ntp
2.1.4.4 Ensure ntp is enabled and running
2.2.1 Ensure X Window System is not installed
2.2.2 Ensure Avahi Server is not installed
2.2.3 Ensure CUPS is not installed
2.2.4 Ensure DHCP Server is not installed
2.2.5 Ensure LDAP server is not installed
2.2.6 Ensure NFS is not installed
2.2.7 Ensure DNS Server is not installed
2.2.8 Ensure FTP Server is not installed
2.2.9 Ensure HTTP server is not installed
2.2.10 Ensure IMAP and POP3 server are not installed
2.2.11 Ensure Samba is not installed
2.2.12 Ensure HTTP Proxy Server is not installed
2.2.13 Ensure SNMP Server is not installed
2.2.14 Ensure NIS Server is not installed
2.2.15 Ensure dnsmasq is not installed
Page 910
Recommendation Set
Correctly
Yes No
2.2.16 Ensure mail transfer agent is configured for local-only
mode
2.2.17 Ensure rsync service is either not installed or is masked
2.3.1 Ensure NIS Client is not installed
2.3.2 Ensure rsh client is not installed
2.3.3 Ensure talk client is not installed
2.3.4 Ensure telnet client is not installed
2.3.5 Ensure LDAP client is not installed
2.3.6 Ensure RPC is not installed
2.4 Ensure nonessential services are removed or masked
3.1.1 Ensure IPv6 status is identified
3.1.2 Ensure wireless interfaces are disabled
3.1.3 Ensure bluetooth is disabled
3.1.4 Ensure DCCP is disabled
3.1.5 Ensure SCTP is disabled
3.1.6 Ensure RDS is disabled
3.1.7 Ensure TIPC is disabled
3.2.1 Ensure packet redirect sending is disabled
3.2.2 Ensure IP forwarding is disabled
3.3.1 Ensure source routed packets are not accepted
3.3.2 Ensure ICMP redirects are not accepted
3.3.3 Ensure secure ICMP redirects are not accepted
3.3.4 Ensure suspicious packets are logged
3.3.5 Ensure broadcast ICMP requests are ignored
3.3.6 Ensure bogus ICMP responses are ignored
3.3.7 Ensure Reverse Path Filtering is enabled
3.3.8 Ensure TCP SYN Cookies is enabled
3.3.9 Ensure IPv6 router advertisements are not accepted
3.4.1.1 Ensure ufw is installed
3.4.1.2 Ensure iptables-persistent is not installed with ufw
3.4.1.3 Ensure ufw service is enabled
Page 911
Recommendation Set
Correctly
Yes No
3.4.1.4 Ensure ufw loopback traffic is configured
3.4.1.5 Ensure ufw outbound connections are configured
3.4.1.6 Ensure ufw firewall rules exist for all open ports
3.4.1.7 Ensure ufw default deny firewall policy
3.4.2.1 Ensure nftables is installed
3.4.2.2 Ensure ufw is uninstalled or disabled with nftables
3.4.2.3 Ensure iptables are flushed with nftables
3.4.2.4 Ensure a nftables table exists
3.4.2.5 Ensure nftables base chains exist
3.4.2.6 Ensure nftables loopback traffic is configured
3.4.2.7 Ensure nftables outbound and established connections
are configured
3.4.2.8 Ensure nftables default deny firewall policy
3.4.2.9 Ensure nftables service is enabled
3.4.2.10 Ensure nftables rules are permanent
3.4.3.1.1 Ensure iptables packages are installed
3.4.3.1.2 Ensure nftables is not installed with iptables
3.4.3.1.3 Ensure ufw is uninstalled or disabled with iptables
3.4.3.2.1 Ensure iptables default deny firewall policy
3.4.3.2.2 Ensure iptables loopback traffic is configured
3.4.3.2.3 Ensure iptables outbound and established connections
are configured
3.4.3.2.4 Ensure iptables firewall rules exist for all open ports
3.4.3.3.1 Ensure ip6tables default deny firewall policy
3.4.3.3.2 Ensure ip6tables loopback traffic is configured
3.4.3.3.3 Ensure ip6tables outbound and established connections
are configured
3.4.3.3.4 Ensure ip6tables firewall rules exist for all open ports
4.1.2 Ensure permissions on /etc/crontab are configured
4.1.3 Ensure permissions on /etc/cron.hourly are configured
4.1.4 Ensure permissions on /etc/cron.daily are configured
4.1.5 Ensure permissions on /etc/cron.weekly are configured
Page 912
Recommendation Set
Correctly
Yes No
4.1.6 Ensure permissions on /etc/cron.monthly are configured
4.1.7 Ensure permissions on /etc/cron.d are configured
4.1.8 Ensure cron is restricted to authorized users
4.1.9 Ensure at is restricted to authorized users
4.2.1 Ensure permissions on /etc/ssh/sshd_config are
configured
4.2.2 Ensure permissions on SSH private host key files are
configured
4.2.3 Ensure permissions on SSH public host key files are
configured
4.2.4 Ensure SSH access is limited
4.2.5 Ensure SSH LogLevel is appropriate
4.2.6 Ensure SSH PAM is enabled
4.2.7 Ensure SSH root login is disabled
4.2.9 Ensure SSH PermitEmptyPasswords is disabled
4.2.11 Ensure SSH IgnoreRhosts is enabled
4.2.12 Ensure SSH X11 forwarding is disabled
4.2.13 Ensure only strong Ciphers are used
4.2.14 Ensure only strong MAC algorithms are used
4.2.15 Ensure only strong Key Exchange algorithms are used
4.2.18 Ensure SSH MaxAuthTries is set to 4 or less
4.2.19 Ensure SSH MaxStartups is configured
4.3.1 Ensure sudo is installed
4.3.2 Ensure sudo commands use pty
4.3.3 Ensure sudo log file exists
4.3.4 Ensure users must provide password for privilege
escalation
4.3.5 Ensure re-authentication for privilege escalation is not
disabled globally
4.3.6 Ensure sudo authentication timeout is configured
correctly
4.3.7 Ensure access to the su command is restricted
4.4.1 Ensure password creation requirements are configured
Page 913
Recommendation Set
Correctly
Yes No
4.4.3 Ensure password reuse is limited
4.4.4 Ensure strong password hashing algorithm is configured
4.4.5 Ensure all current passwords uses the configured
hashing algorithm
4.5.1.1 Ensure minimum days between password changes is
configured
4.5.1.2 Ensure password expiration is 365 days or less
4.5.1.3 Ensure password expiration warning days is 7 or more
4.5.1.4 Ensure inactive password lock is 30 days or less
4.5.1.5 Ensure all users last password change date is in the past
4.5.1.6 Ensure the number of changed characters in a new
password is configured
4.5.1.7 Ensure preventing the use of dictionary words for
passwords is configured
4.5.2 Ensure system accounts are secured
4.5.3 Ensure default group for the root account is GID 0
4.5.4 Ensure default user umask is 027 or more restrictive
4.5.5 Ensure default user shell timeout is configured
4.5.7 Ensure maximum number of same consecutive
characters in a password is configured
5.1.1.1.1 Ensure systemd-journal-remote is installed
5.1.1.1.2 Ensure systemd-journal-remote is configured
5.1.1.1.3 Ensure systemd-journal-remote is enabled
5.1.1.1.4 Ensure journald is not configured to receive logs from a
remote client
5.1.1.2 Ensure journald service is enabled
5.1.1.3 Ensure journald is configured to compress large log files
5.1.1.4 Ensure journald is configured to write logfiles to
persistent disk
5.1.1.5 Ensure journald is not configured to send logs to rsyslog
5.1.1.6 Ensure journald log rotation is configured per site policy
5.1.1.7 Ensure journald default file permissions configured
5.1.2.1 Ensure rsyslog is installed
Page 914
Recommendation Set
Correctly
Yes No
5.1.2.2 Ensure rsyslog service is enabled
5.1.2.3 Ensure journald is configured to send logs to rsyslog
5.1.2.4 Ensure rsyslog default file permissions are configured
5.1.2.5 Ensure logging is configured
5.1.2.6 Ensure rsyslog is configured to send logs to a remote log
host
5.1.2.7 Ensure rsyslog is not configured to receive logs from a
remote client
5.1.3 Ensure all logfiles have appropriate access configured
5.2.1.1 Ensure auditd is installed
5.2.1.2 Ensure auditd service is enabled and active
5.2.1.3 Ensure auditing for processes that start prior to auditd is
enabled
5.2.1.4 Ensure audit_backlog_limit is sufficient
5.2.2.1 Ensure audit log storage size is configured
5.2.2.2 Ensure audit logs are not automatically deleted
5.2.2.3 Ensure system is disabled when audit logs are full
5.2.3.1 Ensure changes to system administration scope
(sudoers) is collected
5.2.3.2 Ensure actions as another user are always logged
5.2.3.3 Ensure events that modify the sudo log file are collected
5.2.3.4 Ensure events that modify date and time information are
collected
5.2.3.5 Ensure events that modify the system's network
environment are collected
5.2.3.6 Ensure use of privileged commands are collected
5.2.3.7 Ensure unsuccessful file access attempts are collected
5.2.3.8 Ensure events that modify user/group information are
collected
5.2.3.9 Ensure discretionary access control permission
modification events are collected
5.2.3.10 Ensure successful file system mounts are collected
5.2.3.11 Ensure session initiation information is collected
Page 915
Recommendation Set
Correctly
Yes No
5.2.3.12 Ensure login and logout events are collected
5.2.3.13 Ensure file deletion events by users are collected
5.2.3.14 Ensure events that modify the system's Mandatory
Access Controls are collected
5.2.3.15 Ensure successful and unsuccessful attempts to use the
chcon command are recorded
5.2.3.16 Ensure successful and unsuccessful attempts to use the
setfacl command are recorded
5.2.3.17 Ensure successful and unsuccessful attempts to use the
chacl command are recorded
5.2.3.18 Ensure successful and unsuccessful attempts to use the
usermod command are recorded
5.2.3.19 Ensure kernel module loading unloading and modification
is collected
5.2.3.20 Ensure the audit configuration is immutable
5.2.3.21 Ensure the running and on disk configuration is the same
5.2.4.1 Ensure audit log files are mode 0640 or less permissive
5.2.4.2 Ensure only authorized users own audit log files
5.2.4.3 Ensure only authorized groups are assigned ownership
of audit log files
5.2.4.4 Ensure the audit log directory is 0750 or more restrictive
5.2.4.5 Ensure audit configuration files are 640 or more
restrictive
5.2.4.6 Ensure audit configuration files are owned by root
5.2.4.7 Ensure audit configuration files belong to group root
5.2.4.8 Ensure audit tools are 755 or more restrictive
5.2.4.9 Ensure audit tools are owned by root
5.2.4.10 Ensure audit tools belong to group root
6.1.1 Ensure permissions on /etc/passwd are configured
6.1.2 Ensure permissions on /etc/passwd- are configured
6.1.3 Ensure permissions on /etc/group are configured
6.1.4 Ensure permissions on /etc/group- are configured
6.1.5 Ensure permissions on /etc/shadow are configured
Page 916
Recommendation Set
Correctly
Yes No
6.1.6 Ensure permissions on /etc/shadow- are configured
6.1.7 Ensure permissions on /etc/gshadow are configured
6.1.8 Ensure permissions on /etc/gshadow- are configured
6.1.9 Ensure permissions on /etc/shells are configured
6.1.10 Ensure permissions on /etc/opasswd are configured
6.1.11 Ensure world writable files and directories are secured
6.1.12 Ensure no unowned or ungrouped files or directories
exist
6.1.13 Ensure SUID and SGID files are reviewed
6.2.1 Ensure accounts in /etc/passwd use shadowed
passwords
6.2.2 Ensure /etc/shadow password fields are not empty
6.2.4 Ensure shadow group is empty
6.2.11 Ensure local interactive user home directories are
configured
6.2.12 Ensure local interactive user dot files access is
configured
Page 917
Appendix: CIS Controls v8 Unmapped
Recommendations
Recommendation Set
Correctly
Yes No
1.5.5 Ensure core dumps are restricted
1.7.1 Ensure message of the day is configured properly
1.7.2 Ensure local login warning banner is configured properly
1.7.3 Ensure remote login warning banner is configured
properly
1.8.2 Ensure GDM login banner is configured
1.8.3 Ensure GDM disable-user-list option is enabled
1.8.7 Ensure GDM disabling automatic mounting of removable
media is not overridden
4.1.1 Ensure cron daemon is enabled and active
4.2.8 Ensure SSH HostbasedAuthentication is disabled
4.2.10 Ensure SSH PermitUserEnvironment is disabled
4.2.16 Ensure SSH AllowTcpForwarding is disabled
4.2.17 Ensure SSH warning banner is configured
4.2.20 Ensure SSH LoginGraceTime is set to one minute or less
4.2.21 Ensure SSH MaxSessions is set to 10 or less
4.2.22 Ensure SSH Idle Timeout Interval is configured
4.4.2 Ensure lockout for failed password attempts is configured
4.5.6 Ensure nologin is not listed in /etc/shells
5.2.4.11 Ensure cryptographic mechanisms are used to protect
the integrity of audit tools
6.2.3 Ensure all groups in /etc/passwd exist in /etc/group
6.2.5 Ensure no duplicate UIDs exist
6.2.6 Ensure no duplicate GIDs exist
6.2.7 Ensure no duplicate user names exist
6.2.8 Ensure no duplicate group names exist
6.2.9 Ensure root PATH Integrity
6.2.10 Ensure root is the only UID 0 account
Page 918
Page 919
Appendix: Change History
Date Version Changes for this version
Jan 13, 2023 2.0.0 Moved - subsection "Configure software and patch
management" (Ticket 17338)
Feb 21, 2023 2.0.0 DELETE - Ensure system is checked to determine if IPv6 is
enabled (Ticket 17732)
Feb 23, 2023 2.0.0 UPDATE - Ensure no world writable files exist (Ticket
17514)
Feb 23, 2023 2.0.0 DELETE - Ensure no unowned files or directories exist
(Ticket 17518)
Feb 23, 2023 2.0.0 DELETE - Ensure no ungrouped files or directories exist
(Ticket 17523)
Feb 23, 2023 2.0.0 DELETE - Ensure sticky bit is set on all world-writable
directories (Ticket 17751)
Feb 23, 2023 2.0.0 DELETE - Audit SUID executables (Ticket 17525)
Feb 23, 2023 2.0.0 DELETE - Audit SGID executables (Ticket 17524)
Feb 23, 2023 2.0.0 DELETE - Ensure no world writable files exist (Ticket
17750)
Feb 23, 2023 2.0.0 ADD - Ensure world writable files and directories are
secured (Ticket 17752)
Feb 23, 2023 2.0.0 ADD - Ensure no unowned or ungrouped files or directories
exist (Ticket 17753)
Feb 23, 2023 2.0.0 ADD - Ensure SUID and SGID files are reviewed (Ticket
17754)
Page 920
Date Version Changes for this version
Feb 27, 2023 2.0.0 Missing user/group ownership change? (Ticket 12783)
Feb 27, 2023 2.0.0 ADD - Ensure local interactive user home directories are
configured (Ticket 17717)
Mar 7, 2023 2.0.0 UPDATE - Configure SSH Server - Update overview (Ticket
17735)
Mar 15, 2023 2.0.0 ADD - Ensure ptrace_scope is restricted (Ticket 17692)
Mar 16, 2023 2.0.0 ADD - Ensure file and directory access is configured (Ticket
17554)
Mar 17, 2023 2.0.0 nothing will be returned by grep if create line is not in conf
file (Ticket 11960)
Mar 17, 2023 2.0.0 UPDATE - Disable unused filesystems (Ticket 17945)
Mar 17, 2023 2.0.0 DROP - Ensure mounting of FAT filesystems is limited
(Ticket 17946)
Mar 17, 2023 2.0.0 UPDATE - Ensure mounting of jffs2 filesystems is disabled
(Ticket 17948)
Page 921
Date Version Changes for this version
Mar 17, 2023 2.0.0 UPDATE - Ensure mounting of hfs filesystems is disabled
(Ticket 17949)
Mar 17, 2023 2.0.0 UPDATE - Ensure mounting of udf filesystems is disabled
(Ticket 17951)
Mar 17, 2023 2.0.0 DROP - Ensure /tmp is configured (Ticket 17953)
Mar 17, 2023 2.0.0 UPDATE - Ensure nodev option set on /tmp partition (Ticket
17954)
Mar 17, 2023 2.0.0 UPDATE - Ensure noexec option set on /tmp partition
(Ticket 17955)
Mar 17, 2023 2.0.0 UPDATE - Ensure nosuid option set on /tmp partition
(Ticket 17956)
Mar 17, 2023 2.0.0 UPDATE - Ensure separate partition exists for /var (Ticket
17957)
Mar 17, 2023 2.0.0 ADD - Ensure nodev option set on /var partition (Ticket
17958)
Mar 17, 2023 2.0.0 ADD - Ensure nosuid option set on /var partition (Ticket
17959)
Mar 17, 2023 2.0.0 UPDATE - Ensure separate partition exists for /var/tmp
(Ticket 17960)
Mar 17, 2023 2.0.0 UPDATE - Ensure noexec option set on /var/tmp partition
(Ticket 17961)
Mar 17, 2023 2.0.0 UPDATE - Ensure nosuid option set on /var/tmp partition
(Ticket 17962)
Mar 17, 2023 2.0.0 UPDATE - Ensure nodev option set on /var/tmp partition
(Ticket 17963)
Page 922
Date Version Changes for this version
Mar 17, 2023 2.0.0 UPDATE - Ensure separate partition exists for /var/log
(Ticket 17964)
Mar 17, 2023 2.0.0 ADD - Ensure nodev option set on /var/log partition (Ticket
17965)
Mar 17, 2023 2.0.0 ADD - Ensure noexec option set on /var/log partition (Ticket
17966)
Mar 17, 2023 2.0.0 ADD - Ensure nosuid option set on /var/log partition (Ticket
17967)
Mar 17, 2023 2.0.0 UPDATE - Ensure separate partition exists for /var/log/audit
(Ticket 17968)
Mar 17, 2023 2.0.0 ADD - Ensure noexec option set on /var/log/audit partition
(Ticket 17969)
Mar 17, 2023 2.0.0 ADD - Ensure nodev option set on /var/log/audit partition
(Ticket 17970)
Mar 17, 2023 2.0.0 ADD - Ensure nosuid option set on /var/log/audit partition
(Ticket 17971)
Mar 17, 2023 2.0.0 UPDATE - Ensure separate partition exists for /home
(Ticket 17972)
Mar 17, 2023 2.0.0 UPDATE - Ensure nodev option set on /home partition
(Ticket 17973)
Mar 17, 2023 2.0.0 ADD - Ensure nosuid option set on /home partition (Ticket
17974)
Mar 17, 2023 2.0.0 UPDATE - Ensure nodev option set on /dev/shm partition
(Ticket 17975)
Mar 17, 2023 2.0.0 UPDATE - Ensure noexec option set on /dev/shm partition
(Ticket 17976)
Mar 17, 2023 2.0.0 UPDATE - Ensure nosuid option set on /dev/shm partition
(Ticket 17977)
Mar 17, 2023 2.0.0 UPDATE - Disable USB Storage (Ticket 17979)
Page 923
Date Version Changes for this version
Mar 17, 2023 2.0.0 DROP - Ensure nodev option set on removable media
partitions (Ticket 17980)
Mar 17, 2023 2.0.0 DROP - Ensure nosuid option set on removable media
partitions (Ticket 17981)
Mar 17, 2023 2.0.0 DROP - Ensure noexec option set on removable media
partitions (Ticket 17982)
Mar 17, 2023 2.0.0 DROP - Ensure permissions on bootloader config are not
overridden (Ticket 17983)
Mar 17, 2023 2.0.0 DROP - Ensure XD/NX support is enabled (Ticket 17984)
Mar 17, 2023 2.0.0 UPDATE - Ensure address space layout randomization
(ASLR) is enabled (Ticket 17985)
Mar 17, 2023 2.0.0 DROP - Ensure prelink is disabled (Ticket 17986)
Mar 17, 2023 2.0.0 ADD - Ensure prelink is not installed (Ticket 17987)
Mar 17, 2023 2.0.0 ADD - Ensure Automatic Error Reporting is not enabled
(Ticket 17988)
Mar 19, 2023 2.0.0 UPDATE - Ensure core dumps are restricted (Ticket 17993)
Mar 19, 2023 2.0.0 UPDATE - Ensure permissions on /etc/motd are configured
(Ticket 17994)
Mar 19, 2023 2.0.0 UPDATE - Ensure permissions on /etc/issue are configured
(Ticket 17995)
Mar 19, 2023 2.0.0 ADD - GNOME Display Manager - subsection (Ticket
17997)
Mar 19, 2023 2.0.0 ADD - Ensure GNOME Display Manager is removed (Ticket
17998)
Mar 19, 2023 2.0.0 ADD - Ensure GDM login banner is configured (Ticket
17999)
Page 924
Date Version Changes for this version
Mar 19, 2023 2.0.0 ADD - Ensure GDM disable-user-list option is enabled
(Ticket 18000)
Mar 19, 2023 2.0.0 ADD - Ensure GDM screen locks when the user is idle
(Ticket 18001)
Mar 19, 2023 2.0.0 ADD - Ensure GDM screen locks cannot be overridden
(Ticket 18002)
Mar 19, 2023 2.0.0 ADD - Ensure GDM automatic mounting of removable
media is disabled (Ticket 18003)
Mar 19, 2023 2.0.0 ADD - Ensure GDM disabling automatic mounting of
removable media is not overridden (Ticket 18004)
Mar 19, 2023 2.0.0 ADD - Ensure GDM autorun-never is enabled (Ticket
18005)
Mar 19, 2023 2.0.0 ADD - Ensure GDM autorun-never is not overridden (Ticket
18006)
Mar 19, 2023 2.0.0 ADD - Ensure XDCMP is not enabled (Ticket 18007)
Mar 19, 2023 2.0.0 DROP - Ensure xinetd is not installed (Ticket 18009)
Mar 19, 2023 2.0.0 DROP - Ensure openbsd-inetd is not installed (Ticket
18010)
Mar 19, 2023 2.0.0 DROP - Ensure chrony is configured (Ticket 18012)
Mar 19, 2023 2.0.0 ADD - Ensure chrony is configured with authorized
timeserver (Ticket 18013)
Mar 19, 2023 2.0.0 ADD - Ensure chrony is running as user _chrony (Ticket
18014)
Mar 19, 2023 2.0.0 ADD - Ensure chrony is enabled and running (Ticket
18015)
Page 925
Date Version Changes for this version
Mar 20, 2023 2.0.0 ADD - Ensure systemd-timesyncd is enabled and running
(Ticket 18018)
Mar 20, 2023 2.0.0 DROP - Ensure ntp is configured (Ticket 18019)
Mar 20, 2023 2.0.0 ADD - Ensure ntp is configured with authorized timeserver
(Ticket 18021)
Mar 20, 2023 2.0.0 ADD - Ensure ntp is running as user ntp (Ticket 18022)
Mar 20, 2023 2.0.0 ADD - Ensure ntp is enabled and running (Ticket 18023)
Mar 20, 2023 2.0.0 UPDATE - Ensure X Window System is not installed (Ticket
18024)
Mar 20, 2023 2.0.0 DROP - Ensure Avahi Server is not enabled (Ticket 18025)
Mar 20, 2023 2.0.0 ADD - Ensure Avahi Server is not installed (Ticket 18026)
Mar 20, 2023 2.0.0 ADD - Ensure CUPS is not installed (Ticket 18028)
Mar 20, 2023 2.0.0 DROP - Ensure CUPS is not enabled (Ticket 18027)
Mar 20, 2023 2.0.0 ADD - Ensure DHCP Server is not installed (Ticket 18030)
Mar 20, 2023 2.0.0 DROP - Ensure DHCP Server is not enabled (Ticket 18029)
Mar 20, 2023 2.0.0 ADD - Ensure LDAP server is not installed (Ticket 18032)
Mar 20, 2023 2.0.0 DROP - Ensure LDAP server is not enabled (Ticket 18031)
Mar 20, 2023 2.0.0 ADD - Ensure NFS is not installed (Ticket 18034)
Mar 20, 2023 2.0.0 DROP - Ensure NFS and RPC are not enabled (Ticket
18033)
Mar 20, 2023 2.0.0 ADD - Ensure DNS Server is not installed (Ticket 18036)
Mar 20, 2023 2.0.0 DROP - Ensure DNS Server is not enabled (Ticket 18035)
Page 926
Date Version Changes for this version
Mar 20, 2023 2.0.0 ADD - Ensure FTP Server is not installed (Ticket 18038)
Mar 20, 2023 2.0.0 DROP - Ensure FTP Server is not enabled (Ticket 18037)
Mar 20, 2023 2.0.0 ADD - Ensure HTTP server is not installed (Ticket 18040)
Mar 20, 2023 2.0.0 DROP - Ensure HTTP server is not enabled (Ticket 18039)
Mar 20, 2023 2.0.0 ADD - Ensure IMAP and POP3 server are not installed
(Ticket 18042)
Mar 20, 2023 2.0.0 DROP - Ensure email services are not enabled (Ticket
18041)
Mar 20, 2023 2.0.0 ADD - Ensure Samba is not installed (Ticket 18044)
Mar 20, 2023 2.0.0 DROP - Ensure Samba is not enabled (Ticket 18043)
Apr 6, 2023 2.0.0 ADD - Ensure HTTP Proxy Server is not installed (Ticket
18046)
Mar 20, 2023 2.0.0 DROP - Ensure HTTP Proxy Server is not enabled (Ticket
18045)
Mar 20, 2023 2.0.0 ADD - Ensure SNMP Server is not installed (Ticket 18048)
Mar 20, 2023 2.0.0 DROP - Ensure SNMP Server is not enabled (Ticket
18047)
Mar 20, 2023 2.0.0 DROP - Ensure NIS Server is not enabled (Ticket 18049)
Mar 20, 2023 2.0.0 ADD - Ensure NIS Server is not installed (Ticket 18050)
Mar 20, 2023 2.0.0 UPDATE - Ensure mail transfer agent is configured for
local-only mode (Ticket 18051)
Mar 20, 2023 2.0.0 DROP - Ensure rsync service is not enabled (Ticket 18053)
Mar 20, 2023 2.0.0 ADD - Ensure rsync service is either not installed or is
masked (Ticket 18052)
Mar 20, 2023 2.0.0 UPDATE - Ensure NIS Client is not installed (Ticket 18055)
Mar 20, 2023 2.0.0 UPDATE - Ensure rsh client is not installed (Ticket 18056)
Page 927
Date Version Changes for this version
Mar 20, 2023 2.0.0 UPDATE - Ensure talk client is not installed (Ticket 18057)
Mar 20, 2023 2.0.0 UPDATE - Ensure telnet client is not installed (Ticket
18058)
Mar 20, 2023 2.0.0 UPDATE - Ensure LDAP client is not installed (Ticket
18059)
Mar 20, 2023 2.0.0 ADD - Ensure nonessential services are removed or
masked (Ticket 18061)
Apr 6, 2023 2.0.0 ADD - Ensure IPv6 status is identified (Ticket 18064)
Mar 20, 2023 2.0.0 UPDATE - Ensure wireless interfaces are disabled (Ticket
18065)
Mar 20, 2023 2.0.0 ADD - Ensure bluetooth is disabled (Ticket 18066)
Mar 20, 2023 2.0.0 UPDATE - Ensure DCCP is disabled (Ticket 18067)
Mar 20, 2023 2.0.0 UPDATE - Ensure SCTP is disabled (Ticket 18068)
Mar 20, 2023 2.0.0 UPDATE - Ensure RDS is disabled (Ticket 18069)
Mar 20, 2023 2.0.0 UPDATE - Ensure TIPC is disabled (Ticket 18070)
Mar 20, 2023 2.0.0 UPDATE - Network Parameters (Host Only) (Ticket 18071)
Mar 20, 2023 2.0.0 UPDATE - Ensure packet redirect sending is disabled
(Ticket 18072)
Mar 20, 2023 2.0.0 UPDATE - Network Parameters (Host and Router) (Ticket
18073)
Mar 20, 2023 2.0.0 UPDATE - Ensure source routed packets are not accepted
(Ticket 18074)
Mar 20, 2023 2.0.0 UPDATE - Ensure ICMP redirects are not accepted (Ticket
18075)
Mar 20, 2023 2.0.0 UPDATE - Ensure secure ICMP redirects are not accepted
(Ticket 18076)
Page 928
Date Version Changes for this version
Mar 20, 2023 2.0.0 UPDATE - Ensure suspicious packets are logged (Ticket
18077)
Mar 20, 2023 2.0.0 UPDATE - Ensure broadcast ICMP requests are ignored
(Ticket 18078)
Mar 20, 2023 2.0.0 UPDATE - Ensure bogus ICMP responses are ignored
(Ticket 18079)
Mar 20, 2023 2.0.0 UPDATE - Ensure Reverse Path Filtering is enabled (Ticket
18080)
Mar 20, 2023 2.0.0 UPDATE - Ensure TCP SYN Cookies is enabled (Ticket
18081)
Mar 20, 2023 2.0.0 UPDATE - Ensure IPv6 router advertisements are not
accepted (Ticket 18082)
Apr 6, 2023 2.0.0 ADD - Ensure RPC is not installed (Ticket 18060)
Mar 21, 2023 2.0.0 UPDATE - Ensure ufw firewall rules exist for all open ports
(Ticket 18090)
Mar 21, 2023 2.0.0 ADD - Ensure ufw default deny firewall policy (Ticket
18091)
Mar 21, 2023 2.0.0 ADD - Ensure ufw is uninstalled or disabled with nftables
(Ticket 18093)
Mar 21, 2023 2.0.0 ADD - Configure iptables software (Ticket 18094)
Mar 21, 2023 2.0.0 ADD - Ensure iptables packages are installed (Ticket
18095)
Mar 21, 2023 2.0.0 ADD - Ensure nftables is not installed with iptables (Ticket
18096)
Mar 21, 2023 2.0.0 ADD - Ensure ufw is uninstalled or disabled with iptables
(Ticket 18097)
Mar 21, 2023 2.0.0 UPDATE - Ensure ip6tables default deny firewall policy
(Ticket 18098)
Page 929
Date Version Changes for this version
Mar 21, 2023 2.0.0 UPDATE - Ensure ip6tables loopback traffic is configured
(Ticket 18099)
Mar 21, 2023 2.0.0 UPDATE - Ensure ip6tables outbound and established
connections are configured (Ticket 18100)
Mar 21, 2023 2.0.0 UPDATE - Ensure ip6tables firewall rules exist for all open
ports (Ticket 18101)
Mar 22, 2023 2.0.0 MOVE - Access, Authentication and Authorization - Moved
up to be section 4 (Ticket 18112)
Mar 22, 2023 2.0.0 DROP - Ensure cron daemon is enabled (Ticket 18114)
Mar 22, 2023 2.0.0 ADD - Ensure cron daemon is enabled and active (Ticket
18115)
Mar 22, 2023 2.0.0 UPDATE - Ensure cron is restricted to authorized users
(Ticket 18123)
Mar 22, 2023 2.0.0 DROP - Ensure SSH Protocol is not set to 1 (Ticket 18125)
Page 930
Date Version Changes for this version
Mar 22, 2023 2.0.0 UPDATE - Ensure permissions on SSH private host key
files are configured (Ticket 18128)
Mar 22, 2023 2.0.0 UPDATE - Ensure permissions on SSH public host key files
are configured (Ticket 17823)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH access is limited (Ticket 18129)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH LogLevel is appropriate (Ticket
18130)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH PAM is enabled (Ticket 18131)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH root login is disabled (Ticket
18132)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH IgnoreRhosts is enabled (Ticket
18136)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH X11 forwarding is disabled (Ticket
18137)
Mar 22, 2023 2.0.0 UPDATE - Ensure only strong Ciphers are used (Ticket
18139)
Mar 22, 2023 2.0.0 UPDATE - Ensure only strong MAC algorithms are used
(Ticket 18138)
Mar 22, 2023 2.0.0 UPDATE - Ensure only strong Key Exchange algorithms
are used (Ticket 18140)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH warning banner is configured
(Ticket 18142)
Page 931
Date Version Changes for this version
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH MaxAuthTries is set to 4 or less
(Ticket 18143)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH MaxStartups is configured (Ticket
18144)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH LoginGraceTime is set to one
minute or less (Ticket 18145)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH MaxSessions is set to 10 or less
(Ticket 18146)
Mar 22, 2023 2.0.0 UPDATE - Ensure SSH Idle Timeout Interval is configured
(Ticket 18147)
Mar 22, 2023 2.0.0 UPDATE - Ensure sudo is installed (Ticket 18148)
Mar 22, 2023 2.0.0 UPDATE - Ensure sudo commands use pty (Ticket 18149)
Mar 22, 2023 2.0.0 UPDATE - Ensure sudo log file exists (Ticket 18150)
Mar 22, 2023 2.0.0 ADD - Ensure users must provide password for privilege
escalation (Ticket 18151)
Mar 22, 2023 2.0.0 ADD - Ensure re-authentication for privilege escalation is
not disabled globally (Ticket 18152)
Mar 22, 2023 2.0.0 ADD - Ensure sudo authentication timeout is configured
correctly (Ticket 18153)
Mar 22, 2023 2.0.0 UPDATE - Ensure access to the su command is restricted
(Ticket 18154)
Mar 22, 2023 2.0.0 UPDATE - Ensure password reuse is limited (Ticket 18155)
Mar 22, 2023 2.0.0 ADD - Ensure all current passwords uses the configured
hashing algorithm (Ticket 18157)
Mar 22, 2023 2.0.0 UPDATE - Ensure all users last password change date is in
the past (Ticket 18158)
Mar 22, 2023 2.0.0 ADD - Ensure the number of changed characters in a new
password is configured (Ticket 18159)
Page 932
Date Version Changes for this version
Mar 22, 2023 2.0.0 ADD - Ensure preventing the use of dictionary words for
passwords is configured (Ticket 18160)
Mar 22, 2023 2.0.0 UPDATE - Ensure strong password hashing algorithm is
configured (Ticket 18156)
Mar 24, 2023 2.0.0 UPDATE - Ensure minimum days between password
changes is configured (Ticket 18172)
Mar 24, 2023 2.0.0 UPDATE - Ensure password expiration warning days is 7 or
more (Ticket 18174)
Mar 24, 2023 2.0.0 UPDATE - Ensure inactive password lock is 30 days or less
(Ticket 18175)
Mar 28, 2023 2.0.0 UPDATE - Ensure password expiration is 365 days or less
(Ticket 18173)
Mar 29, 2023 2.0.0 UPDATE - Ensure nftables loopback traffic is configured
(Ticket 18243)
Mar 29, 2023 2.0.0 ADD - Configure time-based job schedulers (Ticket 18246)
Mar 29, 2023 2.0.0 ADD - Configure privilege escalation (Ticket 18248)
Mar 29, 2023 2.0.0 UPDATE - Ensure password creation requirements are
configured (Ticket 18249)
Mar 30, 2023 2.0.0 UPDATE - Ensure system accounts are secured (Ticket
18251)
Mar 30, 2023 2.0.0 UPDATE - Ensure default user umask is 027 or more
restrictive (Ticket 18161)
Apr 3, 2023 2.0.0 ADD - Ensure nologin is not listed in /etc/shells (Ticket
18269)
Apr 4, 2023 2.0.0 ADD - Ensure default user shell timeout is configured
(Ticket 18288)
Page 933
Date Version Changes for this version
Apr 4, 2023 2.0.0 DROP - Ensure default user shell timeout is 900 seconds or
less (Ticket 18289)
Apr 5, 2023 2.0.0 ADD - Ensure dnsmasq is not installed (Ticket 18294)
Apr 5, 2023 2.0.0 ADD - Ensure journald is not configured to recieve logs
from a remote client (Ticket 18306)
Apr 5, 2023 2.0.0 ADD - Ensure journald service is enabled (Ticket 18307)
Apr 5, 2023 2.0.0 ADD - Ensure journald is not configured to send logs to
rsyslog (Ticket 18310)
Apr 5, 2023 2.0.0 ADD - Ensure journald log rotation is configured per site
policy (Ticket 18311)
Apr 5, 2023 2.0.0 ADD - Ensure journald default file permissions configured
(Ticket 18312)
Apr 5, 2023 2.0.0 ADD - Ensure rsyslog is not configured to receive logs from
a remote client (Ticket 18317)
Page 934
Date Version Changes for this version
Apr 5, 2023 2.0.0 DROP - Ensure remote rsyslog messages are only
accepted on designated log hosts (Ticket 18316)
Apr 5, 2023 2.0.0 DROP - Ensure permissions on all logfiles are configured
(Ticket 18318)
Apr 5, 2023 2.0.0 ADD - Ensure all logfiles have appropriate access
configured (Ticket 18319)
Apr 5, 2023 2.0.0 UPDATE - Ensure auditing for processes that start prior to
auditd is enabled (Ticket 18321)
Apr 5, 2023 2.0.0 UPDATE - Ensure audit log storage size is configured
(Ticket 18323)
Apr 5, 2023 2.0.0 UPDATE - Ensure system is disabled when audit logs are
full (Ticket 18324)
Apr 5, 2023 2.0.0 ADD - Ensure actions as another user are always logged
(Ticket 18326)
Apr 5, 2023 2.0.0 DROP - Ensure system administrator actions (sudolog) are
collected (Ticket 18327)
Apr 5, 2023 2.0.0 ADD - Ensure events that modify the sudo log file are
collected (Ticket 18328)
Apr 5, 2023 2.0.0 UPDATE - Ensure events that modify date and time
information are collected (Ticket 18329)
Page 935
Date Version Changes for this version
Apr 5, 2023 2.0.0 UPDATE - Ensure events that modify the system's network
environment are collected (Ticket 18330)
Apr 5, 2023 2.0.0 ADD - Ensure unsuccessful file access attempts are
collected (Ticket 18332)
Apr 5, 2023 2.0.0 UPDATE - Ensure successful file system mounts are
collected (Ticket 18336)
Apr 5, 2023 2.0.0 UPDATE - Ensure login and logout events are collected
(Ticket 18338)
Apr 5, 2023 2.0.0 UPDATE - Ensure file deletion events by users are
collected (Ticket 18339)
Apr 5, 2023 2.0.0 UPDATE - Ensure events that modify the system's
Mandatory Access Controls are collected (Ticket 18340)
Apr 5, 2023 2.0.0 ADD - Ensure successful and unsuccessful attempts to use
the chcon command are recorded (Ticket 18341)
Apr 5, 2023 2.0.0 ADD - Ensure successful and unsuccessful attempts to use
the setfacl command are recorded (Ticket 18342)
Apr 5, 2023 2.0.0 ADD - Ensure successful and unsuccessful attempts to use
the chacl command are recorded (Ticket 18343)
Apr 5, 2023 2.0.0 ADD - Ensure successful and unsuccessful attempts to use
the usermod command are recorded (Ticket 18344)
Page 936
Date Version Changes for this version
Apr 5, 2023 2.0.0 ADD - Ensure kernel module loading unloading and
modification is collected (Ticket 18346)
Apr 5, 2023 2.0.0 DROP - Ensure kernel module loading and unloading is
collected (Ticket 18345)
Apr 5, 2023 2.0.0 ADD - Ensure the running and on disk configuration is the
same (Ticket 18348)
Apr 5, 2023 2.0.0 Add - Ensure audit log files are mode 0640 or less
permissive (Ticket 18349)
Apr 5, 2023 2.0.0 ADD - Ensure only authorized users own audit log files
(Ticket 18350)
Apr 5, 2023 2.0.0 ADD - Ensure only authorized groups are assigned
ownership of audit log files (Ticket 18351)
Apr 5, 2023 2.0.0 ADD - Ensure the audit log directory is 0750 or more
restrictive (Ticket 18352)
Apr 5, 2023 2.0.0 ADD - Ensure audit configuration files are 640 or more
restrictive (Ticket 18353)
Apr 5, 2023 2.0.0 ADD - Ensure audit configuration files are owned by root
(Ticket 18354)
Apr 5, 2023 2.0.0 ADD - Ensure audit configuration files belong to group root
(Ticket 18355)
Apr 5, 2023 2.0.0 ADD - Ensure audit tools are 755 or more restrictive (Ticket
18356)
Apr 5, 2023 2.0.0 ADD - Ensure audit tools are owned by root (Ticket 18357)
Apr 5, 2023 2.0.0 ADD - Ensure audit tools belong to group root (Ticket
18358)
Page 937
Date Version Changes for this version
Apr 5, 2023 2.0.0 DROP - Ensure sticky bit is set on all world-writable
directories (Ticket 18371)
Apr 5, 2023 2.0.0 DROP - Ensure no world writable files exist (Ticket 18370)
Apr 6, 2023 2.0.0 DROP - Ensure no unowned files or directories exist (Ticket
18372)
Page 938
Date Version Changes for this version
Apr 6, 2023 2.0.0 DROP - Ensure no legacy "+" entries exist in /etc/group
(Ticket 18378)
Apr 6, 2023 2.0.0 DROP - Ensure no legacy "+" entries exist in /etc/shadow
(Ticket 18377)
Apr 6, 2023 2.0.0 DROP - Ensure no legacy "+" entries exist in /etc/passwd
(Ticket 18376)
Apr 6, 2023 2.0.0 DROP - Ensure password fields are not empty (Ticket
18379)
Apr 6, 2023 2.0.0 ADD - Ensure /etc/shadow password fields are not empty
(Ticket 18380)
Apr 6, 2023 2.0.0 ADD - Ensure shadow group is empty (Ticket 18382)
Apr 6, 2023 2.0.0 UPDATE - Ensure root PATH Integrity (Ticket 18383)
Apr 6, 2023 2.0.0 DROP - Ensure local interactive user home directories are
mode 750 or more restrictive (Ticket 18386)
Apr 6, 2023 2.0.0 DROP - Ensure local interactive users own their home
directories (Ticket 18385)
Apr 6, 2023 2.0.0 DROP - Ensure local interactive user home directories exist
(Ticket 18384)
Apr 6, 2023 2.0.0 DROP - Ensure local interactive user dot files are not group
or world writable (Ticket 17458)
Apr 6, 2023 2.0.0 UPDATE - Ensure local interactive user dot files access is
configured (Ticket 17773)
Apr 6, 2023 2.0.0 DROP - Ensure no local interactive user has .netrc files
(Ticket 18387)
Apr 6, 2023 2.0.0 DROP - Ensure no local interactive user has .forward files
(Ticket 18388)
Apr 6, 2023 2.0.0 DROP - Ensure no local interactive user has .rhosts files
(Ticket 18389)
Page 939
Date Version Changes for this version
Apr 6, 2023 2.0.0 DROP - Ensure local interactive user dot files are not group
or world writable (Ticket 18390)
Apr 6, 2023 2.0.0 UPDATE - Ensure ufw loopback traffic is configured (Ticket
18394)
Jun 25, 2023 2.0.1 Fixed Automated Assessment Content (AAC) addressed
“unknown” results
Page 940