From 6ad26f8dc172b5a025fd0384d0f481306233643e Mon Sep 17 00:00:00 2001 From: Alexandre Skrzyniarz Date: Wed, 3 Apr 2024 12:16:31 +0200 Subject: [PATCH] rewrite accounts_passwords_pam_faillock_deny rule to use pam_account_password_faillock template --- .../ansible/shared.yml | 7 - .../bash/shared.sh | 6 - .../oval/debian.xml | 1 - .../oval/openeuler.xml | 291 ------------------ .../oval/shared.xml | 291 ------------------ .../oval/ubuntu.xml | 201 ------------ .../rule.yml | 11 + 7 files changed, 11 insertions(+), 797 deletions(-) delete mode 100644 linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/ansible/shared.yml delete mode 100644 linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/bash/shared.sh delete mode 120000 linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/debian.xml delete mode 100644 linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/openeuler.xml delete mode 100644 linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/shared.xml delete mode 100644 linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/ubuntu.xml diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/ansible/shared.yml deleted file mode 100644 index 8ab749d4f7c3..000000000000 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/ansible/shared.yml +++ /dev/null @@ -1,7 +0,0 @@ -# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv -# reboot = false -# strategy = restrict -# complexity = low -# disruption = low -{{{ ansible_pam_faillock_enable() }}} -{{{ ansible_pam_faillock_parameter_value("deny", "var_accounts_passwords_pam_faillock_deny") }}} diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/bash/shared.sh b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/bash/shared.sh deleted file mode 100644 index b30f58f3f882..000000000000 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/bash/shared.sh +++ /dev/null @@ -1,6 +0,0 @@ -# platform = multi_platform_all - -{{{ bash_instantiate_variables("var_accounts_passwords_pam_faillock_deny") }}} - -{{{ bash_pam_faillock_enable() }}} -{{{ bash_pam_faillock_parameter_value("deny", "$var_accounts_passwords_pam_faillock_deny") }}} diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/debian.xml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/debian.xml deleted file mode 120000 index 70f08ba8db12..000000000000 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/debian.xml +++ /dev/null @@ -1 +0,0 @@ -ubuntu.xml \ No newline at end of file diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/openeuler.xml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/openeuler.xml deleted file mode 100644 index 0abb80d8d5de..000000000000 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/openeuler.xml +++ /dev/null @@ -1,291 +0,0 @@ - - - {{{ oval_metadata("Lockout account after failed login attempts") }}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ^[\s]*auth\N+pam_unix\.so - - - - ^[\s]*auth[\s]+(required|\[(?=.*?\bsuccess=ok\b)?(?=.*?\bnew_authtok_reqd=ok\b)?(?=.*?\bignore=ignore\b)?(?=.*?\bdefault=bad\b)?.*\])[\s]+pam_faillock\.so[\s\w\d=]+preauth[\s\S]*^[\s]*auth[\s]+(sufficient|\[(?=.*\bsuccess=done\b)?(?=.*?\bnew_authtok_reqd=done\b)?(?=.*?\bdefault=ignore\b)?.*\])[\s]+pam_unix\.so[\s\S]*^[\s]*auth[\s]+(required|\[(?=.*?\bsuccess=ok\b)?(?=.*?\bnew_authtok_reqd=ok\b)?(?=.*?\bignore=ignore\b)?(?=.*?\bdefault=die\b)?.*\])[\s]+pam_faillock\.so[\s\w\d=]+authfail - - - - ^[\s]*account[\s]+(required|\[(?=.*?\bsuccess=ok\b)?(?=.*?\bnew_authtok_reqd=ok\b)?(?=.*?\bignore=ignore\b)?(?=.*?\bdefault=bad\b)?.*\])[\s]+pam_unix\.so[\s\S]*^[\s]*account[\s]+(required|\[(?=.*?\bsuccess=ok\b)?(?=.*?\bnew_authtok_reqd=ok\b)?(?=.*?\bignore=ignore\b)?(?=.*?\bdefault=bad\b)?.*\])[\s]+pam_faillock\.so - - - - ^[\s]*auth[\s]+.+[\s]+pam_faillock.so[\s]+[^\n]*deny=([0-9]+) - - - - ^[\s]*deny[\s]*=[\s]*([0-9]+) - - - - - ^/etc/pam.d/system-auth$ - - - 1 - - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - - ^/etc/pam.d/system-auth$ - - 1 - - - - - - - - ^/etc/pam.d/system-auth$ - - 1 - - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - - - - - - - - - 0 - - - - - ^/etc/pam.d/system-auth$ - - 1 - - - - - - - - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - - - - - - - - ^/etc/security/faillock.conf$ - - 1 - - - - - - - - - - - - diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/shared.xml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/shared.xml deleted file mode 100644 index 4c3b56ba06c2..000000000000 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/shared.xml +++ /dev/null @@ -1,291 +0,0 @@ - - - {{{ oval_metadata("Lockout account after failed login attempts") }}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ^[\s]*auth\N+pam_unix\.so - - - - ^[\s]*auth[\s]+(required|\[(?=.*?\bsuccess=ok\b)(?=.*?\bnew_authtok_reqd=ok\b)(?=.*?\bignore=ignore\b)(?=.*?\bdefault=bad\b).*\])[\s]+pam_faillock\.so[\s\w\d=]+preauth[\s\S]*^[\s]*auth[\s]+(sufficient|\[(?=.*\bsuccess=done\b)(?=.*?\bnew_authtok_reqd=done\b)(?=.*?\bdefault=ignore\b).*\])[\s]+pam_unix\.so[\s\S]*^[\s]*auth[\s]+(required|\[(?=.*?\bsuccess=ok\b)(?=.*?\bnew_authtok_reqd=ok\b)(?=.*?\bignore=ignore\b)(?=.*?\bdefault=bad\b).*\])[\s]+pam_faillock\.so[\s\w\d=]+authfail - - - - ^[\s]*account[\s]+(required|\[(?=.*?\bsuccess=ok\b)(?=.*?\bnew_authtok_reqd=ok\b)(?=.*?\bignore=ignore\b)(?=.*?\bdefault=bad\b).*\])[\s]+pam_faillock\.so[\s\S]*^[\s]*account[\s]+(required|\[(?=.*?\bsuccess=ok\b)(?=.*?\bnew_authtok_reqd=ok\b)(?=.*?\bignore=ignore\b)(?=.*?\bdefault=bad\b).*\])[\s]+pam_unix\.so - - - - ^[\s]*auth[\s]+.+[\s]+pam_faillock.so[\s]+[^\n]*deny=([0-9]+) - - - - ^[\s]*deny[\s]*=[\s]*([0-9]+) - - - - - ^/etc/pam.d/system-auth$ - - - 1 - - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - - ^/etc/pam.d/system-auth$ - - 1 - - - - - - - - ^/etc/pam.d/system-auth$ - - 1 - - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - - - - - - - - - 0 - - - - - ^/etc/pam.d/system-auth$ - - 1 - - - - - - - - - - - - - - - ^/etc/pam.d/password-auth$ - - 1 - - - - - - - - - - - - - - - ^/etc/security/faillock.conf$ - - 1 - - - - - - - - - - - - diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/ubuntu.xml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/ubuntu.xml deleted file mode 100644 index 443a85b29346..000000000000 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/oval/ubuntu.xml +++ /dev/null @@ -1,201 +0,0 @@ -{{# Very similar OVAL is used in several rules, differing primarily in faillock.so parameter. #}} -{{# For transferability, we define the parameter and corresponding regular expressions in jinja. #}} -{{# The rules should ideally use a single template. #}} - -{{% set prm_name = "deny" %}} -{{% set prm_regex_conf = "^[\s]*deny[\s]*=[\s]*([0-9]+)" %}} -{{% set prm_regex_pamd = "^[\s]*auth[\s]+.+[\s]+pam_faillock.so[\s]+[^\n]*deny=([0-9]+)" %}} -{{% set ext_variable = "var_accounts_passwords_pam_faillock_deny" %}} -{{% set description = "Lockout account after failed login attempts." %}} - - - - {{{ oval_metadata(description) }}} - - - - - - - - - - - - - - - - - - - - - - - - - ^\s*auth.*pam_unix\.so - - - - ^\s*auth\s+required\s+pam_faillock\.so.*preauth.*[\s\S]*^\s*auth.*pam_unix\.so[\s\S]*^\s*auth\s+\[default=die\]\s+pam_faillock\.so\s+authfail[\s\S]*^\s*auth\s+sufficient\s+pam_faillock\.so\s+authsucc - - - - ^\s*account\s+required\s+pam_faillock\.so\s*(#.*)?$ - - - - {{{ prm_regex_pamd }}} - - - - {{{ prm_regex_conf }}} - - - - - - - - - /etc/pam.d/common-auth - - 1 - - - - - - - - - /etc/pam.d/common-auth - - 1 - - - - - - - - - /etc/pam.d/common-account - - 1 - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - /etc/pam.d/common-auth - - 1 - - - - - - - - - - - - - - - - - /etc/security/faillock.conf - - 1 - - diff --git a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/rule.yml b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/rule.yml index eeb26a045b79..dd724d1625d9 100644 --- a/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/rule.yml +++ b/linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_passwords_pam_faillock_deny/rule.yml @@ -129,3 +129,14 @@ warnings: srg_requirement: |- {{{ full_name }}} must automatically lock an account when three unsuccessful logon attempts occur. + +template: + name: pam_account_password_faillock + vars: + prm_name: deny + prm_regex_conf: ^[\s]*deny[\s]*=[\s]*([0-9]+) + prm_regex_pamd: ^[\s]*auth[\s]+.+[\s]+pam_faillock.so[\s]+[^\n]*deny=([0-9]+) + ext_variable: var_accounts_passwords_pam_faillock_deny + description: Lockout account after failed login attempts. + variable_upper_bound: use_ext_variable + variable_lower_bound: 0