Merge "Adjusting commonly failing tasks"

This commit is contained in:
Jenkins 2015-12-04 16:27:31 +00:00 committed by Gerrit Code Review
commit 141c1dcf24
4 changed files with 81 additions and 43 deletions

View File

@ -167,7 +167,7 @@ action_mail_acct: root # V-38680
# **IMMENENT DANGER** # **IMMENENT DANGER**
admin_space_left_action: SUSPEND # V-54381 admin_space_left_action: SUSPEND # V-54381
## Authentication ## Password complexity and aging
# V-38475 - There is no password length requirement by default in Ubuntu # V-38475 - There is no password length requirement by default in Ubuntu
# 14.04. To set a password length requirement, uncomment # 14.04. To set a password length requirement, uncomment
# password_minimum_length below. The STIG recommendation is 14 characters. # password_minimum_length below. The STIG recommendation is 14 characters.
@ -231,7 +231,13 @@ disable_ipv6: no # V-38546
# necessary. Set this variable to 'no' to skip this change. # necessary. Set this variable to 'no' to skip this change.
disable_core_dumps: yes # V-38675 disable_core_dumps: yes # V-38675
## Fail2ban ## PAM and authentication
# V-38497 requires that accounts with null passwords aren't allowed to
# authenticate via PAM. Ubuntu 14.04's default allows these logins -- see the
# documentation for V-38497 for more details. Set the variable below to 'yes'
# to remove 'nullok_secure' from the PAM configuration or set it to 'no' to
# leave the PAM configuration unaltered.
pam_remove_nullok: yes # V-38497
# V-38501 requires that failed login attempts must lock a user account using # V-38501 requires that failed login attempts must lock a user account using
# pam_faillock, but Ubuntu doesn't package that PAM module. Instead, fail2ban # pam_faillock, but Ubuntu doesn't package that PAM module. Instead, fail2ban
# can be installed to lock out IP addresses with failed logins for 15 minutes. # can be installed to lock out IP addresses with failed logins for 15 minutes.
@ -241,6 +247,16 @@ install_fail2ban: no # V-38501
# to set the time an IP is banned by fail2ban (in seconds). # to set the time an IP is banned by fail2ban (in seconds).
fail2ban_bantime: 900 # V-38501 fail2ban_bantime: 900 # V-38501
## sudo
# V-58901 requires that 'NOPASSWD' and '!authenticate' do not appear in any
# sudoers files since they could lead to a compromise. Set the following
# variables to 'yes' to comment out any lines found with these prohibited
# parameters or leave them set to 'no' (the default) to leave sudoers files
# unaltered. Deployers are urged to review the documentation for this STIG
# before making changes.
sudoers_remove_nopasswd: no # V-58901
sudoers_remove_authenticate: no # V-58901
## AIDE ## AIDE
# The default Ubuntu configuration for AIDE will cause it to wander into some # The default Ubuntu configuration for AIDE will cause it to wander into some
# terrible places on the system, such as /var/lib/lxc and images in /opt. # terrible places on the system, such as /var/lib/lxc and images in /opt.

View File

@ -1,5 +1,17 @@
Making adjustments to PAM configuration can be **very dangerous** for a Ubuntu 14.04 allows accounts with null passwords to authenticate via PAM by
production system, so the Ansible task runs a check for text matching default. This STIG requires that those login attempts are blocked.
``nullok`` in ``/etc/pam.d/common-auth`` (different than
``/etc/pam.d/system-auth`` found in RHEL 6) and prints a warning if it is In Ubuntu, this functionality is controlled by the ``nullok_secure`` parameter
found. found in ``/etc/pam.d/common-auth``. The Ansible task for this STIG will
remove the ``nullok_secure`` from the PAM configuration file. The effects of
the change are immediate and no service restarts are required.
However, deployers can opt-out of this change by adjusting an Ansible variable:
.. code-block:: yaml
pam_remove_nullok: yes
Setting the variable to ``yes`` (the default) will cause the Ansible tasks to
remove the ``nullok_secure`` parameter while setting the variable to ``no``
will leave the PAM configuration unchanged.

View File

@ -1,3 +1,22 @@
The Ansible tasks will search for ``NOPASSWD`` and ``!authenticate`` in the This STIG requires that ``NOPASSWD`` and ``!authenticate`` are not used within
sudo configuration. If either is found, the playbook will fail and an error the sudoers configuration files. Using these directives reduces the security
message will be printed. of the system.
``NOPASSWD`` allows users to run commands as root without providing a password
first. Using ``!authenticate`` with the ``Defaults`` directive will disable
password usage for any users which use ``sudo``.
There are two configuration options for handling these changes. By default,
both of these options are set to ``no``, which means that the sudoers
configuration files will not be altered:
.. code-block:: yaml
sudoers_remove_nopasswd: no
sudoers_remove_authenticate: no
Setting ``sudoers_remove_nopasswd`` to ``yes`` will cause the Ansible tasks to
search for any lines containing ``NOPASSWD`` and comment them out of the
configuration. Setting ``sudoers_remove_authenticate`` will do the same
actions on lines containing ``!authenticate``. Lines that are already
commented will be left unaltered.

View File

@ -89,22 +89,14 @@
# RHEL 6 keeps this content in /etc/pam.d/system-auth, but Ubuntu keeps it in # RHEL 6 keeps this content in /etc/pam.d/system-auth, but Ubuntu keeps it in
# /etc/pam.d/common-auth # /etc/pam.d/common-auth
- name: V-38497 - The system must not have accounts configured with blank or null passwords. - name: V-38497 - The system must not have accounts configured with blank or null passwords.
command: grep nullok /etc/pam.d/common-auth lineinfile:
register: v38497_result dest: /etc/pam.d/common-auth
changed_when: False state: present
failed_when: False regexp: "^(.*)nullok_secure(.*)$"
always_run: True line: '\1\2'
tags: backup: yes
- auth backrefs: yes
- cat1 when: pam_remove_nullok | bool
- V-38497
# Print a warning about making a change. We ought to figure out a better way
# to capture this later.
- name: V-38497 - The system must not have accounts configured with blank or null passwords.
fail:
msg: "FAILED: Remove 'nullok' from /etc/pam.d/system-auth for better security."
when: not check_mode and v38497_result.rc == 0
tags: tags:
- auth - auth
- cat1 - cat1
@ -383,34 +375,33 @@
- cat3 - cat3
- V-38683 - V-38683
- name: Checking for NOPASSWD in sudoers (for V-58901) # This should be updated to use the find module when Ansible 2.0 is available.
shell: "egrep '^[^#]*NOPASSWD' /etc/sudoers /etc/sudoers.d/*" - name: Search for sudoers files (for V-58901)
register: v58901_nopasswd_result shell: find /etc/sudoers* -type f
changed_when: False register: v58901_result
failed_when: v58901_nopasswd_result.rc > 1
always_run: True always_run: True
tags: tags:
- auth - auth
- cat2 - cat2
- V-58901 - V-58901
- name: Checking for !authenticate in sudoers (for V-58901) # The lineinfile module can't be used here since we may need to comment out
shell: "egrep '^[^#]*!authenticate' /etc/sudoers /etc/sudoers.d/*" # multiple lines.
register: v58901_authenticate_result - name: Comment out sudoers lines with NOPASSWD present (for V-58901)
changed_when: False shell: "sed -e '/NOPASSWD/ s/^#*/#/' -i {{ item }}"
failed_when: v58901_authenticate_result.rc > 1 with_items: v58901_result.stdout_lines
always_run: True when: sudoers_remove_nopasswd | bool
tags: tags:
- auth - auth
- cat2 - cat2
- V-58901 - V-58901
- name: V-58901 - The sudo command must require authentication # The lineinfile module can't be used here since we may need to comment out
fail: # multiple lines.
msg: "FAILED: NOPASSWD or !authenticate found in sudo configuration" - name: Comment out sudoers lines with !authenticate present (for V-58901)
when: > shell: "sed -e '/!authenticate/ s/^#*/#/' -i {{ item }}"
not check_mode with_items: v58901_result.stdout_lines
and (v58901_nopasswd_result.rc == 0 or v58901_authenticate_result.rc == 0) when: sudoers_remove_authenticate | bool
tags: tags:
- auth - auth
- cat2 - cat2