Blame SOURCES/scap-security-guide-0.1.49-split-audit-rules.patch

05062e
From dd25ef669719bffe40f3024dbc949e421779f106 Mon Sep 17 00:00:00 2001
05062e
From: Vojtech Polasek <vpolasek@redhat.com>
05062e
Date: Mon, 9 Dec 2019 16:25:50 +0100
05062e
Subject: [PATCH] Split audit rules for OSPP
05062e
05062e
---
05062e
 docs/manual/developer_guide.adoc              |   7 +
05062e
 .../policy_rules/audit_access_failed/rule.yml |  53 +++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_access_success/rule.yml             |  58 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_basic_configuration/rule.yml        |  66 +++++++++
05062e
 .../tests/correct_rules.pass.sh               |   3 +
05062e
 .../tests/file_missing.fail.sh                |   3 +
05062e
 .../tests/file_not_identical.fail.sh          |   4 +
05062e
 .../policy_rules/audit_create_failed/rule.yml |  66 +++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_create_success/rule.yml             |  59 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../policy_rules/audit_delete_failed/rule.yml |  58 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_delete_success/rule.yml             |  57 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../tests/failed_delete_rules.fail.sh         |   1 +
05062e
 .../tests/no_rule.fail.sh                     |   1 +
05062e
 .../audit_immutable_login_uids/rule.yml       |  54 +++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../policy_rules/audit_modify_failed/rule.yml |  66 +++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_modify_success/rule.yml             |  61 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../policy_rules/audit_module_load/rule.yml   |  58 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../policy_rules/audit_ospp_general/rule.yml  | 138 ++++++++++++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_owner_change_failed/rule.yml        |  59 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_owner_change_success/rule.yml       |  60 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_perm_change_failed/rule.yml         |  58 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_perm_change_success/rule.yml        |  57 ++++++++
05062e
 .../tests/correct_rules.pass.sh               |   1 +
05062e
 .../audit_rules_for_ospp/oval/shared.xml      |   8 +-
05062e
 rhel8/profiles/ospp.profile                   |  17 ++-
05062e
 shared/macros-ansible.jinja                   |  15 ++
05062e
 shared/macros-bash.jinja                      |  11 ++
05062e
 shared/macros-oval.jinja                      |  41 ++++++
05062e
 shared/references/cce-redhat-avail.txt        |  11 --
05062e
 .../template_ANSIBLE_audit_file_contents      |  11 ++
05062e
 .../template_BASH_audit_file_contents         |  14 ++
05062e
 .../template_OVAL_audit_file_contents         |   7 +
05062e
 ssg/templates.py                              |  20 +++
05062e
 tests/shared/audit/10-base-config.rules       |  13 ++
05062e
 tests/shared/audit/11-loginuid.rules          |   3 +
05062e
 .../audit/30-ospp-v42-1-create-failed.rules   |  13 ++
05062e
 .../audit/30-ospp-v42-1-create-success.rules  |   7 +
05062e
 .../audit/30-ospp-v42-2-modify-failed.rules   |  13 ++
05062e
 .../audit/30-ospp-v42-2-modify-success.rules  |   7 +
05062e
 .../audit/30-ospp-v42-3-access-failed.rules   |   5 +
05062e
 .../audit/30-ospp-v42-3-access-success.rules  |   4 +
05062e
 .../audit/30-ospp-v42-4-delete-failed.rules   |   5 +
05062e
 .../audit/30-ospp-v42-4-delete-success.rules  |   3 +
05062e
 .../30-ospp-v42-5-perm-change-failed.rules    |   5 +
05062e
 .../30-ospp-v42-5-perm-change-success.rules   |   3 +
05062e
 .../30-ospp-v42-6-owner-change-failed.rules   |   5 +
05062e
 .../30-ospp-v42-6-owner-change-success.rules  |   3 +
05062e
 tests/shared/audit/30-ospp-v42.rules          |  80 ++++++++++
05062e
 tests/shared/audit/43-module-load.rules       |   6 +
05062e
 63 files changed, 1376 insertions(+), 16 deletions(-)
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_access_failed/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_access_failed/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_access_success/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_access_success/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_missing.fail.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_not_identical.fail.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_create_failed/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_create_failed/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_create_success/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_create_success/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_delete_failed/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_delete_failed/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_delete_success/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/failed_delete_rules.fail.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/no_rule.fail.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_modify_failed/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_modify_failed/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_modify_success/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_modify_success/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_module_load/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_module_load/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_ospp_general/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_ospp_general/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/tests/correct_rules.pass.sh
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/rule.yml
05062e
 create mode 100644 linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/tests/correct_rules.pass.sh
05062e
 create mode 100644 shared/templates/template_ANSIBLE_audit_file_contents
05062e
 create mode 100644 shared/templates/template_BASH_audit_file_contents
05062e
 create mode 100644 shared/templates/template_OVAL_audit_file_contents
05062e
 create mode 100644 tests/shared/audit/10-base-config.rules
05062e
 create mode 100644 tests/shared/audit/11-loginuid.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-1-create-failed.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-1-create-success.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-2-modify-failed.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-2-modify-success.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-3-access-failed.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-3-access-success.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-4-delete-failed.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-4-delete-success.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-5-perm-change-failed.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-5-perm-change-success.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-6-owner-change-failed.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42-6-owner-change-success.rules
05062e
 create mode 100644 tests/shared/audit/30-ospp-v42.rules
05062e
 create mode 100644 tests/shared/audit/43-module-load.rules
05062e
05062e
diff --git a/docs/manual/developer_guide.adoc b/docs/manual/developer_guide.adoc
05062e
index 4cccea23d..76c1c1021 100644
05062e
--- a/docs/manual/developer_guide.adoc
05062e
+++ b/docs/manual/developer_guide.adoc
05062e
@@ -1449,6 +1449,13 @@ audit_rules_privileged_commands::
05062e
 ** *path* - the path of the privileged command - eg. `/usr/bin/mount`
05062e
 * Languages: Ansible, Bash, OVAL
05062e
 
05062e
+audit_file_contents::
05062e
+* Ensure that audit `.rules` file specified by parameter `filepath` contains the contents specified in parameter `contents`.
05062e
+* Parameters:
05062e
+** *filepath* - path to audit rules file, e.g.: `/etc/audit/rules.d/10-base-config.rules`
05062e
+** *contents* - expected contents of the file
05062e
+* Languages: Ansible, Bash, OVAL
05062e
+
05062e
 audit_rules_unsuccessful_file_modification::
05062e
 * Ensure there is an Audit rule to record unsuccessful attempts to access files
05062e
 * Parameters:
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_access_failed/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_access_failed/rule.yml
05062e
new file mode 100644
05062e
index 000000000..6172751f1
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_access_failed/rule.yml
05062e
@@ -0,0 +1,53 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of unsuccessful file accesses'
05062e
+
05062e
+{{% set file_contents_audit_access_failed =
05062e
+"## Unsuccessful file access (any other opens) This has to go last.
05062e
+-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that unsuccessful attempts to access a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_access_failed|indent }}}    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+
05062e
+rationale: |-
05062e
+    Unsuccessful attempts to access a file might be signs of malicious activity happening within the system. Auditing of such activities helps in their monitoring and investigation.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82833-5
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-3-access-failed.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_access_failed|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-3-access-failed.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_access_failed|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_access_failed/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_access_failed/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..ce7c7a0dd
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_access_failed/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-3-access-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_access_success/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_access_success/rule.yml
05062e
new file mode 100644
05062e
index 000000000..8d0625a1d
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_access_success/rule.yml
05062e
@@ -0,0 +1,58 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of successful file accesses'
05062e
+
05062e
+{{% set file_contents_audit_access_success =
05062e
+"## Successful file access (any other opens) This has to go last.
05062e
+## These next two are likely to result in a whole lot of events
05062e
+-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-access
05062e
+-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-access
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that successful attempts to access a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_access_success|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-3-access-success.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-3-access-success.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+    
05062e
+
05062e
+rationale: |-
05062e
+    Auditing of successful attempts to access a file helps in investigation of activities performed on the system. 
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82834-3
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-3-access-success.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_access_success|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-3-access-success.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_access_success|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_access_success/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_access_success/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..7092f2c47
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_access_success/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-3-access-success.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/rule.yml
05062e
new file mode 100644
05062e
index 000000000..24cac20a2
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/rule.yml
05062e
@@ -0,0 +1,66 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure basic parameters of Audit system'
05062e
+
05062e
+{{% set file_contents_audit_base_config =
05062e
+"## First rule - delete all
05062e
+-D
05062e
+
05062e
+## Increase the buffers to survive stress events.
05062e
+## Make this bigger for busy systems
05062e
+-b 8192
05062e
+
05062e
+## This determine how long to wait in burst of events
05062e
+--backlog_wait_time 60000
05062e
+
05062e
+## Set failure mode to syslog
05062e
+-f 1
05062e
+
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Perform basic configuration of Audit system.
05062e
+    Make sure that any previously defined rules are cleared, the auditing system is configured to handle sudden bursts of events, and in cases of failure, messages are configured to be directed to system log.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_base_config|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/10-base-config.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/10-base-config.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+
05062e
+rationale: |-
05062e
+    Without basic configurations, audit may not perform as expected. It may not be able to correctly handle events under stressful conditions, or log events in case of failure.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82827-7
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000365-GPOS-00152,SRG-OS-000475-GPOS-00220
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/10-base-config.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_base_config|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/10-base-config.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_base_config|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..2335ce458
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1,3 @@
05062e
+# profiles = xccdf_org.ssgproject.content_profile_ospp
05062e
+
05062e
+cp $SHARED/audit/10-base-config.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_missing.fail.sh b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_missing.fail.sh
05062e
new file mode 100644
05062e
index 000000000..aa506a736
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_missing.fail.sh
05062e
@@ -0,0 +1,3 @@
05062e
+# profiles = xccdf_org.ssgproject.content_profile_ospp
05062e
+
05062e
+rm -f /etc/audit/rules.d/10-base-config.rules
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_not_identical.fail.sh b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_not_identical.fail.sh
05062e
new file mode 100644
05062e
index 000000000..4e7ce04c5
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_basic_configuration/tests/file_not_identical.fail.sh
05062e
@@ -0,0 +1,4 @@
05062e
+# profiles = xccdf_org.ssgproject.content_profile_ospp
05062e
+
05062e
+cp /usr/share/audit/sample-rules/10-base-config.rules /etc/audit/rules.d/
05062e
+echo "some additional text" >> /etc/audit/rules.d/10-base-config.rules
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_create_failed/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_create_failed/rule.yml
05062e
new file mode 100644
05062e
index 000000000..7cd677661
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_create_failed/rule.yml
05062e
@@ -0,0 +1,66 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of unsuccessful file creations'
05062e
+
05062e
+{{% set file_contents_audit_create_failed =
05062e
+"## Unsuccessful file creation (open with O_CREAT)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S open -F a1&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S open -F a1&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S creat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S creat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S open -F a1&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S open -F a1&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S creat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S creat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that unsuccessful attempts to create a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_create_failed|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-1-create-failed.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-1-create-failed.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+rationale: |-
05062e
+    Unsuccessful file creations might be a sign of a malicious action being performed on the system. Keeping log of such events helps in monitoring and investigation of such actions.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82374-0
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-1-create-failed.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_create_failed|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-1-create-failed.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_create_failed|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_create_failed/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_create_failed/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..9a7fe431a
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_create_failed/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-1-create-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_create_success/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_create_success/rule.yml
05062e
new file mode 100644
05062e
index 000000000..4c933ec50
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_create_success/rule.yml
05062e
@@ -0,0 +1,59 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of successful file creations'
05062e
+
05062e
+{{% set file_contents_audit_create_success =
05062e
+"## Successful file creation (open with O_CREAT)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b32 -S open -F a1&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b64 -S open -F a1&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b32 -S creat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b64 -S creat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that successful attempts to create a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_create_success |indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-1-create-success.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-1-create-success.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+
05062e
+rationale: |-
05062e
+    Auditing of successful attempts to create a file helps in investigation of actions which happened on the system.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82829-3
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-1-create-success.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_create_success|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-1-create-success.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_create_success|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_create_success/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_create_success/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..dcc4afe73
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_create_success/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-1-create-success.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_delete_failed/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_delete_failed/rule.yml
05062e
new file mode 100644
05062e
index 000000000..b9084f217
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_delete_failed/rule.yml
05062e
@@ -0,0 +1,58 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of unsuccessful file deletions'
05062e
+
05062e
+{{% set file_contents_audit_delete_failed =
05062e
+"## Unsuccessful file delete
05062e
+-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that unsuccessful attempts to delete a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_delete_failed|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-4-delete-failed.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-4-delete-failed.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+rationale: |-
05062e
+    Unsuccessful attempts to delete a file might be signs of malicious activities. Auditing of such events help in monitoring and investigating of such activities. 
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82835-0
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205,SRG-OS-000468-GPOS-00212,SRG-OS-000467-GPOS-00211
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-4-delete-failed.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_delete_failed|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-4-delete-failed.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_delete_failed|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_delete_failed/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_delete_failed/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..9ae890203
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_delete_failed/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-4-delete-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_delete_success/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/rule.yml
05062e
new file mode 100644
05062e
index 000000000..7d445d751
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/rule.yml
05062e
@@ -0,0 +1,57 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of successful file deletions'
05062e
+
05062e
+{{% set file_contents_audit_delete_success =
05062e
+"## Successful file delete
05062e
+-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-delete
05062e
+-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-delete
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that successful attempts to delete a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_delete_success|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-4-delete-success.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-4-delete-success.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+    
05062e
+
05062e
+rationale: |-
05062e
+    Auditing of successful attempts to delete a file may help in monitoring and investigation of activities performed on the system.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82836-8
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205,SRG-OS-000468-GPOS-00212,SRG-OS-000467-GPOS-00211
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-4-delete-success.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_delete_success|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-4-delete-success.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_delete_success|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..0a348baf6
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-4-delete-success.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/failed_delete_rules.fail.sh b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/failed_delete_rules.fail.sh
05062e
new file mode 100644
05062e
index 000000000..9ae890203
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/failed_delete_rules.fail.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-4-delete-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/no_rule.fail.sh b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/no_rule.fail.sh
05062e
new file mode 100644
05062e
index 000000000..3acb94ab6
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_delete_success/tests/no_rule.fail.sh
05062e
@@ -0,0 +1 @@
05062e
+rm -f /etc/audit/rules.d/30-ospp-v42-4-delete-success.rules.
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/rule.yml
05062e
new file mode 100644
05062e
index 000000000..eb87848e8
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/rule.yml
05062e
@@ -0,0 +1,54 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure immutable Audit login UIDs'
05062e
+
05062e
+{{% set file_contents_audit_immutable_login =
05062e
+"## Make the loginuid immutable. This prevents tampering with the auid.
05062e
+--loginuid-immutable
05062e
+
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Configure kernel to prevent modification of login UIDs once they are set. Changing login UUIDs while this configuration is enforced requires special capabilities which are not available to unprivileged users.   
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_immutable_login|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/11-loginuid.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/11-loginuid.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+
05062e
+rationale: |-
05062e
+    If modification of login UIDs is not prevented, they can be changed by unprivileged users and make auditing complicated or impossible. 
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82828-5
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000462-GPOS-00206,SRG-OS-000475-GPOS-00220
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/11-loginuid.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_immutable_login|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/11-loginuid.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_immutable_login|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..42178a67d
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_immutable_login_uids/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/11-loginuid.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_modify_failed/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_modify_failed/rule.yml
05062e
new file mode 100644
05062e
index 000000000..e9a24d9f5
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_modify_failed/rule.yml
05062e
@@ -0,0 +1,66 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of unsuccessful file modifications'
05062e
+
05062e
+{{% set file_contents_audit_modify_failed =
05062e
+"## Unsuccessful file modifications (open for write or truncate)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S open -F a1&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S open -F a1&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S truncate,ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S truncate,ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S open -F a1&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S open -F a1&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S truncate,ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S truncate,ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that unsuccessful attempts to modify a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_modify_failed|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-2-modify-failed.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-2-modify-failed.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+rationale: |-
05062e
+    Unsuccessful file modifications might be a sign of a malicious action being performed on the system. Auditing of such events helps in detection and investigation of such actions.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82830-1
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-2-modify-failed.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_modify_failed|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-2-modify-failed.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_modify_failed|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_modify_failed/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_modify_failed/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..58a11a63c
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_modify_failed/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-2-modify-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_modify_success/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_modify_success/rule.yml
05062e
new file mode 100644
05062e
index 000000000..71c313ece
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_modify_success/rule.yml
05062e
@@ -0,0 +1,61 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of successful file modifications'
05062e
+
05062e
+{{% set file_contents_audit_modify_success =
05062e
+"## Successful file modifications (open for write or truncate)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b32 -S open -F a1&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b64 -S open -F a1&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b32 -S truncate,ftruncate -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b64 -S truncate,ftruncate -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that successful attempts to modify a file are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_modify_success|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-2-modify-success.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-2-modify-success.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+
05062e
+rationale: |-
05062e
+    Auditing of successful attempts to modify a file helps in investigation of actions which happened on the system.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82832-7
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000458-GPOS-00203,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000461-GPOS-00205
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-2-modify-success.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_modify_success|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-2-modify-success.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_modify_success|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_modify_success/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_modify_success/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..163ffa5db
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_modify_success/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-2-modify-success.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_module_load/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_module_load/rule.yml
05062e
new file mode 100644
05062e
index 000000000..30be01ce0
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_module_load/rule.yml
05062e
@@ -0,0 +1,58 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of loading and unloading of kernel modules'
05062e
+
05062e
+{{% set file_contents_audit_module_load =
05062e
+"## These rules watch for kernel module insertion. By monitoring
05062e
+## the syscall, we do not need any watches on programs.
05062e
+-a always,exit -F arch=b32 -S init_module,finit_module -F key=module-load
05062e
+-a always,exit -F arch=b64 -S init_module,finit_module -F key=module-load
05062e
+-a always,exit -F arch=b32 -S delete_module -F key=module-unload
05062e
+-a always,exit -F arch=b64 -S delete_module -F key=module-unload
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that loading and unloading of kernel modules is audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_module_load|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/43-module-load.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/43-module-load.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+
05062e
+
05062e
+rationale: |-
05062e
+    Loading of a malicious kernel module introduces a risk to the system, as the module has access to sensitive data and perform actions at the operating system kernel level. Having such events audited helps in monitoring and investigating of malicious activities.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82838-4
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000471-GPOS-00216,SRG-OS-000477-GPOS-00222,SRG-OS-000475-GPOS-00220
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/43-module-load.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_module_load|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/43-module-load.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_module_load|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_module_load/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_module_load/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..c2d651e4c
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_module_load/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/43-module-load.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_ospp_general/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_ospp_general/rule.yml
05062e
new file mode 100644
05062e
index 000000000..0649e0682
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_ospp_general/rule.yml
05062e
@@ -0,0 +1,138 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Perform general configuration of Audit for OSPP'
05062e
+
05062e
+{{% set file_contents_audit_ospp_general =
05062e
+"## The purpose of these rules is to meet the requirements for Operating
05062e
+## System Protection Profile (OSPP)v4.2. These rules depends on having
05062e
+## the following rule files copied to /etc/audit/rules.d:
05062e
+##
05062e
+## 10-base-config.rules, 11-loginuid.rules,
05062e
+## 30-ospp-v42-1-create-failed.rules, 30-ospp-v42-1-create-success.rules,
05062e
+## 30-ospp-v42-2-modify-failed.rules, 30-ospp-v42-2-modify-success.rules,
05062e
+## 30-ospp-v42-3-access-failed.rules, 30-ospp-v42-3-access-success.rules,
05062e
+## 30-ospp-v42-4-delete-failed.rules, 30-ospp-v42-4-delete-success.rules,
05062e
+## 30-ospp-v42-5-perm-change-failed.rules,
05062e
+## 30-ospp-v42-5-perm-change-success.rules,
05062e
+## 30-ospp-v42-6-owner-change-failed.rules,
05062e
+## 30-ospp-v42-6-owner-change-success.rules
05062e
+##
05062e
+## original copies may be found in /usr/share/audit/sample-rules/
05062e
+
05062e
+
05062e
+## User add delete modify. This is covered by pam. However, someone could
05062e
+## open a file and directly create or modify a user, so we'll watch passwd and
05062e
+## shadow for writes
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b32 -S open -F a1&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S open -F a1&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b32 -S open -F a1&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S open -F a1&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+
05062e
+## User enable and disable. This is entirely handled by pam.
05062e
+
05062e
+## Group add delete modify. This is covered by pam. However, someone could
05062e
+## open a file and directly create or modify a user, so we'll watch group and
05062e
+## gshadow for writes
05062e
+-a always,exit -F path=/etc/passwd -F perm=wa -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F path=/etc/shadow -F perm=wa -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F path=/etc/group -F perm=wa -F auid>=1000 -F auid!=unset -F key=group-modify
05062e
+-a always,exit -F path=/etc/gshadow -F perm=wa -F auid>=1000 -F auid!=unset -F key=group-modify
05062e
+
05062e
+
05062e
+## Use of special rights for config changes. This would be use of setuid
05062e
+## programs that relate to user accts. This is not all setuid apps because
05062e
+## requirements are only for ones that affect system configuration.
05062e
+-a always,exit -F path=/usr/sbin/unix_chkpwd -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/sbin/usernetctl -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/sbin/userhelper -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/sbin/seunshare -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/mount -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/newgrp -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/newuidmap -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/gpasswd -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/newgidmap -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/umount -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/passwd -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/crontab -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/at -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+
05062e
+## Privilege escalation via su or sudo. This is entirely handled by pam.
05062e
+
05062e
+## Audit log access
05062e
+-a always,exit -F dir=/var/log/audit/ -F perm=r -F auid>=1000 -F auid!=unset -F key=access-audit-trail
05062e
+## Attempts to Alter Process and Session Initiation Information
05062e
+-a always,exit -F path=/var/run/utmp -F perm=wa -F auid>=1000 -F auid!=unset -F key=session
05062e
+-a always,exit -F path=/var/log/btmp -F perm=wa -F auid>=1000 -F auid!=unset -F key=session
05062e
+-a always,exit -F path=/var/log/wtmp -F perm=wa -F auid>=1000 -F auid!=unset -F key=session
05062e
+
05062e
+## Attempts to modify MAC controls
05062e
+-a always,exit -F dir=/etc/selinux/ -F perm=wa -F auid>=1000 -F auid!=unset -F key=MAC-policy
05062e
+
05062e
+## Software updates. This is entirely handled by rpm.
05062e
+
05062e
+## System start and shutdown. This is entirely handled by systemd
05062e
+
05062e
+## Kernel Module loading. This is handled in 43-module-load.rules
05062e
+
05062e
+## Application invocation. The requirements list an optional requirement
05062e
+## FPT_SRP_EXT.1 Software Restriction Policies. This event is intended to
05062e
+## state results from that policy. This would be handled entirely by
05062e
+## that daemon.
05062e
+
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Configure some basic <tt>Audit</tt> parameters specific for OSPP profile. 
05062e
+    In particular, configure <tt>Audit</tt> to watch for direct modification of files storing system user and group information, and usage of applications with special rights which can change system configuration.
05062e
+    Further audited events include access to audit log it self, attempts to Alter Process and Session Initiation Information, and attempts to modify MAC controls.
05062e
+    
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_ospp_general|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+
05062e
+
05062e
+rationale: |-
05062e
+    Auditing of events listed in the description provides data for monitoring and investigation of potentially malicious events e.g. tampering with <tt>Audit</tt> logs, malicious access to files storing information about system users and groups etc.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82373-2
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000004-GPOS-00004,SRG-OS-000241-GPOS-00091,SRG-OS-000476-GPOS-00221,SRG-OS-000327-GPOS-00127,SRG-OS-000475-GPOS-00220,SRG-OS-000239-GPOS-00089,SRG-OS-000274-GPOS-00104,SRG-OS-000275-GPOS-00105,SRG-OS-000303-GPOS-00120,SRG-OS-000304-GPOS-00121
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_ospp_general|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_ospp_general|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_ospp_general/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_ospp_general/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..dcf3a88a6
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_ospp_general/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/rule.yml
05062e
new file mode 100644
05062e
index 000000000..1068fb8a9
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/rule.yml
05062e
@@ -0,0 +1,59 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of unsuccessful ownership changes'
05062e
+
05062e
+{{% set file_contents_audit_owner_change_failed =
05062e
+"## Unsuccessful ownership change
05062e
+-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+-a always,exit -F arch=b64 -S lchown,fchown,chown,fchownat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+-a always,exit -F arch=b64 -S lchown,fchown,chown,fchownat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that unsuccessful attempts to change an ownership of files or directories are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_owner_change_failed|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-6-owner-change-failed.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-6-owner-change-failed.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+    
05062e
+
05062e
+rationale: |-
05062e
+    Unsuccessful attempts to change an ownership of files or directories might be signs of a malicious activity. Having such events audited helps in monitoring and investigation of such activities.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82384-9
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000462-GPOS-00206,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000466-GPOS-00210,SRG-OS-000064-GPOS-00033
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-6-owner-change-failed.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_owner_change_failed|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-6-owner-change-failed.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_owner_change_failed|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..b5227b4c5
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_failed/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-6-owner-change-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/rule.yml
05062e
new file mode 100644
05062e
index 000000000..6ffa0e4fc
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/rule.yml
05062e
@@ -0,0 +1,60 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of successful ownership changes'
05062e
+
05062e
+{{% set file_contents_audit_owner_change_success =
05062e
+"## Successful ownership change
05062e
+-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-owner-change
05062e
+-a always,exit -F arch=b64 -S lchown,fchown,chown,fchownat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-owner-change
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that successful attempts to change an ownership of files or directories are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_owner_change_success|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-6-owner-change-success.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-6-owner-change-success.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    The file has the following SHA-256 checksum:
05062e
+    
7eb41a6aaf6737c2571b6424fae7fa53af4b41a9115b6c5732a5778ccd9900ad
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+
05062e
+rationale: |-
05062e
+    Auditing of successful ownership changes of files or directories helps in monitoring or investingating of activities performed on the system. 
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82385-6
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000462-GPOS-00206,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000466-GPOS-00210,SRG-OS-000064-GPOS-00033
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-6-owner-change-success.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_owner_change_success|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-6-owner-change-success.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_owner_change_success|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..27eaf4a1f
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_owner_change_success/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-6-owner-change-success.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/rule.yml
05062e
new file mode 100644
05062e
index 000000000..7be6299cb
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/rule.yml
05062e
@@ -0,0 +1,58 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of unsuccessful permission changes'
05062e
+
05062e
+{{% set file_contents_audit_perm_change_failed =
05062e
+"## Unsuccessful permission change
05062e
+-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that unsuccessful attempts to change file or directory permissions are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_perm_change_failed|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-5-perm-change-failed.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-5-perm-change-failed.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+rationale: |-
05062e
+    Unsuccessful attempts to change permissions of files or directories might be signs of malicious activity. Having such events audited helps in monitoring and investigation of such activities. 
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82837-6
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000462-GPOS-00206,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000466-GPOS-00210,SRG-OS-000064-GPOS-00033
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-5-perm-change-failed.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_perm_change_failed|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-5-perm-change-failed.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_perm_change_failed|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..149fda66d
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_failed/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-5-perm-change-failed.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/rule.yml b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/rule.yml
05062e
new file mode 100644
05062e
index 000000000..e2a247370
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/rule.yml
05062e
@@ -0,0 +1,57 @@
05062e
+documentation_complete: true
05062e
+
05062e
+prodtype: rhel8
05062e
+
05062e
+title: 'Configure auditing of successful permission changes'
05062e
+
05062e
+{{% set file_contents_audit_perm_change_success =
05062e
+"## Successful permission change
05062e
+-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-perm-change
05062e
+-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-perm-change
05062e
+" %}}
05062e
+
05062e
+description: |-
05062e
+    Ensure that successful attempts to modify permissions of iles or directories are audited.
05062e
+
05062e
+    The following rules configure audit as described above:
05062e
+    
{{{ file_contents_audit_perm_change_success|indent }}}    
05062e
+
05062e
+    The <tt>Audit</tt> package provides pre-configured  rules in <tt>/usr/share/audit/sample-rules</tt>. The above content can be found in <tt>/usr/share/audit/sample-rules/30-ospp-v42-5-perm-change-success.rules</tt>.
05062e
+    To deploy this configuration, it is recommended to copy it over to the <tt>/etc/audit/rules.d/</tt> directory:
05062e
+    
05062e
+    cp /usr/share/audit/sample-rules/30-ospp-v42-5-perm-change-success.rules /etc/audit/rules.d/
05062e
+    
05062e
+    
05062e
+    Load new Audit rules into kernel by running:
05062e
+    
augenrules --load
05062e
+    
05062e
+    Note: This rule utilizes a file provided by <tt>Audit</tt> package to comply with OSPP 4.2.1. You may reuse this rule in different profiles. If you decide to do so, it is recommended that you inspect contents of the file closely and make sure that they are alligned with your needs.
05062e
+
05062e
+
05062e
+rationale: |-
05062e
+    Auditing successful file or directory permission changes helps in monitoring and investigating of activities performed on the system.
05062e
+
05062e
+severity: medium
05062e
+
05062e
+identifiers:
05062e
+    cce@rhel8: 82383-1
05062e
+
05062e
+references:
05062e
+    ospp: FAU_GEN.1.1.c
05062e
+    nist: AU-2(a)
05062e
+    srg: SRG-OS-000462-GPOS-00206,SRG-OS-000463-GPOS-00207,SRG-OS-000465-GPOS-00209,SRG-OS-000474-GPOS-00219,SRG-OS-000475-GPOS-00220,SRG-OS-000466-GPOS-00210,SRG-OS-000064-GPOS-00033
05062e
+
05062e
+ocil_clause: 'the file does not exist or the content differs'
05062e
+
05062e
+ocil: |-
05062e
+    To verify that the <tt>Audit</tt> is correctly configured according to recommended rules, check the content of the file with the following command:
05062e
+    
cat /etc/audit/rules.d/30-ospp-v42-5-perm-change-success.rules
05062e
+    The output has to be exactly as follows:
05062e
+    
{{{ file_contents_audit_perm_change_success|indent }}}    
05062e
+
05062e
+template:
05062e
+    name: audit_file_contents
05062e
+    vars:
05062e
+        filepath: /etc/audit/rules.d/30-ospp-v42-5-perm-change-success.rules
05062e
+        contents: |+
05062e
+            {{{ file_contents_audit_perm_change_success|indent(12) }}}
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/tests/correct_rules.pass.sh b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/tests/correct_rules.pass.sh
05062e
new file mode 100644
05062e
index 000000000..cfa6c3f90
05062e
--- /dev/null
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_perm_change_success/tests/correct_rules.pass.sh
05062e
@@ -0,0 +1 @@
05062e
+cp $SHARED/audit/30-ospp-v42-5-perm-change-success.rules /etc/audit/rules.d/
05062e
diff --git a/linux_os/guide/system/auditing/policy_rules/audit_rules_for_ospp/oval/shared.xml b/linux_os/guide/system/auditing/policy_rules/audit_rules_for_ospp/oval/shared.xml
05062e
index 9e5b6032f..d25ea0840 100644
05062e
--- a/linux_os/guide/system/auditing/policy_rules/audit_rules_for_ospp/oval/shared.xml
05062e
+++ b/linux_os/guide/system/auditing/policy_rules/audit_rules_for_ospp/oval/shared.xml
05062e
@@ -1,15 +1,15 @@
05062e
 {{% macro audit_file_compare_criterion(file_id) %}}
05062e
-      <criterion comment="check {{{ file_id }}}.rules file" test_ref="test_compare_{{{ file_id }}}" />
05062e
+      <criterion comment="check {{{ file_id }}}.rules file" test_ref="test_compare_{{{ file_id }}}_old" />
05062e
 {{% endmacro %}}
05062e
 
05062e
 {{% macro audit_file_compare_test(file_id) %}}
05062e
   
05062e
   comment="Compare {{{ file_id }}}.rules file in /etc/audit/rules.d against file in /usr/share/doc/audit/"
05062e
-  id="test_compare_{{{ file_id }}}" version="1">
05062e
-    <ind:object object_ref="object_etc_{{{ file_id }}}" />
05062e
+  id="test_compare_{{{ file_id }}}_old" version="1">
05062e
+    <ind:object object_ref="object_etc_{{{ file_id }}}_old" />
05062e
     <ind:state state_ref="state_doc_{{{ file_id }}}" />
05062e
   </ind:textfilecontent54_test>
05062e
-  <ind:textfilecontent54_object id="object_etc_{{{ file_id }}}" version="1">
05062e
+  <ind:textfilecontent54_object id="object_etc_{{{ file_id }}}_old" version="1">
05062e
     <ind:filepath>/etc/audit/rules.d/{{{ file_id }}}.rules</ind:filepath>
05062e
     <ind:pattern operation="pattern match">(?:.*\n)*</ind:pattern>
05062e
     <ind:instance datatype="int">1</ind:instance>
05062e
diff --git a/rhel8/profiles/ospp.profile b/rhel8/profiles/ospp.profile
05062e
index ef3ced501..5d3713ec7 100644
05062e
--- a/rhel8/profiles/ospp.profile
05062e
+++ b/rhel8/profiles/ospp.profile
05062e
@@ -377,7 +377,22 @@ selections:
05062e
     ## AU-2(a) / FAU_GEN.1.1.c
05062e
     ## Audit Kernel Module Loading and Unloading Events (Success/Failure)
05062e
     ## AU-2(a) / FAU_GEN.1.1.c
05062e
-    - audit_rules_for_ospp
05062e
+    - audit_basic_configuration
05062e
+    - audit_immutable_login_uids
05062e
+    - audit_create_failed
05062e
+    - audit_create_success
05062e
+    - audit_modify_failed
05062e
+    - audit_modify_success
05062e
+    - audit_access_failed
05062e
+    - audit_access_success
05062e
+    - audit_delete_failed
05062e
+    - audit_delete_success
05062e
+    - audit_perm_change_failed
05062e
+    - audit_perm_change_success
05062e
+    - audit_owner_change_failed
05062e
+    - audit_owner_change_success
05062e
+    - audit_ospp_general
05062e
+    - audit_module_load
05062e
 
05062e
     ## Enable Automatic Software Updates
05062e
     ## SI-2 / FMT_MOF_EXT.1
05062e
diff --git a/shared/macros-ansible.jinja b/shared/macros-ansible.jinja
05062e
index f752e7a2b..c7fa22113 100644
05062e
--- a/shared/macros-ansible.jinja
05062e
+++ b/shared/macros-ansible.jinja
05062e
@@ -202,3 +202,18 @@
05062e
 {{%- macro ansible_coredump_config_set(msg='', parameter='', value='') %}}
05062e
 {{{ ansible_set_config_file(msg, "/etc/systemd/coredump.conf", parameter=parameter, value=value, create="no", separator="=", separator_regex="\s*=\s*") }}}
05062e
 {{%- endmacro %}}
05062e
+
05062e
+{{#
05062e
+  Generates an Ansible task that puts 'contents' into a file at 'filepath'
05062e
+  Parameters:
05062e
+    - filepath - filepath of the file to check
05062e
+    - contents - contents that should be in the file
05062e
+#}}
05062e
+{{%- macro ansible_file_contents(filepath='', contents='') %}}
05062e
+- name: "Put contents into {{{ filepath }}} according to policy"
05062e
+  copy:
05062e
+    dest: "{{{ filepath }}}"
05062e
+    content: |+
05062e
+        {{{ contents|indent(8) }}}
05062e
+    force: yes
05062e
+{{%- endmacro %}}
05062e
diff --git a/shared/macros-bash.jinja b/shared/macros-bash.jinja
05062e
index dc7fd2558..bc522fc1e 100644
05062e
--- a/shared/macros-bash.jinja
05062e
+++ b/shared/macros-bash.jinja
05062e
@@ -509,3 +509,14 @@ if ! grep -qE '^\s*account\s+required\s+pam_faillock\.so.*$' "{{{ pam_file }}}"
05062e
     sed -E -i --follow-symlinks '/^\s*account\s*required\s*pam_unix.so/i account     required      pam_faillock.so' "{{{ pam_file }}}"
05062e
 fi
05062e
 {{%- endmacro -%}}
05062e
+
05062e
+{{#
05062e
+  Generates bash script code that puts 'contents' into a file at 'filepath'
05062e
+  Parameters:
05062e
+    - filepath - filepath of the file to check
05062e
+    - contents - contents that should be in the file
05062e
+#}}
05062e
+{{%- macro bash_file_contents(filepath='', contents='') %}}
05062e
+cat << 'EOF' > {{{ filepath }}}
05062e
+{{{ contents }}}EOF
05062e
+{{%- endmacro %}}
05062e
diff --git a/shared/macros-oval.jinja b/shared/macros-oval.jinja
05062e
index 5f391efdc..11752785f 100644
05062e
--- a/shared/macros-oval.jinja
05062e
+++ b/shared/macros-oval.jinja
05062e
@@ -448,3 +448,44 @@
05062e
     <unix:command_line operation="pattern match">^.*[\s]+{{{ option }}}=.*({{{ value }}}).*([\s]+.*$|$)</unix:command_line>
05062e
   </unix:process58_state>
05062e
 {{%- endmacro -%}}
05062e
+
05062e
+{{#
05062e
+  Macro which generates OVAL definition, test and object that check for contents
05062e
+  of the file.
05062e
+  Parameters:
05062e
+    - filepath - filepath of the file to check
05062e
+    - contents - contents that should be in the file
05062e
+#}}
05062e
+{{%- macro oval_file_contents(filepath='', filepath_id='', contents='') -%}}
05062e
+  <def-group>
05062e
+    <definition class="compliance" id="{{{ rule_id }}}" version="1">
05062e
+      <metadata>
05062e
+        <title>Check that contents of {{{ filepath }}} are as expected</title>
05062e
+        {{{- oval_affected(products) }}}
05062e
+        <description>Inspects the contents of {{{ filepath }}}</description>
05062e
+      </metadata>
05062e
+      <criteria operator="AND">
05062e
+          <criterion comment="Check contents of file" test_ref="test_whole_file_contents_{{{ filepath_id }}}" />
05062e
+      </criteria>
05062e
+    </definition>
05062e
+
05062e
+    
05062e
+    comment="Tests if contents of {{{ filepath }}} is exactly what is defined in rule description"
05062e
+    id="test_whole_file_contents_{{{ filepath_id }}}" version="1">
05062e
+      <ind:object object_ref="object_whole_file_contents_{{{ filepath_id }}}" />
05062e
+      <ind:state state_ref="state_whole_file_contents_{{{ filepath_id }}}" />
05062e
+    </ind:textfilecontent54_test>
05062e
+
05062e
+    <ind:textfilecontent54_object id="object_whole_file_contents_{{{ filepath_id }}}" version="1">
05062e
+      <ind:behaviors singleline="true" multiline="false" />
05062e
+      <ind:filepath>{{{ filepath }}}</ind:filepath>
05062e
+      <ind:pattern operation="pattern match">^.*$</ind:pattern>
05062e
+      <ind:instance datatype="int">1</ind:instance>
05062e
+    </ind:textfilecontent54_object>
05062e
+
05062e
+    <ind:textfilecontent54_state id="state_whole_file_contents_{{{ filepath_id }}}" version="1">
05062e
+      <ind:text operation="equals">{{{ contents }}}</ind:text>
05062e
+    </ind:textfilecontent54_state>
05062e
+
05062e
+  </def-group>
05062e
+{{%- endmacro %}}
05062e
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
05062e
index 1733872df..a961f0ec0 100644
05062e
--- a/shared/references/cce-redhat-avail.txt
05062e
+++ b/shared/references/cce-redhat-avail.txt
05062e
@@ -103,17 +103,6 @@ CCE-82823-6
05062e
 CCE-82824-4
05062e
 CCE-82825-1
05062e
 CCE-82826-9
05062e
-CCE-82827-7
05062e
-CCE-82828-5
05062e
-CCE-82829-3
05062e
-CCE-82830-1
05062e
-CCE-82832-7
05062e
-CCE-82833-5
05062e
-CCE-82834-3
05062e
-CCE-82835-0
05062e
-CCE-82836-8
05062e
-CCE-82837-6
05062e
-CCE-82838-4
05062e
 CCE-82839-2
05062e
 CCE-82841-8
05062e
 CCE-82842-6
05062e
diff --git a/shared/templates/template_ANSIBLE_audit_file_contents b/shared/templates/template_ANSIBLE_audit_file_contents
05062e
new file mode 100644
05062e
index 000000000..c28527454
05062e
--- /dev/null
05062e
+++ b/shared/templates/template_ANSIBLE_audit_file_contents
05062e
@@ -0,0 +1,11 @@
05062e
+# platform = multi_platform_all
05062e
+# reboot = false
05062e
+# strategy = restrict
05062e
+# complexity = low
05062e
+# disruption = low
05062e
+{{{
05062e
+    ansible_file_contents(
05062e
+        filepath=FILEPATH,
05062e
+        contents=CONTENTS,
05062e
+    )
05062e
+}}}
05062e
diff --git a/shared/templates/template_BASH_audit_file_contents b/shared/templates/template_BASH_audit_file_contents
05062e
new file mode 100644
05062e
index 000000000..f264be6f1
05062e
--- /dev/null
05062e
+++ b/shared/templates/template_BASH_audit_file_contents
05062e
@@ -0,0 +1,14 @@
05062e
+# platform = multi_platform_all
05062e
+# reboot = false
05062e
+# strategy = restrict
05062e
+# complexity = low
05062e
+# disruption = low
05062e
+
05062e
+{{{
05062e
+    bash_file_contents(
05062e
+        filepath=FILEPATH,
05062e
+        contents=CONTENTS,
05062e
+    )
05062e
+}}}
05062e
+
05062e
+augenrules --load
05062e
diff --git a/shared/templates/template_OVAL_audit_file_contents b/shared/templates/template_OVAL_audit_file_contents
05062e
new file mode 100644
05062e
index 000000000..02e1b661d
05062e
--- /dev/null
05062e
+++ b/shared/templates/template_OVAL_audit_file_contents
05062e
@@ -0,0 +1,7 @@
05062e
+{{{
05062e
+    oval_file_contents(
05062e
+        filepath=FILEPATH,
05062e
+        filepath_id=FILEPATH_ID,
05062e
+        contents=CONTENTS
05062e
+    )
05062e
+}}}
05062e
diff --git a/ssg/templates.py b/ssg/templates.py
05062e
index 8a96c8ed4..e5ed4890b 100644
05062e
--- a/ssg/templates.py
05062e
+++ b/ssg/templates.py
05062e
@@ -1,8 +1,10 @@
05062e
+from __future__ import absolute_import
05062e
 from __future__ import print_function
05062e
 
05062e
 import os
05062e
 import sys
05062e
 import re
05062e
+from xml.sax.saxutils import unescape
05062e
 
05062e
 import ssg.build_yaml
05062e
 
05062e
@@ -93,6 +95,10 @@ def audit_rules_privileged_commands(data, lang):
05062e
         data["path"] = path.replace("/", "\\/")
05062e
     return data
05062e
 
05062e
+@template(["ansible", "bash", "oval"])
05062e
+def audit_rules_rule_file(data, lang):
05062e
+    return data
05062e
+
05062e
 
05062e
 @template(["ansible", "bash", "oval"])
05062e
 def audit_rules_unsuccessful_file_modification(data, lang):
05062e
@@ -124,6 +130,20 @@ def audit_rules_usergroup_modification(data, lang):
05062e
     return data
05062e
 
05062e
 
05062e
+@template(["ansible", "bash", "oval"])
05062e
+def audit_file_contents(data, lang):
05062e
+    if lang == "oval":
05062e
+        pathid = re.sub(r'[-\./]', '_', data["filepath"])
05062e
+        # remove root slash made into '_'
05062e
+        pathid = pathid[1:]
05062e
+        data["filepath_id"] = pathid
05062e
+
05062e
+    # The build system converts "<",">" and "&" for us
05062e
+    if lang == "bash" or lang == "ansible":
05062e
+        data["contents"] = unescape(data["contents"])
05062e
+    return data
05062e
+
05062e
+
05062e
 def _file_owner_groupowner_permissions_regex(data):
05062e
     data["is_directory"] = data["filepath"].endswith("/")
05062e
     if "missing_file_pass" not in data:
05062e
diff --git a/tests/shared/audit/10-base-config.rules b/tests/shared/audit/10-base-config.rules
05062e
new file mode 100644
05062e
index 000000000..b86d66f9d
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/10-base-config.rules
05062e
@@ -0,0 +1,13 @@
05062e
+## First rule - delete all
05062e
+-D
05062e
+
05062e
+## Increase the buffers to survive stress events.
05062e
+## Make this bigger for busy systems
05062e
+-b 8192
05062e
+
05062e
+## This determine how long to wait in burst of events
05062e
+--backlog_wait_time 60000
05062e
+
05062e
+## Set failure mode to syslog
05062e
+-f 1
05062e
+
05062e
diff --git a/tests/shared/audit/11-loginuid.rules b/tests/shared/audit/11-loginuid.rules
05062e
new file mode 100644
05062e
index 000000000..9b0a3e98a
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/11-loginuid.rules
05062e
@@ -0,0 +1,3 @@
05062e
+## Make the loginuid immutable. This prevents tampering with the auid.
05062e
+--loginuid-immutable
05062e
+
05062e
diff --git a/tests/shared/audit/30-ospp-v42-1-create-failed.rules b/tests/shared/audit/30-ospp-v42-1-create-failed.rules
05062e
new file mode 100644
05062e
index 000000000..6aca1b943
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-1-create-failed.rules
05062e
@@ -0,0 +1,13 @@
05062e
+## Unsuccessful file creation (open with O_CREAT)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S open -F a1&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S open -F a1&0100 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S creat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S creat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S open -F a1&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S open -F a1&0100 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b32 -S creat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
+-a always,exit -F arch=b64 -S creat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-create
05062e
diff --git a/tests/shared/audit/30-ospp-v42-1-create-success.rules b/tests/shared/audit/30-ospp-v42-1-create-success.rules
05062e
new file mode 100644
05062e
index 000000000..4141e3c60
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-1-create-success.rules
05062e
@@ -0,0 +1,7 @@
05062e
+## Successful file creation (open with O_CREAT)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b32 -S open -F a1&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b64 -S open -F a1&0100 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b32 -S creat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
+-a always,exit -F arch=b64 -S creat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-create
05062e
diff --git a/tests/shared/audit/30-ospp-v42-2-modify-failed.rules b/tests/shared/audit/30-ospp-v42-2-modify-failed.rules
05062e
new file mode 100644
05062e
index 000000000..ffe5bfd61
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-2-modify-failed.rules
05062e
@@ -0,0 +1,13 @@
05062e
+## Unsuccessful file modifications (open for write or truncate)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S open -F a1&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S open -F a1&01003 -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S truncate,ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S truncate,ftruncate -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S open -F a1&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S open -F a1&01003 -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b32 -S truncate,ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
+-a always,exit -F arch=b64 -S truncate,ftruncate -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-modification
05062e
diff --git a/tests/shared/audit/30-ospp-v42-2-modify-success.rules b/tests/shared/audit/30-ospp-v42-2-modify-success.rules
05062e
new file mode 100644
05062e
index 000000000..5617e018a
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-2-modify-success.rules
05062e
@@ -0,0 +1,7 @@
05062e
+## Successful file modifications (open for write or truncate)
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b32 -S open -F a1&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b64 -S open -F a1&01003 -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b32 -S truncate,ftruncate -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
+-a always,exit -F arch=b64 -S truncate,ftruncate -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-modification
05062e
diff --git a/tests/shared/audit/30-ospp-v42-3-access-failed.rules b/tests/shared/audit/30-ospp-v42-3-access-failed.rules
05062e
new file mode 100644
05062e
index 000000000..a5aad3a95
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-3-access-failed.rules
05062e
@@ -0,0 +1,5 @@
05062e
+## Unsuccessful file access (any other opens) This has to go last.
05062e
+-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
+-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-access
05062e
diff --git a/tests/shared/audit/30-ospp-v42-3-access-success.rules b/tests/shared/audit/30-ospp-v42-3-access-success.rules
05062e
new file mode 100644
05062e
index 000000000..0c8a6b657
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-3-access-success.rules
05062e
@@ -0,0 +1,4 @@
05062e
+## Successful file access (any other opens) This has to go last.
05062e
+## These next two are likely to result in a whole lot of events
05062e
+-a always,exit -F arch=b32 -S open,openat,open_by_handle_at -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-access
05062e
+-a always,exit -F arch=b64 -S open,openat,open_by_handle_at -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-access
05062e
diff --git a/tests/shared/audit/30-ospp-v42-4-delete-failed.rules b/tests/shared/audit/30-ospp-v42-4-delete-failed.rules
05062e
new file mode 100644
05062e
index 000000000..946c9cc17
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-4-delete-failed.rules
05062e
@@ -0,0 +1,5 @@
05062e
+## Unsuccessful file delete
05062e
+-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
+-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-delete
05062e
diff --git a/tests/shared/audit/30-ospp-v42-4-delete-success.rules b/tests/shared/audit/30-ospp-v42-4-delete-success.rules
05062e
new file mode 100644
05062e
index 000000000..7955cdf85
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-4-delete-success.rules
05062e
@@ -0,0 +1,3 @@
05062e
+## Successful file delete
05062e
+-a always,exit -F arch=b32 -S unlink,unlinkat,rename,renameat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-delete
05062e
+-a always,exit -F arch=b64 -S unlink,unlinkat,rename,renameat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-delete
05062e
diff --git a/tests/shared/audit/30-ospp-v42-5-perm-change-failed.rules b/tests/shared/audit/30-ospp-v42-5-perm-change-failed.rules
05062e
new file mode 100644
05062e
index 000000000..49b9299d5
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-5-perm-change-failed.rules
05062e
@@ -0,0 +1,5 @@
05062e
+## Unsuccessful permission change
05062e
+-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
+-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-perm-change
05062e
diff --git a/tests/shared/audit/30-ospp-v42-5-perm-change-success.rules b/tests/shared/audit/30-ospp-v42-5-perm-change-success.rules
05062e
new file mode 100644
05062e
index 000000000..52cbac873
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-5-perm-change-success.rules
05062e
@@ -0,0 +1,3 @@
05062e
+## Successful permission change
05062e
+-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-perm-change
05062e
+-a always,exit -F arch=b64 -S chmod,fchmod,fchmodat,setxattr,lsetxattr,fsetxattr,removexattr,lremovexattr,fremovexattr -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-perm-change
05062e
diff --git a/tests/shared/audit/30-ospp-v42-6-owner-change-failed.rules b/tests/shared/audit/30-ospp-v42-6-owner-change-failed.rules
05062e
new file mode 100644
05062e
index 000000000..44e7148c2
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-6-owner-change-failed.rules
05062e
@@ -0,0 +1,5 @@
05062e
+## Unsuccessful ownership change
05062e
+-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+-a always,exit -F arch=b64 -S lchown,fchown,chown,fchownat -F exit=-EACCES -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
+-a always,exit -F arch=b64 -S lchown,fchown,chown,fchownat -F exit=-EPERM -F auid>=1000 -F auid!=unset -F key=unsuccessful-owner-change
05062e
diff --git a/tests/shared/audit/30-ospp-v42-6-owner-change-success.rules b/tests/shared/audit/30-ospp-v42-6-owner-change-success.rules
05062e
new file mode 100644
05062e
index 000000000..056b706fc
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42-6-owner-change-success.rules
05062e
@@ -0,0 +1,3 @@
05062e
+## Successful ownership change
05062e
+-a always,exit -F arch=b32 -S lchown,fchown,chown,fchownat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-owner-change
05062e
+-a always,exit -F arch=b64 -S lchown,fchown,chown,fchownat -F success=1 -F auid>=1000 -F auid!=unset -F key=successful-owner-change
05062e
diff --git a/tests/shared/audit/30-ospp-v42.rules b/tests/shared/audit/30-ospp-v42.rules
05062e
new file mode 100644
05062e
index 000000000..3dced1725
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/30-ospp-v42.rules
05062e
@@ -0,0 +1,80 @@
05062e
+## The purpose of these rules is to meet the requirements for Operating
05062e
+## System Protection Profile (OSPP)v4.2. These rules depends on having
05062e
+## the following rule files copied to /etc/audit/rules.d:
05062e
+##
05062e
+## 10-base-config.rules, 11-loginuid.rules,
05062e
+## 30-ospp-v42-1-create-failed.rules, 30-ospp-v42-1-create-success.rules,
05062e
+## 30-ospp-v42-2-modify-failed.rules, 30-ospp-v42-2-modify-success.rules,
05062e
+## 30-ospp-v42-3-access-failed.rules, 30-ospp-v42-3-access-success.rules,
05062e
+## 30-ospp-v42-4-delete-failed.rules, 30-ospp-v42-4-delete-success.rules,
05062e
+## 30-ospp-v42-5-perm-change-failed.rules,
05062e
+## 30-ospp-v42-5-perm-change-success.rules,
05062e
+## 30-ospp-v42-6-owner-change-failed.rules,
05062e
+## 30-ospp-v42-6-owner-change-success.rules
05062e
+##
05062e
+## original copies may be found in /usr/share/audit/sample-rules/
05062e
+
05062e
+
05062e
+## User add delete modify. This is covered by pam. However, someone could
05062e
+## open a file and directly create or modify a user, so we'll watch passwd and
05062e
+## shadow for writes
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b32 -S open -F a1&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S open -F a1&03 -F path=/etc/passwd -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b32 -S openat,open_by_handle_at -F a2&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S openat,open_by_handle_at -F a2&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b32 -S open -F a1&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F arch=b64 -S open -F a1&03 -F path=/etc/shadow -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+
05062e
+## User enable and disable. This is entirely handled by pam.
05062e
+
05062e
+## Group add delete modify. This is covered by pam. However, someone could
05062e
+## open a file and directly create or modify a user, so we'll watch group and
05062e
+## gshadow for writes
05062e
+-a always,exit -F path=/etc/passwd -F perm=wa -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F path=/etc/shadow -F perm=wa -F auid>=1000 -F auid!=unset -F key=user-modify
05062e
+-a always,exit -F path=/etc/group -F perm=wa -F auid>=1000 -F auid!=unset -F key=group-modify
05062e
+-a always,exit -F path=/etc/gshadow -F perm=wa -F auid>=1000 -F auid!=unset -F key=group-modify
05062e
+
05062e
+
05062e
+## Use of special rights for config changes. This would be use of setuid
05062e
+## programs that relate to user accts. This is not all setuid apps because
05062e
+## requirements are only for ones that affect system configuration.
05062e
+-a always,exit -F path=/usr/sbin/unix_chkpwd -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/sbin/usernetctl -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/sbin/userhelper -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/sbin/seunshare -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/mount -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/newgrp -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/newuidmap -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/gpasswd -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/newgidmap -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/umount -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/passwd -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/crontab -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+-a always,exit -F path=/usr/bin/at -F perm=x -F auid>=1000 -F auid!=unset -F key=special-config-changes
05062e
+
05062e
+## Privilege escalation via su or sudo. This is entirely handled by pam.
05062e
+
05062e
+## Audit log access
05062e
+-a always,exit -F dir=/var/log/audit/ -F perm=r -F auid>=1000 -F auid!=unset -F key=access-audit-trail
05062e
+## Attempts to Alter Process and Session Initiation Information
05062e
+-a always,exit -F path=/var/run/utmp -F perm=wa -F auid>=1000 -F auid!=unset -F key=session
05062e
+-a always,exit -F path=/var/log/btmp -F perm=wa -F auid>=1000 -F auid!=unset -F key=session
05062e
+-a always,exit -F path=/var/log/wtmp -F perm=wa -F auid>=1000 -F auid!=unset -F key=session
05062e
+
05062e
+## Attempts to modify MAC controls
05062e
+-a always,exit -F dir=/etc/selinux/ -F perm=wa -F auid>=1000 -F auid!=unset -F key=MAC-policy
05062e
+
05062e
+## Software updates. This is entirely handled by rpm.
05062e
+
05062e
+## System start and shutdown. This is entirely handled by systemd
05062e
+
05062e
+## Kernel Module loading. This is handled in 43-module-load.rules
05062e
+
05062e
+## Application invocation. The requirements list an optional requirement
05062e
+## FPT_SRP_EXT.1 Software Restriction Policies. This event is intended to
05062e
+## state results from that policy. This would be handled entirely by
05062e
+## that daemon.
05062e
+
05062e
diff --git a/tests/shared/audit/43-module-load.rules b/tests/shared/audit/43-module-load.rules
05062e
new file mode 100644
05062e
index 000000000..890750744
05062e
--- /dev/null
05062e
+++ b/tests/shared/audit/43-module-load.rules
05062e
@@ -0,0 +1,6 @@
05062e
+## These rules watch for kernel module insertion. By monitoring
05062e
+## the syscall, we do not need any watches on programs.
05062e
+-a always,exit -F arch=b32 -S init_module,finit_module -F key=module-load
05062e
+-a always,exit -F arch=b64 -S init_module,finit_module -F key=module-load
05062e
+-a always,exit -F arch=b32 -S delete_module -F key=module-unload
05062e
+-a always,exit -F arch=b64 -S delete_module -F key=module-unload
05062e
-- 
05062e
2.21.1
05062e