-
Notifications
You must be signed in to change notification settings - Fork 707
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.4.2 Ensure pam_unix does not include remember
- Loading branch information
1 parent
0238b4e
commit e388457
Showing
6 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...ounts-restrictions/password_storage/accounts_password_pam_unix_no_remember/bash/shared.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,27 @@ | ||
# platform = multi_platform_ubuntu | ||
# reboot = false | ||
# strategy = configure | ||
# complexity = low | ||
# disruption = medium | ||
|
||
{{{ bash_pam_unix_enable() }}} | ||
config_file="/usr/share/pam-configs/cac_unix" | ||
sed -i -E '/^Password:/,/^[^[:space:]]/ { | ||
/pam_unix\.so/ { | ||
s/\s*\bremember=\d+\b//g | ||
} | ||
}' "$config_file" | ||
|
||
sed -i -E '/^Password-Initial:/,/^[^[:space:]]/ { | ||
/pam_unix\.so/ { | ||
s/\s*\bremember=\d+\b//g | ||
} | ||
}' "$config_file" | ||
|
||
{{{ bash_remove_pam_module_option('/etc/pam.d/common-auth', 'auth', '', 'pam_unix.so', 'remember') }}} | ||
{{{ bash_remove_pam_module_option('/etc/pam.d/common-account', 'account', '', 'pam_unix.so', 'remember') }}} | ||
{{{ bash_remove_pam_module_option('/etc/pam.d/common-password', 'password', '', 'pam_unix.so', 'remember') }}} | ||
{{{ bash_remove_pam_module_option('/etc/pam.d/common-session', 'session', '', 'pam_unix.so', 'remember') }}} | ||
{{{ bash_remove_pam_module_option('/etc/pam.d/common-session-noninteractive', 'session', '', 'pam_unix.so', 'remember') }}} | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update |
19 changes: 19 additions & 0 deletions
19
...unts-restrictions/password_storage/accounts_password_pam_unix_no_remember/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,19 @@ | ||
<def-group> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("The pam_unix module should not include remember option") }}} | ||
<criteria> | ||
<criterion comment="make sure the remember option is not used in pam_unix.so module" | ||
test_ref="test_pam_unix_no_remember" /> | ||
</criteria> | ||
</definition> | ||
<ind:textfilecontent54_test check="all" check_existence="none_exist" version="1" | ||
id="test_pam_unix_no_remember" | ||
comment="make sure remember is not used in /etc/pam.d/common-auth"> | ||
<ind:object object_ref="object_pam_unix_no_remember" /> | ||
</ind:textfilecontent54_test> | ||
<ind:textfilecontent54_object id="object_pam_unix_no_remember" version="1"> | ||
<ind:filepath operation="pattern match">^/etc/pam.d/common-(password|auth|account|session|session-noninteractive)$</ind:filepath> | ||
<ind:pattern operation="pattern match">^[^#]*\bremember=\d+\b.*$</ind:pattern> | ||
<ind:instance datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
</def-group> |
21 changes: 21 additions & 0 deletions
21
...ts/accounts-restrictions/password_storage/accounts_password_pam_unix_no_remember/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,21 @@ | ||
documentation_complete: true | ||
|
||
title: 'Avoid using remember in pam_unix module' | ||
|
||
description: |- | ||
The <tt>remember</tt> option stores the last n passwords for each user in <tt>/etc/security/opasswd</tt>, | ||
enforcing password history and preventing users from reusing the same passwords. However, this feature | ||
relies on the MD5 password hash algorithm, which is less secure. Instead, the <tt>pam_pwhistory</tt> | ||
module should be used. This module also stores the last n passwords in <tt>/etc/security/opasswd</tt> | ||
and it uses the password hash algorithm configured in the pam_unix module, such as yescrypt or SHA512, | ||
offering enhanced security. | ||
rationale: |- | ||
Removing the <tt>remember</tt> argument ensures the use of a stronger password hashing algorithm. | ||
A more robust hash algorithm increases the difficulty for attackers to crack stored | ||
passwords in <tt>/etc/security/opasswd</tt>, thereby improving system security and | ||
protecting user credentials. | ||
severity: medium | ||
|
||
platform: package[pam] |
4 changes: 4 additions & 0 deletions
4
...ictions/password_storage/accounts_password_pam_unix_no_remember/tests/no_remember.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,4 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
|
||
sed -i --follow-symlinks '/\bremember=\d+\b/d' /etc/pam.d/common-* |
7 changes: 7 additions & 0 deletions
7
.../password_storage/accounts_password_pam_unix_no_remember/tests/remember_commented.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,7 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
|
||
for pam_file in /etc/pam.d/common-*; do | ||
sed -i --follow-symlinks '/\bremember=\d+\b/d' $pam_file | ||
echo "# auth sufficient pam_unix.so try_first_pass bremember=1" >> $pam_file | ||
done |
9 changes: 9 additions & 0 deletions
9
...ns/password_storage/accounts_password_pam_unix_no_remember/tests/remember_present.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,9 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
|
||
for FILE in "/etc/pam.d/common-*"; do | ||
if ! grep -q "^[^#].*pam_unix\.so.*\bremember=\d+\b" ${FILE}; then | ||
sed -i 's/\(^[^#].*pam_unix\.so\)/\1 remember=1/g' ${FILE} | ||
fi | ||
done | ||
|