Well, I'll try again in a different way, maybe that helps. There are three possibilities of what can be stored in the "password" field of the local
passwd(5) database:
- An actual hash of an actual password.
- Some "invalid" string, typically
*
, sometimes !
is used as well ... any value that is NOT a valid hash is considered a "disabled password", so password authentication is disabled in any case for that account.
- Nothing at all, IOW an empty string. That's what PAM calls a "null password". It means the password is empty/unset, whether authentication is allowed without password can be configured by the administrator.
Now, it's (technically) possible to compute a hash of an empty string and store that hash. I agree with
smithi, this is just weird. Still it's what happens when entering "nothing" (by just hitting enter) in
passwd(1). I consider this a bug, especially because the
nullok
option is checked to decide whether this is allowed at all. But when authenticating,
nullok
only checks for an empty password field, aka "no hash stored".
You can't entirely prevent having a hash of the empty string stored, an admin could always manually store that hash. But IMHO it doesn't make any sense to distinguish that case from the "no hash stored" case, they should semantically be the same: password is empty. I'm still waiting for some feedback on my reviews that attempt to "sanitize" the behavior of
pam_unix(8)...
Isn't there some program which will decrypt passwords and show what is recorded somewhere?
The whole point of storing "encrypted" passwords is using a one-way hash function for that, so they can never be decrypted. This prevents instant password disclosure when the password database is ever leaked. Of course it
is possible to try offline brute-force attacks on the hashes (by testing millions of passwords...), and older hash algorithms are broken (e.g. md5, which can be cracked pretty quickly).