Skip to content

Configure the root Account lock for Failed Password Attempts via pam_tally2

An XCCDF Rule

Description

This rule configures the system to lock out the root account after a number of incorrect login attempts using pam_tally2.so.

Rationale

By limiting the number of failed logon attempts, the risk of unauthorized system access via user password guessing, also known as brute-forcing, is reduced. Limits are imposed by locking the account.

ID
xccdf_org.ssgproject.content_rule_accounts_passwords_pam_tally2_deny_root
Severity
Medium
References
Updated



Remediation - Shell Script

# Remediation is applicable only in certain platforms
if rpm --quiet -q pam; then

if grep -qP '^\s*auth\s+'"required"'\s+pam_tally2.so\s.*\bonerr=fail\b' "/etc/pam.d/login"; then
    sed -i -E --follow-symlinks 's/(.*auth.*'"required"'.*pam_tally2.so.*)\sonerr=fail=?[[:alnum:]]*(.*)/\1\2/g' "/etc/pam.d/login"
fi

Remediation - Ansible

- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - CCE-91281-6
  - NIST-800-53-AC-7(b)