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 agent reads /etc/shadow and reports the names of accounts whose password field (the second field) is
empty. It does not read or send password hashes.
Why it matters
An empty password field means "no password needed". * or ! in that field means the opposite: password
login is impossible, which is the normal state for system accounts such as www-data.
SSH refuses empty passwords by default (PermitEmptyPasswords no). Other ways in go through PAM, and the
default PAM configuration of Debian, Ubuntu and RHEL accepts empty passwords: the pam_unix line carries the
option nullok (in /etc/pam.d/common-auth on Debian and Ubuntu, in /etc/pam.d/system-auth on RHEL and
Rocky Linux). So any local user can su to that account without a password, 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
Find the accounts:
sudo awk -F: '$2 == "" { print $1 }' /etc/shadow
For each one, either set a password or lock it. 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)
The commands are the same on all distributions apart from the path of nologin. Do not use passwd -d to
"clear" a password: it empties the field, which is the problem this check looks for. On RHEL it also
removes a lock that was set 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 no password.
When a warning is fine
Not on a server. Kiosk or lab machines with a deliberately open account should get an automatic login of the desktop instead of an empty password, and no sudo rights for that account.
Sources
- shadow(5) — empty password field,
!and* - pam_unix(8) — the
nullokoption - passwd(1) —
-l,-S - sshd_config(5) —
PermitEmptyPasswords, defaultno