Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule set_password_hashing_algorithm_systemauth to Ubuntu STIG profile #11864

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,6 +2,13 @@

{{% if product in ["sle15", "sle12"] -%}}
{{{ bash_ensure_pam_module_configuration('/etc/pam.d/common-password', 'password', 'required', 'pam_unix.so', 'sha512', '', '') }}}
{{% elif 'ubuntu' in product -%}}
# Can't use macro bash_ensure_pam_module_configuration because the control
# contains special characters and is not static ([success=N default=ignore)
PAM_FILE_PATH=/etc/pam.d/common-password
if ! grep -qP '^\s*password\s+.*\s+pam_unix.so\s+.*\s+sha512\b' "$PAM_FILE_PATH"; then
sed -i -E --follow-symlinks '/\s*password\s+.*\s+pam_unix.so.*/ s/$/ sha512/' "$PAM_FILE_PATH"
fi
{{%- else -%}}
{{{ bash_ensure_pam_module_configuration('/etc/pam.d/system-auth', 'password', 'sufficient', 'pam_unix.so', 'sha512', '', '') }}}
{{%- endif %}}
Expand Up @@ -17,6 +17,9 @@
{{% if product in ['sle12', 'sle15'] %}}
<ind:filepath>/etc/pam.d/common-password</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*password[\s]+(?:(?:required))[\s]+pam_unix\.so[\s]+.*sha512.*$</ind:pattern>
{{% elif 'ubuntu' in product %}}
<ind:filepath>/etc/pam.d/common-password</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*password[\s]+(?:\[success=\d+\s+default=ignore\])[\s]+pam_unix\.so[\s]+[^#]*[\s]sha512(\s.*)?$</ind:pattern>
{{% else %}}
<ind:filepath>/etc/pam.d/system-auth</ind:filepath>
<ind:pattern operation="pattern match">^[\s]*password[\s]+(?:(?:required)|(?:sufficient))[\s]+pam_unix\.so[\s]+.*sha512.*$</ind:pattern>
Expand Down
Expand Up @@ -3,7 +3,7 @@ documentation_complete: true

title: "Set PAM''s Password Hashing Algorithm"

{{% if product in ["sle12", "sle15"] %}}
{{% if product in ["sle12", "sle15"] or 'ubuntu' in product %}}
{{% set pam_passwd_file_path = "/etc/pam.d/common-password" %}}
{{% else %}}
{{% set pam_passwd_file_path = "/etc/pam.d/system-auth" %}}
Expand All @@ -19,6 +19,8 @@ description: |-
<br />
{{% if product in ["sle12", "sle15"] %}}
<pre>password required pam_unix.so sha512 <i>other arguments...</i></pre>
{{% elif 'ubuntu' in product %}}
<pre>password [success=1 default=ignore] pam_unix.so sha512 <i>other arguments...</i></pre>
{{% else %}}
<pre>password sufficient pam_unix.so sha512 <i>other arguments...</i></pre>
{{% endif %}}
Expand Down Expand Up @@ -69,6 +71,7 @@ references:
stigid@rhel8: RHEL-08-010159
stigid@sle12: SLES-12-010230
stigid@sle15: SLES-15-020170
stigid@ubuntu2204: UBTU-22-611055

ocil_clause: '"sha512" is missing, or is commented out'

Expand All @@ -80,6 +83,8 @@ ocil: |-
<pre>$ sudo grep "^password.*pam_unix\.so.*sha512" {{{ pam_passwd_file_path }}}
{{% if product in ["sle12", "sle15"] -%}}
password required pam_unix.so sha512
{{% elif 'ubuntu' in product %}}
password [success=1 default=ignore] pam_unix.so sha512
{{% else %}}
password sufficient pam_unix.so sha512
{{%- endif -%}}
Expand All @@ -88,7 +93,7 @@ ocil: |-
platform: package[pam]

fixtext: |-
{{% if product in ['ol9', 'rhel9'] -%}}
{{% if product in ['ol9', 'rhel9', 'ubuntu2204'] -%}}
Configure {{{ full_name }}} to use a FIPS 140-3 approved cryptographic hashing algorithm for system authentication.
{{% else %}}
Configure {{{ full_name }}} to use a FIPS 140-2 approved cryptographic hashing algorithm for system authentication.
Expand All @@ -97,6 +102,8 @@ fixtext: |-
Edit/modify the following line in the "{{{ pam_passwd_file_path }}}" file to include the sha512 option for pam_unix.so:
{{% if product in ['sle12', 'sle15'] -%}}
password required pam_unix.so sha512
{{% elif 'ubuntu' in product %}}
password [success=1 default=ignore] pam_unix.so sha512
{{% else %}}
password sufficient pam_unix.so sha512
{{%- endif %}}
Expand Down
@@ -0,0 +1,7 @@
#!/bin/bash
# platform = multi_platform_ubuntu
# remediation = none

sed -i --follow-symlinks '/^\s*password.*pam_unix\.so/ s/sha512//g' /etc/pam.d/common-password
sed -i --follow-symlinks '/^\s*password.*pam_unix\.so/ s/$/ # sha512/' /etc/pam.d/common-password

@@ -1,8 +1,16 @@
#!/bin/bash
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7,Red Hat Virtualization 4,multi_platform_fedora
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7,Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ubuntu

{{% if 'ubuntu' in product %}}
pam_file="/etc/pam.d/common-password"

if ! grep -q "^\s*password.*pam_unix\.so.*sha512" "$pam_file"; then
sed -i --follow-symlinks '/^\s*password.*pam_unix\.so/ s/$/ sha512/' "$pam_file"
fi
{{% else %}}
pam_file="/etc/pam.d/system-auth"

if ! grep -q "^password.*sufficient.*pam_unix\.so.*sha512" "$pam_file"; then
sed -i --follow-symlinks '/^password.*sufficient.*pam_unix\.so/ s/$/ sha512/' "$pam_file"
fi
{{% endif %}}
@@ -1,4 +1,8 @@
#!/bin/bash
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7,Red Hat Virtualization 4,multi_platform_fedora
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7,Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ubuntu

{{% if 'ubuntu' in product %}}
sed -i --follow-symlinks '/^\s*password.*pam_unix\.so/ s/sha512//g' "/etc/pam.d/common-password"
{{% else %}}
sed -i --follow-symlinks '/^password.*sufficient.*pam_unix\.so/ s/sha512//g' "/etc/pam.d/system-auth"
{{% endif %}}
@@ -0,0 +1,6 @@
#!/bin/bash
# platform = multi_platform_ubuntu

sed -i --follow-symlinks '/^\s*password.*pam_unix\.so/ s/sha512//g' /etc/pam.d/common-password
sed -i --follow-symlinks '/^\s*password.*pam_unix\.so/ s/$/ sha5122/' /etc/pam.d/common-password

3 changes: 1 addition & 2 deletions products/ubuntu2204/profiles/stig.profile
Expand Up @@ -620,9 +620,8 @@ selections:
# UBTU-22-654225 The Ubuntu operating system must generate audit records when successful/unsuccessful attempts to modify the /etc/sudoers.d directory occur
- audit_rules_sudoers_d

### TODO (rule needed; reevaluate requirement)
# Analogous to set_password_hashing_algorithm_passwordauth
# UBTU-22-611055 The Ubuntu operating system must store only encrypted representations of passwords
- set_password_hashing_algorithm_systemauth

### TODO (rule needed)
# Analogous to audit_rules_login_events_lastlog
Expand Down