-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12800 from alanmcanonical/ubt24_53333
Ubuntu 24.04: Implement rule 5.3.3.3.3 Ensure pam_pwhistory includes use_authtok
- Loading branch information
Showing
11 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
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
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
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 |
60 changes: 60 additions & 0 deletions
60
...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,60 @@ | ||
{{% 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"/> | ||
</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> | ||
|
||
</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 |