4.4.2.1.4 Ensure password failed attempts lockout includes root account

Information

even_deny_root - Root account can become locked as well as regular accounts

root_unlock_time=n - This option implies even_deny_root option. Allow access after n seconds to root account after the account is locked. In case the option is not specified the value is the same as of the unlock_time option.

Locking out user IDs after n unsuccessful consecutive login attempts mitigates brute force password attacks against your systems.

Solution

Edit the files /etc/pam.d/system-auth and /etc/pam.d/password-auth :

Add the following lines to the auth section:

auth required pam_faillock.so preauth silent audit deny=5 unlock_time=900 even_deny_root
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900 even_deny_root

The auth sections should look similar to the following example:

Example:

auth required pam_env.so
auth required pam_faillock.so preauth silent audit deny=5 unlock_time=900 even_deny_root # <- Under "auth required pam_env.so"
auth sufficient pam_unix.so try_first_pass
auth [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900 even_deny_root # <- Last auth line before "auth requisite pam_succeed_if.so"
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so

WARNING: The ordering on the lines in the auth section is important. The preauth line needs to below the line auth required pam_env.so and above all password validation lines. The authfail line needs to be after all password validation lines such as pam_sss.so Incorrect order can cause you to be locked out of the system.

Impact:

Use of unlock_time=0 or root_unlock_time=0 may allow an attacker to cause denial of service to legitimate users.

See Also

https://workbench.cisecurity.org/benchmarks/15962