Skip to content

Commit f789220

Browse files
authored
Merge pull request #14222 from jan-cerny/accounts_password_pam_unix_enabled
Add accounts_password_pam_unix_enabled to RHEL 10 CIS
2 parents 82a26ab + ea3fd4b commit f789220

File tree

9 files changed

+60
-24
lines changed

9 files changed

+60
-24
lines changed

controls/cis_rhel10.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,13 +1930,11 @@ controls:
19301930
levels:
19311931
- l1_server
19321932
- l1_workstation
1933-
status: partial
1934-
notes: |-
1935-
This module is always present by default. It is necessary to investigate if a new rule to
1936-
check its existence needs to be created. But so far the rule no_empty_passwords, used in
1937-
5.3.3.4 can ensure this requirement is attended.
1933+
status: automated
19381934
related_rules:
19391935
- no_empty_passwords
1936+
rules:
1937+
- accounts_password_pam_unix_enabled
19401938

19411939
- id: 5.3.2.1.1
19421940
title: Ensure password failed attempts lockout is configured (Automated)
Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
1-
{{% set file_stem = ["auth","account","password","session"] %}}
1+
{{% if product == "rhel10" %}}
2+
{{% set pam_files = ["password-auth", "system-auth"] %}}
3+
{{% else %}}
4+
{{% set pam_files = ["common"] %}}
5+
{{% endif %}}
6+
{{% set pam_sections = ["auth","account","password","session"] %}}
27
<def-group>
38
<definition class="compliance" id="{{{ rule_id }}}" version="1">
49
{{{ oval_metadata("Ensure pam_unix.so is properly configured in PAM configuration files", rule_title=rule_title) }}}
5-
<criteria operator="AND" comment="Check if pam_unix.so is properly defined in all PAM files">
6-
{{% for stem in file_stem %}}
7-
<criterion test_ref="test_pam_unix_common_{{{ stem }}}"
8-
comment="pam_unix has correctly set in common-{{{ stem }}}"/>
10+
<criteria operator="AND" comment="Check if pam_unix.so is properly defined in all PAM files">
11+
{{% for pam_file in pam_files %}}
12+
{{% for pam_section in pam_sections %}}
13+
<criterion test_ref="test_pam_unix_{{{ pam_file }}}_{{{ pam_section }}}" comment="pam_unix is configured in {{{ pam_section }}} section in {{{ pam_file }}}" />
14+
{{% endfor %}}
915
{{% endfor %}}
1016
</criteria>
1117
</definition>
1218

1319
<!-- Check occurrences of pam_unix.so in common-{auth,account,password} file -->
14-
{{% macro test_pam_unix(stem) %}}
15-
<ind:textfilecontent54_test check="all" id="test_pam_unix_common_{{{ stem }}}" version="1"
20+
{{% macro test_pam_unix(full_path, pam_file, pam_section) %}}
21+
<ind:textfilecontent54_test check="all" id="test_pam_unix_{{{ pam_file }}}_{{{ pam_section }}}" version="1"
1622
check_existence="only_one_exists"
17-
comment="No more than one pam_unix.so is expected in {{{ stem }}} section of /etc/pam.d/common-{{{ stem }}}">
18-
<ind:object object_ref="obj_pam_unix_common_{{{ stem }}}" />
23+
comment="No more than one pam_unix.so is expected in {{{ pam_section }}} section of {{{ full_path }}}">
24+
<ind:object object_ref="obj_pam_unix_{{{ pam_file }}}_{{{ pam_section }}}" />
1925
</ind:textfilecontent54_test>
2026
{{% endmacro %}}
2127

22-
{{% macro object_pam_unix(stem) %}}
23-
<ind:textfilecontent54_object id="obj_pam_unix_common_{{{ stem }}}" version="1"
24-
comment="Get the occurrences of pam_unix.so in {{{ stem }}} section of /etc/pam.d/common-{{{ stem }}}">
25-
<ind:filepath>/etc/pam.d/common-{{{ stem }}}</ind:filepath>
26-
<ind:pattern operation="pattern match">^[\s]*{{{stem}}}[\s]+(required|\[(?=.*?\bsuccess=\d+\b)?(?=.*?\bnew_authtok_reqd=ok\b)?(?=.*?\bdefault=ignore\b)?.*\])[\s]+pam_unix\.so.*$</ind:pattern>
28+
{{% macro object_pam_unix(full_path, pam_file, pam_section) %}}
29+
<ind:textfilecontent54_object id="obj_pam_unix_{{{ pam_file }}}_{{{ pam_section }}}" version="1"
30+
comment="Get the occurrences of pam_unix.so in {{{ pam_section }}} section of {{{ full_path }}}">
31+
<ind:filepath>{{{ full_path }}}</ind:filepath>
32+
{{% if product == "rhel10" %}}
33+
<ind:pattern operation="pattern match">^[\s]*{{{ pam_section }}}[\s]+(required|sufficient)[\s]+pam_unix\.so.*$</ind:pattern>
34+
{{% else %}}
35+
<ind:pattern operation="pattern match">^[\s]*{{{ pam_section }}}[\s]+(required|\[(?=.*?\bsuccess=\d+\b)?(?=.*?\bnew_authtok_reqd=ok\b)?(?=.*?\bdefault=ignore\b)?.*\])[\s]+pam_unix\.so.*$</ind:pattern>
36+
{{% endif %}}
2737
<ind:instance datatype="int" operation="equals">1</ind:instance>
2838
</ind:textfilecontent54_object>
2939
{{% endmacro %}}
3040

31-
{{% for file in file_stem %}}
32-
{{{ test_pam_unix(stem=file) }}}
33-
{{{ object_pam_unix(stem=file) }}}
41+
{{% for pam_file in pam_files %}}
42+
{{% for pam_section in pam_sections %}}
43+
{{% if product == "rhel10" %}}
44+
{{% set full_path = "/etc/pam.d/" + pam_file %}}
45+
{{% else %}}
46+
{{% set full_path = "/etc/pam.d/" + pam_file + "-" + pam_section %}}
47+
{{% endif %}}
48+
{{{ test_pam_unix(full_path, pam_file, pam_section) }}}
49+
{{{ object_pam_unix(full_path, pam_file, pam_section) }}}
50+
{{% endfor %}}
3451
{{% endfor %}}
35-
3652
</def-group>

linux_os/guide/system/accounts/accounts-pam/accounts_password_pam_unix_enabled/rule.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ description: |-
2525
rationale: |-
2626
The system should only provide access after performing authentication of a user.
2727
28+
identifiers:
29+
cce@rhel10: CCE-87536-9
30+
2831
severity: medium
2932

3033
platform: package[pam]
34+
35+
{{% if product == "rhel10" %}}
36+
warnings:
37+
- general: |-
38+
Automated remediation of this rule isn't available, you should use authselect to manage PAM settings.
39+
{{% endif %}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# platform = multi_platform_rhel
3+
4+
# Ensure pam_unix.so is present in all sections of both PAM files
5+
for pam_file in /etc/pam.d/system-auth /etc/pam.d/password-auth; do
6+
{{{ bash_ensure_pam_module_line("$pam_file", "auth", "sufficient", "pam_unix.so") }}}
7+
{{{ bash_ensure_pam_module_line("$pam_file", "account", "required", "pam_unix.so") }}}
8+
{{{ bash_ensure_pam_module_line("$pam_file", "password", "sufficient", "pam_unix.so") }}}
9+
{{{ bash_ensure_pam_module_line("$pam_file", "session", "required", "pam_unix.so") }}}
10+
done

shared/references/cce-redhat-avail.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ CCE-87529-4
469469
CCE-87530-2
470470
CCE-87532-8
471471
CCE-87533-6
472-
CCE-87536-9
473472
CCE-87537-7
474473
CCE-87538-5
475474
CCE-87539-3

tests/data/profile_stability/rhel10/cis.profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ accounts_password_pam_pwhistory_use_authtok
2222
accounts_password_pam_pwquality_password_auth
2323
accounts_password_pam_pwquality_system_auth
2424
accounts_password_pam_unix_authtok
25+
accounts_password_pam_unix_enabled
2526
accounts_password_pam_unix_no_remember
2627
accounts_password_set_max_life_existing
2728
accounts_password_set_min_life_existing

tests/data/profile_stability/rhel10/cis_server_l1.profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ accounts_password_pam_pwhistory_use_authtok
2121
accounts_password_pam_pwquality_password_auth
2222
accounts_password_pam_pwquality_system_auth
2323
accounts_password_pam_unix_authtok
24+
accounts_password_pam_unix_enabled
2425
accounts_password_pam_unix_no_remember
2526
accounts_password_set_max_life_existing
2627
accounts_password_set_warn_age_existing

tests/data/profile_stability/rhel10/cis_workstation_l1.profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ accounts_password_pam_pwhistory_use_authtok
2121
accounts_password_pam_pwquality_password_auth
2222
accounts_password_pam_pwquality_system_auth
2323
accounts_password_pam_unix_authtok
24+
accounts_password_pam_unix_enabled
2425
accounts_password_pam_unix_no_remember
2526
accounts_password_set_max_life_existing
2627
accounts_password_set_warn_age_existing

tests/data/profile_stability/rhel10/cis_workstation_l2.profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ accounts_password_pam_pwhistory_use_authtok
2222
accounts_password_pam_pwquality_password_auth
2323
accounts_password_pam_pwquality_system_auth
2424
accounts_password_pam_unix_authtok
25+
accounts_password_pam_unix_enabled
2526
accounts_password_pam_unix_no_remember
2627
accounts_password_set_max_life_existing
2728
accounts_password_set_min_life_existing

0 commit comments

Comments
 (0)