forked from ComplianceAsCode/content
-
Notifications
You must be signed in to change notification settings - Fork 0
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 ComplianceAsCode#12723 from alanmcanonical/ubt24_5323
Ubuntu 24.04: Implement 5.3.2.3 Ensure pam_pwquality module is enabled
- Loading branch information
Showing
9 changed files
with
114 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
3 changes: 3 additions & 0 deletions
3
...quality/password_quality_pwquality/accounts_password_pam_pwquality_enabled/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,3 @@ | ||
# platform = multi_platform_ubuntu | ||
|
||
{{{ bash_pam_pwquality_enable() }}} |
37 changes: 37 additions & 0 deletions
37
...uality/password_quality_pwquality/accounts_password_pam_pwquality_enabled/oval/ubuntu.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,37 @@ | ||
{{% if 'ubuntu' in product %}} | ||
{{% set configuration_files = ["common-password"] %}} | ||
{{% endif %}} | ||
<def-group> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="2"> | ||
{{{ oval_metadata("Check pam_pwquality module is enabled") }}} | ||
<criteria operator="AND" comment="Check for pam_pwquality module in PAM files"> | ||
{{% for file in configuration_files %}} | ||
<criterion comment="pam_pwquality has correctly set in {{{ file }}}" | ||
test_ref="test_password_pam_pwquality_enabled_{{{ file | escape_id }}}" /> | ||
{{% endfor %}} | ||
</criteria> | ||
</definition> | ||
|
||
{{% macro test_pwquality_enabled(path, test_ref) %}} | ||
<ind:textfilecontent54_test check="all" id="test_{{{ test_ref }}}" version="1" | ||
check_existence="at_least_one_exists" | ||
comment="Check for pam_pwquality.so module in PAM file of {{{ path }}}"> | ||
<ind:object object_ref="obj_{{{ test_ref }}}" /> | ||
</ind:textfilecontent54_test> | ||
{{% endmacro %}} | ||
|
||
{{% macro object_pwquality_enabled(path, test_ref) %}} | ||
<ind:textfilecontent54_object id="obj_{{{ test_ref }}}" version="1"> | ||
<ind:filepath>{{{ path }}}</ind:filepath> | ||
<ind:pattern operation="pattern match">^\s*password\s+(?:(?:required)|(?:requisite))\s+pam_pwquality\.so.*$</ind:pattern> | ||
<ind:instance datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
{{% endmacro %}} | ||
|
||
{{% for file in configuration_files %}} | ||
{{{ test_pwquality_enabled( path="/etc/pam.d/" ~ file , | ||
test_ref="password_pam_pwquality_enabled_" ~ (file | escape_id)) }}} | ||
{{{ object_pwquality_enabled( path="/etc/pam.d/" ~ file , | ||
test_ref="password_pam_pwquality_enabled_" ~ (file | escape_id)) }}} | ||
{{% endfor %}} | ||
</def-group> |
21 changes: 21 additions & 0 deletions
21
...sword_quality/password_quality_pwquality/accounts_password_pam_pwquality_enabled/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: 'Verify pam_pwquality module is activated' | ||
|
||
description: |- | ||
The <tt>pam_pwquality.so</tt> module ensures password quality by evaluating user-created passwords | ||
against a system dictionary and a set of rules designed to detect weak choices. Originally derived | ||
from the pam_cracklib module, this module is backward-compatible with options of pam_cracklib. | ||
<br /><br /> | ||
The module's process includes prompting the user for a password, checking its strength, and if it | ||
meets the criteria requesting the password again for confirmation. If both entries match, the | ||
password is passed to subsequent modules to be set as the new authentication token. | ||
rationale: |- | ||
Strong passwords significantly increase the time and effort required for unauthorized access, | ||
increasing overall system security. | ||
severity: medium | ||
|
||
platform: package[pam] |
4 changes: 4 additions & 0 deletions
4
...assword_quality_pwquality/accounts_password_pam_pwquality_enabled/tests/commented.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,4 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
|
||
sed -i 's/\(^.*pam_pwquality\.so.*\)/# \1/' /etc/pam.d/common-password |
27 changes: 27 additions & 0 deletions
27
...uality/password_quality_pwquality/accounts_password_pam_pwquality_enabled/tests/common.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 @@ | ||
{{% if 'ubuntu' in product %}} | ||
configuration_files=("common-password") | ||
{{% elif product in ['ol8', 'ol9', 'rhel8', 'rhel9'] %}} | ||
configuration_files=("password-auth" "system-auth") | ||
{{% else %}} | ||
configuration_files=("system-auth") | ||
{{% endif %}} | ||
|
||
|
||
{{% if product in ['ol8', 'ol9', 'rhel8', 'rhel9'] %}} | ||
authselect create-profile testingProfile --base-on sssd | ||
|
||
for file in ${configuration_files[@]}; do | ||
sed -i --follow-symlinks "/pam_pwquality\.so/d" \ | ||
"/etc/authselect/custom/testingProfile/$file" | ||
done | ||
authselect select --force custom/testingProfile | ||
{{% elif 'ubuntu' in product %}} | ||
rm -f /usr/share/pam-configs/pwquality | ||
DEBIAN_FRONTEND=noninteractive pam-auth-update | ||
{{% else %}} | ||
for file in ${configuration_files[@]}; do | ||
sed -i --follow-symlinks "/pam_pwquality\.so/d" "/etc/pam.d/$file" | ||
done | ||
{{% endif%}} | ||
|
||
truncate -s 0 /etc/security/pwquality.conf |
14 changes: 14 additions & 0 deletions
14
.../password_quality_pwquality/accounts_password_pam_pwquality_enabled/tests/correct.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,14 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
|
||
cat << EOF > /usr/share/pam-configs/pwquality | ||
Name: Pwquality password strength checking | ||
Default: yes | ||
Priority: 1024 | ||
Conflicts: cracklib | ||
Password-Type: Primary | ||
Password: | ||
requisite pam_pwquality.so | ||
EOF | ||
|
||
DEBIAN_FRONTEND=noninteractive pam-auth-update |
4 changes: 4 additions & 0 deletions
4
.../password_quality_pwquality/accounts_password_pam_pwquality_enabled/tests/missing.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,4 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_ubuntu | ||
|
||
source common.sh |