From 99534e1ce78edfe001449ccd97fca89d6607105a Mon Sep 17 00:00:00 2001 From: rchikov Date: Mon, 15 May 2023 14:12:36 +0200 Subject: [PATCH 1/3] Fixes in SLE 12/15 rule accounts_passwords_pam_tally2_deny_root --- controls/anssi.yml | 2 ++ controls/cis_sle12.yml | 1 + controls/cis_sle15.yml | 1 + .../ansible/shared.yml | 7 ++++++- .../bash/shared.sh | 7 ++++++- .../oval/shared.xml | 8 ++++++-- .../rule.yml | 8 +++++--- .../tests/pam_tally2_absent_account_config.fail.sh | 14 ++++++++++++++ .../tests/pam_tally2_deny_missing.fail.sh | 14 ++++++++++++++ .../tests/pam_tally2_even_deny_root_absent.fail.sh | 13 +++++++++++++ .../pam_tally2_even_deny_root_present.pass.sh | 13 +++++++++++++ 11 files changed, 81 insertions(+), 7 deletions(-) diff --git a/controls/anssi.yml b/controls/anssi.yml index ddcbc880fa0..83b48120013 100644 --- a/controls/anssi.yml +++ b/controls/anssi.yml @@ -755,6 +755,8 @@ controls: - var_accounts_passwords_pam_faillock_deny=3 - accounts_passwords_pam_faillock_deny - accounts_passwords_pam_faillock_deny_root + # same as above but for pam_tally2 module + - accounts_passwords_pam_tally2_deny_root # Automatically unlock users after 15 min to prevent DoS - var_accounts_passwords_pam_faillock_unlock_time=900 - accounts_passwords_pam_faillock_unlock_time diff --git a/controls/cis_sle12.yml b/controls/cis_sle12.yml index 468b25f8b98..d7e07507990 100644 --- a/controls/cis_sle12.yml +++ b/controls/cis_sle12.yml @@ -1770,6 +1770,7 @@ controls: rules: - accounts_passwords_pam_tally2 - var_password_pam_tally2=5 + - accounts_passwords_pam_tally2_deny_root - id: 5.3.3 title: Ensure password reuse is limited (Automated) diff --git a/controls/cis_sle15.yml b/controls/cis_sle15.yml index 1625a0cbf6a..7dc066a6451 100644 --- a/controls/cis_sle15.yml +++ b/controls/cis_sle15.yml @@ -1954,6 +1954,7 @@ controls: rules: - accounts_passwords_pam_tally2 - var_password_pam_tally2=5 + - accounts_passwords_pam_tally2_deny_root - id: 5.3.3 title: Ensure password reuse is limited (Automated) diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/ansible/shared.yml index ee0243ec978..0ab5d238974 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/ansible/shared.yml +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/ansible/shared.yml @@ -4,6 +4,11 @@ # complexity = low # disruption = low +{{% if product in ["sle12","sle15"] %}} +{{{ ansible_remove_pam_module_option('/etc/pam.d/login', 'auth', 'required', 'pam_tally2.so', 'onerr=fail') }}} +{{{ ansible_ensure_pam_module_option('/etc/pam.d/login', 'auth', 'required', 'pam_tally2.so', 'even_deny_root', '', '') }}} +{{% else %}} +{{{ ansible_remove_pam_module_option('/etc/pam.d/common-auth', 'auth', 'required', 'pam_tally2.so', 'onerr=fail') }}} {{{ ansible_ensure_pam_module_option('/etc/pam.d/common-auth', 'auth', 'required', 'pam_tally2.so', 'even_deny_root', '', '') }}} - +{{% endif %}} {{{ ansible_ensure_pam_module_option('/etc/pam.d/common-account', 'account', 'required', 'pam_tally2.so', '', '', '') }}} diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/bash/shared.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/bash/shared.sh index 30f18f34d10..58c9f5379a0 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/bash/shared.sh +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/bash/shared.sh @@ -4,6 +4,11 @@ # complexity = low # disruption = low +{{% if product in ["sle12","sle15"] %}} +{{{ bash_remove_pam_module_option('/etc/pam.d/login', 'auth', 'required', 'pam_tally2.so', 'onerr=fail') }}} +{{{ bash_ensure_pam_module_option('/etc/pam.d/login', 'auth', 'required', 'pam_tally2.so', 'even_deny_root', '', '') }}} +{{% else %}} +{{{ bash_remove_pam_module_option('/etc/pam.d/common-auth', 'auth', 'required', 'pam_tally2.so', 'onerr=fail') }}} {{{ bash_ensure_pam_module_option('/etc/pam.d/common-auth', 'auth', 'required', 'pam_tally2.so', 'even_deny_root', '', '') }}} - +{{% endif %}} {{{ bash_ensure_pam_module_option('/etc/pam.d/common-account', 'account', 'required', 'pam_tally2.so', '', '', '') }}} diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/oval/shared.xml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/oval/shared.xml index ed355f9bc96..6261beca979 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/oval/shared.xml +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_tally2_deny_root/oval/shared.xml @@ -17,9 +17,13 @@ + {{% if product in ["sle12","sle15"] %}} + /etc/pam.d/login + {{% else %}} /etc/pam.d/common-auth - ^\s*auth\s+required\s+pam_tally2\.so\s+[^\n]*deny=[[4-9]|[1-9][0-9]]+([\s+\S+]*)even_deny_root([\s+\S+])*\s*(\\)*$ - 1 + {{% endif %}} + ^\s*auth(?:(?!\n)\s)+required(?:(?!\n)\s)+pam_tally2.so(?:(?!\n)\s)+(?:(?:(?:(?!\n)\s)?[^\n]+)?onerr=fail(?:(?:(?!\n)\s)+[^\n]+)?(?:(?!\n)\s)+deny=(\d+)(?:(?:\s+\S+)*\s*$))|(?:(?:(?:(?!\n)\s)?[^\n]+)?deny=(\d+)(?:(?:(?!\n)\s)+[^\n]+)?(?:(?!\n)\s)+even_deny_root(?:(?:\s+\S+)*\s*$)) + 1 root account is locked after a defined number of failed password attempts, run the following command: -
$ grep even_deny_root /etc/pam.d/common-auth
+
$ grep even_deny_root /etc/pam.d/login
The output should show even_deny_root. fixtext: |- To configure the system to lock out the root account after a number of incorrect login - attempts using pam_tally2.so, modify the content of both /etc/pam.d/common-auth and + attempts using pam_tally2.so, modify the content of both /etc/pam.d/login and /etc/pam.d/common-account as follows: