Skip to content

Commit 7232017

Browse files
authored
Merge pull request #14367 from Arden97/auditd_var_lib_selinux
Add audit monitoring for SELinux policy changes in /var/lib/selinux
2 parents d859af0 + 805f03f commit 7232017

18 files changed

Lines changed: 82 additions & 5 deletions

components/audit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ rules:
131131
- audit_rules_mac_modification_etc_apparmor_d
132132
- audit_rules_mac_modification_etc_selinux
133133
- audit_rules_mac_modification_usr_share
134+
- audit_rules_mac_modification_var_lib_selinux
134135
- audit_rules_media_export
135136
- audit_rules_networkconfig_modification
136137
- audit_rules_networkconfig_modification_etc_hosts

controls/cis_fedora.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,7 @@ controls:
29572957
rules:
29582958
- audit_rules_mac_modification_etc_selinux
29592959
- audit_rules_mac_modification_usr_share
2960+
- audit_rules_mac_modification_var_lib_selinux
29602961

29612962
- id: 6.3.3.24
29622963
title: Ensure successful and unsuccessful attempts to use the chcon command are collected (Automated)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
documentation_complete: true
2+
3+
title: 'Record Events that Modify the System''s Mandatory Access Controls in /var/lib/selinux'
4+
5+
description: |-
6+
{{{ describe_audit_rules_watch("/var/lib/selinux/", "MAC-policy") }}}
7+
Note that monitoring /var/lib/selinux/ will generate a significant burst of audit events
8+
during both selinux-policy* package upgrade and policy rebuild.
9+
10+
rationale: |-
11+
The system's mandatory access policy (SELinux) should not be
12+
arbitrarily changed by anything other than administrator action. All changes to
13+
MAC policy should be audited.
14+
15+
severity: medium
16+
17+
identifiers:
18+
cce@rhel8: CCE-86459-5
19+
cce@rhel9: CCE-86461-1
20+
cce@rhel10: CCE-86465-2
21+
22+
ocil_clause: 'the system is not configured to audit attempts to change the MAC policy'
23+
24+
ocil: |-
25+
To determine if the system is configured to audit changes to its SELinux
26+
configuration files, run the following command:
27+
<pre>$ sudo auditctl -l | grep "dir=/var/lib/selinux"</pre>
28+
If the system is configured to watch for changes to its SELinux
29+
configuration, a line should be returned (including
30+
<tt>perm=wa</tt> indicating permissions that are watched).
31+
32+
template:
33+
name: audit_rules_watch
34+
vars:
35+
path: "/var/lib/selinux/"
36+
key: MAC-policy

shared/checks/oval/audit_rules_auditctl.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ind:object object_ref="object_audit_rules_auditctl" />
1919
</ind:textfilecontent54_test>
2020
<ind:textfilecontent54_object id="object_audit_rules_auditctl" version="1">
21-
{{% if product in ['rhel10', 'ol10'] %}}
21+
{{% if product in ['fedora', 'rhel10', 'ol10'] %}}
2222
<ind:filepath>/usr/lib/systemd/system/audit-rules.service</ind:filepath>
2323
<ind:pattern operation="pattern match">^ExecStart=\/sbin\/auditctl.*$</ind:pattern>
2424
{{% else %}}

shared/checks/oval/audit_rules_augenrules.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ind:object object_ref="object_audit_rules_augenrules" />
1919
</ind:textfilecontent54_test>
2020
<ind:textfilecontent54_object id="object_audit_rules_augenrules" version="1">
21-
{{% if product in ['rhel10', 'ol10'] %}}
21+
{{% if product in ['fedora', 'rhel10', 'ol10'] %}}
2222
<ind:filepath>/usr/lib/systemd/system/audit-rules.service</ind:filepath>
2323
<ind:pattern operation="pattern match">^ExecStart=(\/usr|)?\/sbin\/augenrules.*$</ind:pattern>
2424
{{% else %}}

shared/macros/20-test-scenarios.jinja

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ This macro changes the configuration of the audit service so that it looks like
1515
{{%- endmacro -%}}
1616

1717

18+
{{#
19+
This macro changes the configuration of the audit service so that it looks like augenrules is used to load rules.
20+
#}}
21+
22+
{{%- macro setup_augenrules_environment () -%}}
23+
{{% if product in ["fedora", "ol10", "rhel10"] %}}
24+
sed -i "s%^ExecStart=.*%ExecStart=/sbin/augenrules%" /usr/lib/systemd/system/audit-rules.service
25+
{{% else %}}
26+
{{% if product == "sle15" %}}
27+
sed -i "s%^#ExecStartPost=.*%ExecStartPost=-/sbin/augenrules%" /usr/lib/systemd/system/auditd.service
28+
{{% else %}}
29+
sed -i "s%^ExecStartPost=.*%ExecStartPost=-/sbin/augenrules%" /usr/lib/systemd/system/auditd.service
30+
{{% endif %}}
31+
{{% endif %}}
32+
{{%- endmacro -%}}
33+
34+
1835
{{#
1936
This macro is used by pam_account_password_faillock template to initialize
2037
the external variable and parameter value to a desired state.

shared/references/cce-redhat-avail.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
CCE-86459-5
2-
CCE-86461-1
3-
CCE-86465-2
41
CCE-86466-0
52
CCE-86468-6
63
CCE-86469-4

shared/templates/audit_rules_watch/tests/augenrules_correct.pass.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# packages = audit
33

4+
{{{ setup_augenrules_environment() }}}
5+
46
path={{{ PATH }}}
57
style={{{ audit_watches_style }}}
68
filter_type={{{ FILTER_TYPE }}}

shared/templates/audit_rules_watch/tests/augenrules_correct_extra_permission.pass.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# packages = audit
33

4+
{{{ setup_augenrules_environment() }}}
5+
46
path={{{ PATH }}}
57
style={{{ audit_watches_style }}}
68
filter_type={{{ FILTER_TYPE }}}

shared/templates/audit_rules_watch/tests/augenrules_correct_without_key.pass.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# packages = audit
33

4+
{{{ setup_augenrules_environment() }}}
5+
46
path={{{ PATH }}}
57
style={{{ audit_watches_style }}}
68
filter_type={{{ FILTER_TYPE }}}

0 commit comments

Comments
 (0)