Blame SOURCES/scap-security-guide-0.1.58-RHEL_08_030650-PR_7283.patch

9be3b2
From 065b6e540a2aa437ddf5239c97ed4e1fddf43b50 Mon Sep 17 00:00:00 2001
9be3b2
From: Matthew Burket <mburket@redhat.com>
9be3b2
Date: Mon, 26 Jul 2021 09:00:49 -0500
9be3b2
Subject: [PATCH] Update rule aide_check_audit_tools for RHEL-08-030650
9be3b2
9be3b2
---
9be3b2
 .../aide_check_audit_tools/ansible/shared.yml | 27 ++++++++++++------
9be3b2
 .../aide_check_audit_tools/bash/shared.sh     | 25 +++++++++++++++++
9be3b2
 .../aide_check_audit_tools/oval/shared.xml    | 20 +++++++++++++
9be3b2
 .../aide/aide_check_audit_tools/rule.yml      | 28 ++++++++++++-------
9be3b2
 .../tests/correct.pass.sh                     | 15 ++++++++++
9be3b2
 .../tests/correct_with_selinux.pass.sh        | 12 ++++++++
9be3b2
 .../tests/not_config.fail.sh                  | 14 ++++++++++
9be3b2
 products/rhel8/profiles/stig.profile          |  1 +
9be3b2
 shared/references/cce-redhat-avail.txt        |  1 -
9be3b2
 .../data/profile_stability/rhel8/stig.profile |  1 +
9be3b2
 .../profile_stability/rhel8/stig_gui.profile  |  1 +
9be3b2
 11 files changed, 126 insertions(+), 19 deletions(-)
9be3b2
 create mode 100644 linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/bash/shared.sh
9be3b2
 create mode 100644 linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct.pass.sh
9be3b2
 create mode 100644 linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct_with_selinux.pass.sh
9be3b2
 create mode 100644 linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/not_config.fail.sh
9be3b2
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/ansible/shared.yml
9be3b2
index 73afaeff869..edef272183d 100644
9be3b2
--- a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/ansible/shared.yml
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/ansible/shared.yml
9be3b2
@@ -1,18 +1,29 @@
9be3b2
-# platform = multi_platform_sle
9be3b2
+# platform = multi_platform_sle,multi_platform_rhel
9be3b2
 # reboot = false
9be3b2
 # strategy = restrict
9be3b2
 # complexity = low
9be3b2
 # disruption = low
9be3b2
 
9be3b2
-- name: Install aide package
9be3b2
-  zypper:
9be3b2
-    name: aide
9be3b2
-    state: latest
9be3b2
+{{% if 'rhel' not in product %}}
9be3b2
+{{% set aide_string = 'p+i+n+u+g+s+b+acl+selinux+xattrs+sha512' %}}
9be3b2
+{{% else %}}
9be3b2
+{{% set aide_string = 'p+i+n+u+g+s+b+acl+xattrs+sha512' %}}
9be3b2
+{{% endif %}}
9be3b2
+
9be3b2
+
9be3b2
+
9be3b2
+- name: Ensure aide is installed
9be3b2
+  package:
9be3b2
+    name: "{{ item }}"
9be3b2
+    state: present
9be3b2
+  with_items:
9be3b2
+    - aide
9be3b2
+
9be3b2
 
9be3b2
 - name: Set audit_tools fact
9be3b2
   set_fact:
9be3b2
     audit_tools:
9be3b2
-      - /usr/sbin/audispd
9be3b2
+      {{% if 'rhel' not in product %}}- /usr/sbin/audispd{{% endif %}}
9be3b2
       - /usr/sbin/auditctl
9be3b2
       - /usr/sbin/auditd
9be3b2
       - /usr/sbin/augenrules
9be3b2
@@ -24,11 +35,11 @@
9be3b2
   lineinfile:
9be3b2
     path: /etc/aide.conf
9be3b2
     regexp: ^{{ item }}\s
9be3b2
-    line: "{{ item }} p+i+n+u+g+s+b+acl+selinux+xattrs+sha512"
9be3b2
+    line: "{{ item }} {{{ aide_string }}}"
9be3b2
   with_items: "{{ audit_tools }}"
9be3b2
 
9be3b2
 - name: Configure AIDE to properly protect audit tools
9be3b2
   lineinfile:
9be3b2
     path: /etc/aide.conf
9be3b2
-    line: "{{ item }} p+i+n+u+g+s+b+acl+selinux+xattrs+sha512"
9be3b2
+    line: "{{ item }} {{{ aide_string }}}"
9be3b2
   with_items: "{{ audit_tools }}"
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/bash/shared.sh b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/bash/shared.sh
9be3b2
new file mode 100644
9be3b2
index 00000000000..0875eeec648
9be3b2
--- /dev/null
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/bash/shared.sh
9be3b2
@@ -0,0 +1,25 @@
9be3b2
+# platform = multi_platform_rhel
9be3b2
+# reboot = false
9be3b2
+# strategy = restrict
9be3b2
+# complexity = low
9be3b2
+# disruption = low
9be3b2
+. /usr/share/scap-security-guide/remediation_functions
9be3b2
+
9be3b2
+{{{ bash_package_install("aide") }}}
9be3b2
+
9be3b2
+{{% set configString = "p+i+n+u+g+s+b+acl+xattrs+sha512" %}}
9be3b2
+{{% set configFile = "/etc/aide.conf" %}}
9be3b2
+{{% for file in (
9be3b2
+      "/usr/sbin/auditctl",
9be3b2
+      "/usr/sbin/auditd",
9be3b2
+      "/usr/sbin/ausearch",
9be3b2
+      "/usr/sbin/aureport",
9be3b2
+      "/usr/sbin/autrace",
9be3b2
+      "/usr/sbin/augenrules" ) %}}
9be3b2
+
9be3b2
+if grep -i '^.*{{{file}}}.*$' {{{ configFile }}}; then
9be3b2
+sed -i "s#.*{{{file}}}.*#{{{file}}} {{{ configString }}}#" {{{ configFile }}}
9be3b2
+else
9be3b2
+echo "{{{ file }}} {{{ configString }}}" >> {{{ configFile }}}
9be3b2
+fi
9be3b2
+{{% endfor %}}
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/oval/shared.xml b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/oval/shared.xml
9be3b2
index 32e6325a3ab..22c6276a1f5 100644
9be3b2
--- a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/oval/shared.xml
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/oval/shared.xml
9be3b2
@@ -8,13 +8,19 @@
9be3b2
       <criterion comment="ausearch is checked in /etc/aide.conf" test_ref="test_aide_verify_ausearch" />
9be3b2
       <criterion comment="aureport is checked in /etc/aide.conf" test_ref="test_aide_verify_aureport" />
9be3b2
       <criterion comment="autrace is checked in /etc/aide.conf" test_ref="test_aide_verify_autrace" />
9be3b2
+      {{% if 'rhel' not in product %}}
9be3b2
       <criterion comment="audispd is checked in /etc/aide.conf" test_ref="test_aide_verify_audispd" />
9be3b2
+      {{% endif %}}
9be3b2
       <criterion comment="augenrules is checked in /etc/aide.conf" test_ref="test_aide_verify_augenrules" />
9be3b2
     </criteria>
9be3b2
   </definition>
9be3b2
 
9be3b2
   <ind:textfilecontent54_state id="state_aide_check_attributes" version="1">
9be3b2
+    {{% if 'rhel' not in product %}}
9be3b2
     <ind:subexpression operation="equals">p+i+n+u+g+s+b+acl+selinux+xattrs+sha512</ind:subexpression>
9be3b2
+    {{% else %}}
9be3b2
+    <ind:subexpression operation="pattern match">p\+i\+n\+u\+g\+s\+b\+acl(|\+selinux)\+xattrs\+sha512</ind:subexpression>
9be3b2
+    {{% endif %}}
9be3b2
   </ind:textfilecontent54_state>
9be3b2
 
9be3b2
   
9be3b2
@@ -95,6 +101,20 @@
9be3b2
     <ind:instance datatype="int" operation="equals">1</ind:instance>
9be3b2
   </ind:textfilecontent54_object>
9be3b2
 
9be3b2
+  
9be3b2
+  comment="rsyslogd is checked in /etc/aide.conf" check="all"
9be3b2
+  check_existence="all_exist" version="1">
9be3b2
+    <ind:object object_ref="object_aide_verify_rsyslogd" />
9be3b2
+    <ind:state state_ref="state_aide_check_attributes" />
9be3b2
+  </ind:textfilecontent54_test>
9be3b2
+  
9be3b2
+  version="1">
9be3b2
+    <ind:filepath>/etc/aide.conf</ind:filepath>
9be3b2
+    <ind:pattern operation="pattern match">^/usr/sbin/rsyslogd\s+([^\n]+)$</ind:pattern>
9be3b2
+    <ind:instance datatype="int" operation="equals">1</ind:instance>
9be3b2
+  </ind:textfilecontent54_object>
9be3b2
+
9be3b2
+
9be3b2
   
9be3b2
   comment="augenrules is checked in /etc/aide.conf" check="all"
9be3b2
   check_existence="all_exist" version="1">
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/rule.yml b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/rule.yml
9be3b2
index 126ee756cc0..17a95bf4b31 100644
9be3b2
--- a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/rule.yml
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/rule.yml
9be3b2
@@ -1,11 +1,11 @@
9be3b2
 documentation_complete: true
9be3b2
 
9be3b2
-prodtype: sle12,sle15,ubuntu2004
9be3b2
+prodtype: sle12,sle15,ubuntu2004,rhel8,fedora
9be3b2
 
9be3b2
 title: 'Configure AIDE to Verify the Audit Tools'
9be3b2
 
9be3b2
 description: |-
9be3b2
-    The SUSE operating system file integrity tool must be configured to protect the integrity of the audit tools.
9be3b2
+    The operating system file integrity tool must be configured to protect the integrity of the audit tools.
9be3b2
 
9be3b2
 rationale: |-
9be3b2
     Protecting the integrity of the tools used for auditing purposes is a
9be3b2
@@ -31,32 +31,40 @@ rationale: |-
9be3b2
 severity: medium
9be3b2
 
9be3b2
 identifiers:
9be3b2
+    cce@rhel8: CCE-85964-5
9be3b2
     cce@sle12: CCE-83204-8
9be3b2
     cce@sle15: CCE-85610-4
9be3b2
 
9be3b2
 references:
9be3b2
     disa: CCI-001496
9be3b2
-    nist@sle12: AU-9(3),AU-9(3).1
9be3b2
+    nist: AU-9(3),AU-9(3).1
9be3b2
     srg: SRG-OS-000278-GPOS-00108
9be3b2
+    stigid@rhel8: RHEL-08-030650
9be3b2
     stigid@sle12: SLES-12-010540
9be3b2
     stigid@sle15: SLES-15-030630
9be3b2
     stigid@ubuntu2004: UBTU-20-010205
9be3b2
 
9be3b2
 ocil_clause: 'integrity checks of the audit tools are missing or incomplete'
9be3b2
 
9be3b2
+{{% if 'rhel' not in product %}}
9be3b2
+{{% set aide_string = 'p+i+n+u+g+s+b+acl+selinux+xattrs+sha512' %}}
9be3b2
+{{% else %}}
9be3b2
+{{% set aide_string = 'p+i+n+u+g+s+b+acl+xattrs+sha512' %}}
9be3b2
+{{% endif %}}
9be3b2
+
9be3b2
 ocil: |-
9be3b2
     Check that AIDE is properly configured to protect the integrity of the
9be3b2
     audit tools by running the following command:
9be3b2
 
9be3b2
     
# sudo cat /etc/aide.conf | grep /usr/sbin/au
9be3b2
 
9be3b2
-    /usr/sbin/auditctl p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
-    /usr/sbin/auditd p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
-    /usr/sbin/ausearch p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
-    /usr/sbin/aureport p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
-    /usr/sbin/autrace p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
-    /usr/sbin/audispd p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
-    /usr/sbin/augenrules p+i+n+u+g+s+b+acl+selinux+xattrs+sha512
9be3b2
+    /usr/sbin/auditctl {{{ aide_string }}}
9be3b2
+    /usr/sbin/auditd {{{ aide_string }}}
9be3b2
+    /usr/sbin/ausearch {{{ aide_string }}}
9be3b2
+    /usr/sbin/aureport {{{ aide_string }}}
9be3b2
+    /usr/sbin/autrace {{{ aide_string }}}
9be3b2
+    {{% if 'rhel' not in product %}}/usr/sbin/audispd {{{ aide_string }}}{{% endif %}}
9be3b2
+    /usr/sbin/augenrules {{{ aide_string }}}
9be3b2
 
9be3b2
     If AIDE is configured properly to protect the integrity of the audit tools,
9be3b2
     all lines listed above will be returned from the command.
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct.pass.sh b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct.pass.sh
9be3b2
new file mode 100644
9be3b2
index 00000000000..756b88d8a23
9be3b2
--- /dev/null
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct.pass.sh
9be3b2
@@ -0,0 +1,15 @@
9be3b2
+#!/bin/bash
9be3b2
+# platform = multi_platform_rhel,multi_platform_fedora
9be3b2
+
9be3b2
+
9be3b2
+yum -y install aide
9be3b2
+aide --init
9be3b2
+
9be3b2
+
9be3b2
+declare -a bins
9be3b2
+bins=('/usr/sbin/auditctl' '/usr/sbin/auditd' '/usr/sbin/augenrules' '/usr/sbin/aureport' '/usr/sbin/ausearch' '/usr/sbin/autrace')
9be3b2
+
9be3b2
+for theFile in "${bins[@]}"
9be3b2
+do
9be3b2
+    echo "$theFile p+i+n+u+g+s+b+acl+xattrs+sha512"  >> /etc/aide.conf
9be3b2
+done
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct_with_selinux.pass.sh b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct_with_selinux.pass.sh
9be3b2
new file mode 100644
9be3b2
index 00000000000..f3a2a126d3d
9be3b2
--- /dev/null
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/correct_with_selinux.pass.sh
9be3b2
@@ -0,0 +1,12 @@
9be3b2
+#!/bin/bash
9be3b2
+# platform = multi_platform_rhel,multi_platform_fedora
9be3b2
+
9be3b2
+yum -y install aide
9be3b2
+
9be3b2
+declare -a bins
9be3b2
+bins=('/usr/sbin/auditctl' '/usr/sbin/auditd' '/usr/sbin/augenrules' '/usr/sbin/aureport' '/usr/sbin/ausearch' '/usr/sbin/autrace')
9be3b2
+
9be3b2
+for theFile in "${bins[@]}"
9be3b2
+do
9be3b2
+    echo "$theFile p+i+n+u+g+s+b+acl+selinux+xattrs+sha5122" >> /etc/aide.conf
9be3b2
+done
9be3b2
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/not_config.fail.sh b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/not_config.fail.sh
9be3b2
new file mode 100644
9be3b2
index 00000000000..4315cef2073
9be3b2
--- /dev/null
9be3b2
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_check_audit_tools/tests/not_config.fail.sh
9be3b2
@@ -0,0 +1,14 @@
9be3b2
+#!/bin/bash
9be3b2
+# platform = multi_platform_rhel,multi_platform_fedora
9be3b2
+
9be3b2
+
9be3b2
+yum -y install aide
9be3b2
+aide --init
9be3b2
+
9be3b2
+declare -a bins
9be3b2
+bins=('/usr/sbin/auditctl' '/usr/sbin/auditd' '/usr/sbin/augenrules' '/usr/sbin/aureport' '/usr/sbin/ausearch' '/usr/sbin/autrace')
9be3b2
+
9be3b2
+for theFile in "${bins[@]}"
9be3b2
+do
9be3b2
+    echo sed -i "s#^.*${theFile}.*##g" /etc/aide.conf
9be3b2
+done
9be3b2
diff --git a/products/rhel8/profiles/stig.profile b/products/rhel8/profiles/stig.profile
9be3b2
index 7270a8f91f2..6b3232a9e00 100644
9be3b2
--- a/products/rhel8/profiles/stig.profile
9be3b2
+++ b/products/rhel8/profiles/stig.profile
9be3b2
@@ -822,6 +822,7 @@ selections:
9be3b2
     # RHEL-08-030640
9be3b2
 
9be3b2
     # RHEL-08-030650
9be3b2
+    - aide_check_audit_tools
9be3b2
 
9be3b2
     # RHEL-08-030660
9be3b2
     - auditd_audispd_configure_sufficiently_large_partition
9be3b2
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
9be3b2
index 665f903ead4..ff557cc2323 100644
9be3b2
--- a/shared/references/cce-redhat-avail.txt
9be3b2
+++ b/shared/references/cce-redhat-avail.txt
9be3b2
@@ -97,7 +97,6 @@ CCE-85960-3
9be3b2
 CCE-85961-1
9be3b2
 CCE-85962-9
9be3b2
 CCE-85963-7
9be3b2
-CCE-85964-5
9be3b2
 CCE-85965-2
9be3b2
 CCE-85966-0
9be3b2
 CCE-85967-8
9be3b2
diff --git a/tests/data/profile_stability/rhel8/stig.profile b/tests/data/profile_stability/rhel8/stig.profile
9be3b2
index 7d59cfff625..692a1690b19 100644
9be3b2
--- a/tests/data/profile_stability/rhel8/stig.profile
9be3b2
+++ b/tests/data/profile_stability/rhel8/stig.profile
9be3b2
@@ -60,6 +60,7 @@ selections:
9be3b2
 - accounts_user_home_paths_only
9be3b2
 - accounts_user_interactive_home_directory_defined
9be3b2
 - accounts_user_interactive_home_directory_exists
9be3b2
+- aide_check_audit_tools
9be3b2
 - aide_scan_notification
9be3b2
 - aide_verify_acls
9be3b2
 - aide_verify_ext_attributes
9be3b2
diff --git a/tests/data/profile_stability/rhel8/stig_gui.profile b/tests/data/profile_stability/rhel8/stig_gui.profile
9be3b2
index 2c2daad6f6d..cf119c02a17 100644
9be3b2
--- a/tests/data/profile_stability/rhel8/stig_gui.profile
9be3b2
+++ b/tests/data/profile_stability/rhel8/stig_gui.profile
9be3b2
@@ -71,6 +71,7 @@ selections:
9be3b2
 - accounts_user_home_paths_only
9be3b2
 - accounts_user_interactive_home_directory_defined
9be3b2
 - accounts_user_interactive_home_directory_exists
9be3b2
+- aide_check_audit_tools
9be3b2
 - aide_scan_notification
9be3b2
 - aide_verify_acls
9be3b2
 - aide_verify_ext_attributes