Prevent Login to Accounts With Empty Password
An XCCDF Rule
Description
If an account is configured for password authentication
but does not have an assigned password, it may be possible to log
into the account without authentication. Remove any instances of the
nullok
in
password authentication configurations in /etc/pam.d/
to prevent logins with empty passwords.
warning alert: Warning
If the system relies on
authselect
tool to manage PAM settings, the remediation
will also use authselect
tool. However, if any manual modification was made in
PAM files, the authselect
integrity check will fail and the remediation will be
aborted in order to preserve intentional changes. In this case, an informative message will
be shown in the remediation report.
Note that this rule is not applicable for systems running within a
container. Having user with empty password within a container is not
considered a risk, because it should not be possible to directly login into
a container anyway.Rationale
If an account has an empty password, anyone could log in and run commands with the privileges of that account. Accounts with empty passwords should never be used in operational environments.
- ID
- xccdf_org.ssgproject.content_rule_no_empty_passwords
- Severity
- High
- References
- Updated
Remediation - Ansible
- name: Find files in /etc/pam.d/ with password auth
find:
paths: /etc/pam.d
contains: .*pam_unix\.so.*nullok.*
recurse: true
register: find_pam_conf_files_result
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
PAM_PATH="/etc/pam.d/"
NULLOK_FILES=$(grep -rl ".*pam_unix\\.so.*nullok.*" ${PAM_PATH})
for FILE in ${NULLOK_FILES}; do