Skip to content

Commit 3cb7bd2

Browse files
authored
Merge pull request ComplianceAsCode#6256 from vojtapolasek/add_rhel8_ospp_pam_whell
add rule use_pam_wheel_for_su
2 parents d46bba2 + b170fc7 commit 3cb7bd2

File tree

11 files changed

+89
-1
lines changed

11 files changed

+89
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv
2+
# reboot = false
3+
# strategy = restrict
4+
# complexity = low
5+
# disruption = low
6+
7+
- name: "restrict usage of su command only to members of wheel group"
8+
replace:
9+
path: "/etc/pam.d/su"
10+
regexp: '^[\s]*#[\s]*auth[\s]+required[\s]+pam_wheel\.so[\s]+use_uid$'
11+
replace: "auth required pam_wheel.so use_uid"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv
3+
4+
# uncomment the option if commented
5+
sed '/^[[:space:]]*#[[:space:]]*auth[[:space:]]\+required[[:space:]]\+pam_wheel\.so[[:space:]]\+use_uid$/s/^[[:space:]]*#//' -i /etc/pam.d/su
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<def-group>
2+
<definition class="compliance" id="use_pam_wheel_for_su" version="1">
3+
{{{ oval_metadata("Only members of the wheel group should be able to authenticate through the su command.") }}}
4+
<criteria operator="AND">
5+
<criterion test_ref="test_use_pam_wheel_for_su" />
6+
</criteria>
7+
</definition>
8+
9+
<ind:textfilecontent54_test check="all" check_existence="at_least_one_exists" comment="check /etc/pam.d/su for correct setting" id="test_use_pam_wheel_for_su" version="1">
10+
<ind:object object_ref="object_use_pam_wheel_for_su" />
11+
</ind:textfilecontent54_test>
12+
13+
<ind:textfilecontent54_object comment="check /etc/pam.d/su for correct setting" id="object_use_pam_wheel_for_su" version="1">
14+
<ind:filepath>/etc/pam.d/su</ind:filepath>
15+
<ind:pattern operation="pattern match">^[\s]*auth[\s]+required[\s]+pam_wheel\.so[\s]+use_uid$</ind:pattern>
16+
<ind:instance datatype="int">1</ind:instance>
17+
</ind:textfilecontent54_object>
18+
19+
</def-group>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
documentation_complete: true
2+
3+
prodtype: fedora,ol7,ol8,rhel7,rhel8,rhv4
4+
5+
title: 'Enforce usage of pam_wheel for su authentication'
6+
7+
description: |-
8+
To ensure that only users who are members of the <tt>wheel</tt> group can
9+
run commands with altered privileges through the <tt>su</tt> command, make
10+
sure that the following line exists in the file <tt>/etc/pam.d/su</tt>:
11+
<pre>auth required pam_wheel.so use_uid</pre>
12+
13+
rationale: |-
14+
The <tt>su</tt> program allows to run commands with a substitute user and
15+
group ID. It is commonly used to run commands as the root user. Limiting
16+
access to such command is considered a good security practice.
17+
18+
severity: medium
19+
20+
identifiers:
21+
cce@rhel8: CCE-83318-6
22+
23+
references:
24+
ospp: FMT_SMF_EXT.1.1
25+
26+
ocil_clause: 'the line is not in the file or it is commented'
27+
28+
ocil: |-
29+
Run the following command to check if the line is present:
30+
<pre>grep pam_wheel /etc/pam.d/su</pre>
31+
The output should contain the following line:
32+
<pre>auth required pam_wheel.so use_uid</pre>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
#clean possible commented lines
4+
sed -i '/^.*auth.*required.*pam_wheel\.so.*use_uid$/d' /etc/pam.d/su
5+
6+
#apply correct line
7+
echo "auth required pam_wheel.so use_uid" >> /etc/pam.d/su
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
#clean possible commented lines
4+
sed -i '/^.*auth.*required.*pam_wheel\.so.*use_uid$/d' /etc/pam.d/su
5+
6+
#apply commented line
7+
echo "#auth required pam_wheel.so use_uid" >> /etc/pam.d/su
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# remediation = none
3+
4+
#clean possible lines
5+
sed -i '/^.*auth.*required.*pam_wheel\.so.*use_uid$/d' /etc/pam.d/su

rhel8/profiles/ospp.profile

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ selections:
223223
- securetty_root_login_console_only
224224
- var_password_pam_unix_remember=5
225225
- accounts_password_pam_unix_remember
226+
- use_pam_wheel_for_su
226227

227228
### SELinux Configuration
228229
- var_selinux_state=enforcing

shared/references/cce-redhat-avail.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CCE-83315-2
22
CCE-83316-0
33
CCE-83317-8
4-
CCE-83318-6
54
CCE-83319-4
65
CCE-83320-2
76
CCE-83322-8

tests/data/profile_stability/rhel8/ospp.profile

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ selections:
220220
- sysctl_user_max_user_namespaces
221221
- timer_dnf-automatic_enabled
222222
- usbguard_allow_hid_and_hub
223+
- use_pam_wheel_for_su
223224
- zipl_audit_argument
224225
- zipl_audit_backlog_limit_argument
225226
- zipl_bls_entries_only

tests/data/profile_stability/rhel8/stig.profile

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ selections:
242242
- sysctl_user_max_user_namespaces
243243
- timer_dnf-automatic_enabled
244244
- usbguard_allow_hid_and_hub
245+
- use_pam_wheel_for_su
245246
- var_sshd_set_keepalive=0
246247
- var_rekey_limit_size=1G
247248
- var_rekey_limit_time=1hour

0 commit comments

Comments
 (0)