An account has an empty password
- Check
users.empty_password- Severity
- critical
- Runs
- on the server, in the daily run of the agent
- Looks at
- Empty password field in /etc/shadow (only the account name is reported)
What the check looks at
The accounts in /etc/shadow whose password field (the second field) is empty. The check fails when there is one
and reports the account names. The agent does not keep or send password hashes.
Risk
An empty field means that the account does not need a password; * or ! means that password login is
impossible, the normal state for system accounts such as www-data. SSH refuses empty passwords by default
(PermitEmptyPasswords no), but the default PAM configuration of Debian, Ubuntu and RHEL accepts them: the
pam_unix line carries the option nullok (in /etc/pam.d/common-auth on Debian and Ubuntu,
/etc/pam.d/system-auth on RHEL and Rocky Linux). Any local user can then su to the account, and anyone at
the console can log in with it. If the account has sudo rights, that is a path to root.
How to fix it
Set a password or lock each account the check reports. For people:
sudo passwd <name>
For service accounts that never log in, lock the password and set a shell that refuses logins:
sudo passwd -l <name>
sudo usermod -s /usr/sbin/nologin <name> # Debian, Ubuntu, RHEL, Rocky, Alma
sudo usermod -s /sbin/nologin <name> # Alpine (needs the shadow package)
Do not "clear" a password with passwd -d: it empties the field, and on RHEL it also removes a lock on the
password.
How to check the fix
sudo awk -F: '$2 == "" { print $1 }' /etc/shadow
sudo passwd -S <name>
The first command must print nothing. passwd -S shows P for a usable password and L for a locked one (RHEL
prints LK and Password locked.); NP means that the account does not have a password.
When a warning is fine
Not on a server. A kiosk or lab machine with an open account should log in to the desktop automatically, with a password on the account and without sudo rights for it.
Sources
- shadow(5) (an empty password field,
!and*) - pam_unix(8) (the
nullokoption) - passwd(1) (
-l,-S) - sshd_config(5) (
PermitEmptyPasswords, defaultno)