5.5.3 Ensure password reuse is limited

Information

The /etc/security/opasswd file stores the users' old passwords and can be checked to ensure that users are not recycling recent passwords.

- remember=<5> - Number of old passwords to remember

Forcing users not to reuse their past 5 passwords make it less likely that an attacker will be able to guess the password.

Note: These change only apply to accounts configured on the local system.

Solution

Set remembered password history to conform to site policy.

Run the following script to add or modify the pam_pwhistory.so and pam_unix.so lines to include the remember option:

#!/usr/bin/env bash

{
file="/etc/authselect/$(head -1 /etc/authselect/authselect.conf | grep 'custom/')/system-auth"
if ! grep -Pq -- '^h*passwordh+(requisite|required|sufficient)h+pam_pwhistory.soh+([^#
r]+h+)?remember=([5-9]|[1-9][0-9]+)b.*$' "$file"; then
if grep -Pq -- '^h*passwordh+(requisite|required|sufficient)h+pam_pwhistory.soh+([^#
r]+h+)?remember=d+b.*$' "$file"; then
sed -ri 's/^s*(passwords+(requisite|required|sufficient)s+pam_pwhistory.sos+([^#
r]+s+)?)(remember=S+s*)(s+.*)?$/1 remember=5 5/' $file
elif grep -Pq -- '^h*passwordh+(requisite|required|sufficient)h+pam_pwhistory.soh+([^#
r]+h+)?.*$' "$file"; then
sed -ri '/^s*passwords+(requisite|required|sufficient)s+pam_pwhistory.so/ s/$/ remember=5/' $file
else
sed -ri '/^s*passwords+(requisite|required|sufficient)s+pam_unix.so/i password required pam_pwhistory.so remember=5 use_authtok' $file
fi
fi
if ! grep -Pq -- '^h*passwordh+(requisite|required|sufficient)h+pam_unix.soh+([^#
r]+h+)?remember=([5-9]|[1-9][0-9]+)b.*$' "$file"; then
if grep -Pq -- '^h*passwordh+(requisite|required|sufficient)h+pam_unix.soh+([^#
r]+h+)?remember=d+b.*$' "$file"; then
sed -ri 's/^s*(passwords+(requisite|required|sufficient)s+pam_unix.sos+([^#
r]+s+)?)(remember=S+s*)(s+.*)?$/1 remember=5 5/' $file
else
sed -ri '/^s*passwords+(requisite|required|sufficient)s+pam_unix.so/ s/$/ remember=5/' $file
fi
fi
authselect apply-changes
}

See Also

https://workbench.cisecurity.org/files/3742

Item Details

Category: IDENTIFICATION AND AUTHENTICATION

References: 800-53|IA-5(1), CSCv7|4.4

Plugin: Unix

Control ID: 1bcb980ec9a5b7d66cc1ff607380d0765e1f6f49faa1933db0250851c7b2459d