-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement rule 5.3.3.3.3 Ensure pam_pwhistory includes use_authtok
- Loading branch information
1 parent
b813196
commit 5c8adcd
Showing
9 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
.../locking_out_password_attempts/accounts_password_pam_pwhistory_use_authtok/bash/ubuntu.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# platform = multi_platform_ubuntu | ||
|
||
{{{ bash_pam_pwhistory_enable('cac_pwhistory','requisite') }}} | ||
conf_file=/usr/share/pam-configs/cac_pwhistory | ||
if ! grep -qE 'pam_pwhistory\.so\s+[^#]*\buse_authtok\b' "$conf_file"; then | ||
sed -i -E '/^Password:/,/^[^[:space:]]/ { | ||
/pam_pwhistory\.so/ { | ||
s/$/ use_authtok/g | ||
} | ||
}' "$conf_file" | ||
fi | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update --enable cac_pwhistory |
75 changes: 75 additions & 0 deletions
75
...locking_out_password_attempts/accounts_password_pam_pwhistory_use_authtok/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{{% if "sle12" in product or "debian" in product or "ubuntu" in product %}} | ||
{{%- set accounts_password_pam_file = '/etc/pam.d/common-password' -%}} | ||
{{% else %}} | ||
{{%- set accounts_password_pam_file = '/etc/pam.d/system-auth' -%}} | ||
{{% endif %}} | ||
|
||
<def-group> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("Configure the system to include use_authtok for pam_pwhistory common_password configuration file") }}} | ||
<criteria operator="AND" comment="Check if pam_pwhistory.so is properly configured"> | ||
<criterion test_ref="{{{ rule_id }}}_test_pwhistory_exists" | ||
comment="At least one pwhistory line exists"/> | ||
<criterion test_ref="{{{ rule_id }}}_test_password_pam_pwhistory_use_authtok" | ||
comment="use_authtok is configured in pam pwhistory in common_password file"/> | ||
<criterion test_ref="{{{ rule_id }}}_test_password_pam_pwhistory_without_use_authtok" | ||
comment="use_authtok is configured not in pam pwhistory in common_password file"/> | ||
</criteria> | ||
</definition> | ||
|
||
<ind:textfilecontent54_test id="{{{ rule_id }}}_test_pwhistory_exists" version="1" | ||
check="all" check_existence="at_least_one_exists" | ||
comment="At least one pwhistory line exists"> | ||
<ind:object object_ref="{{{ rule_id }}}_obj_pwhistory_exists" /> | ||
</ind:textfilecontent54_test> | ||
|
||
<ind:textfilecontent54_object id="{{{ rule_id }}}_obj_pwhistory_exists" version="1"> | ||
<ind:filepath>{{{ accounts_password_pam_file }}}</ind:filepath> | ||
<ind:pattern operation="pattern match">^[^#\n\r]*password[ \t]+.*pam_pwhistory\.so.*$</ind:pattern> | ||
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_test id="{{{ rule_id }}}_test_password_pam_pwhistory_use_authtok" version="1" | ||
check="all" check_existence="any_exist" state_operator="AND" | ||
comment="use_authtok is configured in pam pwhistory in common_password file"> | ||
<ind:object object_ref="{{{ rule_id }}}_obj_use_authtok" /> | ||
<ind:state state_ref="{{{ rule_id }}}_ste_use_authtok" /> | ||
</ind:textfilecontent54_test> | ||
|
||
<ind:textfilecontent54_object id="{{{ rule_id }}}_obj_use_authtok" version="1"> | ||
<set> | ||
<object_reference>{{{ rule_id }}}_obj_use_authtok_password_lines_except_first</object_reference> | ||
<filter action="include">{{{ rule_id }}}_ste_use_authtok_pam_pwhistory_lines</filter> | ||
</set> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_state id="{{{ rule_id }}}_ste_use_authtok" version="1"> | ||
<ind:subexpression operation="pattern match">^[^#\n\r]*pam_pwhistory\.so[ \t]+[^#\n\r]*use_authtok.*$</ind:subexpression> | ||
</ind:textfilecontent54_state> | ||
|
||
<!-- Get all password lines except the first line. This is to avoid matching a pam_pwhistory | ||
line on the top of the stack, which does not need use_authtok to pass --> | ||
<ind:textfilecontent54_object id="{{{ rule_id }}}_obj_use_authtok_password_lines_except_first" version="1"> | ||
<ind:filepath>{{{ accounts_password_pam_file }}}</ind:filepath> | ||
<ind:pattern operation="pattern match">^[ \t]*password[ \t]+(.+)$</ind:pattern> | ||
<ind:instance datatype="int" operation="greater than or equal">2</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_state id="{{{ rule_id }}}_ste_use_authtok_pam_pwhistory_lines" version="1"> | ||
<ind:subexpression operation="pattern match">^[^#\n\r]*pam_pwhistory\.so.*$</ind:subexpression> | ||
</ind:textfilecontent54_state> | ||
|
||
<!-- Test to check if use_authtok is not configured in the first password line containing pam_pwhistory.so --> | ||
<ind:textfilecontent54_test id="{{{ rule_id }}}_test_password_pam_pwhistory_without_use_authtok" version="1" | ||
check="all" check_existence="all_exist" | ||
comment="use_authtok is configured not in pam pwhistory on top of stack in common_password file"> | ||
<ind:object object_ref="{{{ rule_id }}}_obj_without_use_authtok" /> | ||
</ind:textfilecontent54_test> | ||
|
||
<ind:textfilecontent54_object id="{{{ rule_id }}}_obj_without_use_authtok" version="1"> | ||
<ind:filepath>{{{ accounts_password_pam_file }}}</ind:filepath> | ||
<ind:pattern operation="pattern match">^[ \t]*password[ \t]+[^#\n\r]*pam_pwhistory\.so.*$</ind:pattern> | ||
<ind:instance datatype="int" operation="equals">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
</def-group> |
18 changes: 18 additions & 0 deletions
18
...ts-pam/locking_out_password_attempts/accounts_password_pam_pwhistory_use_authtok/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
documentation_complete: true | ||
|
||
|
||
title: 'Enforce Password History with use_authtok' | ||
|
||
description: |- | ||
The <tt>use_authtok</tt> option ensures the pam_pwhistory module uses the new | ||
password provided by a previously stacked PAM module during password | ||
changes, rather than prompting the user again. | ||
rationale: |- | ||
The <tt>use_authtok</tt> option allows multiple PAM modules to validate the new | ||
password before it is accepted, ensuring it meets all security requirements | ||
without requiring the user to re-enter it multiple times. | ||
severity: medium | ||
|
||
platform: package[pam] |
16 changes: 16 additions & 0 deletions
16
...ounts_password_pam_pwhistory_use_authtok/tests/ubuntu_argument_missing_first_line.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# packages = pam | ||
|
||
config_file=/usr/share/pam-configs/tmp_pwhistory | ||
|
||
cat << EOF > "$config_file" | ||
Name: pwhistory password history checking | ||
Default: yes | ||
Priority: 1024 | ||
Password-Type: Primary | ||
Password: requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update --enable tmp_pwhistory | ||
rm "$config_file" |
19 changes: 19 additions & 0 deletions
19
...unts_password_pam_pwhistory_use_authtok/tests/ubuntu_argument_missing_second_line.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# packages = pam | ||
|
||
config_file=/usr/share/pam-configs/tmp_pwhistory | ||
|
||
cat << EOF > "$config_file" | ||
Name: pwhistory password history checking | ||
Default: yes | ||
Priority: 1024 | ||
Password-Type: Primary | ||
Password: | ||
requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass # use_authtok | ||
[success=end default=ignore] pam_unix.so obscure use_authtok try_first_pass yescrypt | ||
requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update --enable tmp_pwhistory | ||
rm "$config_file" |
19 changes: 19 additions & 0 deletions
19
...empts/accounts_password_pam_pwhistory_use_authtok/tests/ubuntu_commented_argument.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# packages = pam | ||
|
||
config_file=/usr/share/pam-configs/tmp_pwhistory | ||
|
||
cat << EOF > "$config_file" | ||
Name: pwhistory password history checking | ||
Default: yes | ||
Priority: 1024 | ||
Password-Type: Primary | ||
Password: | ||
requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass # use_authtok | ||
[success=end default=ignore] pam_unix.so obscure use_authtok try_first_pass yescrypt | ||
requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass # use_authtok | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update --enable tmp_pwhistory | ||
rm "$config_file" |
19 changes: 19 additions & 0 deletions
19
...nts_password_pam_pwhistory_use_authtok/tests/ubuntu_commented_argument_first_line.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# packages = pam | ||
|
||
config_file=/usr/share/pam-configs/tmp_pwhistory | ||
|
||
cat << EOF > "$config_file" | ||
Name: pwhistory password history checking | ||
Default: yes | ||
Priority: 1024 | ||
Password-Type: Primary | ||
Password: | ||
requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass # use_authtok | ||
[success=end default=ignore] pam_unix.so obscure use_authtok try_first_pass yescrypt | ||
requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass use_authtok | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update --enable tmp_pwhistory | ||
rm "$config_file" |
16 changes: 16 additions & 0 deletions
16
...empts/accounts_password_pam_pwhistory_use_authtok/tests/ubuntu_correct_first_line.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# packages = pam | ||
|
||
config_file=/usr/share/pam-configs/tmp_pwhistory | ||
|
||
cat << EOF > "$config_file" | ||
Name: pwhistory password history checking | ||
Default: yes | ||
Priority: 1024 | ||
Password-Type: Primary | ||
Password-Initial: requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update --enable tmp_pwhistory | ||
rm "$config_file" |
7 changes: 7 additions & 0 deletions
7
...t_password_attempts/accounts_password_pam_pwhistory_use_authtok/tests/ubuntu_null.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
# packages = pam | ||
|
||
if [[ -f /usr/share/pam-configs/pwhistory ]]; then | ||
pam-auth-update --disable pwhistory | ||
fi |