## Guide to the Secure Configuration of Ubuntu 1404

> with profile Profile for ANSSI DAT-NT28 Restrictive Level
> This profile contains items for GNU/Linux installations exposed to unauthenticated flows or multiple sources.

The SCAP Security Guide Project
https://www.open-scap.org/security-policies/scap-security-guide
This guide presents a catalog of security-relevant configuration settings for Ubuntu 1404. It is a rendering of content structured in the eXtensible Configuration Checklist Description Format (XCCDF) in order to support security automation. The SCAP content is is available in the config_item="scap-security-guide" package which is developed at https://www.open-scap.org/security-policies/scap-security-guide.
Providing system administrators with such guidance informs them how to securely configure systems under their control in a variety of network roles. Policy makers and baseline creators can use this catalog of settings, with its associated references to higher-level security control catalogs, in order to assist them in security baseline creation. This guide is a italics="catalog, not a checklist," and satisfaction of every item is not likely to be possible or sensible in many operational scenarios. However, the XCCDF format enables granular selection and adjustment of settings, and their association with OVAL and OCIL content provides an automated checking capability. Transformations of this document, and its associated automated checking content, are capable of providing baselines that meet a diverse set of policy objectives. Some example XCCDF italics="Profiles", which are selections of items that form checklists and can be used as baselines, are available with this guide. They can be processed, in an automated fashion, with tools that support the Security Content Automation Protocol (SCAP). The DISA STIG for Ubuntu 1404, which provides required settings for US Department of Defense systems, is one example of a baseline created from this guidance.
Do not attempt to implement any of the settings in this guide without first testing them in a non-operational environment. The creators of this guidance assume no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.

Profile Title | Profile for ANSSI DAT-NT28 Restrictive Level
Profile ID | xccdf_org.ssgproject.content_profile_anssi_np_nt28_restrictive

## Revision History

Current version: 0.1.39

- draft (as of 2018-07-26)

## Platforms

- cpe:/o:canonical:ubuntu_linux:14.04

## Table of Contents

1. Services

1. Deprecated services
2. Generic required services
3. SSH Server
4. APT service configuration

2. System Settings

1. Configure Syslog
2. Access Control using sudo
3. Hardening the filesystem
4. File Permissions and Masks

## Checklist

contains 36 rules

### Services [ref]group

The best protection against vulnerable software is running less software. This section describes how to review the software which Ubuntu 1404 installs on a system and disable software which is not needed. It then enumerates the software packages installed on a default Ubuntu 1404 system and provides guidance about which ones can be safely disabled.
Ubuntu 1404 provides a convenient minimal install option that essentially installs the bare necessities for a functional system. When building Ubuntu 1404 systems, it is highly recommended to select the minimal packages and then build up the system from there.

contains 16 rules

### Deprecated services [ref]group

Some deprecated software services impact the overall system security due to their behavior (leak of confidentiality in network exchange, usage as uncontrolled communication channel, risk associated with the service due to its old age, etc.

contains 5 rules

#### Uninstall the nis package [ref]rule

The support for Yellowpages should not be installed unless it is required.

Rationale:

NIS is the historical SUN service for central account management, more and more replaced by LDAP. NIS does not support efficiently security constraints, ACL, etc. and should not be used.

Severity: low

Identifiers: CCE-

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    # CAUTION: This remediation script will remove nis
    #	   from the system, and may remove any packages
    #	   that depend on nis. Execute this
    #	   remediation AFTER testing on a non-production
    #	   system!

    apt-get remove --purge nis

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    - name: Ensure nis is removed
      package:
        name="{{item}}"
        state=absent
      with_items:
        - nis
      tags:
        - package_nis_removed
        - low_severity
        - disable_strategy
        - low_complexity
        - low_disruption
        - CCE-

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    include remove_nis

    class remove_nis {
      package { 'nis':
        ensure => 'purged',
      }
    }

#### Uninstall the inet-based telnet server [ref]rule

The inet-based telnet daemon should be uninstalled.

Rationale:

telnet allows clear text communications, and does not protect any data transmission between client and server. Any confidential data can be listened and no integrity checking is made.

Severity: high

Identifiers: CCE-

References: NT007(R03), AC-17(8), CM-7

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    # CAUTION: This remediation script will remove inetutils-telnetd
    #	   from the system, and may remove any packages
    #	   that depend on inetutils-telnetd. Execute this
    #	   remediation AFTER testing on a non-production
    #	   system!

    apt-get remove --purge inetutils-telnetd

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    - name: Ensure inetutils-telnetd is removed
      package:
        name="{{item}}"
        state=absent
      with_items:
        - inetutils-telnetd
      tags:
        - package_inetutils-telnetd_removed
        - high_severity
        - disable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-AC-17(8)
        - NIST-800-53-CM-7

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    include remove_inetutils-telnetd

    class remove_inetutils-telnetd {
      package { 'inetutils-telnetd':
        ensure => 'purged',
      }
    }

#### Uninstall the ntpdate package [ref]rule

ntpdate is a historical ntp synchronization client for unixes. It sould be uninstalled.

Rationale:

ntpdate is an old not security-compliant ntp client. It should be replaced by modern ntp clients such as ntpd, able to use cryptographic mechanisms integrated in NTP.

Severity: low

Identifiers: CCE-

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    # CAUTION: This remediation script will remove ntpdate
    #	   from the system, and may remove any packages
    #	   that depend on ntpdate. Execute this
    #	   remediation AFTER testing on a non-production
    #	   system!

    apt-get remove --purge ntpdate

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    - name: Ensure ntpdate is removed
      package:
        name="{{item}}"
        state=absent
      with_items:
        - ntpdate
      tags:
        - package_ntpdate_removed
        - low_severity
        - disable_strategy
        - low_complexity
        - low_disruption
        - CCE-

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    include remove_ntpdate

    class remove_ntpdate {
      package { 'ntpdate':
        ensure => 'purged',
      }
    }

#### Uninstall the ssl compliant telnet server [ref]rule

The telnet daemon, even with ssl support, should be uninstalled.

Rationale:

telnet, even with ssl support, should not be installed. When remote shell is required, up-to-date ssh daemon can be used.

Severity: high

Identifiers: CCE-

References: NT007(R02), AC-17(8), CM-7

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    # CAUTION: This remediation script will remove telnetd-ssl
    #	   from the system, and may remove any packages
    #	   that depend on telnetd-ssl. Execute this
    #	   remediation AFTER testing on a non-production
    #	   system!

    apt-get remove --purge telnetd-ssl

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    - name: Ensure telnetd-ssl is removed
      package:
        name="{{item}}"
        state=absent
      with_items:
        - telnetd-ssl
      tags:
        - package_telnetd-ssl_removed
        - high_severity
        - disable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-AC-17(8)
        - NIST-800-53-CM-7

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    include remove_telnetd-ssl

    class remove_telnetd-ssl {
      package { 'telnetd-ssl':
        ensure => 'purged',
      }
    }

#### Uninstall the telnet server [ref]rule

The telnet daemon should be uninstalled.

Rationale:

telnet allows clear text communications, and does not protect any data transmission between client and server. Any confidential data can be listened and no integrity checking is made.

Severity: high

Identifiers: CCE-

References: NT007(R03), AC-17(8), CM-7

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    # CAUTION: This remediation script will remove telnetd
    #	   from the system, and may remove any packages
    #	   that depend on telnetd. Execute this
    #	   remediation AFTER testing on a non-production
    #	   system!

    apt-get remove --purge telnetd

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    - name: Ensure telnetd is removed
      package:
        name="{{item}}"
        state=absent
      with_items:
        - telnetd
      tags:
        - package_telnetd_removed
        - high_severity
        - disable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-AC-17(8)
        - NIST-800-53-CM-7

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | disable

    include remove_telnetd

    class remove_telnetd {
      package { 'telnetd':
        ensure => 'purged',
      }
    }

### Generic required services [ref]group

Some services need to be deployed in order to ensure basic verifications and reporting on GNU/Linux operating systems. Each of these service take part in the administrability of the system.

contains 5 rules

#### Install the cron service [ref]rule

The Cron service should be installed.

Rationale:

The cron service allow periodic job execution, needed for almost all administrative tasks and services (software update, log rotating, etc.). Access to cron service should be restricted to administrative accounts only.

Severity: medium

Identifiers: CCE-

References: NT28(R50), CM-7

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    - name: Ensure cron is installed
      package:
        name="{{item}}"
        state=present
      with_items:
        - cron
      tags:
        - package_cron_installed
        - medium_severity
        - enable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-CM-7

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    include install_cron

    class install_cron {
      package { 'cron':
        ensure => 'installed',
      }
    }

#### Install the ntp service [ref]rule

The ntpd service should be installed.

Rationale:

Time synchronization (using NTP) is required by almost all network and administrative tasks (syslog, cryptographic based services (authentication, etc.), etc.). Ntpd is regulary maintained and updated, supporting security features such as RFC 5906.

Severity: high

Identifiers: CCE-

References: NT012(R03), CCI-000160, AU-8(1), Req-10.4

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    - name: Ensure ntp is installed
      package:
        name="{{item}}"
        state=present
      with_items:
        - ntp
      tags:
        - package_ntp_installed
        - high_severity
        - enable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-AU-8(1)
        - PCI-DSS-Req-10.4

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    include install_ntp

    class install_ntp {
      package { 'ntp':
        ensure => 'installed',
      }
    }

#### install the auditd service [ref]rule

The auditd service should be installed.

Rationale:

The auditd service is an access monitoring and accounting daemon, watching system calls to audit any access, in comparision with potential local access control policy such as SELinux policy.

Severity: medium

Identifiers: CCE-

References: NT28(R50)

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    - name: Ensure auditd is installed
      package:
        name="{{item}}"
        state=present
      with_items:
        - auditd
      tags:
        - package_auditd_installed
        - medium_severity
        - enable_strategy
        - low_complexity
        - low_disruption
        - CCE-

Remediation Puppet snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    include install_auditd

    class install_auditd {
      package { 'auditd':
        ensure => 'installed',
      }
    }

#### Enable the ntpd service [ref]rule

The ntpd service should be enabled.

Rationale:

Time synchronization (using NTP) is required by almost all network and administrative tasks (syslog, cryptographic based services (authentication, etc.), etc.). Ntpd is regulary maintained and updated, supporting security features such as RFC 5906.

Severity: high

Identifiers: CCE-

References: NT012(R03), CCI-000160, AU-8(1), Req-10.4

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    - name: Enable service ntpd
      service:
        name="{{item}}"
        enabled="yes"
        state="started"
      with_items:
        - ntpd
      tags:
        - service_ntpd_enabled
        - high_severity
        - enable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-AU-8(1)
        - PCI-DSS-Req-10.4

#### Enable the auditd service [ref]rule

The auditd service should be enabled.

Rationale:

The auditd service is an access monitoring and accounting daemon, watching system calls to audit any access, in comparision with potential local access control policy such as SELinux policy.

Severity: medium

Identifiers: CCE-

References: NT28(R50), CCI-000347, CCI-000157, CCI-000172, CCI-000880, CCI-001353, CCI-001462, CCI-001487, CCI-001115, CCI-001454, CCI-000067, CCI-000158, CCI-000831, CCI-001190, CCI-001312, CCI-001263, CCI-000130, CCI-000120, CCI-001589, AC-17(1), AU-1(b), AU-10, AU-12(a), AU-12(c), IR-5, Req-10

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | enable

    - name: Enable service auditd
      service:
        name="{{item}}"
        enabled="yes"
        state="started"
      with_items:
        - auditd
      tags:
        - service_auditd_enabled
        - medium_severity
        - enable_strategy
        - low_complexity
        - low_disruption
        - CCE-
        - NIST-800-53-AC-17(1)
        - NIST-800-53-AU-1(b)
        - NIST-800-53-AU-10
        - NIST-800-53-AU-12(a)
        - NIST-800-53-AU-12(c)
        - NIST-800-53-IR-5
        - PCI-DSS-Req-10

### SSH Server [ref]group

The SSH protocol is recommended for remote access (remote login and secure remote file transfer). SSH provides both confidentiality and integrity for exchanged data but needs to be configured properly in term of:
Cryptography usage, according to the current CVEs associated to the various cryptographic modes
Authentication and autorization, depending on your needs but requiring some specific initial generic security
consideration in the OpenSSH configuration writing More detailed information is available from the OpenSSH project's website http://www.openssh.org. The Ubuntu package for server side implementation is called `openssh-server`.

contains 5 rules

### Configure OpenSSH Server if deployed [ref]group

If the system needs to act as an SSH server, then certain changes should be made to the OpenSSH daemon configuration file `/etc/ssh/sshd_config`. The following recommendations can be applied to this file. See the `sshd_config(5)` man page for more detailed information.

contains 5 rules

#### Allow Only SSH Protocol 2 [ref]rule

Only SSH protocol version 2 connections should be permitted. The default setting in `/etc/ssh/sshd_config` is correct, and can be verified by ensuring that the following line appears:

    Protocol 2

Rationale:

SSH protocol version 1 suffers from design flaws that result in security vulnerabilities and should not be used.

Severity: high

Identifiers: CCE-

References: NT007(R1), AC-17(7), IA-5(1)(c)

#### Disable SSH Access via Empty Passwords [ref]rule

To explicitly disallow remote login from accounts with empty passwords, add or correct the following line in `/etc/ssh/sshd_config`:

    PermitEmptyPasswords no

Any accounts with empty passwords should be disabled immediately, and PAM configuration should prevent users from being able to assign themselves empty passwords.Rationale:

Configuring this setting for the SSH daemon provides additional assurance that remote login via SSH will require a password, even in the event of misconfiguration elsewhere.

Severity: high

Identifiers: CCE-

References: NT007(R17), AC-3

#### Set SSH Idle Timeout Interval [ref]rule

SSH allows administrators to set an idle timeout interval. After this interval has passed, the idle user will be automatically logged out.
To set an idle timeout interval, edit the following line in `/etc/ssh/sshd_config` as follows:

    ClientAliveInterval interval

The timeout interval is given in seconds. To have a timeout of 15 minutes, set interval to 900.
If a shorter timeout has already been set for the login shell, that value will preempt any SSH setting made here. Keep in mind that some processes may stop SSH from correctly detecting that the user is idle.Rationale:

Causing idle users to be automatically logged out guards against compromises one system leading trivially to compromises on another.

Severity: unknown

Identifiers: CCE-

References: AC-2(5), SA-8, Req-8.1.8

#### Set SSH Client Alive Count [ref]rule

To ensure the SSH idle timeout occurs precisely when the `ClientAliveCountMax` is set, edit `/etc/ssh/sshd_config` as follows:

    ClientAliveCountMax 0

Rationale:

This ensures a user login will be terminated as soon as the `ClientAliveCountMax` is reached.

Severity: unknown

Identifiers: CCE-

References: AC-2(5), SA-8

#### Disable SSH Root Login [ref]rule

The root user should never be allowed to login to a system directly over a network. To disable root login via SSH, add or correct the following line in `/etc/ssh/sshd_config`:

    PermitRootLogin no

Rationale:

Permitting direct root login reduces auditable information about who ran privileged commands on the system and also allows direct attack attempts on root's password.

Severity: medium

Identifiers: CCE-

References: NT007(R21), AC-3, AC-6(2), IA-2(1)

### APT service configuration [ref]group

The apt service manage the package management and update of the whole system. Its configuration need to be properly defined to ensure efficient security updates, packages and repository authentication and proper lifecycle management.

contains 1 rule

#### Disable unauthenticated repositories in APT configuration [ref]rule

Unauthenticated repositories should not be used for updates.

Rationale:

Repositories hosts all packages that will be intsalled on the system during update. If a repository is not authenticated, the associated packages can't be trusted, and then should not be installed localy.

Severity: unknown

References: NT28(R15)

### System Settings [ref]group

Contains rules that check correct system settings.

contains 20 rules

### Configure Syslog [ref]group

The syslog service has been the default Unix logging mechanism for many years. It has a number of downsides, including inconsistent log format, lack of authentication for received messages, and lack of authentication, encryption, or reliable transport for messages sent over a network. However, due to its long history, syslog is a de facto standard which is supported by almost all Unix applications.
In Ubuntu 1404, rsyslog has replaced syslog as the syslog daemon of choice, and it includes some additional security features such as reliable, connection-oriented (i.e. TCP) transmission of logs, the option to log to database formats, and the encryption of log data en route to a central logging server. This section discusses how to configure rsyslog for best effect, and how to use tools provided with the system to maintain and monitor logs. Yet, it is also possible to install syslog-ng to manage local and server-side logging services. Both are tested here, to let the administrator choose.

contains 4 rules

### Ensure Proper Configuration of Log Files [ref]group

The file `/etc/rsyslog.conf` controls where log message are written. These are controlled by lines called rules, which consist of a selector and an action. These rules are often customized depending on the role of the system, the requirements of the environment, and whatever may enable the administrator to most effectively make use of log data. The default rules in Ubuntu 1404 are:

    auth,authpriv.*			/var/log/auth.log
    *.*;auth,authpriv.none          -/var/log/syslog
    daemon.*                        -/var/log/daemon.log
    kern.*                          -/var/log/kern.log
    lpr.*                           -/var/log/lpr.log
    mail.*                          -/var/log/mail.log
    user.*                          -/var/log/user.log
    mail.info                       -/var/log/mail.info
    mail.warn                       -/var/log/mail.warn
    mail.err                        /var/log/mail.err
    news.crit                       /var/log/news/news.crit
    news.err                        /var/log/news/news.err
    news.notice                     -/var/log/news/news.notice

See the man page `rsyslog.conf(5)` for more information. Note that the `rsyslog` daemon is configured to use traditional timestamping to be understood by any log processing program. For high precision timestamping, comment the following line in `/etc/rsyslog.conf`:

    $ ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

contains 3 rules

#### Ensure System Log Files Have Correct Permissions [ref]rule

The file permissions for all log files written by `rsyslog` should be set to 640, or more restrictive. These log files are determined by the second part of each Rule line in `/etc/rsyslog.conf` and typically all appear in `/var/log`. For each log file LOGFILE referenced in `/etc/rsyslog.conf`, run the following command to inspect the file's permissions:

    $ ls -l LOGFILE

If the permissions are not 640 or more restrictive, run the following command to correct this:

    $ sudo chmod 0640 LOGFILE

Rationale:

Log files can contain valuable information regarding system configuration. If the system log files are not protected unauthorized users could change the logged data, eliminating their forensic value.

Severity: medium

References: NT28(R36), 5.1.4, CCI-001314, SI-11, Req-10.5.1, Req-10.5.2

#### Ensure Log Files Are Owned By Appropriate User [ref]rule

The owner of all log files written by `rsyslog` should be root. These log files are determined by the second part of each Rule line in `/etc/rsyslog.conf` and typically all appear in `/var/log`. For each log file LOGFILE referenced in `/etc/rsyslog.conf`, run the following command to inspect the file's owner:

    $ ls -l LOGFILE

If the owner is not `root`, run the following command to correct this:

    $ sudo chown root LOGFILE

Rationale:

The log files generated by rsyslog contain valuable information regarding system configuration, user authentication, and other such information. Log files should be protected from unauthorized access.

Severity: medium

References: NT28(R46), NT28(R5), CCI-001314, AC-6, SI-11, Req-10.5.1, Req-10.5.2

#### Ensure Log Files Are Owned By Appropriate Group [ref]rule

The group-owner of all log files written by `rsyslog` should be root. These log files are determined by the second part of each Rule line in `/etc/rsyslog.conf` and typically all appear in `/var/log`. For each log file LOGFILE referenced in `/etc/rsyslog.conf`, run the following command to inspect the file's group owner:

    $ ls -l LOGFILE

If the owner is not `adm`, run the following command to correct this:

    $ sudo chgrp adm LOGFILE

Rationale:

The log files generated by rsyslog contain valuable information regarding system configuration, user authentication, and other such information. Log files should be protected from unauthorized access.

Severity: medium

References: NT28(R46), NT28(R5), CCI-001314, AC-6, SI-11, Req-10.5.1, Req-10.5.2

### Ensure All Logs are Rotated by <tt>logrotate</tt> [ref]group

Edit the file `/etc/logrotate.d/rsyslog`. Find the first line, which should look like this (wrapped for clarity):

    /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler \
      /var/log/boot.log /var/log/cron {

Edit this line so that it contains a one-space-separated listing of each log file referenced in `/etc/rsyslog.conf`.
All logs in use on a system must be rotated regularly, or the log files will consume disk space over time, eventually interfering with system operation. The file `/etc/logrotate.d/syslog` is the configuration file used by the `logrotate` program to maintain all log files written by `syslog`. By default, it rotates logs weekly and stores four archival copies of each log. These settings can be modified by editing `/etc/logrotate.conf`, but the defaults are sufficient for purposes of this guide.
Note that `logrotate` is run nightly by the cron job `/etc/cron.daily/logrotate`. If particularly active logs need to be rotated more often than once a day, some other mechanism must be used.

contains 1 rule

#### Ensure Logrotate Runs Periodically [ref]rule

The `logrotate` utility allows for the automatic rotation of log files. The frequency of rotation is specified in `/etc/logrotate.conf`, which triggers a cron task. To configure logrotate to run daily, add or correct the following line in `/etc/logrotate.conf`:

    # rotate log files frequency
    daily

Rationale:

Log files that are not properly rotated run the risk of growing so large that they fill up the /var/log partition. Valuable logging information could be lost if the /var/log partition becomes full.

Severity: unknown

References: CCI-000366, AU-9, Req-10.7

### Access Control using sudo [ref]group

`Sudo`, which stands for "su 'do'", provides the ability to delegate authority to certain users, groups of users, or system administrators. When configured for system users and/or groups, `Sudo` can allow a user or group to execute privileged commands that normally only `root` is allowed to execute.
For more information on `Sudo` and addition `Sudo` configuration options, see https://www.sudo.ws

contains 2 rules

#### Ensure Users Re-Authenticate for Privilege Escalation - sudo !authenticate [ref]rule

The sudo `!authenticate` option, when specified, allows a user to execute commands using sudo without having to authenticate. This should be disabled by making sure that the `!authenticate` option does not exist in `/etc/sudoers` configuration file or any sudo configuration snippets in `/etc/sudoers.d/`.

Rationale:

Without re-authentication, users may access resources or perform tasks for which they do not have authorization.
When operating systems provide the capability to escalate a functional capability, it is critical that the user re-authenticate.

Severity: medium

References: NT28(R5), CCI-002038, IA-11, SRG-OS-000373-GPOS-00156, SRG-OS-000373-GPOS-00157, SRG-OS-000373-GPOS-00158

#### Ensure Users Re-Authenticate for Privilege Escalation - sudo NOPASSWD [ref]rule

The sudo `NOPASSWD` tag, when specified, allows a user to execute commands using sudo without having to authenticate. This should be disabled by making sure that the `NOPASSWD` tag does not exist in `/etc/sudoers` configuration file or any sudo configuration snippets in `/etc/sudoers.d/`.

Rationale:

Without re-authentication, users may access resources or perform tasks for which they do not have authorization.
When operating systems provide the capability to escalate a functional capability, it is critical that the user re-authenticate.

Severity: medium

References: NT28(R5), CCI-002038, IA-11, SRG-OS-000373-GPOS-00156, SRG-OS-000373-GPOS-00157, SRG-OS-000373-GPOS-00158

### Hardening the filesystem [ref]group

Hardening the filesystem and its usage is an efficient way to ensure an efficient separation of services, data and configurations while ensuring a more precise management of filesystem level access rights, enabling deactivation of some specific rights at the filesystem level. Moreover, the Linux Virtual file system support various hardening mechanisms that can be set using sysctl.

contains 7 rules

### Partitioning [ref]group

Separating various locations of the file systems in different partitions allows a more restrictive segregation, distinctly from one location to another. Moreover, some native restrictions can be made by partitioning, such as no hard link between different filesystems, and reduce the corruption impact to the affected filesystem instead of the entire system. The last gain is to allow a differenciated usage of storage media, depending on the operational needs (speed, resilience, etc.).

contains 5 rules

#### Ensure /home Located On Separate Partition [ref]rule

If user home directories will be stored locally, create a separate partition for `/home` at installation time (or migrate it later using LVM). If `/home` will be mounted from another system such as an NFS server, then creating a separate partition is not necessary at installation time, and the mountpoint can instead be configured later.

Rationale:

Ensuring that `/home` is mounted on its own partition enables the setting of more restrictive mount options, and also helps ensure that users cannot trivially fill partitions used for log or audit data storage.

Severity: unknown

References: NT28(R12), CCI-001208, SC-32

#### Ensure /tmp Located On Separate Partition [ref]rule

The `/tmp` directory is a world-writable directory used for temporary file storage. Ensure it has its own partition or logical volume at installation time, or migrate it using LVM (when non-ephemeral is needed) or use tmpfs if possible.

Rationale:

The `/tmp` partition is used as temporary storage by many programs. Placing `/tmp` in its own partition enables the setting of more restrictive mount options, which can help protect programs which use it.

Severity: unknown

References: NT28(R12), SC-32

#### Ensure /var Located On Separate Partition [ref]rule

The `/var` directory is used by daemons and other system services to store frequently-changing data. Ensure that `/var` has its own partition or logical volume at installation time, or migrate it using LVM.

Rationale:

Ensuring that `/var` is mounted on its own partition enables the setting of more restrictive mount options. This helps protect system services such as daemons or other programs which use it. It is not uncommon for the `/var` directory to contain world-writable directories installed by other software packages.

Severity: unknown

References: NT28(R12), SC-32

#### Ensure /var/log/audit Located On Separate Partition [ref]rule

Audit logs are stored in the `/var/log/audit` directory. Ensure that it has its own partition or logical volume at installation time, or migrate it later using LVM. Make absolutely certain that it is large enough to store all audit logs that will be created by the auditing daemon.

Rationale:

Placing `/var/log/audit` in its own partition enables better separation between audit files and other files, and helps ensure that auditing cannot be halted due to the partition running out of space.

Severity: unknown

References: AU-4, AU-9, SC-32

#### Ensure /var/log Located On Separate Partition [ref]rule

System logs are stored in the `/var/log` directory. Ensure that it has its own partition or logical volume at installation time, or migrate it using LVM.

Rationale:

Placing `/var/log` in its own partition enables better separation between log files and other files in `/var/`.

Severity: unknown

References: NT28(R12), NT28(R47), AU-9, SC-32

### filesystem rights management [ref]group

Adding filesystem specific hardening seriously limits various exploitation vectors based on filesystem invalid usage, such as invalid file types in invalid places (devices or setuid root files in external media, executable file in insecure filesystems, etc.). Some of these hardening require an efficient system partitioning.

contains 2 rules

#### Disallow creating symlinks to a file you not own [ref]rule

To set the runtime status of the `fs.protected_hardlinks` kernel parameter, run the following command:

    $ sudo sysctl -w fs.protected_hardlinks=1

If this is not the system's default value, add the following line to `/etc/sysctl.conf`:

    fs.protected_hardlinks = 1

Rationale:

Disallowing such hardlink mitigate vulnerabilities based on insecure file system accessed by privilegied programs, avoiding an exploitation vector exploiting unsafe use of `open()` or `creat()`.

Severity: unknown

References: NT28(R23), 1.6.1, SI-11

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | medium
Reboot: | true
Strategy: | disable

    - name: Ensure sysctl fs.protected_hardlinks is set to 1
      sysctl:
        name: fs.protected_hardlinks
        value: 1
        state: present
        reload: yes
      tags:
        - sysctl_fs_protected_hardlinks
        - unknown_severity
        - disable_strategy
        - low_complexity
        - medium_disruption
        - NIST-800-53-SI-11

#### Disallow creating symlinks to a file you not own [ref]rule

To set the runtime status of the `fs.protected_symlinks` kernel parameter, run the following command:

    $ sudo sysctl -w fs.protected_symlinks=1

If this is not the system's default value, add the following line to `/etc/sysctl.conf`:

    fs.protected_symlinks = 1

Rationale:

Disallowing such symlink mitigate vulnerabilities based on insecure file system accessed by privilegied programs, avoiding an exploitation vector exploiting unsafe use of `open()` or `creat()`.

Severity: unknown

References: NT28(R23), 1.6.1, SI-11

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | medium
Reboot: | true
Strategy: | disable

    - name: Ensure sysctl fs.protected_symlinks is set to 1
      sysctl:
        name: fs.protected_symlinks
        value: 1
        state: present
        reload: yes
      tags:
        - sysctl_fs_protected_symlinks
        - unknown_severity
        - disable_strategy
        - low_complexity
        - medium_disruption
        - NIST-800-53-SI-11

### File Permissions and Masks [ref]group

Traditional Unix security relies heavily on file and directory permissions to prevent unauthorized users from reading or modifying files to which they should not have access.
Several of the commands in this section search filesystems for files or directories with certain characteristics, and are intended to be run on every local partition on a given system. When the variable PART appears in one of the commands below, it means that the command is intended to be run repeatedly, with the name of each local partition substituted for PART in turn.
The following command prints a list of all xfs partitions on the local system, which is the default filesystem for Red Hat Enterprise Linux 7 installations:

    $ mount -t xfs | awk '{print $3}'

For any systems that use a different local filesystem type, modify this command as appropriate.

contains 7 rules

### Verify Permissions on Important Files and Directories [ref]group

Permissions for many files on a system must be set restrictively to ensure sensitive information is properly protected. This section discusses important permission restrictions which can be verified to ensure that no harmful discrepancies have arisen.

contains 5 rules

### Verify Permissions on Files with Local Account Information and Credentials [ref]group

The default restrictive permissions for files which act as important security databases such as `passwd`, `shadow`, `group`, and `gshadow` files must be maintained. Many utilities need read access to the `passwd` file in order to function properly, but read access to the `shadow` file allows malicious attacks against system passwords, and should never be enabled.

contains 4 rules

#### Verify Permissions and ownership on group File [ref]rule

To properly set the permissions of `/etc/passwd`, run the command:

    $ sudo chmod 0644 /etc/passwd

To properly set the owner of `/etc/passwd`, run the command:

    $ sudo chown root /etc/passwd

To properly set the group owner of `/etc/passwd`, run the command:

    $ sudo chgrp root /etc/passwd

Rationale:

The `/etc/shadow` file contains information about the groups that are configured on the system. Protection of this file is critical for system security.

Severity: medium

References: AC-6

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    chmod 0644 /etc/group

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    - name: Ensure permission 0644 on /etc/group
      file:
        path="{{item}}"
        mode=0644
      with_items:
        - /etc/group
      tags:
        - file_permissions_etc_group
        - medium_severity
        - configure_strategy
        - low_complexity
        - low_disruption
        - NIST-800-53-AC-6

#### Verify Permissions and ownership on shadow File [ref]rule

To properly set the permissions of `/etc/shadow`, run the command:

    $ sudo chmod 0640 /etc/shadow

To properly set the owner of `/etc/shadow`, run the command:

    $ sudo chown root /etc/shadow

To properly set the group owner of `/etc/shadow`, run the command:

    $ sudo chgrp shadow /etc/shadow

Rationale:

The `/etc/shadow` file contains the list of local system accounts and stores password hashes. Protection of this file is critical for system security. Failure to give ownership of this file to root provides the designated owner with access to sensitive information which could weaken the system security posture.

Severity: medium

References: NT28(R36), AC-6, Req-8.7.c

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    chmod 0640 /etc/shadow

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    - name: Ensure permission 0640 on /etc/shadow
      file:
        path="{{item}}"
        mode=0640
      with_items:
        - /etc/shadow
      tags:
        - file_permissions_etc_shadow
        - medium_severity
        - configure_strategy
        - low_complexity
        - low_disruption
        - NIST-800-53-AC-6
        - PCI-DSS-Req-8.7.c

#### Verify Permissions and ownership on gshadow File [ref]rule

To properly set the permissions of `/etc/gshadow`, run the command:

    $ sudo chmod 0640 /etc/gshadow

To properly set the owner of `/etc/gshadow`, run the command:

    $ sudo chown root /etc/gshadow

To properly set the group owner of `/etc/gshadow`, run the command:

    $ sudo chgrp shadow /etc/gshadow

Rationale:

The `/etc/shadow` file contains group password hashes. Protection of this file is critical for system security.

Severity: medium

References: NT28(R36), AC-6

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    chmod 0640 /etc/gshadow

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    - name: Ensure permission 0640 on /etc/gshadow
      file:
        path="{{item}}"
        mode=0640
      with_items:
        - /etc/gshadow
      tags:
        - file_permissions_etc_gshadow
        - medium_severity
        - configure_strategy
        - low_complexity
        - low_disruption
        - NIST-800-53-AC-6

#### Verify Permissions and ownership on passwd File [ref]rule

To properly set the permissions of `/etc/passwd`, run the command:

    $ sudo chmod 0644 /etc/passwd

To properly set the owner of `/etc/passwd`, run the command:

    $ sudo chown root /etc/passwd

To properly set the group owner of `/etc/passwd`, run the command:

    $ sudo chgrp root /etc/passwd

Rationale:

The `/etc/shadow` file contains information about the users that are configured on the system. Protection of this file is critical for system security.

Severity: medium

References: AC-6

Remediation Shell script: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    chmod 0644 /etc/passwd

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | low
Strategy: | configure

    - name: Ensure permission 0644 on /etc/passwd
      file:
        path="{{item}}"
        mode=0644
      with_items:
        - /etc/passwd
      tags:
        - file_permissions_etc_passwd
        - medium_severity
        - configure_strategy
        - low_complexity
        - low_disruption
        - NIST-800-53-AC-6

### Verify permissions on files containing sensitive informations about the system [ref]group

Various files contains sensitive informations that can leads to specific weaknesses or give structural informations for local exploits.

contains 1 rule

#### Verify that local System.map file (if exists) is readable only by root [ref]rule

Files containing sensitive informations should be protected by restrictive permissions. Most of the time, there is no need that these files need to be read by any non-root user To properly set the permissions of `/boot/System.map-*`, run the command:

    $ sudo chmod 0600 /boot/System.map-*

To properly set the owner of `/boot/System.map-*`, run the command:

    $ sudo chown root /boot/System.map-*

Rationale:

The `System.map` file contains information about kernel symbols and can give some hints to generate local exploitation.

Severity: unknown

References: NT28(R13)

### Restrict Programs from Dangerous Execution Patterns [ref]group

The recommendations in this section are designed to ensure that the system's features to protect against potentially dangerous program execution are activated. These protections are applied at the system initialization or kernel level, and defend against certain types of badly-configured or compromised programs.

contains 2 rules

### Disable Core Dumps [ref]group

A core dump file is the memory image of an executable program when it was terminated by the operating system due to errant behavior. In most cases, only software developers legitimately need to access these files. The core dump files may also contain sensitive information, or unnecessarily occupy large amounts of disk space.
Once a hard limit is set in `/etc/security/limits.conf`, a user cannot increase that limit within his or her own session. If access to core dumps is required, consider restricting them to only certain users or groups. See the `limits.conf` man page for more information.
The core dumps of setuid programs are further protected. The `sysctl` variable `fs.suid_dumpable` controls whether the kernel allows core dumps from these programs at all. The default value of 0 is recommended.

contains 1 rule

#### Disable Core Dumps for SUID programs [ref]rule

To set the runtime status of the `fs.suid_dumpable` kernel parameter, run the following command:

    $ sudo sysctl -w fs.suid_dumpable=0

If this is not the system's default value, add the following line to `/etc/sysctl.conf`:

    fs.suid_dumpable = 0

Rationale:

The core dump of a setuid program is more likely to contain wve data, as the program itself runs with greater privileges than the user who initiated execution of the program. Disabling the ability for any setuid program to write a core file decreases the risk of unauthorized access of such data.

Severity: unknown

References: NT28(R23), 1.6.1, SI-11

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | medium
Reboot: | true
Strategy: | disable

    - name: Ensure sysctl fs.suid_dumpable is set to 0
      sysctl:
        name: fs.suid_dumpable
        value: 0
        state: present
        reload: yes
      tags:
        - sysctl_fs_suid_dumpable
        - unknown_severity
        - disable_strategy
        - low_complexity
        - medium_disruption
        - NIST-800-53-SI-11

### Enable ExecShield [ref]group

ExecShield describes kernel features that provide protection against exploitation of memory corruption errors such as buffer overflows. These features include random placement of the stack and other memory regions, prevention of execution in memory that should only hold data, and special handling of text buffers. These protections are enabled by default on 32-bit systems and controlled through `sysctl` variables `kernel.exec-shield` and `kernel.randomize_va_space`. On the latest 64-bit systems, `kernel.exec-shield` cannot be enabled or disabled with `sysctl`.

contains 1 rule

#### Enable Randomized Layout of Virtual Address Space [ref]rule

To set the runtime status of the `kernel.randomize_va_space` kernel parameter, run the following command:

    $ sudo sysctl -w kernel.randomize_va_space=2

If this is not the system's default value, add the following line to `/etc/sysctl.conf`:

    kernel.randomize_va_space = 2

Rationale:

Address space layout randomization (ASLR) makes it more difficult for an attacker to predict the location of attack code they have introduced into a process's address space during an attempt at exploitation. Additionally, ASLR makes it more difficult for an attacker to know the location of existing code in order to re-purpose it using return oriented programming (ROP) techniques.

Severity: medium

References: NT28(R23), 1.6.1, SC-30(2)

Remediation Ansible snippet: (show)

Complexity: | low
Disruption: | medium
Reboot: | true
Strategy: | disable

    - name: Ensure sysctl kernel.randomize_va_space is set to 2
      sysctl:
        name: kernel.randomize_va_space
        value: 2
        state: present
        reload: yes
      tags:
        - sysctl_kernel_randomize_va_space
        - medium_severity
        - disable_strategy
        - low_complexity
        - medium_disruption
        - NIST-800-53-SC-30(2)

Red Hat and Red Hat Enterprise Linux are either registered trademarks or trademarks of Red Hat, Inc. in the United States and other countries. All other names are registered trademarks or trademarks of their respective companies.