CIS BenchMark Linux7
CIS BenchMark Linux7
Here /tmp is created as a file and mounted as a partition using loop mount option. Make sure there is
enough free space under / to spare a 2G file for /tmp. Run df -h command to verify the free space.
Use dd command to create a file of 2G. Change the count if you want to increase the size.
Use lsof command to check if there is any application or process using /tmp actively. If you see any
outputs you need to get downtime and reboot the instance. You don't need to run the following
command. During booting, it will automatically get mounted as the entries are there in the fstab file.
# lsof /tmp
or
Remediation
For new installations, during installation create a custom partition setup and specify a separate
partition for /tmp.
For systems that were previously installed, create a new partition for /tmp if not using tmpfs.
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,noexec,nodev,nosuid
Impact
========================================
=======================================
vim /etc/modprobe.d/usb_storage.conf
rmmod usb-storage
rmmod usb-storage
====================================================================
Systems need to have package manager repositories configured to ensure they receive the latest patches
and updates.
Rationale:
If a system's package repositories are misconfigured important patches may not be identified or a rogue
repository could introduce compromised software.
NOTE: Nessus has provided the target output to assist in reviewing the benchmark to ensure target
compliance.
Solution
================================================
visudo
Defaults use_pty
Note: visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the sudoers file
against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. If the
sudoers file is currently being edited you will receive a message to try again later. The -f option allows
you to tell visudo which file to edit.
Rationale:
Attackers can run a malicious program using sudo, which would again fork a background process that
remains even when the main program has finished executing.
This can be mitigated by configuring sudo to run other commands only from a pseudo-pty, whether I/O
logging is turned on or not.
Solution
Edit the file /etc/sudoers or a file in /etc/sudoers.d/ with visudo or visudo -f <PATH TO FILE> and add the
following line:
Defaults use_pty
==============================================
visudo
Defaults logfile='/var/log/sudo.log'
Note: visudo edits the sudoers file in a safe fashion, analogous to vipw(8). visudo locks the sudoers file
against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. If the
sudoers file is currently being edited you will receive a message to try again later. The -f option allows
you to tell visudo which file to edit.
Rationale:
Impact:
Editing the sudo configuration incorrectly can cause sudo to stop functioning
Solution
edit the file /etc/sudoers or a file in /etc/sudoers.d/ with visudo or visudo -f <PATH TO FILE> and add the
following line:
Example:
Defaults logfile='/var/log/sudo.log'
===============================================================
Periodic checking of the filesystem integrity is needed to detect changes to the filesystem.
Rationale:
Periodic file checking allows the system administrator to determine on a regular basis if critical files have
been changed in an unauthorized fashion.
Solution
# crontab -u root -e
OR if aidecheck.service and aidecheck.timer will be used to schedule and run aide check:
Create or edit the file /etc/systemd/system/aidecheck.service and add the following lines:
[Unit]
Description=Aide Check
[Service]
Type=simple
ExecStart=/usr/sbin/aide --check
[Install]
WantedBy=multi-user.target
Create or edit the file /etc/systemd/system/aidecheck.timer and add the following lines:
[Unit]
[Timer]
OnCalendar=*-*-* 05:00:00
Unit=aidecheck.service
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
====================================================
Recent processors in the x86 family support the ability to prevent code execution on a per memory page
basis. Generically and on AMD processors, this ability is called No Execute (NX), while on Intel processors
it is called Execute Disable (XD). This ability can help prevent exploitation of buffer overflow
vulnerabilities and should be activated whenever possible. Extra steps must be taken to ensure that this
protection is enabled, particularly on 32-bit x86 systems. Other processors, such as Itanium and POWER,
have included such support since inception and the standard kernel for those platforms supports the
feature.
Note: Ensure your system supports the XD or NX bit and has PAE support before implementing this
recommendation as this may prevent it from booting if these are not supported by your hardware
Rationale:
Enabling any feature that can protect against buffer overflow attacks enhances the security of the
system.
Solution
On 32 bit systems install a kernel with PAE support, no installation is required on 64 bit systems:
If necessary configure your bootloader to load the new kernel and reboot the system.
===============================================================================
Address space layout randomization (ASLR) is an exploit mitigation technique which randomly arranges
the address space of key data areas of a process.
Rationale:
Randomly placing virtual memory regions will make it difficult to write memory page exploits as the
memory placement will be consistently shifting.
Solution
kernel.randomize_va_space = 2
Run the following commands to comment out entries that override the default setting of
kernel.randomize_va_space:
# sed -ri 's/^s*kernel.randomize_va_spaces*=s*([0-1]|[3-9]|[1-9][0-9]+)/# &/gi' /etc/sysctl.conf
===================================================================
rm /etc/motd
The contents of the /etc/motd file are displayed to users after login and function as a message of the day
for authenticated users.
Unix-based systems have typically displayed information about the OS release and patch level upon
logging in to the system. This information can be useful to developers who are developing software for a
particular OS platform. If mingetty(8) supports the following options, they display operating system
information: m - machine architecture r - operating system release s - operating system name v -
operating system version
Rationale:
Warning messages inform users who are attempting to login to the system of their legal status regarding
the system and must include the name of the organization that owns the system and any monitoring
policies that are in place. Displaying OS and patch level information in login banners also has the side
effect of providing detailed system information to attackers attempting to target specific exploits of a
system. Authorized users can easily get this information by running the ' uname -a ' command once they
have logged in.
Solution
Edit the /etc/motd file with the appropriate contents according to your site policy, remove any instances
of m , r , s , v or references to the OS platform
OR
# rm /etc/motd
========================================
ntp is a daemon which implements the Network Time Protocol (NTP). It is designed to synchronize
system clocks across a variety of systems and use a source that is highly accurate. More information on
NTP can be found at http://www.ntp.org. ntp can be configured to be a client and/or a server.
Rationale:
If ntp is in use on the system proper configuration is vital to ensuring time synchronization is working
properly.
Solution
server <remote-server>
OPTIONS='-u ntp:ntp'
2.2.7 Ensure nfs-utils is not installed or the nfs-server service is masked : Fail
=====================================================================================
=====
The Network File System (NFS) is one of the first and most widely distributed file systems in the UNIX
environment. It provides the ability for systems to mount file systems of other servers through the
network.
Rationale:
If the system does not require network shares, it is recommended that the nfs-utils and nfs-kernel-server
packages be removed to reduce the attack surface of the system.
Note: many of the libvirt packages used by Enterprise Linux virtualization are dependent on the nfs-utils
package. If the nfs-utils or nfs-kernel-server packages are required as a dependency, the nfs-server
service should be disabled and masked to reduce the attack surface of the system
Solution
OR
Run the following command to stop and mask the nfs-server service:
2.2.8 Ensure rpcbind is not installed or the rpcbind services are masked : Fail
=====================================================================================
==
systemctl status rpcbind
The rpcbind utility maps RPC services to the ports on which they listen. RPC processes notify rpcbind
when they start, registering the ports they are listening on and the RPC program numbers they expect to
serve. The client system then contacts rpcbind on the server with a particular RPC program number. The
rpcbind service redirects the client to the proper port number so it can communicate with the requested
service
Portmapper is an RPC service, which always listens on tcp and udp 111, and is used to map other RPC
services (such as nfs, nlockmgr, quotad, mountd, etc.) to their corresponding port number on the server.
When a remote host makes an RPC call to that server, it first consults with portmap to determine where
the RPC server is listening.
Rationale:
A small request (~82 bytes via UDP) sent to the Portmapper generates a large response (7x to 28x
amplification), which makes it a suitable tool for DDoS attacks. If rpcbind is not required, it is
recommended that the rpcbind package be removed to reduce the attack surface of the system.
Note: many of the libvirt packages used by Enterprise Linux virtualization, and the nfs-utils package used
for The Network File System (NFS) are dependent on the rpcbind package. If the rpcbind is required as a
dependency, the services rpcbind.service and rpcbind.socket should be stopped and masked to reduce
the attack surface of the system.
Solution
OR
Run the following commands to stop and mask the rpcbind and rpcbind.socket services:
==========================================================
HTTP or web servers provide the ability to host web site content.
Rationale:
Unless there is a need to run the system as a web server, it is recommended that the package be
removed to reduce the potential attack surface.
Notes:
Several http servers exist. apache, apache2, lighttpd, and nginx are example packages that provide an
HTTP server.
These and other packages should also be audited, and removed if not required.
Solution
2.2.17 Ensure rsync is not installed or the rsyncd service is masked : Fail
===========================================================================
The rsyncd service can be used to synchronize files between systems over network links.
Rationale:
Unless required, the rsync package should be removed to reduce the attack surface area of the system.
The rsyncd service presents a security risk as it uses unencrypted protocols for communication.
Note: If a required dependency exists for the rsync package, but the rsyncd service is not required, the
service should be masked.
Impact:
There are packages that are dependent on the rsync package. If the rsync package is removed, these
packages will be removed as well.
Before removing the rsync package, review any dependent packages to determine if they are required on
the system. If a dependent package is required, mask the rsyncd service and leave the rsync package
installed.
Solution
OR
============================================================
Wireless networking is used when wired networks are unavailable. Red Hat Enterprise Linux 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.
Solution
Impact:
Many if not all laptop workstations and some desktop workstations will connect via wireless requiring
these interfaces be enabled.
=========================================================
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. An attacker could use a
compromised host to send invalid ICMP redirects to other router devices in an attempt to corrupt
routing and have users access a system set up by the attacker as opposed to a valid system.
Solution
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
# sysctl -w net.ipv4.conf.all.send_redirects=0
# sysctl -w net.ipv4.conf.default.send_redirects=0
# sysctl -w net.ipv4.route.flush=1
==============================================================
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
# sysctl net.ipv4.conf.all.accept_source_route
net.ipv4.conf.all.accept_source_route = 0
# sysctl net.ipv4.conf.default.accept_source_route
net.ipv4.conf.default.accept_source_route = 0
Remediation
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
# sysctl -w net.ipv4.conf.all.accept_source_route=0
# sysctl -w net.ipv4.conf.default.accept_source_route=0
# sysctl -w net.ipv4.route.flush=1
==============================================================
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.
Solution
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
======================================================================
rsyslog will create logfiles that do not already exist on the system. This setting controls what
permissions will be applied to these newly created files.
Rationale:
It is important to ensure that log files have the correct permissions to ensure that sensitive data is
archived and protected.
Solution
Edit the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and set every instance of $FileCreateMode to
0640 or more restrictive:
$FileCreateMode 0640
4.2.1.5 Ensure rsyslog is configured to send logs to a remote log host : Fail
==================================================================================
RSyslog supports the ability to send log events it gathers to a remote log host or to receive messages
from remote hosts, thus enabling centralised log management.
Rationale:
Storing log data on a remote host protects log integrity from local attacks. If an attacker gains root
access on the local system, they could tamper with or remove log data that is stored on the local
system.
Solution
Edit the /etc/rsyslog.conf and /etc/rsyslog.d/*.conf files and add the following line (where
loghost.example.com is the name of your central log host). The target directive may either be a fully
qualified domain name or an IP address.
action.resumeRetryCount='100'
queue.type='LinkedList' queue.size='1000')
4.2.1.6 Ensure remote rsyslog messages are only accepted on designated log hosts. : Fail
=================================================
There are several options available to limit which users and group can access the system via SSH. It is
recommended that at least one of the following options be leveraged:
AllowUsers:
The AllowUsers variable gives the system administrator the option of allowing specific users to ssh into
the system. The list consists of space separated user names. Numeric user IDs are not recognized with
this variable. If a system administrator wants to restrict user access further by only allowing the allowed
users to log in from a particular host, the entry can be specified in the form of user@host.
AllowGroups:
The AllowGroups variable gives the system administrator the option of allowing specific groups of users
to ssh into the system. The list consists of space separated group names. Numeric group IDs are not
recognized with this variable.
DenyUsers:
The DenyUsers variable gives the system administrator the option of denying specific users to ssh into
the system. The list consists of space separated user names. Numeric user IDs are not recognized with
this variable. If a system administrator wants to restrict user access further by specifically denying a
user's access from a particular host, the entry can be specified in the form of user@host.
DenyGroups:
The DenyGroups variable gives the system administrator the option of denying specific groups of users to
ssh into the system. The list consists of space separated group names. Numeric group IDs are not
recognized with this variable.
Rationale:
Restricting which users can remotely access the system via SSH will help ensure that only authorized
users access the system.
Solution
Edit the /etc/ssh/sshd_config file to set one or more of the parameter as follows:
AllowUsers <userlist>
OR
AllowGroups <grouplist>
OR
DenyUsers <userlist>
OR
DenyGroups <grouplist>
Default Value:
None
=========================================================
The MaxStartups parameter specifies the maximum number of concurrent unauthenticated connections
to the SSH daemon.
Rationale:
To protect a system from denial of service due to a large number of pending authentication connection
attempts, use the rate limiting function of MaxStartups to protect availability of sshd logins and prevent
overwhelming the daemon.
Solution
maxstartups 10:30:60
======================================================
The MaxSessions parameter specifies the maximum number of open sessions permitted from a given
connection.
Rationale:
To protect a system from denial of service due to a large number of concurrent sessions, use the rate
limiting function of MaxSessions to protect availability of sshd logins and prevent overwhelming the
daemon.
Solution
MaxSessions 10
Default Value:
MaxSessions 10
See Also