Probo Agent on Linux password policy check reads an outdated setting
Linux password policy check reads an outdated setting
Summary
On Linux, the password_policy device posture check reads only PASS_MIN_LEN from /etc/login.defs, and passes the device whenever that value is any non-negative integer. As a result:
- A device with no length requirement (PASS_MIN_LEN 0) passes.
- A device with a real password policy enforced by PAM (pam_pwquality) fails if login.defs doesn't set PASS_MIN_LEN, which is the default on several major distros.
So the result doesn't reflect the password policy that is actually in force.
Where
Reading the file: https://github.com/getprobo/probo/blob/de5d605cf5f69cdb6f6b6120c6e183ce9a9a6c03/pkg/deviceagent/checks/checks_linux.go#L888-L899
Pass/fail logic: https://github.com/getprobo/probo/blob/de5d605cf5f69cdb6f6b6120c6e183ce9a9a6c03/pkg/deviceagent/checks/posture_verdict.go#L38-L57
Problems
-
There is no minimum threshold. Any value of 0 or more passes. PASS_MIN_LEN 0 and PASS_MIN_LEN 1 both pass, even though neither is a password policy.
-
The setting it reads is mostly ignored on modern distros. When shadow-utils is built with PAM, as it is on Debian, Ubuntu, Fedora and RHEL, PAM decides password length when a password is changed, not login.defs. The setting that's enforced is minlen in /etc/security/pwquality.conf (or in /etc/security/pwquality.conf.d/*.conf, or as pam_pwquality.so minlen=N in the PAM stack). On these systems PASS_MIN_LEN doesn't enforce anything, whatever its value.
-
A missing value fails. On distros whose default login.defs doesn't set PASS_MIN_LEN, the check returns Fail with parse_error: "PASS_MIN_LEN not set", even when pwquality enforces a strong policy. A missing value fails while a value of 0 passes.
Steps to reproduce
Pass with no policy: set PASS_MIN_LEN 0 in /etc/login.defs. Expected: Fail. Actual: Pass. Fail with a real policy: remove or comment out PASS_MIN_LEN in /etc/login.defs, and set minlen = 14 in /etc/security/pwquality.conf with pam_pwquality enabled. Expected: Pass. Actual: Fail.
Suggested fix
- Read the enforced minimum length from pwquality: minlen in /etc/security/pwquality.conf and pwquality.conf.d/*.conf, plus any minlen= argument on pam_pwquality.so (or pam_cracklib.so) in /etc/pam.d/common-password or /etc/pam.d/system-auth. Fall back to login.defs only if PAM has no length rule.
- Pass only when the effective minimum meets a threshold (for example 8). Fail when it's below the threshold, and return Unknown when nothing can be determined.
- Record which source supplied the value (pwquality.conf, the PAM argument or login.defs) in the evidence.
Hello @zintrepid,
Fixed in #2352 and shipped in probo-agent v0.9.1. Thanks for the report! Closing this issue, feel free to reopen it if you still see a wrong verdict after updating.