CIS CentOS Linux 7 Benchmark v1.1.01 PDF
CIS CentOS Linux 7 Benchmark v1.1.01 PDF
CIS CentOS Linux 7 Benchmark v1.1.01 PDF
v1.1.0 - 04-02-2015
http://benchmarks.cisecurity.org
The CIS Security Benchmarks division provides consensus-oriented information security products, services, tools, metrics, suggestions, and
recommendations (the “SB Products”) as a public service to Internet users worldwide. Downloading or using SB Products in any way signifies
and confirms your acceptance of and your binding agreement to these CIS Security Benchmarks Terms of Use.
SPECIAL RULES FOR CIS MEMBER ORGANIZATIONS: CIS reserves the right to create special rules for: (1) CIS Members; and (2) Non-
Member organizations and individuals with which CIS has a written contractual relationship. CIS hereby grants to each CIS Member
Organization in good standing the right to distribute the SB Products within such Member's own organization, whether by manual or
electronic means. Each such Member Organization acknowledges and agrees that the foregoing grants in this paragraph are subject to the
terms of such Member's membership arrangement with CIS and may, therefore, be modified or terminated by CIS at any time.
1|Page
Table of Contents
Table of Contents ..........................................................................................................................................................2
Overview ...........................................................................................................................................................................4
Intended Audience ..................................................................................................................................................4
Consensus Guidance ...............................................................................................................................................4
Typographical Conventions ................................................................................................................................5
Scoring Information................................................................................................................................................5
Profile Definitions....................................................................................................................................................6
Acknowledgements.................................................................................................................................................7
Recommendations........................................................................................................................................................8
1 Install Updates, Patches and Additional Security Software ............................................................8
1.1 Filesystem Configuration ........................................................................................................................8
1.2 Configure Software Updates ............................................................................................................... 25
1.3 Advanced Intrusion Detection Environment (AIDE) .............................................................. 28
1.4 Configure SELinux ................................................................................................................................... 30
1.5 Secure Boot Settings ............................................................................................................................... 35
1.6 Additional Process Hardening ........................................................................................................... 37
2 OS Services ........................................................................................................................................................... 40
2.1 Remove Legacy Services ....................................................................................................................... 40
3 Special Purpose Services ............................................................................................................................... 51
4 Network Configuration and Firewalls .................................................................................................... 63
4.1 Modify Network Parameters (Host Only) .................................................................................... 63
4.2 Modify Network Parameters (Host and Router)....................................................................... 65
4.3 Wireless Networking .............................................................................................................................. 72
4.4 IPv6 ................................................................................................................................................................. 73
4.5 Install TCP Wrappers ............................................................................................................................. 75
4.6 Uncommon Network Protocols ......................................................................................................... 79
5 Logging and Auditing ...................................................................................................................................... 82
5.1 Configure rsyslog...................................................................................................................................... 83
2|Page
5.2 Configure System Accounting (auditd).......................................................................................... 88
6 System Access, Authentication and Authorization ........................................................................ 109
6.1 Configure cron and anacron............................................................................................................. 109
6.2 Configure SSH ......................................................................................................................................... 118
6.3 Configure PAM ........................................................................................................................................ 129
7 User Accounts and Environment ............................................................................................................ 135
7.1 Set Shadow Password Suite Parameters (/etc/login.defs) ............................................... 135
8 Warning Banners ........................................................................................................................................... 140
9 System Maintenance ..................................................................................................................................... 144
9.1 Verify System File Permissions ...................................................................................................... 144
9.2 Review User and Group Settings ................................................................................................... 154
Appendix: Change History .................................................................................................................................. 171
3|Page
Overview
This document, CIS CentOS Linux 7 Benchmark, provides prescriptive guidance for
establishing a secure configuration posture for CentOS version 7.0 running on x86 and x64
platforms. To obtain the latest version of this guide, please visit
http://benchmarks.cisecurity.org. If you have questions, comments, or have identified
ways to improve this guide, please write us at [email protected].
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 CentOS Linux 7.
Consensus Guidance
This benchmark was created using a consensus review process comprised subject matter
experts. 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://community.cisecurity.org.
4|Page
Typographical Conventions
The following typographical conventions are used throughout this guide:
Convention Meaning
Stylized Monospace font Used for blocks of code, command, and script examples.
Text should be interpreted exactly as presented.
Monospace font Used for inline code, commands, or examples. Text should
be interpreted exactly as presented.
<italic font in brackets> Italic texts set in angle brackets denote a variable
requiring substitution for a real value.
Scoring Information
A scoring status indicates whether compliance with the given recommendation impacts the
assessed target's benchmark score. The following scoring statuses are used in this
benchmark:
Scored
Failure to comply with "Scored" recommendations will decrease the final benchmark score.
Compliance with "Scored" recommendations will increase the final benchmark score.
Not Scored
Failure to comply with "Not Scored" recommendations will not decrease the final
benchmark score. Compliance with "Not Scored" recommendations will not increase the
final benchmark score.
5|Page
Profile Definitions
The following configuration profiles are defined by this Benchmark:
Level 1
Level 2
This profile extends the "Level 1" profile. Items in this profile exhibit one or more of
the following characteristics:
6|Page
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:
Editor
Rael Daruszka , Center for Internet Security
Additionally, the CIS community thanks the following individuals for their contributions to
previous CIS Red Hat Linux Benchmarks, which were used in the development of this
benchmark: Carole Fennelly, Jonathan Klein, Samuel Apperson, Robert Aspinall, Bill
Munyan, Michael Boelen, Frank Breedijk, Schuberg Philis, Than Thi Cham, Mike Cross,
Ralph Durkee, William Eckler, Wallace Epperson , Philippe Eveque , Howard Farmer, AJ
Fasano, Victor Forno, Blake Frantz, Jason Frisvold, Vladimir Giszpenc, Alex Gockmann,
Hilary Holz, Duncan Innes, Roger Kennedy, David Kennel, Heinrich Wilhelm , Christophe
Lafaille, Lucky Leavell, Rodney McKee, Nikhil Mittal, Jason Morgan, Alexei Nazario, Delvin
Nelson , Mihai Nitulescu, Tom Pietschmann, Ely Pinto, Alexey Rogozhkin, Keith Schincke,
Bruno Silva, Stephen Smoogen, Laura Stitely, Andrew Stueve, Tran Thanh Chien, Robert
Thomas, Stephen Tihor, George Toft, Sven Vermeulen, Vytautas Vysniauskas, Don Williams,
Joe Wulf, Steve Grubb, Margaret Garland, Paul Frederick, Michelle Vogeler, Wei Chea Ang,
Onn Chee Wong, Craig Sayler, Kevin Simmons, and Jonathon Brandt Buckley.
7|Page
Recommendations
1 Install Updates, Patches and Additional Security Software
Note: If you are repartitioning a system that has already been installed, make sure the data
has been copied over to the new partition, unmount it and then remove the data from the
directory that was in the old partition. Otherwise it will still consume space in the old
partition that will be masked when the new filesystem is mounted. For example, if a system
is in single-user mode with no filesystems mounted and the administrator adds a lot of data
to the /tmp directory, this data will still consume space in / once the /tmp filesystem is
mounted unless it is removed first.
Level 1
Description:
The /tmp directory is a world-writable directory used for temporary storage by all users
and some applications.
Rationale:
8|Page
useless for an attacker to install executable code. It would also prevent an attacker from
establishing a hardlink to a system setuid program and wait for it to be updated. Once the
program was updated, the hardlink 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.
Audit:
Remediation:
For new installations, check the box to "Review and modify partitioning" and create a
separate partition for /tmp.
For systems that were previously installed, use the Logical Volume Manager (LVM) to
create partitions.
References:
Level 1
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 attempt to create block or character special devices in /tmp.
Audit:
9|Page
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options). See the
fstab(5) manual page for more information.
Level 1
Description:
The nosuid mount option specifies that the filesystem cannot contain set userid files.
Rationale:
Since the /tmp filesystem is only intended for temporary file storage, set this option to
ensure that users cannot create set userid files in /tmp.
Audit:
Remediation:
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options). See the
fstab(5) manual page for more information.
Level 1
Description:
10 | P a g e
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:
Remediation:
Edit the /etc/fstab file and add noexec to the fourth field (mounting options). See the
fstab(5) manual page for more information.
Level 1
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:
Since the /var directory may contain world-writable files and directories, there is a risk of
resource exhaustion if it is not bound to a separate partition.
Audit:
Remediation:
For new installations, check the box to "Review and modify partitioning" and create a
separate partition for /var.
11 | P a g e
For systems that were previously installed, use the Logical Volume Manager (LVM) to
create partitions.
References:
Level 1
Description:
The /var/tmp directory is normally a standalone directory in the /var file system. Binding
/var/tmp to /tmp establishes an unbreakable link to /tmp that cannot be removed (even by
the root user). It also allows /var/tmp to inherit the same mount options that /tmp owns,
allowing /var/tmp to be protected in the same /tmp is protected. It will also prevent /var
from filling up with temporary files as the contents of /var/tmp will actually reside in the
file system containing /tmp.
Rationale:
All programs that use /var/tmp and /tmp to read/write temporary files will always be
written to the /tmp file system, preventing a user from running the /var file system out of
space or trying to perform operations that have been blocked in the /tmp filesystem.
Audit:
Remediation:
Level 1
Description:
Rationale:
There are two important reasons to ensure that system logs are stored on a separate
partition: protection against resource exhaustion (since logs can grow quite large) and
protection of audit data.
Audit:
# grep "[[:space:]]/var/log[[:space:]]" /etc/fstab
<volume> /var/log <fstype> <options>
Remediation:
For new installations, check the box to "Review and modify partitioning" and create a
separate partition for /var/log.
For systems that were previously installed, use the Logical Volume Manager (LVM) to
create partitions.
References:
Level 1
Description:
The auditing daemon, auditd, stores log data in the /var/log/audit directory.
Rationale:
There are two important reasons to ensure that data gathered by auditd is stored on a
separate partition: protection against resource exhaustion (since the audit.log file can
grow quite large) and protection of audit data. The audit daemon calculates how much free
13 | P a g e
space is left and performs actions based on the results. If other processes (such as syslog)
consume space in the same partition as auditd, it may not perform as desired.
Audit:
Remediation:
For new installations, check the box to "Review and modify partitioning" and create a
separate partition for /var/log/audit. For systems that were previously installed, use the
Logical Volume Manager (LVM) to create partitions.
References:
Level 1
Description:
The /home directory is used to support disk storage needs of local users.
Rationale:
If the system is intended to support local users, create a separate partition for the /home
directory to protect against resource exhaustion and restrict the type of files that can be
stored under /home.
Audit:
Remediation:
For new installations, check the box to "Review and modify partitioning" and create a
separate partition for /home.
For systems that were previously installed, use the Logical Volume Manager (LVM) to
create partitions.
14 | P a g e
References:
Level 1
Description:
When set on a file system, this option prevents character and block special devices from
being defined, or if they exist, from being used as character and block special devices.
Rationale:
Since the user partitions are not intended to support devices, set this option to ensure that
users cannot attempt to create block or character special devices.
Note: The actions in the item refer to the /home partition. If you have created other user
partitions, it is recommended that the Remediation and Audit steps be applied to these
partitions as well.
Audit:
# grep "[[:space:]]/home[[:space:]]" /etc/fstab
Verify that nodev is an option
# mount | grep /home
<each user partition> on <mount point> type <fstype> (nodev)
Note: There may be other options listed for this filesystem
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options). See the
fstab(5) manual page for more information.
Level 1
Description:
15 | P a g e
Set nodev on removable media to prevent character and block special devices that are
present on the removable be treated as these device files.
Rationale:
Removable media containing character and block special devices could be used to
circumvent security controls by allowing non-root users to access sensitive device files
such as /dev/kmem or the raw disk partitions.
Audit:
Remediation:
Edit the /etc/fstab file and add "nodev" to the fourth field (mounting options). Look for
entries that have mount points that contain words such as floppy or cdrom. See the
fstab(5) manual page for more information.
Level 1
Description:
Set noexec on removable media to prevent programs from executing from the removable
media.
Rationale:
Setting this option on a file system prevents users from executing programs from the
removable. This deters users from being to introduce potentially malicious software on the
system.
Audit:
Remediation:
16 | P a g e
Edit the /etc/fstab file and add noexec to the fourth field (mounting options). Look for
entries that have mount points that contain words such as floppy or cdrom. See the
fstab(5) manual page for more information.
Level 1
Description:
Set nosuid on removable media to prevent setuid and setgid executable files that are on
that media from being executed as setuid and setgid.
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:
Remediation:
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options). Look for
entries that have mount points that contain words such as floppy or cdrom. See the
fstab(5) manual page for more information.
Level 1
Description:
The nodev mount option specifies that the /dev/shm (temporary filesystem stored in
memory) cannot contain block or character special devices.
Rationale:
17 | P a g e
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:
Remediation:
Edit the /etc/fstab file and add nodev to the fourth field (mounting options of entries
that have mount points that contain /dev/shm. See the fstab(5) manual page for more
information.
Level 1
Description:
The nosuid mount option specifies that the /dev/shm (temporary filesystem stored in
memory) will not execute setuid and setgid on executable programs as such, but rather
execute them with the uid and gid of the user executing the program.
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:
Remediation:
18 | P a g e
Edit the /etc/fstab file and add nosuid to the fourth field (mounting options). Look for
entries that have mount points that contain /dev/shm. See the fstab(5) manual page for
more information.
Level 1
Description:
Set noexec on the shared memory partition to prevent programs from executing from
there.
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:
Remediation:
Edit the /etc/fstab file and add noexec to the fourth field (mounting options). Look for
entries that have mount points that contain /dev/shm. See the fstab(5) manual page for
more information.
Level 1
Description:
19 | P a g e
Setting the sticky bit on world writable directories prevents users from deleting or
renaming files in that directory that are not owned by them.
Rationale:
This feature prevents the ability to delete or rename files in world writable directories
(such as /tmp) that are owned by another user.
Audit:
# df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type d
\( -perm -0002 -a ! -perm -1000 \) 2>/dev/null
Remediation:
# df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type d
\( -perm -0002 -a ! -perm -1000 \) 2>/dev/null | xargs chmod a+t
Level 2
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
server. If this filesystem type is not needed, disable it.
Audit:
# /sbin/modprobe -n -v cramfs
install /bin/true
# /sbin/lsmod | grep cramfs
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
20 | P a g e
1.1.19 Disable Mounting of freevxfs Filesystems (Not Scored)
Profile Applicability:
Level 2
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
server. If this filesystem type is not needed, disable it.
Audit:
# /sbin/modprobe -n -v freevxfs
install /bin/true
# /sbin/lsmod | grep freevxfs
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
Level 2
Description:
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
server. If this filesystem type is not needed, disable it.
Audit:
21 | P a g e
# /sbin/modprobe -n -v jffs2
install /bin/true
# /sbin/lsmod | grep jffs2
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
Level 2
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
server. If this filesystem type is not needed, disable it.
Audit:
# /sbin/modprobe -n -v hfs
install /bin/true
# /sbin/lsmod | grep hfs
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
Level 2
Description:
22 | P a g e
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
server. If this filesystem type is not needed, disable it.
Audit:
# /sbin/modprobe -n -v hfsplus
install /bin/true
# /sbin/lsmod | grep hfsplus
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
Level 2
Description:
Rationale:
Removing support for unneeded filesystem types reduces the local attack surface of the
server. If this filesystem type is not needed, disable it.
Audit:
# /sbin/modprobe -n -v squashfs
install /bin/true
# /sbin/lsmod | grep squashfs
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
23 | P a g e
install squashfs /bin/true
Level 2
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
server. If this filesystem type is not needed, disable it.
Audit:
# /sbin/modprobe -n -v udf
install /bin/true
# /sbin/lsmod | grep udf
<No output>
Remediation:
Edit or create the file /etc/modprobe.d/CIS.conf and add the following line:
24 | P a g e
1.2 Configure Software Updates
CentOS uses the yum command line tool to install and update software packages. Patch
management procedures may vary widely between enterprises. Large enterprises may
choose to install a CentOS update server that can be used in place of CentOS's servers,
whereas a single deployment of a CentOS system may prefer to get updates from CentOS's
servers. Updates can be performed automatically or manually, depending on the site's
policy for patch management. Many large enterprises prefer to test patches on a non-
production system before rolling out to production.
For the purpose of this benchmark, the requirement is to ensure that a patch management
system is configured and maintained. The specifics on patch update procedures are left to
the organization.
Level 1
Description:
CentOS cryptographically signs updates with a GPG key to verify that they are valid.
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:
Run the following command to ensure that the system has the CentOS GPG key properly
installed:
Remediation:
Compare the GPG key with the one from CentOS's web site at
http://mirror.centos.org/centos/. The following command can be used to print the
installed release key's fingerprint, which is actually contained in the file referenced below:
25 | P a g e
References:
Level 1
Description:
The gpgcheck option, found in the main section of the /etc/yum.conf file determines if an
RPM package's signature is always checked prior to its installation.
Rationale:
Audit:
Run the following command to verify that gpgcheck is set to 1 in all occurrences of the
/etc/yum.conf file:
Remediation:
gpgcheck=1
Level 1
Description:
The yum update utility performs software updates, including dependency analysis, based
on repository metadata and can be run manually from the command line, invoked from one
of the provided front-end tools, or configured to run automatically at specified intervals.
26 | P a g e
Rationale:
The yum update utility is the preferred method to update software since it checks for
dependencies and ensures that the software is installed correctly. Refer to your local patch
management procedures for the method used to perform yum updates.
Audit:
Perform the following command to determine if there are any packages that need to be
updated:
# yum check-update
Remediation:
# yum update
Level 1
Description:
RPM has the capability of verifying installed packages by comparing the installed files
against the file information stored in the package.
Rationale:
Verifying packages gives a system administrator the ability to detect if package files were
changed, which could indicate that a valid binary was overwritten with a trojaned binary.
Audit:
Remediation:
27 | P a g e
Address unexpected discrepancies identified in the audit step.
Level 2
Description:
Rationale:
Install AIDE to make use of the file integrity features to monitor critical files for changes
that could affect the security of the system.
Audit:
Remediation:
Use yum to install AIDE (-y option may be used to assume yes at all prompts):
Initialize AIDE:
Note: The prelinking feature can interfere with AIDE because it alters binaries to speed up
their start up times. Set PRELINKING=no in /etc/sysconfig/prelink and run
28 | P a g e
/usr/sbin/prelink -ua to restore the binaries to their prelinked state, thus avoiding false
positives from AIDE.
Level 2
Description:
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:
Perform the following to determine if there is a cron job scheduled to run the aide check.
Remediation:
# crontab -u root -e
Add the following line to the crontab:
0 5 * * * /usr/sbin/aide --check
Note: The checking in this instance occurs every day at 5am. Alter the frequency and time
of the checks in compliance with site policy.
29 | P a g e
1.4 Configure SELinux
SELinux provides a Mandatory Access Control (MAC) system that greatly augments the
default Discretionary Access Control (DAC) model. Under SELinux, every process and every
object (files, sockets, pipes) on the system is assigned a security context, a label that
includes detailed type information about the object. The kernel allows processes to access
objects only if that access is explicitly allowed by the policy in effect. The policy defines
transitions, so that a user can be allowed to run software, but the software can run under a
different context than the user's default. 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 SELinux MAC rules. The action will not be allowed if either
one of these models does not permit the action. In this way, SELinux rules can only make a
system's permissions more restrictive and secure. SELinux requires a complex policy to
allow all the actions required of a system under normal operation. Three such policies have
been designed for use with CentOS 7 and are included with the system: targeted, strict,
and mls. These are described as follows:
targeted: consists mostly of Type Enforcement (TE) rules, and a small number of
Role-Based Access Control (RBAC) rules. Targeted restricts the actions of many
types of programs, but leaves interactive users largely unaffected.
strict: also uses TE and RBAC rules, but on more programs and more aggressively.
mls: implements Multi-Level Security (MLS), which introduces even more kinds of
labels (sensitivity and category) and rules that govern access based on these.
This section provides guidance for the configuration of the targeted policy.
References:
30 | P a g e
1.4.1 Ensure SELinux is not disabled in /boot/grub2/grub.cfg (Scored)
Profile Applicability:
Level 2
Description:
Configure SELINUX to be enabled at boot time and verify that it has not been overwritten
by the grub boot parameters
Rationale:
Audit:
Remediation:
Level 2
Description:
Rationale:
SELinux must be enabled at boot time in to ensure that the controls it provides are in effect
at all times.
Audit:
31 | P a g e
Perform the following to determine if SELinux is enabled at boot time.
# /usr/sbin/sestatus
Remediation:
SELINUX=enforcing
Level 2
Description:
Configure SELinux to meet or exceed the default targeted policy, which constrains daemons
and system software only.
Rationale:
Security configuration requirements vary from site to site. Some sites may mandate a
policy that is stricter than the default policy, which is perfectly acceptable. This item is
intended to ensure that at least the default recommendations are met.
Audit:
# /usr/sbin/sestatus
32 | P a g e
Note: If your organization requires stricter policies, verify that they are selected by using
the "grep" command on the /etc/selinux/config file.
Remediation:
SELINUXTYPE=targeted
Note: If your organization requires stricter policies, make sure they are added to the
/etc/selinux/config file.
Level 2
Description:
The SETroubleshoot service notifies desktop users of SELinux denials through a user-
friendly interface. The service provides important information around configuration errors,
unauthorized intrusions, and other potential errors.
Rationale:
Audit:
# rpm -q setroubleshoot
setroubleshoot.<package version>.<hardware platform>
Remediation:
Level 2
Description:
33 | P a g e
The mcstransd daemon provides category label information to client processes requesting
information. The label translations are defined in /etc/selinux/targeted/setrans.conf
Rationale:
Since this service is not used very often, disable it to reduce the amount of potentially
vulnerable code running on the system.
Audit:
# rpm -q mcstrans
mcstrans.<package version>.<hardware platform>
Remediation:
Level 2
Description:
Daemons that are not defined in SELinux policy will inherit the security context of their
parent process.
Rationale:
Since daemons are launched and descend from the init process, they will inherit the
security context label initrc_t. This could cause the unintended consequence of giving the
process more permission than it requires.
Audit:
Perform the following to determine if unconfined daemons are running on the system.
# ps -eZ | egrep "initrc" | egrep -vw "tr|ps|egrep|bash|awk" | tr ':' ' ' | awk '{
print $NF }'
Remediation:
Level 1
Description:
Rationale:
Setting the owner and group to root prevents non-root users from changing the file.
Audit:
Perform the following to determine if the /boot/grub2/grub.cfg file has the correct
ownership:
Remediation:
Level 1
Description:
Set permission on the /boot/grub2/grub.cfg file to read and write for root only.
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
35 | P a g e
parameters may be able to identify weaknesses in security upon boot and be able to exploit
them.
Audit:
Remediation:
Level 1
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 SELinux at boot time).
Audit:
Perform the following to determine if a password is required to set command line boot
parameters:
Remediation:
36 | P a g e
# grub2-mkpasswd-pbkdf2
Enter password: <password>
Reenter password: <password>
Your PBKDF2 is <encrypted-password>
Add the following into /etc/grub.d/00_header or a custom /etc/grub.d configuration
file:
cat <<EOF
set superusers="<user-list>"
password_pbkdf2 <user> <encrypted-password>
EOF
# grub2-mkconfig -o /boot/grub2/grub.cfg
Level 1
Description:
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:
37 | P a g e
# /sbin/sysctl fs.suid_dumpable
fs.suid_dumpable = 0
Remediation:
* hard core 0
Add the following line to the /etc/sysctl.conf file.
fs.suid_dumpable = 0
Level 1
Description:
Set the system flag to force randomized virtual memory region placement.
Rationale:
Randomly placing virtual memory regions will make it difficult for to write memory page
exploits as the memory placement will be consistently shifting.
Audit:
# /sbin/sysctl kernel.randomize_va_space
kernel.randomize_va_space = 2
Remediation:
kernel.randomize_va_space = 2
Level 1
Description:
38 | P a g e
Periodically, CentOS releases updates to the CentOS operating system to support new
hardware platforms, deliver new functionality as well as the bundle together a set of
patches that can be tested as a unit.
Rationale:
Newer updates may contain security enhancements that would not be available through
the standard patching process. As a result, it is recommended that the latest update of
the CentOS software 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:
# uname -r
or
# cat /etc/centos-release
Remediation:
Use the latest update when installing new systems and upgrade to or reinstall with the
latest update as appropriate for existing systems.
39 | P a g e
2 OS 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 what services
can be safely disabled and under which circumstances, greatly reducing the number of
possible threats to the resulting system.
Note: The audit items in the section check to see if the packages are listed in the yum
database and installed using rpm. It could be argued that someone may have installed them
separately. However, this is also true for any other type of rogue software. It is beyond the
scope of this benchmark to address software that is installed using non-standard methods
and installation directories.
Level 1
Description:
The telnet-server package contains the telnetd daemon, which accepts connections from
users from other systems via the telnet protocol.
Rationale:
The telnet protocol is insecure and unencrypted. The use of an unencrypted transmission
medium could allow a user with access to sniff network traffic the ability to steal
credentials. The ssh package provides an encrypted session and stronger security and is
included in most Linux distributions.
Audit:
40 | P a g e
Perform the following to determine if the telnet-server package is on the system.
# rpm -q telnet-server
package telnet-server is not installed
Remediation:
Level 1
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 authorized user to steal credentials. The ssh package provides an
encrypted session and stronger security and is included in most Linux distributions.
Audit:
# rpm -q telnet
package telnet is not installed
Remediation:
Level 1
Description:
The Berkeley rsh-server (rsh, rlogin, rcp) package contains legacy services that exchange
credentials in clear-text.
41 | P a g e
Rationale:
These legacy service contain numerous security exposures and have been replaced with
the more secure SSH package.
Audit:
# rpm -q rsh-server
package rsh-server is not installed
Remediation:
# yum erase rsh-server
Level 1
Description:
The rsh 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 package removes the
clients for rsh, rcp and rlogin.
Audit:
# rpm -q rsh
package rsh is not installed
Remediation:
42 | P a g e
Profile Applicability:
Level 1
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
(ypbind) 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.
Audit:
# rpm -q ypbind
package ypbind is not installed
Remediation:
Level 1
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 been
43 | P a g e
replaced by such protocols as Lightweight Directory Access Protocol (LDAP). It is
recommended that the service be disabled and other, more secure services be used
Audit:
# rpm -q ypserv
package ypserv is not installed
Remediation:
Level 1
Description:
Trivial File Transfer Protocol (TFTP) is a simple file transfer protocol, typically used to
automatically transfer configuration or boot files between machines. TFTP does not
support authentication and can be easily hacked. The package tftp is a client program that
allows for connections to a tftp server.
Rationale:
It is recommended that TFTP be removed, unless there is a specific need for TFTP (such as
a boot server). In that case, use extreme caution when configuring the services.
Audit:
# rpm -q tftp
package tftp is not installed
Remediation:
# yum erase tftp
44 | P a g e
Level 1
Description:
Trivial File Transfer Protocol (TFTP) is a simple file transfer protocol, typically used to
automatically transfer configuration or boot machines from a boot server. The package
tftp-server is the server package used to define and support a TFTP server.
Rationale:
TFTP does not support authentication nor does it ensure the confidentiality of integrity of
data. It is recommended that TFTP be removed, unless there is a specific need for TFTP. In
that case, extreme caution must be used when configuring the services.
Audit:
# rpm -q tftp-server
package tftp-server is not installed
Remediation:
# yum erase tftp-server
Level 1
Description:
The talk software makes it possible for users to send and receive messages across
systems through a terminal session. The talk client (allows initialization of talk sessions)
is installed by default.
Rationale:
The software presents a security risk as it uses unencrypted protocols for communication.
Audit:
45 | P a g e
Remediation:
Level 1
Description:
The talk software makes it possible for users to send and receive messages across systems
through a terminal session. The talk client (allows initiate of talk sessions) is installed by
default.
Rationale:
The software presents a security risk as it uses unencrypted protocols for communication.
Audit:
# rpm -q talk-server
package talk-server is not installed
Remediation:
Level 2
Description:
The eXtended InterNET Daemon (xinetd) is an open source super daemon that replaced
the original inetd daemon. The xinetd daemon listens for well known services and
dispatches the appropriate daemon to properly respond to service requests.
Rationale:
46 | P a g e
If there are no xinetd services required, it is recommended that the daemon be deleted
from the system.
Audit:
# rpm -q xinetd
package xinetd is not installed
Remediation:
# yum erase xinetd
Level 1
Description:
chargen-dgram is a network service that responds with 0 to 512 ASCII characters for each
datagram it receives. This service is intended for debugging and testing purposes. It is
recommended that this service be disabled.
Rationale:
Disabling this service will reduce the remote attack surface of the system.
Audit:
# chkconfig --list chargen-dgram
chargen-dgram: off
Remediation:
Level 1
47 | P a g e
Description:
chargen-stream is a network service that responds with 0 to 512 ASCII characters for each
connection it receives. This service is intended for debugging and testing purposes. It is
recommended that this service be disabled.
Rationale:
Disabling this service will reduce the remote attack surface of the system.
Audit:
Remediation:
Level 1
Description:
daytime-dgram is a network service that responds with the server's current date and time.
This service is intended for debugging and testing purposes. It is recommended that this
service be disabled.
Rationale:
Disabling this service will reduce the remote attack surface of the system.
Audit:
Remediation:
48 | P a g e
2.1.15 Disable daytime-stream (Scored)
Profile Applicability:
Level 1
Description:
daytime-stream is a network service that responds with the server's current date and
time. This service is intended for debugging and testing purposes. It is recommended that
this service be disabled.
Rationale:
Disabling this service will reduce the remote attack surface of the system.
Audit:
Remediation:
Level 1
Description:
echo-dgram is a network service that responds to clients with the data sent to it by the
client. This service is intended for debugging and testing purposes. It is recommended that
this service be disabled.
Rationale:
Disabling this service will reduce the remote attack surface of the system.
Audit:
49 | P a g e
# chkconfig --list echo-dgram
echo-dgram: off
Remediation:
Level 1
Description:
echo-stream is a network service that responds to clients with the data sent to it by the
client. This service is intended for debugging and testing purposes. It is recommended that
this service be disabled.
Rationale:
Disabling this service will reduce the remote attack surface of the system.
Audit:
# chkconfig --list echo-stream
echo-stream: off
Remediation:
Level 1
Description:
tcpmux-server is a network service that allows a client to access other network services
running on the server. It is recommended that this service be disabled.
50 | P a g e
Rationale:
tcpmux-server can be abused to circumvent the server's host based firewall. Additionally,
tcpmux-server can be leveraged by an attacker to effectively port scan the server.
Audit:
Remediation:
Level 1
Description:
Set the default umask for all processes started at boot time. The settings in umask
selectively turn off default permission when a file is created by a daemon process.
Rationale:
Setting the umask to 027 will make sure that files created by daemons will not be readable,
writable or executable by any other than the group and owner of the daemon process and
will not be writable by the group of the daemon process. The daemon process can manually
override these settings if these files need additional permission.
Audit:
51 | P a g e
Remediation:
umask 027
Level 1
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 Window system is
typically used on desktops where users login, but not on servers where users typically do
not login.
Rationale:
Unless your organization specifically requires graphical login access via the X Window
System, remove the server to reduce the potential attack surface.
Audit:
Perform the following to ensure the system is not booting into graphical mode:
Perform the following to determine if the X Window server is installed on the system:
# rpm -q xorg-x11-server-common
package xorg-x11-server-common is not installed
Remediation:
# cd /etc/lib/systemd/system/
# unlink default.target
# ln -s /usr/lib/systemd/system/multi-user.target default.target
Uninstall the X Window Server:
Level 1
Description:
Rationale:
Since servers are not normally used for printing, this service is not needed unless
dependencies require it. If this is the case, disable the service to reduce the potential attack
surface. If for some reason the service is required on the server, follow the
recommendations in sub-sections 3.2.1 - 3.2.5 to secure it.
Audit:
Remediation:
Level 1
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:
53 | P a g e
If the system does not need to print jobs or accept print jobs from other systems, it is
recommended that CUPS be disabled to reduce the potential attack surface.
Audit:
Remediation:
References:
Level 1
Description:
The Dynamic Host Configuration Protocol (DHCP) is a service that allows machines to be
dynamically assigned IP addresses.
Rationale:
Unless a server is specifically set up to act as a DHCP server, it is recommended that this
service be deleted to reduce the potential attack surface.
Audit:
# rpm -q dhcp
package dhcp is not installed
Remediation:
References:
54 | P a g e
1. More detailed documentation on DHCP is available at
http://www.isc.org/software/dhcp.
Level 1
Description:
The Network Time Protocol (NTP) is designed to synchronize system clocks across a
variety of systems and use a source that is highly accurate. The version of NTP delivered
with CentOS can be found at http://www.ntp.org. NTP can be configured to be a client
and/or a server.
Rationale:
It is recommended that physical systems and virtual guests lacking direct access to the
physical host's clock be configured as NTP clients to synchronize their clocks (especially to
support time sensitive security mechanisms like Kerberos). This also ensures log files have
consistent time records across the enterprise, which aids in forensic investigations.
Audit:
The following script checks for the correct parameters on restrict default and restrict -6
default:
Remediation:
55 | P a g e
server <ntp-server>
Note: <ntp-server> is the IP address or hostname of a trusted time server. Configuring an
NTP server is outside the scope of this benchmark.
OPTIONS="-u ntp:ntp"
References:
Level 1
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. The default client/server LDAP application for CentOS is OpenLDAP.
Rationale:
If the server will not need to act as an LDAP client or server, it is recommended that the
software be disabled to reduce the potential attack surface.
Audit:
# rpm -q openldap-servers
package openldap-servers is not installed
# rpm -q openldap-clients
package openldap-clients is not installed
Remediation:
56 | P a g e
References:
Level 1
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 server does not export NFS shares or act as an NFS client, it is recommended that
these services be disabled to reduce remote attack surface.
Audit:
Remediation:
# systemctl disable nfslock
# systemctl disable rpcgssd
# systemctl disable rpcbind
# systemctl disable rpcidmapd
# systemctl disable rpcsvcgssd
Level 1
Description:
57 | P a g e
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 server is specifically designated to act as a DNS server, it is recommended that the
package be deleted to reduce the potential attack surface.
Audit:
# rpm -q bind
package bind is not installed
Remediation:
Level 1
Description:
The File Transfer Protocol (FTP) provides networked computers with the ability to transfer
files.
Rationale:
Audit:
# rpm -q vsftpd
package vsftpd is not installed
Remediation:
# yum erase vsftpd
58 | P a g e
3.11 Remove HTTP Server (Not Scored)
Profile Applicability:
Level 1
Description:
HTTP or web servers provide the ability to host web site content. The default HTTP server
shipped with CentOS Linux is Apache.
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:
# rpm -q httpd
package httpd is not installed
Remediation:
# yum erase httpd
Level 1
Description:
Dovecot is an open source IMAP and POP3 server for Linux based systems.
Rationale:
Unless POP3 and/or IMAP servers are to be provided to this server, it is recommended that
the service be deleted to reduce the potential attack surface.
Audit:
59 | P a g e
# rpm -q dovecot
package dovecot is not installed
Remediation:
References:
1. http://www.dovecot.org
Level 1
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 Small 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 can be deleted to reduce the potential attack surface.
Audit:
# rpm -q samba
package samba is not installed
Remediation:
# yum erase samba
Level 1
Description:
60 | P a g e
The default HTTP proxy package shipped with CentOS Linux is squid.
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:
# rpm -q squid
package squid is not installed
Remediation:
Level 1
Description:
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 communicates using SNMP v1, which transmits data in the clear and does
not require authentication to execute commands. Unless absolutely necessary, it is
recommended that the SNMP service not be used.
Audit:
# rpm -q net-snmp
package net-snmp is not installed
Remediation:
# yum erase net-snmp
61 | P a g e
3.16 Configure Mail Transfer Agent for Local-Only Mode (Scored)
Profile Applicability:
Level 1
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. By default, the MTA is set to loopback mode on CentOS.
Rationale:
The software for all Mail Transfer Agents is complex and most have a long history of
security issues. While it is important to ensure that the system can process local mail
messages, it is not necessary to have the MTA's daemon listening on a port unless the
server is intended to be a mail server that receives and processes mail from other systems.
Audit:
Perform the following command and make sure that the MTA is listening on the loopback
address (127.0.0.1):
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 = localhost
62 | P a g e
4 Network Configuration and Firewalls
This section provides guidance for secure network and firewall configuration.
Level 1
Description:
The net.ipv4.ip_forward flag is used to tell the server whether it can forward packets or
not. If the server is not to be used as a router, set the flag to 0.
Rationale:
Setting the flag to 0 ensures that a server with multiple interfaces (for example, a hard
proxy), will never be able to forward packets, and therefore, never serve as a router.
Audit:
# /sbin/sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
Remediation:
net.ipv4.ip_forward=0
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.ip_forward=0
# /sbin/sysctl -w net.ipv4.route.flush=1
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:
# /sbin/sysctl net.ipv4.conf.all.send_redirects
net.ipv4.conf.all.send_redirects = 0
# /sbin/sysctl net.ipv4.conf.default.send_redirects
net.ipv4.conf.default.send_redirects = 0
Remediation:
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.conf.all.send_redirects=0
# /sbin/sysctl -w net.ipv4.conf.default.send_redirects=0
# /sbin/sysctl -w net.ipv4.route.flush=1
64 | P a g e
4.2 Modify Network Parameters (Host and Router)
The following network parameters determine if the system is to act as a router. A system
acts as a router if it has at least two interfaces and is configured to perform routing
functions.
Level 1
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:
Audit:
# /sbin/sysctl net.ipv4.conf.all.accept_source_route
net.ipv4.conf.all.accept_source_route = 0
# /sbin/sysctl net.ipv4.conf.default.accept_source_route
net.ipv4.conf.default.accept_source_route = 0
Remediation:
65 | P a g e
Set the net.ipv4.conf.all.accept_source_route and
net.ipv4.conf.default.accept_source_route parameters to 0 in /etc/sysctl.conf:
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route=0
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.conf.all.accept_source_route=0
# /sbin/sysctl -w net.ipv4.conf.default.accept_source_route=0
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 1
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. By setting
net.ipv4.conf.all.accept_redirects to 0, the system will not accept any ICMP redirect
messages, and therefore, won't allow outsiders to update the system's routing tables.
Rationale:
Attackers could use bogus ICMP redirect messages to maliciously alter the system routing
tables and get them to send packets to incorrect networks and allow your system packets
to be captured.
Audit:
# /sbin/sysctl net.ipv4.conf.all.accept_redirects
net.ipv4.conf.all.accept_redirects = 0
# /sbin/sysctl net.ipv4.conf.default.accept_redirects
net.ipv4.conf.default.accept_redirects = 0
Remediation:
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.default.accept_redirects=0
Modify active kernel parameters to match:
66 | P a g e
# /sbin/sysctl -w net.ipv4.conf.all.accept_redirects=0
# /sbin/sysctl -w net.ipv4.conf.default.accept_redirects=0
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 2
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:
Audit:
Perform the following to determine if ICMP redirect messages will be rejected from known
gateways.
# /sbin/sysctl net.ipv4.conf.all.secure_redirects
net.ipv4.conf.all.secure_redirects = 0
# /sbin/sysctl net.ipv4.conf.default.secure_redirects
net.ipv4.conf.default.secure_redirects = 0
Remediation:
net.ipv4.conf.all.secure_redirects=0
net.ipv4.conf.default.secure_redirects=0
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.conf.all.secure_redirects=0
# /sbin/sysctl -w net.ipv4.conf.default.secure_redirects=0
# /sbin/sysctl -w net.ipv4.route.flush=1
67 | P a g e
Level 1
Description:
When enabled, this feature logs packets with un-routable source addresses to the kernel
log.
Rationale:
Enabling this feature and logging these packets allows an administrator to investigate the
possibility that an attacker is sending spoofed packets to their server.
Audit:
# /sbin/sysctl net.ipv4.conf.all.log_martians
net.ipv4.conf.all.log_martians = 1
# /sbin/sysctl net.ipv4.conf.default.log_martians
net.ipv4.conf.default.log_martians = 1
Remediation:
net.ipv4.conf.all.log_martians=1
net.ipv4.conf.default.log_martians=1
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.conf.all.log_martians=1
# /sbin/sysctl -w net.ipv4.conf.default.log_martians=1
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 1
Description:
Rationale:
68 | P a g e
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:
Perform the following to determine if all ICMP echo and timestamp requests to broadcast
and multicast addresses will be ignored.
# /sbin/sysctl net.ipv4.icmp_echo_ignore_broadcasts
net.ipv4.icmp_echo_ignore_broadcasts = 1
Remediation:
net.ipv4.icmp_echo_ignore_broadcasts=1
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 1
Description:
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:
69 | P a g e
# /sbin/sysctl net.ipv4.icmp_ignore_bogus_error_responses
net.ipv4.icmp_ignore_bogus_error_responses = 1
Remediation:
net.ipv4.icmp_ignore_bogus_error_responses=1
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.icmp_ignore_bogus_error_responses=1
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 2
Description:
Rationale:
Setting these flags is a good way to deter attackers from sending your server bogus packets
that cannot be responded to. One instance where this feature breaks down is if
asymmetrical routing is employed. This is would occur when using dynamic routing
protocols (bgp, ospf, etc) on your system. If you are using asymmetrical routing on your
server, you will not be able to enable this feature without breaking the routing.
Audit:
# /sbin/sysctl net.ipv4.conf.all.rp_filter
net.ipv4.conf.all.rp_filter = 1
# /sbin/sysctl net.ipv4.conf.default.rp_filter
net.ipv4.conf.default.rp_filter = 1
Remediation:
70 | P a g e
Set the net.ipv4.conf.all.rp_filter and net.ipv4.conf.default.rp_filter
parameters to 1 in /etc/sysctl.conf:
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.default.rp_filter=1
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv4.conf.all.rp_filter=1
# /sbin/sysctl -w net.ipv4.conf.default.rp_filter=1
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 1
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 server 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 server by
sending many SYN packets without completing the three way handshake. This will quickly
use up slots in the kernel's half-open connection queue and prevent legitimate connections
from succeeding. SYN cookies allow the server to keep accepting valid connections, even if
under a denial of service attack.
Audit:
# /sbin/sysctl net.ipv4.tcp_syncookies
net.ipv4.tcp_syncookies = 1
Remediation:
71 | P a g e
Set the net.ipv4.tcp_syncookies parameter to 1 in /etc/sysctl.conf:
net.ipv4.tcp_syncookies=1
# /sbin/sysctl -w net.ipv4.tcp_syncookies=1
# /sbin/sysctl -w net.ipv4.route.flush=1
Level 1
Description:
Wireless networking is used when wired networks are unavailable. CentOS 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.
Audit:
# ip link show
Validate that all interfaces using wireless are down.
Remediation:
Use the following commands to list all interfaces and identify devices with wireless
interfaces. Once identified, shutdown the interface and remove it.
# ip link show
# iw list
# ip link set <interface> down
# rm /etc/sysconfig/network-scripts/ifcfg-<interface>
72 | P a g e
4.4 IPv6
IPv6 is a networking protocol that supersedes IPv4. It has more routable addresses and has
built in security
Level 1
Description:
Rationale:
It is recommended that systems 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.
Audit:
Perform the following to determine if the system is disabled from accepting router
advertisements:
# /sbin/sysctl net.ipv6.conf.all.accept_ra
net.ipv6.conf.all.accept_ra = 0
# /sbin/sysctl net.ipv6.conf.default.accept_ra
net.ipv6.conf.default.accept_ra = 0
Remediation:
net.ipv6.conf.all.accept_ra=0
net.ipv6.conf.default.accept_ra=0
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv6.conf.all.accept_ra=0
# /sbin/sysctl -w net.ipv6.conf.default.accept_ra=0
# /sbin/sysctl -w net.ipv6.route.flush=1
73 | P a g e
4.4.1.2 Disable IPv6 Redirect Acceptance (Not Scored)
Profile Applicability:
Level 1
Description:
This setting prevents the system from accepting ICMP redirects. ICMP redirects tell the
system about alternate routes for sending traffic.
Rationale:
It is recommended that systems not accept ICMP redirects 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.
Audit:
# /sbin/sysctl net.ipv6.conf.all.accept_redirects
net.ipv6.conf.all.accept_redirect = 0
# /sbin/sysctl net.ipv6.conf.default.accept_redirects
net.ipv6.conf.default.accept_redirect = 0
Remediation:
net.ipv6.conf.all.accept_redirects=0
net.ipv6.conf.default.accept_redirects=0
Modify active kernel parameters to match:
# /sbin/sysctl -w net.ipv6.conf.all.accept_redirects=0
# /sbin/sysctl -w net.ipv6.conf.default.accept_redirects=0
# /sbin/sysctl -w net.ipv6.route.flush=1
Level 1
Description:
Although IPv6 has many advantages over IPv4, few organizations have implemented IPv6.
74 | P a g e
Rationale:
If IPv6 is not to be used, it is recommended that it be disabled to reduce the attack surface
of the system.
Audit:
Remediation:
net.ipv6.conf.all.disable_ipv6=1
Modify active kernel parameters to match:
# /sbin/sysctl net.ipv6.conf.all.disable_ipv6=1
Level 1
Description:
TCP Wrappers provides a simple access list and standardized logging method for services
capable of supporting it. In the past, services that were called from inetd and xinetd
supported the use of tcp wrappers. As inetd and xinetd have been falling in disuse, any
service that can support tcp wrappers will have the libwrap.so library attached to it.
Rationale:
TCP Wrappers provide a good simple access list mechanism to services that may not have
that support built in. It is recommended that all services that can support TCP Wrappers,
use it.
75 | P a g e
Audit:
Remediation:
Level 1
Description:
The /etc/hosts.allow file specifies which IP addresses are permitted to connect to the
host. It is intended to be used in conjunction with the /etc/hosts.deny file.
Rationale:
The /etc/hosts.allow file supports access control by IP and helps ensure that only
authorized systems can connect to the server.
Audit:
Run the following command to verify the contents of the /etc/hosts.allow file.
# cat /etc/hosts.allow
[contents will vary, depending on your network configuration]
Remediation:
Create /etc/hosts.allow:
76 | P a g e
4.5.3 Verify Permissions on /etc/hosts.allow (Scored)
Profile Applicability:
Level 1
Description:
Rationale:
It is critical to ensure that the /etc/hosts.allow 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 determine the permissions on the /etc/hosts.allow file.
# /bin/ls -l /etc/hosts.allow
-rw-r--r-- 1 root root 2055 Jan 30 16:30 /etc/hosts.allow
Remediation:
If the permissions of the /etc/hosts.allow file are incorrect, run the following command
to correct them:
Level 1
Description:
The /etc/hosts.deny file specifies which IP addresses are not permitted to connect to the
host. It is intended to be used in conjunction with the /etc/hosts.allow file.
Rationale:
The /etc/hosts.deny file serves as a failsafe so that any host not specified in
/etc/hosts.allow is denied access to the server.
77 | P a g e
Audit:
Verify that /etc/hosts.deny exists and is configured to deny all hosts not explicitly listed
in /etc/hosts.allow:
Remediation:
Create /etc/hosts.deny:
Level 1
Description:
The /etc/hosts.deny file contains network information that is used by many system
applications and therefore must be readable for these applications to operate.
Rationale:
It is critical to ensure that the /etc/hosts.deny 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 determine the permissions on the /etc/hosts.deny file.
# /bin/ls -l /etc/hosts.deny
-rw-r--r-- 1 root root 2055 Jan 30 16:30 /etc/hosts.deny
Remediation:
If the permissions of the /etc/hosts.deny file are incorrect, run the following command to
correct them:
78 | P a g e
4.6 Uncommon Network Protocols
CentOS Linux supports several network protocols that are not commonly used. If these
protocols are not needed, it is recommended that they be disabled in the kernel.
Level 1
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:
Remediation:
Level 1
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
79 | P a g e
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:
Remediation:
Level 1
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:
Remediation:
# echo "install rds /bin/true" >> /etc/modprobe.d/CIS.conf
80 | P a g e
4.6.4 Disable TIPC (Not Scored)
Profile Applicability:
Level 1
Description:
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:
Remediation:
# echo "install tipc /bin/true" >> /etc/modprobe.d/CIS.conf
Level 1
Description:
Rationale:
A firewall provides extra protection for the Linux system by limiting communications in
and out of the box to specific addresses and ports.
Audit:
81 | P a g e
Perform the following to determine if firewalld is enabled:
Remediation:
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. The standard Internet protocol
for time synchronization is the Network Time Protocol (NTP), which is supported by most
network-ready devices. See the ntpd(8) manual page for more information on configuring
NTP.
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.
82 | P a g e
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).
Level 1
Description:
The rsyslog package is a third party package that provides many enhancements to syslog,
such as multi-threading, TCP communication, message filtering and data base support.
Rationale:
Audit:
# rpm -q rsyslog
rsyslog.<package version>.<hardware platform>
Remediation:
83 | P a g e
Level 1
Description:
The systemctl command can be used to ensure that the rsyslog service is turned on.
Rationale:
If the rsyslog service is not activated the system will not have a syslog service running.
Audit:
Remediation:
# systemctl enable rsyslog
Level 1
Description:
The /etc/rsyslog.conf file 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 the /etc/rsyslog.conf file to ensure appropriate logging is set. In
addition, perform the following command and ensure that the log files are logging
information:
84 | P a g e
# ls -l /var/log/
Remediation:
Edit the following lines in the /etc/rsyslog.conf file as appropriate for your
environment:
auth,user.* /var/log/messages
kern.* /var/log/kern.log
daemon.* /var/log/daemon.log
syslog.* /var/log/syslog
lpr,news,uucp,local0,local1,local2,local3,local4,local5,local6.* /var/log/unused.log
References:
Level 1
Description:
A log file must already exist for rsyslog to be able to write to it.
Rationale:
It is important to ensure that log files exist and have the correct permissions to ensure that
sensitive rsyslog data is archived and protected.
Audit:
For each <logfile> listed in the /etc/rsyslog.conf file, perform the following command
and verify that the <owner>:<group> is root:root and the permissions are 0600 (for sites
that have not implemented a secure group) and root:securegrp with permissions of 0640
(for sites that have implemented a secure group):
# ls -l <logfile>
Remediation:
85 | P a g e
Create the /var/log/ directory and for each <logfile> listed in the /etc/rsyslog.conf file,
perform the following commands:
# touch <logfile>
# chown root:root <logfile>
# chmod og-rwx <logfile>
For sites that have implemented a secure admin group:
Create the /var/log/ directory and for each <logfile> listed in the /etc/rsyslog.conf file,
perform the following commands (where is the name of the security group):
# touch <logfile>
# chown root:<securegrp> <logfile>
# chmod g-wx,o-rwx<logfile>
References:
Level 1
Description:
The rsyslog utility supports the ability to send logs it gathers to a remote log host running
syslogd(8) or to receive messages from remote hosts, reducing administrative overhead.
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 file and verify that logs are sent to a central host (where
logfile.example.com is the name of your central log host).
Remediation:
86 | P a g e
Edit the /etc/rsyslog.conf file and add the following line (where logfile.example.com is
the name of your central log host).
*.* @@loghost.example.com
References:
Level 1
Description:
By default, rsyslog does not listen for log messages coming in from remote systems. The
ModLoad tells rsyslog to load the imtcp.so module so it can listen over a network via
TCP. The InputTCPServerRun option instructs rsyslogd to listen on the specified TCP
port.
Rationale:
The guidance in the section ensures that remote log hosts are configured to only accept
rsyslog data from hosts within the specified domain and that those systems that are not
designed to be log hosts do not accept any remote rsyslog messages. This provides
protection from spoofed log data and ensures that system administrators are reviewing
reasonably complete syslog data in a central location.
Audit:
Remediation:
87 | P a g e
On hosts that are designated as log hosts edit the /etc/rsyslog.conf file and un-comment
the following lines:
$ModLoad imtcp.so
$InputTCPServerRun 514
Note: On hosts that are not designated log hosts these lines should be commented out
instead.
References:
Note: 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. For 32 bit systems, only one rule is needed.
Level 2
Description:
88 | P a g e
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:
Perform the following to determine the maximum size of the audit log files.
Remediation:
max_log_file = <MB>
Note: MB is the number of MegaBytes the file can be.
Level 2
Description:
The auditd daemon can be configured to halt the system when the audit logs are full.
Rationale:
Audit:
Perform the following to determine if auditd is configured to notify the administrator and
halt the system when audit logs are full.
89 | P a g e
Remediation:
space_left_action = email
action_mail_acct = root
admin_space_left_action = halt
Level 2
Description:
Normally, auditd will hold 4 logs of maximum log file size before deleting older log files.
Rationale:
In high security contexts, the benefits of maintaining a long audit history exceed the cost of
storing the audit history.
Audit:
Remediation:
max_log_file_action = keep_logs
Level 2
Description:
Rationale:
90 | P a g e
The capturing of system events provides system administrators with information to allow
them to determine if unauthorized access to their system is occurring.
Audit:
Remediation:
5.2.3 Enable Auditing for Processes That Start Prior to auditd (Scored)
Profile Applicability:
Level 2
Description:
Configure grub 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:
Remediation:
GRUB_CMDLINE_LINUX="audit=1"
And run the following command to update the grub configuration:
# grub2-mkconfig -o /boot/grub2/grub.cfg
91 | P a g e
5.2.4 Record Events That Modify Date and Time Information (Scored)
Profile Applicability:
Level 2
Description:
Capture events where the system date and/or time has been modified. The parameters in
this section are set to determine if the adjtimex (tune kernel clock), settimeofday (Set
time, using timeval and timezone structures) stime (using seconds since 1/1/1970) or
clock_settime (allows for the setting of several internal clocks and timers) system calls
have been executed and always write an audit record to the /var/log/audit.log file upon
exit, tagging the records with the identifier "time-change"
Rationale:
Unexpected changes in system date and/or time could be a sign of malicious activity on the
system.
Audit:
Perform the following to determine if events where the system date and/or time has been
modified are captured.
On a 64 bit system, perform the following command and ensure the output is as
shown. Note: "-a always,exit" may be specified as "-a exit,always".
Remediation:
For 64 bit systems, add the following lines to the /etc/audit/audit.rules file.
92 | P a g e
-a always,exit -F arch=b64 -S clock_settime -k time-change
-a always,exit -F arch=b32 -S clock_settime -k time-change
-w /etc/localtime -p wa -k time-change
Level 2
Description:
Record events affecting the group, passwd (user IDs), shadow and gshadow (passwords) or
/etc/security/opasswd (old passwords, based on remember parameter in the PAM
configuration) files. 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.
Audit:
Perform the following to determine if events that modify user/group information are
recorded.
Remediation:
93 | P a g e
-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
Level 2
Description:
Record changes to network environment files or system calls. The below parameters
monitor the sethostname (set the system's host name) or setdomainname (set the system's
domainname) system calls, and write an audit event on system call exit. The other
parameters monitor the /etc/issue and /etc/issue.net files (messages displayed pre-
login), /etc/hosts (file containing host names and associated IP addresses) and
/etc/sysconfig/network (directory containing network interface scripts and
configurations) files.
Rationale:
Audit:
94 | P a g e
On a 64 bit system, perform the following command and ensure the output is as shown
to determine if events that modify the system's environment are recorded. Note: "-a
always,exit" may be specified as "-a exit,always".
Remediation:
For 64 bit systems, add the following lines to the /etc/audit/audit.rules file.
Level 2
95 | P a g e
Description:
Monitor SELinux 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/selinux directory.
Rationale:
Changes to files in this directory could indicate that an unauthorized user is attempting to
modify access controls and change security contexts, leading to a compromise of the
system.
Audit:
Perform the following to determine if events that modify the system's mandatory access
controls are recorded
Remediation:
-w /etc/selinux/ -p wa -k MAC-policy
Execute the following command to restart auditd:
Level 2
Description:
Monitor login and logout events. The parameters below track changes to files associated
with login/logout events. The file /var/log/faillog tracks failed events from login. The
file /var/log/lastlog maintain records of the last time a user successfully logged in. The
file /var/log/btmp keeps track of failed login attempts and can be read by entering the
command /usr/bin/last -f /var/log/btmp. All audit records will be tagged with the
identifier "logins."
Rationale:
96 | P a g e
Monitoring login/logout events could provide a system administrator with information
associated with brute force attacks against user logins.
Audit:
Perform the following to determine if login and logout events are recorded.
Remediation:
-w /var/log/faillog -p wa -k logins
-w /var/log/lastlog -p wa -k logins
-w /var/log/tallylog -p wa -k logins
Level 2
Description:
Monitor session initiation events. The parameters in this section track changes to the files
associated with session events. The file /var/run/utmp file tracks all currently logged in
users. The /var/log/wtmp file tracks logins, logouts, shutdown and reboot events. All audit
records will be tagged with the identifier "session."
Rationale:
Monitoring these files for changes could alert a system administrator to logins occurring at
unusual hours, which could indicate intruder activity (i.e. a user logging in at a time when
they do not normally log in).
Audit:
97 | P a g e
-w /var/log/wtmp -p wa -k session
-w /var/log/btmp -p wa -k session
Remediation:
-w /var/run/utmp -p wa -k session
-w /var/log/wtmp -p wa -k session
-w /var/log/btmp -p wa -k session
Level 2
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
chmod, fchmod and fchmodat system calls affect the permissions associated with a file. The
chown, fchown, fchownat and lchown system calls affect owner and group attributes on a
file. The setxattr, lsetxattr, fsetxattr (set extended file attributes) and removexattr,
lremovexattr, fremovexattr (remove extended file attributes) control extended file
attributes. In all cases, an audit record will only be written for non-system userids (auid >=
1000) and will ignore Daemon events (auid = 4294967295). 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.
Audit:
For 64 bit systems, perform the following command and ensure the output is as shown to
determine if permission modifications are being recorded. Note: "-a always,exit" may be
specified as "-a exit,always".
98 | P a g e
# grep perm_mod /etc/audit/audit.rules
-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F auid>=1000 \
-F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b32 -S chmod -S fchmod -S fchmodat -F auid>=1000 \
-F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b64 -S chown -S fchown -S fchownat -S lchown -F auid>=1000 \
-F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b32 -S chown -S fchown -S fchownat -S lchown -F auid>=1000 \
-F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b64 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S \
lremovexattr -S fremovexattr -F auid>=1000 -F auid!=4294967295 -k perm_mod
-a always,exit -F arch=b32 -S setxattr -S lsetxattr -S fsetxattr -S removexattr -S \
lremovexattr -S fremovexattr -F auid>=1000 -F auid!=4294967295 -k perm_mod
For 32 bit systems, perform the following command and ensure the output is as shown to
determine if permission modifications are being recorded. Note: "-a always,exit" may be
specified as "-a exit,always".
Remediation:
For 64 bit systems, add the following lines to the /etc/audit/audit.rules file.
99 | P a g e
5.2.11 Collect Unsuccessful Unauthorized Access Attempts to Files
(Scored)
Profile Applicability:
Level 2
Description:
Monitor for unsuccessful attempts to access files. The parameters below are associated
with system calls that control creation (creat), opening (open, openat) and truncation
(truncate, ftruncate) of files. An audit log record will only be written if the user is a non-
privileged user (auid > = 1000), is not a Daemon event (auid=4294967295) and if the
system call returned EACCES (permission denied to the file) or EPERM (some other
permanent error associated with the specific system call). All audit records will be tagged
with the identifier "access."
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.
Audit:
On 64 bit systems, perform the following command and ensure the output is as shown to
determine if there are unsuccessful attempts to access files. Note: "-a always,exit" may
be specified as "-a exit,always".
100 | P a g e
Remediation:
For 64 bit systems, add the following lines to the /etc/audit/audit.rules file.
Level 2
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:
Audit:
Verify that an audit line for each setuid/setgid program identified in the find command
appears in the audit file with the above attributes.
Remediation:
101 | P a g e
To remediate this issue, the system administrator will have to execute a find command to
locate all the privileged programs and then add an audit line for each one of them. The
audit parameters associated with this are as follows:
-F path=" $1 " - will populate each file name found through the find command and
processed by awk.
-F perm=x - will write an audit record if the file is executed.
-F auid>=1000 - will write a record if the user executing the command is not a privileged
user.
-F auid!= 4294967295 - will ignore Daemon events
# find PART -xdev \( -perm -4000 -o -perm -2000 \) -type f | awk '{print \
"-a always,exit -F path=" $1 " -F perm=x -F auid>=1000 -F auid!=4294967295 \
-k privileged" }'
Next, add those lines to the /etc/audit/audit.rules file.
Level 2
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.
102 | P a g e
Note: This tracks successful and unsuccessful mount commands. File system mounts do not
have to come from external media and this action still does not verify write (e.g. CD ROMS)
Audit:
For 64 bit systems perform the following command and ensure the output is as shown to
determine if filesystem mounts are recorded. Note: "-a always,exit" may be specified as
"-a exit,always".
Remediation:
For 64 bit systems, add the following lines to the /etc/audit/audit.rules file.
Level 2
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 the unlink (remove a file),
unlinkat (remove a file attribute), rename (rename a file) and renameat (rename a file
attribute) system calls and tags them with the identifier "delete".
103 | P a g e
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.
Audit:
For 64 bit systems, perform the following command and ensure the output is as shown to
determine if file deletion events by user are recorded.
Remediation:
At a minimum, configure the audit system to collect file deletion events for all users and
root.
104 | P a g e
Profile Applicability:
Level 2
Description:
Monitor scope changes for system administrations. 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 will be written to when the file or its attributes have changed. The
audit records will be tagged with the identifier "scope."
Rationale:
Changes in the /etc/sudoers file can indicate that an unauthorized change has been made
to scope of system administrator activity.
Audit:
Remediation:
-w /etc/sudoers -p wa -k scope
Level 2
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
105 | P a g e
the /var/log/sudo.log file will be opened for write and the executed administration
command will be written to the log.
Rationale:
Audit:
Remediation:
-w /var/log/sudo.log -p wa -k actions
Level 2
Description:
Monitor the loading and unloading of kernel modules. The programs insmod (install a
kernel module), rmmod (remove a kernel module), and modprobe (a more sophisticated
program to load and unload modules, as well as some other features) control loading and
unloading of modules. The init_module (load a module) and delete_module (delete a
module) 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:
106 | P a g e
Monitoring the use of insmod, rmmod and modprobe could provide system administrators
with evidence that an unauthorized user loaded or unloaded a kernel module, possibly
compromising the security of the system. Monitoring of the init_module and
delete_module system calls would reflect an unauthorized user attempting to use a
different program to load and unload modules.
Audit:
Remediation:
-w /sbin/insmod -p x -k modules
-w /sbin/rmmod -p x -k modules
-w /sbin/modprobe -p x -k modules
For 32 bit systems, add
-a always,exit -F arch=b32 -S init_module -S delete_module -k modules
For 64 bit systems, add
-a always,exit -F arch=b64 -S init_module -S delete_module -k modules
Level 2
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.
Rationale:
In immutable mode, unauthorized users cannot execute changes to the audit system to
potential hide malicious activity and then put the audit rules back. Users would most likely
107 | P a g e
notice a system reboot and that could alert administrators of an attempt to make
unauthorized audit changes.
Audit:
Remediation:
-e 2
Level 1
Description:
The system includes the capability of rotating log files regularly to avoid filling up the
system with logs or making the logs unmanageable large. The file
/etc/logrotate.d/syslog is the configuration file used to rotate log files created by
syslog or rsyslog. These files are rotated on a weekly basis via a cron job and the last 4
weeks are kept.
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:
Perform the following to determine if the appropriate system logs are rotated.
108 | P a g e
Remediation:
Level 1
Description:
The anacron daemon is used on systems that are not up 24x7. The anacron daemon will
execute jobs that would have normally been run had the system not been down.
Rationale:
Cron jobs may include critical security or administrative functions that need to run on a
regular basis. Use this daemon on machines that are not up 24x7, or if there are jobs that
need to be executed after the system has been brought back up after a maintenance
window.
Audit:
# rpm -q cronie-anacron
cronie-anacron.<package version>.<hardware platform>
Remediation:
# yum install cronie-anacron
Note: NSA Guidance recommends disabling anacron for systems that are intended to be up
24X7, with the rationale that unnecessary software should be disabled to reduce risk.
However, even systems that are designed to be up at all times can experience downtime
109 | P a g e
that could prevent important system maintenance jobs from running. Review the
requirements for your site to determine your appropriate risk level.
Level 1
Description:
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 crond is used
to execute them.
Audit:
Remediation:
# systemctl enable crond
Level 1
Description:
The /etc/anacrontab file is used by anacron to control its own jobs. The commands in
this item make sure that root is the user and group owner of the file and is the only user
that can read and write the file.
Rationale:
This file contains information on what system jobs are run by anacron. Write access to
these files could provide unprivileged users with the ability to elevate their privileges. Read
110 | P a g e
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:
Perform the following to determine if the /etc/anacrontab file has the correct
permissions.
Remediation:
Level 1
Description:
The /etc/crontab file is used by cron to control its own jobs. The commands in this item
make here sure that root is the user and group owner of the file and is the only user that
can read and write the file.
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:
Perform the following to determine if the /etc/crontab file has the correct permissions.
Remediation:
# chown root:root /etc/crontab
# chmod og-rwx /etc/crontab
111 | P a g e
6.1.5 Set User/Group Owner and Permission on /etc/cron.hourly (Scored)
Profile Applicability:
Level 1
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.
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:
Perform the following to determine if the /etc/cron.hourly file has the correct
permissions.
Remediation:
Level 1
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
112 | P a g e
read/write and search access to user and group root, preventing regular users from
accessing this directory.
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means for gaining unauthorized elevated privileges. Granting read access to this directory
could give an unprivileged user insight in how to gain elevated privileges or circumvent
auditing controls.
Audit:
Perform the following to determine if the /etc/cron.daily directory has the correct
permissions.
Remediation:
Level 1
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.
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.
113 | P a g e
Audit:
Perform the following to determine if the /etc/cron.weekly directory has the correct
permissions.
Remediation:
Level 1
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.
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:
Perform the following to determine if the /etc/cron.monthly directory has the correct
permissions.
Remediation:
114 | P a g e
# chown root:root /etc/cron.monthly
# chmod og-rwx /etc/cron.monthly
Level 1
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.
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:
Perform the following to determine if the /etc/cron.d directory has the correct
permissions.
Remediation:
Level 1
Description:
115 | P a g e
The at daemon works with the cron daemon to allow non-privileged users to submit one
time only jobs at their convenience. There are two files that control at: /etc/at.allow and
/etc/at.deny. If /etc/at.allow exists, then users listed in the file are the only ones that
can create at jobs. If /etc/at.allow does not exist and /etc/at.deny does exist, then any
user on the system, with the exception of those listed in /etc/at.deny, are allowed to
execute at jobs. An empty /etc/at.deny file allows any user to create at jobs. If neither
/etc/at.allow nor /etc/at.deny exist, then only superuser can create at jobs. The
commands below remove the /etc/at.deny file and create an empty /etc/at.allow file
that can only be read and modified by user and group root.
Rationale:
Granting write access to this directory for non-privileged users could provide them the
means to gain 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. In addition, it is a better practice to create a white list of users who can
execute at jobs versus a blacklist of users who can't execute at jobs as a system
administrator will always know who can create jobs and does not have to worry about
remembering to add a user to the blacklist when a new user id is created.
Audit:
Remediation:
# rm /etc/at.deny
# touch /etc/at.allow
# chown root:root /etc/at.allow
# chmod og-rwx /etc/at.allow
Level 1
Description:
116 | P a g e
/etc/cron.deny are checked. Any user not specifically defined in those files is allowed to
use at and cron. By removing the files, only users in /etc/cron.allow and /etc/at.allow
are allowed to use at and cron. Note that 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:
Perform the following to determine if the remediation in the section has been performed:
# ls -l /etc/cron.deny
[no output returned]
# ls -l /etc/at.deny
[no output returned]
# ls -l /etc/cron.allow
-rw------- 1 root root /etc/cron.allow
# ls -l /etc/at.allow
-rw------- 1 root root /etc/at.allow
Remediation:
Run the following to ensure cron.deny and at.deny are removed and permissions are set
correctly:
# /bin/rm /etc/cron.deny
# /bin/rm /etc/at.deny
# chmod og-rwx /etc/cron.allow
# chmod og-rwx /etc/at.allow
# chown root:root /etc/cron.allow
# chown root:root /etc/at.allow
117 | P a g e
6.2 Configure SSH
Description: SSH is a secure, encrypted replacement for common login services such as
telnet, ftp, rlogin, rsh, and rcp.
Rationale: 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.
Level 1
Description:
SSH supports two different and incompatible protocols: SSH1 and SSH2. SSH1 was the
original protocol and was subject to security issues. SSH2 is more advanced and secure.
Rationale:
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
Protocol 2
Level 1
Description:
The INFO parameter specifies that login and logout activity will be logged.
118 | P a g e
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. 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.
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
LogLevel INFO
Level 1
Description:
Rationale:
Audit:
Run the following command to determine the user and group ownership on the
/etc/ssh/sshd_config file.
119 | P a g e
# /bin/ls -l /etc/ssh/sshd_config
-rw------- 1 root root 762 Sep 23 002 /etc/ssh/sshd_config
Remediation:
If the user and group ownership of the /etc/ssh/sshd_config file are incorrect, run the
following command to correct them:
Level 1
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:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
X11Forwarding no
120 | P a g e
Profile Applicability:
Level 1
Description:
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, it is set the
number based on site policy.
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
MaxAuthTries 4
Level 1
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:
121 | P a g e
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
IgnoreRhosts yes
Level 1
Description:
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:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
HostbasedAuthentication no
122 | P a g e
Level 1
Description:
The PermitRootLogin parameter specifies if the root user can log in using ssh(1). The
default is no.
Rationale:
Disallowing root logins over SSH requires server admins to authenticate using their own
individual account, then escalating to root via sudo or su. This in turn limits opportunity
for non-repudiation and provides a clear audit trail in the event of a security incident
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
PermitRootLogin no
Level 1
Description:
The PermitEmptyPasswords parameter specifies if the 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:
123 | P a g e
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
PermitEmptyPasswords no
Level 1
Description:
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 trojaned programs).
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
PermitUserEnvironment no
124 | P a g e
Level 1
Description:
This variable limits the types of ciphers that SSH can use during communication.
Rationale:
Based on research conducted at various institutions, it was determined that the symmetric
portion of the SSH Transport Protocol (as described in RFC 4253) has security weaknesses
that allowed recovery of up to 32 bits of plaintext from a block of ciphertext that was
encrypted with the Cipher Block Chaining (CBC) method. From that research, new Counter
mode algorithms (as described in RFC4344) were designed that are not vulnerable to these
types of attacks and these algorithms are now recommended for standard use.
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
References:
Level 1
Description:
125 | P a g e
variable is set, sshd will send client alive messages at every ClientAliveInterval
interval. When the number of consecutive client alive messages are sent with no response
from the client, the ssh session is terminated. For example, if the ClientAliveInterval is
set to 15 seconds and the ClientAliveCountMax is set to 3, the client ssh session will be
terminated after 45 seconds of idle time.
Rationale:
Having no timeout value associated with a connection could allow an unauthorized user
access to another user's ssh session (e.g. user walks away from their computer and doesn't
lock the screen). Setting a timeout value at least reduces the risk of this happening..
While the recommended setting is 300 seconds (5 minutes), set this timeout value based on
site policy. The recommended setting for ClientAliveCountMax is 0. In this case, the client
session will be terminated after 5 minutes of idle time and no keepalive messages will be
sent.
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
ClientAliveInterval 300
ClientAliveCountMax 0
Level 1
Description:
There are several options available to limit which users and group can access the system
via SSH. It is recommended that at least of the following options be leveraged:
AllowUsers
126 | P a g e
The AllowUsers variable gives the system administrator the option of allowing specific
users to ssh into the system. The list consists of comma separated user names. Numeric
userIDs are not recognized with this variable. If a system administrator wants to restrict
user access further by only allowing the allowed users to log in from a particular host, the
entry can be specified in the form of user@host.
AllowGroups
The AllowGroups variable gives the system administrator the option of allowing specific
groups of users to ssh into the system. The list consists of comma separated user names.
Numeric groupIDs are not recognized with this variable.
DenyUsers
The DenyUsers variable gives the system administrator the option of denying specific
users to ssh into the system. The list consists of comma separated user names. Numeric
userIDs are not recognized with this variable. If a system administrator wants to restrict
user access further by specifically denying a user's access from a particular host, the entry
can be specified in the form of user@host.
DenyGroups
The DenyGroups variable gives the system administrator the option of denying specific
groups of users to ssh into the system. The list consists of comma separated group names.
Numeric groupIDs 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.
Audit:
To verify the correct SSH setting, run the following command and verify that the output is
as shown:
Remediation:
127 | P a g e
Edit the /etc/ssh/sshd_config file to set one or more of the parameter as follows:
AllowUsers <userlist>
AllowGroups <grouplist>
DenyUsers <userlist>
DenyGroups <grouplist>
Level 1
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. Consult with your legal department for the appropriate warning banner for
your site.
Audit:
To verify the correct SSH setting, run the following command and verify that <bannerfile>
is either /etc/issue or /etc/issue.net:
Remediation:
Banner /etc/issue.net
128 | P a g e
6.3 Configure PAM
PAM (Pluggable Authentication Modules) is a service that implements modular
authentication modules on UNIX systems. PAM is implemented as a set of shared objects
that are loaded and executed when a program needs to authenticate a user. Files for PAM
are typically located in the /etc/pam.d directory. PAM must be carefully configured to
secure system authentication. While this section covers some of PAM, please consult other
PAM resources to fully understand the configuration capabilities.
Level 1
Description:
The commands below change password encryption from md5 to sha512 (a much stronger
hashing algorithm). All existing accounts will need to perform a password change to
upgrade the stored hashes to the new algorithm.
Rationale:
The SHA-512 algorithm provides much stronger hashing than MD5, thus providing
additional protection to the system by increasing the level of effort for an attacker to
successfully determine passwords.
Note that these change only apply to accounts configured on the local system.
Audit:
Remediation:
129 | P a g e
Any system accounts that need to be expired should be carefully done separately by the
system administrator to prevent any potential problems.
# cat /etc/passwd | awk -F: '( $3 >=1000 && $1 != "nfsnobody" ) { print $1 }' | xargs
-n 1 chage -d 0
Level 1
Description:
The pam_pwquality module checks of the strength of passwords. It performs checks such
as making sure a password is not a dictionary word, it is a certain length, contains a mix of
characters (e.g. alphabet, numeric, other) and more. The following are definitions of
the pam_pwquality.so options.
The setting shown above is one possible policy. Alter these values to conform to your own
organization's password policies.
Rationale:
Strong passwords protect systems from being hacked through brute force methods.
Audit:
130 | P a g e
# grep pam_pwquality.so /etc/pam.d/system-auth
password requisite pam_pwquality.so try_first_pass local_users_only retry=3
authtok_type=
Check settings in /etc/security/pwquality.conf:
minlen=14
dcredit=-1
ucredit=-1
ocredit=-1
lcredit=-1
Remediation:
minlen=14
dcredit=-1
ucredit=-1
ocredit=-1
lcredit=-1
Level 1
Description:
Lock out userIDs after n unsuccessful consecutive login attempts. The first sets of changes
are made to the main PAM configuration files /etc/pam.d/system-auth and
/etc/pam.d/password-auth. The second set of changes are applied to the program specific
PAM configuration file (in this case, the ssh daemon). The second set of changes must be
applied to each program that will lock out userID's.
Rationale:
Locking out userIDs after n unsuccessful consecutive login attempts mitigates brute force
password attacks against your systems.
131 | P a g e
Audit:
Perform the following to determine the current settings for userID lockout.
Remediation:
# cat /etc/pam.d/password-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required pam_env.so
auth required pam_faillock.so preauth audit silent deny=5 unlock_time=900
auth [success=1 default=bad] pam_unix.so
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900
auth sufficient pam_faillock.so authsucc audit deny=5 unlock_time=900
auth required pam_deny.so
# cat /etc/pam.d/system-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required pam_env.so
auth required pam_faillock.so preauth audit silent deny=5 unlock_time=900
auth [success=1 default=bad] pam_unix.so
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900
auth sufficient pam_faillock.so authsucc audit deny=5 unlock_time=900
auth required pam_deny.so
Note: If a user has been locked out because they have reached the maximum consecutive
failure count defined by deny= in the pam_faillock.so module, the user can be unlocked
by issuing the command /usr/sbin/faillock -u --reset. This command sets the failed
count to 0, effectively unlocking the userid.
Level 1
132 | P a g e
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.
Note that these change only apply to accounts configured on the local system.
Audit:
Perform the following to determine the current setting for reuse of older passwords:
Remediation:
Level 1
Description:
The file /etc/securetty contains a list of valid terminals that may be logged in directly as
root.
Rationale:
Since the system console has special properties to handle emergency situations, it is
important to ensure that the console is in a physically secure location and that
unauthorized consoles have not been defined.
Audit:
# cat /etc/securetty
Remediation:
133 | P a g e
Remove entries for any consoles that are not in a physically secure location.
Level 1
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 the
wheel group to execute su.
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:
Remediation:
134 | P a g e
7 User Accounts and Environment
This section provides guidance on setting up secure defaults for system and user accounts
and their environment. Guidance for monitoring these settings and others that may change
over time is provided in Section 10 System Maintenance.
Level 1
Description:
Rationale:
Audit:
Remediation:
PASS_MAX_DAYS 90
Modify active user parameters to match:
135 | P a g e
# chage --maxdays 90 <user>
Level 1
Description:
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:
Remediation:
PASS_MIN_DAYS 7
Modify active user parameters to match:
Level 1
Description:
136 | P a g e
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:
# grep PASS_WARN_AGE /etc/login.defs
PASS_WARN_AGE 7
# chage --list <user>
Number of days of warning before password expires: 7
Remediation:
Level 1
Description:
There are a number of accounts provided with the CentOS 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
locked to prevent them from being used to provide an interactive shell. By
default, CentOS sets 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 /sbin/nologin. This
prevents the account from potentially being used to run any commands.
Audit:
Run the following script to determine if any system accounts can be accessed:
egrep -v "^\+" /etc/passwd | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" &&
$1!="halt" && $3<1000 && $7!="/sbin/nologin") {print}'
There should be no results returned.
137 | P a g e
Remediation:
Accounts that have been locked are prohibited from running commands on the
system. Such accounts are not able to login to the system nor are they able to use
scheduled execution facilities such as cron. To make sure system accounts cannot be
accessed, using the following script:
#!/bin/bash
for user in `awk -F: '($3 < 1000) {print $1 }' /etc/passwd`; do
if [ $user != "root" ]
then
/usr/sbin/usermod -L $user
if [ $user != "sync" ] && [ $user != "shutdown" ] && [ $user != "halt" ]
then
/usr/sbin/usermod -s /sbin/nologin $user
fi
fi
done
Level 1
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:
Remediation:
# usermod -g 0 root
Level 1
138 | P a g e
Description:
The default umask determines the permissions of files created by users. The user creating
the file has the discretion of making their files and directories readable by others via the
chmod command. Users who wish to allow their files and directories to be readable by
others by default may choose a different default umask by inserting the umask command
into the standard shell configuration files (.profile, .cshrc, etc.) in their home directories.
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.
Note: The directives in this section apply to bash and shell. If other shells are supported on
the system, it is recommended that their configuration files also are checked.
Audit:
# grep "^umask 077" /etc/bashrc
umask 077
# grep "^umask 077" /etc/profile.d/*
umask 077
Remediation:
Edit the /etc/bashrc and /etc/profile.d/cis.sh files (and the appropriate files for any
other shell supported on your system) and add the following the UMASK parameter as
shown:
umask 77
Level 1
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 35 or more days be
disabled.
139 | P a g e
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:
Remediation:
# useradd -D -f 35
8 Warning Banners
Presenting a warning message prior to the normal user login may assist 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.
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.
Level 1
Description:
The contents of the /etc/issue file are displayed prior to the login prompt on the system's
console and serial devices, and also prior to logins via telnet. The contents of the
/etc/motd file is generally displayed after all successful logins, no matter where the user is
140 | P a g e
logging in from, but is thought to be less useful because it only provides notification to the
user after the machine has been accessed.
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. Consult with your organization's legal
counsel for the appropriate wording for your specific organization.
Audit:
Run the following commands and ensure that the files exist and have the correct
permissions.
# /bin/ls -l /etc/motd
-rw-r--r-- 1 root root 2055 Jan 30 16:30 /etc/motd
# ls /etc/issue
-rw-r--r-- 1 root root 2055 Jan 30 16:30 /etc/issue
# ls /etc/issue.net
-rw-r--r-- 1 root root 2055 Jan 30 16:30 /etc/issue.net
The commands above simply validate the presence of the /etc/motd, /etc/issue and
/etc/issue.net files. Review the contents of these files with the " cat" command and
ensure that it is appropriate for your organization.
Remediation:
# touch /etc/motd
# echo "Authorized uses only. All activity may be \
monitored and reported." > /etc/issue
# echo "Authorized uses only. All activity may be \
monitored and reported." > /etc/issue.net
Level 1
Description:
141 | P a g e
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:
Rationale:
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:
Remediation:
Edit the /etc/motd, /etc/issue and /etc/issue.net files and remove any lines
containing \m, \r, \s or \v.
Level 1
Description:
The GNOME Display Manager is used for login session management. See the manual page
gdm(1) for more information. The remediation action for this item sets a warning message
for GDM users before they log in.
Rationale:
142 | P a g e
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. Consult with your organization's legal
counsel for the appropriate wording for your specific organization.
Audit:
Verify that a message is shown when logging in via the GNOME Display Manager.
Remediation:
[org/gnome/login-screen]
banner-message-enable=true
banner-message-text='Type the banner message here'
dconf update
143 | P a g e
9 System Maintenance
No matter how securely a system has been installed and hardened, administrator and user
activity over time can introduce security exposures. The section describes tasks to be
performed on a regular, ongoing basis - perhaps in an automated fashion via the cron
utility.
Note: unlike other sections, the items in this section specify an Audit action followed by a
Remediation action since it is necessary to determine what the current setting is before
determining remediation measures, which will vary depending on the site's policy.
Level 2
Description:
The RPM package manager has a number of useful options. One of these, the -V (or -
verify) option, can be used to verify that system packages are correctly installed. The -V
option can be used to verify a particular package or to verify all system packages ( -Va). If
no output is returned, the package is installed correctly. The following table describes the
meaning of output from the verify option:
Code Meaning
S File size differs.
M File mode differs (includes permissions and file type).
5 The MD5 checksum differs.
D The major and minor version numbers differ on a device file.
L A mismatch occurs in a link.
U The file ownership differs.
G The file group owner differs.
T The file time (mtime) differs.
The rpm -qf command can be used to determine which package a particular file belongs
to. For example the following command determines which package the /etc/passwd file
belongs to:
144 | P a g e
# rpm -V setup-2.5.58-7.el5
.M...... c /etc/passwd
S.5....T c /etc/printcap
Note that you can feed the output of the rpm -qf command to the rpm -V command:
Rationale:
It is important to confirm that packaged system files and directories are maintained with
the permissions they were intended to have from the OS vendor.
Note: Since packages and important files may change with new updates and releases, it is
recommended to verify everything, not just a finite list of files. This can be a time
consuming task and is therefore not a scored benchmark item, but is provided for those
interested in additional security measures.
Audit:
Run the following command to review all installed packages. Note that this may be very
time consuming and may be best scheduled via the cron utility. It is recommended that the
output of this command be redirected to a file that can be reviewed later.
# rpm -Va --nomtime --nosize --nomd5 --nolinkto > <filename>
Remediation:
Correct any discrepancies found and rerun the command until output is clean or risk is
mitigated or accepted.
References:
1. http://docs.fedoraproject.org/en-
US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/index.html
Level 1
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.
145 | P a g e
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 determine the permissions on the /etc/passwd file.
# /bin/ls -l /etc/passwd
-rw-r--r-- 1 root root 2055 Jan 30 16:30 /etc/passwd
Remediation:
If the permissions of the /etc/passwd file are incorrect, run the following command to
correct them:
Level 1
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 determine the permissions on the /etc/shadow file.
# /bin/ls -l /etc/shadow
---------- 1 root root 633 Sep 23 2002 /etc/shadow
146 | P a g e
Remediation:
If the permissions of the /etc/shadow file are incorrect, run the following command to
correct them:
Level 1
Description:
The /etc/gshadow file contains information about group 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/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 expiration) could also be useful to subvert the
group accounts.
Audit:
Run the following command to determine the permissions on the /etc/gshadow file.
# /bin/ls -l /etc/gshadow
---------- 1 root root 633 Sep 23 2002 /etc/gshadow
Remediation:
If the permissions of the /etc/gshadow file are incorrect, run the following command to
correct them:
Level 1
Description:
147 | P a g e
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:
Audit:
Run the following command to determine the permissions on the /etc/group file.
# /bin/ls -l /etc/group
-rw-r--r-- 1 root root 762 Sep 23 002 /etc/group
Remediation:
If the permissions of the /etc/group file are incorrect, run the following command to
correct them:
Level 1
Description:
The /etc/passwd file contains a list of all the valid userIDs defined in the system, but not
the passwords. The command below sets the owner and group of the file to root.
Rationale:
Audit:
Run the following command to determine the user and group ownership on the
/etc/passwd file.
148 | P a g e
# /bin/ls -l /etc/passwd
-rw-r--r-- 1 root root 762 Sep 23 002 /etc/passwd
Remediation:
If the user and group ownership of the /etc/passwd file are incorrect, run the following
command to correct them:
Level 1
Description:
The /etc/shadow file contains the one-way cipher text passwords for each user defined in
the /etc/passwd file. The command below sets the user and group ownership of the file to
root.
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 determine the permissions on the /etc/shadow file.
# /bin/ls -l /etc/shadow
---------- 1 root root 762 Sep 23 2002 /etc/shadow
Remediation:
If the ownership of the /etc/shadow file are incorrect, run the following command to
correct them:
149 | P a g e
Level 1
Description:
The /etc/gshadow file contains information about group 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/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 expiration) could also be useful to subvert the
group accounts.
Audit:
Run the following command to determine the permissions on the /etc/gshadow file.
# /bin/ls -l /etc/gshadow
---------- 1 root root 633 Sep 23 2002 /etc/gshadow
Remediation:
If the ownership of the /etc/gshadow file are incorrect, run the following command to
correct them:
Level 1
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:
Audit:
150 | P a g e
Run the following command to determine the permissions on the /etc/group file.
# /bin/ls -l /etc/group
-rw-r--r-- 1 root root 762 Sep 23 002 /etc/group
Remediation:
If the ownership of the /etc/group file are incorrect, run the following command to
correct them:
Level 1
Description:
Unix-based systems support variable settings to control access to files. World writable files
are the least secure. See the chmod(2) man page for more information.
Rationale:
Data in world-writable files can be modified and compromised by any user on the system.
World writable files may also indicate an incorrectly written script or program that could
potentially be the cause of a larger compromise to the system's integrity.
Audit:
#!/bin/bash
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -
perm -0002
Remediation:
Removing write access for the "other" category (chmod o-w <filename>) is advisable, but
always consult relevant vendor documentation to avoid breaking any application
dependencies on a given file.
Level 1
151 | P a g e
Description:
Sometimes when administrators delete users from the password file they neglect to
remove all files owned by those users from the system.
Rationale:
A new user who is assigned the deleted user's user ID or group ID may then end up
"owning" these files, and thus have more access on the system than was intended.
Audit:
#!/bin/bash
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -
ls
Remediation:
Locate files that are owned by users or groups not listed in the system configuration files,
and reset the ownership of these files to some active user on the system as appropriate.
Level 1
Description:
Sometimes when administrators delete users from the password file they neglect to
remove all files owned by those users from the system.
Rationale:
A new user who is assigned the deleted user's user ID or group ID may then end up
"owning" these files, and thus have more access on the system than was intended.
Audit:
#!/bin/bash
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -
ls
Remediation:
Locate files that are owned by users or groups not listed in the system configuration files,
and reset the ownership of these files to some active user on the system as appropriate.
152 | P a g e
9.1.13 Find SUID System Executables (Not Scored)
Profile Applicability:
Level 1
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 program is to enable users to perform
functions (such as changing their password) that require root privileges.
Rationale:
There are valid reasons for SUID programs, but it is important to identify and review such
programs to ensure they are legitimate.
Audit:
#!/bin/bash
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -
perm -4000 -print
Remediation:
Ensure that no rogue set-UID 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
as described below:
Level 1
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 SGID program is to enable users to perform
functions (such as changing their password) that require root privileges.
153 | P a g e
Rationale:
There are valid reasons for SGID programs, but it is important to identify and review such
programs to ensure they are legitimate. Review the files returned by the action in the audit
section and check to see if system binaries have a different md5 checksum than what from
the package. This is an indication that the binary may have been replaced. The following is
an example of checking the "sudo" executable:
Audit:
#!/bin/bash
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type f -
perm -2000 -print
Remediation:
Ensure that no rogue set-GID programs have been introduced into the system
Level 1
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:
154 | P a g e
# /bin/cat /etc/shadow | /bin/awk -F: '($2 == "" ) { print $1 " does not have a
password "}'
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:
# /usr/bin/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.
Level 1
Description:
The character + in various files used to be markers for systems to insert data from NIS
maps at a certain point in a system configuration file. These entries are no longer required
on CentOS 7 systems, but may exist in files that have been imported from other platforms.
Rationale:
These entries may provide an avenue for attackers to gain privileged access on the system.
Audit:
Remediation:
Level 1
Description:
155 | P a g e
The character + in various files used to be markers for systems to insert data from NIS
maps at a certain point in a system configuration file. These entries are no longer required
on CentOS 7 systems, but may exist in files that have been imported from other platforms.
Rationale:
These entries may provide an avenue for attackers to gain privileged access on the system.
Audit:
Remediation:
Level 1
Description:
The character + in various files used to be markers for systems to insert data from NIS
maps at a certain point in a system configuration file. These entries are no longer required
on CentOS 7 systems, but may exist in files that have been imported from other platforms.
Rationale:
These entries may provide an avenue for attackers to gain privileged access on the system.
Audit:
Remediation:
156 | P a g e
Profile Applicability:
Level 1
Description:
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 7.5 Restrict root Login to System Console.
Audit:
Run the following command and verify that only the word "root" is returned:
Remediation:
Level 1
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:
#!/bin/bash
if [ "`echo $PATH | /bin/grep :: `" != "" ]; then
echo "Empty Directory in PATH (::)"
157 | P a g e
fi
Remediation:
Level 1
Description:
While the system administrator can establish secure permissions for users' home
directories, the users can easily override these.
Rationale:
Group or world-writable user home directories may enable malicious users to steal or
modify other users' data or to gain another user's system privileges.
Audit:
158 | P a g e
#!/bin/bash
for dir in `/bin/cat /etc/passwd | /bin/egrep -v '(root|halt|sync|shutdown)' |\
/bin/awk -F: '($8 == "PS" && $7 != "/sbin/nologin") { print $6 }'`; do
dirperm=`/bin/ls -ld $dir | /bin/cut -f1 -d" "`
if [ `echo $dirperm | /bin/cut -c6 ` != "-" ]; then
echo "Group Write permission set on directory $dir"
fi
if [ `echo $dirperm | /bin/cut -c8 ` != "-" ]; then
echo "Other Read permission set on directory $dir"
fi
Remediation:
Making global modifications to user home directories without alerting the user community
can result in unexpected outages and unhappy users. Therefore, it is recommended that a
monitoring policy be established to report user file permissions and determine the action
to be taken in accordance with site policy.
Level 1
Description:
While the system administrator can establish secure permissions for users' "dot" files, the
users can easily override these.
Rationale:
Group or world-writable user configuration files may enable malicious users to steal or
modify other users' data or to gain another user's system privileges.
Audit:
#!/bin/bash
for dir in `/bin/cat /etc/passwd | /bin/egrep -v '(root|sync|halt|shutdown)' |
/bin/awk -F: '($7 != "/sbin/nologin") { print $6 }'`; do
for file in $dir/.[A-Za-z0-9]*; do
159 | P a g e
if [ `echo $fileperm | /bin/cut -c6 ` != "-" ]; then
echo "Group Write permission set on file $file"
fi
if [ `echo $fileperm | /bin/cut -c9 ` != "-" ]; then
echo "Other Write permission set on file $file"
fi
fi
done
done
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.
Level 1
Description:
While the system administrator can establish secure permissions for users' .netrc files,
the users can easily override these.
Rationale:
.netrc files may contain unencrypted passwords that may be used to attack other
systems.
Audit:
#!/bin/bash
for dir in `/bin/cat /etc/passwd | /bin/egrep -v '(root|sync|halt|shutdown)' |\
/bin/awk -F: '($7 != "/sbin/nologin") { print $6 }'`; do
for file in $dir/.netrc; do
if [ ! -h "$file" -a -f "$file" ]; then
fileperm=`/bin/ls -ld $file | /bin/cut -f1 -d" "`
if [ `echo $fileperm | /bin/cut -c5 ` != "-" ]
then
echo "Group Read set on $file"
fi
if [ `echo $fileperm | /bin/cut -c6 ` != "-" ]
then
echo "Group Write set on $file"
fi
160 | P a g e
if [ `echo $fileperm | /bin/cut -c7 ` != "-" ]
then
echo "Group Execute set on $file"
fi
if [ `echo $fileperm | /bin/cut -c8 ` != "-" ]
then
echo "Other Read set on $file"
fi
if [ `echo $fileperm | /bin/cut -c9 ` != "-" ]
then
echo "Other Write set on $file"
fi
if [ `echo $fileperm | /bin/cut -c10 ` != "-" ]
then
echo "Other Execute set on $file"
fi
fi
done
done
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 .netrc file permissions and determine the action to be
taken in accordance with site policy.
Level 1
Description:
While no .rhosts files are shipped with CentOS 7, users can easily create them.
Rationale:
This action is only meaningful if .rhosts support is permitted in the file /etc/pam.conf.
Even though the .rhosts files are ineffective if support is disabled in /etc/pam.conf, they
may have been brought over from other systems and could contain information useful to
an attacker for those other systems.
Audit:
#!/bin/bash
for dir in `/bin/cat /etc/passwd | /bin/egrep -v '(root|halt|sync|shutdown)' |\
/bin/awk -F: '($7 != "/sbin/nologin") { print $6 }'`; do
for file in $dir/.rhosts; do
if [ ! -h "$file" -a -f "$file" ]; then
echo ".rhosts file in $dir"
161 | P a g e
fi done
done
Remediation:
If any users have .rhosts files determine why they have them.
Level 1
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:
#!/bin/bash
Remediation:
Analyze the output of the Audit step above and perform the appropriate action to correct
any discrepancies found.
9.2.12 Check That Users Are Assigned Valid Home Directories (Scored)
Profile Applicability:
Level 1
Description:
162 | P a g e
Users can be defined in /etc/passwd without a home directory or with a home directory
does not actually exist.
Rationale:
If the user's home directory does not exist or is unassigned, the user will be placed in "/"
and will not be able to write any files or have local environment variables set.
Audit:
This script checks to make sure that home directories assigned in the /etc/passwd file
exist.
#!/bin/bash
cat /etc/passwd | awk -F: '{ print $1 " " $3 " " $6 }' | while read user uid dir; do
if [ $uid -ge 1000 -a ! -d "$dir" -a $user != "nfsnobody" ]; then
echo "The home directory ($dir) of user $user does not exist."
fi
done
Remediation:
If any users' home directories do not exist, create them and make sure the respective user
owns the directory. Users without assigned should be removed or assigned a home
directory as appropriate.
Level 1
Description:
The user home directory is space defined for the particular user to set local environment
variables and to store personal files.
Rationale:
Since the user is accountable for files stored in the user home directory, the user must be
the owner of the directory.
Audit:
This script checks to make sure users own the home directory they are assigned to in the
/etc/passwd file.
163 | P a g e
#!/bin/bash
cat /etc/passwd | awk -F: '{ print $1 " " $3 " " $6 }' | while read user uid dir; do
if [ $uid -ge 1000 -a -d "$dir" -a $user != "nfsnobody" ]; then
owner=$(stat -L -c "%U" "$dir")
if [ "$owner" != "$user" ]; then
echo "The home directory ($dir) of user $user is owned by $owner."
fi
fi
done
Remediation:
Change the ownership any home directories that are not owned by the defined user to the
correct user.
Level 1
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:
This script checks to make sure all UIDs in the /etc/passwd file are unique.
#!/bin/bash
echo "The Output for the Audit of Control 9.2.15 - Check for Duplicate UIDs is"
/bin/cat /etc/passwd | /bin/cut -f3 -d":" | /bin/sort -n | /usr/bin/uniq -c |\
while read x ; do
[ -z "${x}" ] && break
set - $x
if [ $1 -gt 1 ]; then
users=`/bin/gawk -F: '($3 == n) { print $1 }' n=$2 \
/etc/passwd | /usr/bin/xargs`
echo "Duplicate UID ($2): ${users}"
fi
done
Remediation:
164 | P a g e
Based on the results of the script, establish unique UIDs and review all files owned by the
shared UID to determine which UID they are supposed to belong to.
Level 1
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.
Note: In the case of extremely large groups it can become necessary to split a GID across
group names due to character limits per line. Any such instances should be carefully
audited, unless absolutely necessary such instances should be avoided.
Audit:
This script checks to make sure all GIDs in the /etc/group file are unique. You can also use
the /usr/sbin/grpck command to check for other inconsistencies in the /etc/group file.
#!/bin/bash
echo "The Output for the Audit of Control 9.2.16 - Check for Duplicate GIDs is"
Remediation:
Based on the results of the script, establish unique GIDs and review all files owned by the
shared GID to determine which group they are supposed to belong to.
165 | P a g e
9.2.16 Check That Reserved UIDs Are Assigned to System Accounts
(Scored)
Profile Applicability:
Level 1
Description:
Traditionally, UNIX systems establish "reserved" UIDs (0-999 range) that are intended for
system accounts.
Rationale:
If a user is assigned a UID that is in the reserved range, even if it is not presently in use,
security exposures can arise if a subsequently installed application uses the same UID.
Audit:
This script checks to make sure that "reserved" UIDs (0-499 range) are not assigned to
non-system (default) accounts.
#!/bin/bash
defUsers="root bin daemon adm lp sync shutdown halt mail news uucp operator games
gopher ftp nobody nscd vcsa rpc mailnull smmsp pcap ntp dbus avahi sshd rpcuser
nfsnobody haldaemon avahi-autoipd distcache apache oprofile webalizer dovecot squid
named xfs gdm sabayon usbmuxd rtkit abrt saslauth pulse postfix tcpdump"
/bin/cat /etc/passwd |\
/bin/awk -F: '($3 < 1000) { print $1" "$3 }' |\
while read user uid; do
found=0
for tUser in ${defUsers}
do
if [ ${user} = ${tUser} ]; then
found=1
fi
done
if [ $found -eq 0 ]; then
echo "User $user has a reserved UID ($uid)."
fi
done
Remediation:
Based on the results of the script, change any UIDs that are in the reserved range to one
that is in the user range. Review all files owned by the reserved UID to determine which
UID they are supposed to belong to.
Level 1
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:
This script checks to make sure all user names in the /etc/passwd file are unique.
#!/bin/bash
echo "The Output for the Audit of Control 9.2.18 - Check for Duplicate User Names is"
cat /etc/passwd | cut -f1 -d":" | /bin/sort -n | /usr/bin/uniq -c |\
while read x ; do
[ -z "${x}" ] && break
set - $x
if [ $1 -gt 1 ]; then
uids=`/bin/gawk -F: '($1 == n) { print $3 }' n=$2 \
/etc/passwd | xargs`
echo "Duplicate User Name ($2): ${uids}"
fi
done
Remediation:
Based on the results of the script, establish unique user names for the users. File
ownerships will automatically reflect the change as long as the users have unique UIDs.
Level 1
Description:
167 | P a g e
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:
This script checks to make sure all group names in the /etc/group file are unique.
#!/bin/bash
echo "The Output for the Audit of Control 9.2.19 - Check for Duplicate Group Names is"
cat /etc/group | cut -f1 -d":" | /bin/sort -n | /usr/bin/uniq -c |\
while read x ; do
[ -z "${x}" ] && break
set - $x
if [ $1 -gt 1 ]; then
gids=`/bin/gawk -F: '($1 == n) { print $3 }' n=$2 \
/etc/group | xargs`
echo "Duplicate Group Name ($2): ${gids}"
fi
done
Remediation:
Based on the results of the script, establish unique names for the user groups. File group
ownerships will automatically reflect the change as long as the groups have unique GIDs.
Level 1
Description:
The .netrc file contains data for logging into a remote host for file transfers via FTP.
Rationale:
The .netrc file presents a significant security risk since it stores passwords in
unencrypted form. Even if FTP is disabled, user accounts may have brought over .netrc
files from other systems which could pose a risk to those systems.
168 | P a g e
Audit:
#!/bin/bash
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 .netrc files and determine the action to be taken in
accordance with site policy.
Level 1
Description:
The .forward file specifies an email address to forward the user's mail to.
Rationale:
Use of the .forward file poses a security risk in that sensitive data may be inadvertently
transferred outside the organization. The .forward file also poses a risk as it can be used
to execute commands that may perform unintended actions.
Audit:
This script checks for the presence of .forward files that may be in violation of the site
security policy.
#!/bin/bash
Remediation:
169 | P a g e
Making global modifications to users' files without alerting the user community can result
in unexpected outages and unhappy users. Therefore, it is recommended that a monitoring
policy be established to report user .forward files and determine the action to be taken in
accordance with site policy.
170 | P a g e
Appendix: Change History
Date Version Changes for this version
171 | P a g e
04-02-2015 1.1.0 Updated 6.3.2 title (Ticket #7)
172 | P a g e