4.4.2.4 Ensure pam_pwhistory module is enabled

Information

The pam_history.so module saves the last passwords for each user in order to force password change history and keep the user from alternating between the same password too frequently.

Requiring users not to reuse their passwords make it less likely that an attacker will be able to guess the password or use a compromised password.

Solution

Run the following script to verify the pam_pwhistory.so lines exist in the profile templates:

#!/usr/bin/env bash

{
l_module_name="pwhistory"
l_pam_profile="$(head -1 /etc/authselect/authselect.conf)"
if grep -Pq -- '^custom/' <<< "$l_pam_profile"; then
l_pam_profile_path="/etc/authselect/$l_pam_profile"
else
l_pam_profile_path="/usr/share/authselect/default/$l_pam_profile"
fi
grep -P -- "bpam_$l_module_name.sob" "$l_pam_profile_path"/{password,system}-auth
}

Example Output with a custom profile named "custom-profile":

/etc/authselect/custom/custom-profile/password-auth:password required pam_pwhistory.so use_authtok {include if "with-pwhistory"}

/etc/authselect/custom/custom-profile/system-auth:password required pam_pwhistory.so use_authtok {include if "with-pwhistory"}

Note: The lines may not include {include if "with-pwhistory"}

- IF - the lines shown above are not returned, refer to the Recommendation "Ensure active authselect profile includes pam modules" to update the authselect profile template files to include the pam_pwhistory entries before continuing this remediation.

- IF - the lines include {include if "with-pwhistory"} run the following command to enable the authselect with-pwhistory feature and update the files in /etc/pam.d to include pam_faillock.so :

# authselect enable-feature with-pwhistory

- IF - any of the pam_pwhistory lines exist without {include if "with-pwhistory"} run the following command to update the files in /etc/pam.d to include pam_pwhistory.so :

# authselect apply-changes

See Also

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

Item Details

Category: IDENTIFICATION AND AUTHENTICATION

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

Plugin: Unix

Control ID: b3f37e9a506919f41f737a062d9a5ae50eed5396de7f622f755b235b77ee8846