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

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