Skip to content

Commit

Permalink
Merge pull request #11864 from mpurg/ubuntu_2204_stig_611055
Browse files Browse the repository at this point in the history
Add rule set_password_hashing_algorithm_systemauth to Ubuntu STIG profile
  • Loading branch information
dodys committed Apr 29, 2024
2 parents 9e91c4d + 1ca1e4a commit 2c2507f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
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 %}}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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 %}}
Original file line number Diff line number Diff line change
@@ -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 %}}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 2c2507f

Please sign in to comment.