Blame SOURCES/scap-security-guide-0.1.58-RHEL_08_020320-PR_7303.patch

9be3b2
From d6f7334d642fb311d32d7a171c460cd05e6625b8 Mon Sep 17 00:00:00 2001
9be3b2
From: Matthew Burket <mburket@redhat.com>
9be3b2
Date: Fri, 6 Aug 2021 10:48:46 -0500
9be3b2
Subject: [PATCH] Add rule for RHEL-08-020320
9be3b2
9be3b2
---
9be3b2
 .../ansible/shared.yml                           |  0
9be3b2
 .../bash/shared.sh                               |  2 +-
9be3b2
 .../oval/shared.xml                              |  2 +-
9be3b2
 .../accounts_authorized_local_users/rule.yml     | 12 +++++++++---
9be3b2
 .../tests/bad_user.fail.sh                       |  2 ++
9be3b2
 .../tests/default.pass.sh                        | 16 ++++++++++++++++
9be3b2
 ...var_accounts_authorized_local_users_regex.var |  1 +
9be3b2
 products/rhel8/profiles/stig.profile             |  3 ++-
9be3b2
 shared/references/cce-redhat-avail.txt           |  1 -
9be3b2
 tests/data/profile_stability/rhel8/stig.profile  |  2 ++
9be3b2
 .../profile_stability/rhel8/stig_gui.profile     |  2 ++
9be3b2
 11 files changed, 36 insertions(+), 7 deletions(-)
9be3b2
 rename linux_os/guide/system/{software/sap_host => accounts/accounts-restrictions}/accounts_authorized_local_users/ansible/shared.yml (100%)
9be3b2
 rename linux_os/guide/system/{software/sap_host => accounts/accounts-restrictions}/accounts_authorized_local_users/bash/shared.sh (95%)
9be3b2
 rename linux_os/guide/system/{software/sap_host => accounts/accounts-restrictions}/accounts_authorized_local_users/oval/shared.xml (98%)
9be3b2
 rename linux_os/guide/system/{software/sap_host => accounts/accounts-restrictions}/accounts_authorized_local_users/rule.yml (88%)
9be3b2
 create mode 100644 linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/bad_user.fail.sh
9be3b2
 create mode 100644 linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/default.pass.sh
9be3b2
 rename linux_os/guide/system/{software/sap_host => accounts/accounts-restrictions}/var_accounts_authorized_local_users_regex.var (81%)
9be3b2
9be3b2
diff --git a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/ansible/shared.yml
9be3b2
similarity index 100%
9be3b2
rename from linux_os/guide/system/software/sap_host/accounts_authorized_local_users/ansible/shared.yml
9be3b2
rename to linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/ansible/shared.yml
9be3b2
diff --git a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/bash/shared.sh b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/bash/shared.sh
9be3b2
similarity index 95%
9be3b2
rename from linux_os/guide/system/software/sap_host/accounts_authorized_local_users/bash/shared.sh
9be3b2
rename to linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/bash/shared.sh
9be3b2
index c342acf36d1..fedb02d84ce 100644
9be3b2
--- a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/bash/shared.sh
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/bash/shared.sh
9be3b2
@@ -10,7 +10,7 @@ default_os_user="root"
9be3b2
 for username in $( sed 's/:.*//' /etc/passwd ) ; do
9be3b2
 	if [[ ! "$username" =~ ($default_os_user|$var_accounts_authorized_local_users_regex) ]];
9be3b2
         then
9be3b2
-		userdel $username ; 
9be3b2
+		userdel $username ;
9be3b2
 	fi
9be3b2
 done
9be3b2
 
9be3b2
diff --git a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/oval/shared.xml b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/oval/shared.xml
9be3b2
similarity index 98%
9be3b2
rename from linux_os/guide/system/software/sap_host/accounts_authorized_local_users/oval/shared.xml
9be3b2
rename to linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/oval/shared.xml
9be3b2
index 4e42081d0dc..c56799ded20 100644
9be3b2
--- a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/oval/shared.xml
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/oval/shared.xml
9be3b2
@@ -32,6 +32,6 @@
9be3b2
     var_ref="var_accounts_authorized_local_users_regex"></ind:subexpression>
9be3b2
   </ind:textfilecontent54_state>
9be3b2
 
9be3b2
-  
9be3b2
+  
9be3b2
   comment="accounts authorized local users on operating system"/>
9be3b2
 </def-group>
9be3b2
diff --git a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/rule.yml b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/rule.yml
9be3b2
similarity index 88%
9be3b2
rename from linux_os/guide/system/software/sap_host/accounts_authorized_local_users/rule.yml
9be3b2
rename to linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/rule.yml
9be3b2
index ddbda30afe6..e2311f6a5c3 100644
9be3b2
--- a/linux_os/guide/system/software/sap_host/accounts_authorized_local_users/rule.yml
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/rule.yml
9be3b2
@@ -1,6 +1,6 @@
9be3b2
 documentation_complete: true
9be3b2
 
9be3b2
-prodtype: ol7,sle12,sle15
9be3b2
+prodtype: ol7,sle12,sle15,fedora,rhel8
9be3b2
 
9be3b2
 title: 'Only Authorized Local User Accounts Exist on Operating System'
9be3b2
 
9be3b2
@@ -26,11 +26,10 @@ rationale: |-
9be3b2
 severity: medium
9be3b2
 
9be3b2
 identifiers:
9be3b2
+    cce@rhel8: CCE-85987-6
9be3b2
     cce@sle12: CCE-83195-8
9be3b2
     cce@sle15: CCE-85561-9
9be3b2
 
9be3b2
-severity: medium
9be3b2
-
9be3b2
 references:
9be3b2
     disa: CCI-000366
9be3b2
     nist@sle12: CM-6(b),CM-6.1(iv)
9be3b2
@@ -41,6 +40,13 @@ references:
9be3b2
 
9be3b2
 ocil_clause: 'there are unauthorized local user accounts on the system'
9be3b2
 
9be3b2
+{{% if 'rhel' in product %}}
9be3b2
+warnings:
9be3b2
+    - general: |-
9be3b2
+        Automatic remediation of this control is not available. Due the unique
9be3b2
+        requirements of each system.
9be3b2
+{{% endif %}}
9be3b2
+
9be3b2
 ocil: |-
9be3b2
     To verify that there are no unauthorized local user accounts, run the following command:
9be3b2
     
$ less /etc/passwd 
9be3b2
diff --git a/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/bad_user.fail.sh b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/bad_user.fail.sh
9be3b2
new file mode 100644
9be3b2
index 00000000000..6dabaff6bc6
9be3b2
--- /dev/null
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/bad_user.fail.sh
9be3b2
@@ -0,0 +1,2 @@
9be3b2
+#! /bin/bash
9be3b2
+adduser testuser
9be3b2
diff --git a/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/default.pass.sh b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/default.pass.sh
9be3b2
new file mode 100644
9be3b2
index 00000000000..d942f81d04f
9be3b2
--- /dev/null
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-restrictions/accounts_authorized_local_users/tests/default.pass.sh
9be3b2
@@ -0,0 +1,16 @@
9be3b2
+#! /bin/bash
9be3b2
+# platform = multi_platform_rhel
9be3b2
+
9be3b2
+var_accounts_authorized_local_users_regex="^(root|bin|daemon|adm|lp|sync|shutdown|halt|mail|operator|games|ftp|nobody|pegasus|systemd-bus-proxy|systemd-network|dbus|polkitd|abrt|unbound|tss|libstoragemgmt|rpc|colord|usbmuxd$|pcp|saslauth|geoclue|setroubleshoot|rtkit|chrony|qemu|radvd|rpcuser|nfsnobody|pulse|gdm|gnome-initial-setup|postfix|avahi|ntp|sshd|tcpdump|oprofile|uuidd)$"
9be3b2
+
9be3b2
+# never delete the root user
9be3b2
+default_os_user="root"
9be3b2
+
9be3b2
+# delete users that is in /etc/passwd but neither in default_os_user
9be3b2
+# nor in var_accounts_authorized_local_users_regex
9be3b2
+for username in $( sed 's/:.*//' /etc/passwd ) ; do
9be3b2
+	if [[ ! "$username" =~ ($default_os_user|$var_accounts_authorized_local_users_regex) ]];
9be3b2
+        then
9be3b2
+		echo $username ;
9be3b2
+	fi
9be3b2
+done
9be3b2
diff --git a/linux_os/guide/system/software/sap_host/var_accounts_authorized_local_users_regex.var b/linux_os/guide/system/accounts/accounts-restrictions/var_accounts_authorized_local_users_regex.var
9be3b2
similarity index 81%
9be3b2
rename from linux_os/guide/system/software/sap_host/var_accounts_authorized_local_users_regex.var
9be3b2
rename to linux_os/guide/system/accounts/accounts-restrictions/var_accounts_authorized_local_users_regex.var
9be3b2
index 81626307321..2f456764617 100644
9be3b2
--- a/linux_os/guide/system/software/sap_host/var_accounts_authorized_local_users_regex.var
9be3b2
+++ b/linux_os/guide/system/accounts/accounts-restrictions/var_accounts_authorized_local_users_regex.var
9be3b2
@@ -22,5 +22,6 @@ operator: pattern match
9be3b2
 interactive: true
9be3b2
 
9be3b2
 options:
9be3b2
+    rhel8: "^(root|bin|daemon|adm|lp|sync|shutdown|halt|mail|operator|games|ftp|nobody|pegasus|systemd-bus-proxy|systemd-network|dbus|polkitd|abrt|unbound|tss|libstoragemgmt|rpc|colord|usbmuxd$|pcp|saslauth|geoclue|setroubleshoot|rtkit|chrony|qemu|radvd|rpcuser|nfsnobody|pulse|gdm|gnome-initial-setup|postfix|avahi|ntp|sshd|tcpdump|oprofile|uuidd|systemd-resolve|systemd-coredump|sssd|rngd)$"
9be3b2
     ol7forsap: "^(root|bin|daemon|adm|lp|sync|shutdown|halt|mail|operator|games|ftp|nobody|pegasus|systemd-bus-proxy|systemd-network|dbus|polkitd|abrt|unbound|tss|libstoragemgmt|rpc|colord|usbmuxd$|pcp|saslauth|geoclue|setroubleshoot|rtkit|chrony|qemu|radvd|rpcuser|nfsnobody|pulse|gdm|gnome-initial-setup|postfix|avahi|ntp|sshd|tcpdump|oprofile|uuidd)$"
9be3b2
     saponol7 : "^(root|bin|daemon|adm|lp|sync|shutdown|halt|mail|operator|games|ftp|nobody|pegasus|systemd-bus-proxy|systemd-network|dbus|polkitd|abrt|unbound|tss|libstoragemgmt|rpc|colord|usbmuxd$|pcp|saslauth|geoclue|setroubleshoot|rtkit|chrony|qemu|radvd|rpcuser|nfsnobody|pulse|gdm|gnome-initial-setup|postfix|avahi|ntp|sshd|tcpdump|oprofile|uuidd|[a-z][a-z0-9][a-z0-9]adm|ora[a-z][a-z0-9][a-z0-9]|sapadm|oracle)$"
9be3b2
diff --git a/products/rhel8/profiles/stig.profile b/products/rhel8/profiles/stig.profile
9be3b2
index f66b2a24a75..ec2929e8dc4 100644
9be3b2
--- a/products/rhel8/profiles/stig.profile
9be3b2
+++ b/products/rhel8/profiles/stig.profile
9be3b2
@@ -54,6 +54,7 @@ selections:
9be3b2
     - sshd_approved_macs=stig
9be3b2
     - sshd_approved_ciphers=stig
9be3b2
     - sshd_idle_timeout_value=10_minutes
9be3b2
+    - var_accounts_authorized_local_users_regex=rhel8
9be3b2
     - var_accounts_passwords_pam_faillock_deny=3
9be3b2
     - var_accounts_passwords_pam_faillock_fail_interval=900
9be3b2
     - var_accounts_passwords_pam_faillock_unlock_time=never
9be3b2
@@ -576,7 +577,7 @@ selections:
9be3b2
     - accounts_logon_fail_delay
9be3b2
 
9be3b2
     # RHEL-08-020320
9be3b2
-    # - accounts_authorized_local_users
9be3b2
+    - accounts_authorized_local_users
9be3b2
 
9be3b2
     # RHEL-08-020330
9be3b2
     - sshd_disable_empty_passwords
9be3b2
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
9be3b2
index 1d54e8ec15f..3047c2d9b92 100644
9be3b2
--- a/shared/references/cce-redhat-avail.txt
9be3b2
+++ b/shared/references/cce-redhat-avail.txt
9be3b2
@@ -115,7 +115,6 @@ CCE-85983-5
9be3b2
 CCE-85984-3
9be3b2
 CCE-85985-0
9be3b2
 CCE-85986-8
9be3b2
-CCE-85987-6
9be3b2
 CCE-85988-4
9be3b2
 CCE-85989-2
9be3b2
 CCE-85990-0
9be3b2
diff --git a/tests/data/profile_stability/rhel8/stig.profile b/tests/data/profile_stability/rhel8/stig.profile
9be3b2
index fcae79f6d88..9496f1e1d1d 100644
9be3b2
--- a/tests/data/profile_stability/rhel8/stig.profile
9be3b2
+++ b/tests/data/profile_stability/rhel8/stig.profile
9be3b2
@@ -27,6 +27,7 @@ selections:
9be3b2
 - account_emergency_expire_date
9be3b2
 - account_temp_expire_date
9be3b2
 - account_unique_id
9be3b2
+- accounts_authorized_local_users
9be3b2
 - accounts_have_homedir_login_defs
9be3b2
 - accounts_logon_fail_delay
9be3b2
 - accounts_max_concurrent_login_sessions
9be3b2
@@ -358,6 +359,7 @@ selections:
9be3b2
 - var_auditd_disk_error_action=halt
9be3b2
 - var_auditd_max_log_file_action=syslog
9be3b2
 - var_auditd_disk_full_action=halt
9be3b2
+- var_accounts_authorized_local_users_regex=rhel8
9be3b2
 - var_system_crypto_policy=fips
9be3b2
 - var_sudo_timestamp_timeout=always_prompt
9be3b2
 title: DISA STIG for Red Hat Enterprise Linux 8
9be3b2
diff --git a/tests/data/profile_stability/rhel8/stig_gui.profile b/tests/data/profile_stability/rhel8/stig_gui.profile
9be3b2
index 2bbd1881f51..9e0c648a5f8 100644
9be3b2
--- a/tests/data/profile_stability/rhel8/stig_gui.profile
9be3b2
+++ b/tests/data/profile_stability/rhel8/stig_gui.profile
9be3b2
@@ -38,6 +38,7 @@ selections:
9be3b2
 - account_emergency_expire_date
9be3b2
 - account_temp_expire_date
9be3b2
 - account_unique_id
9be3b2
+- accounts_authorized_local_users
9be3b2
 - accounts_have_homedir_login_defs
9be3b2
 - accounts_logon_fail_delay
9be3b2
 - accounts_max_concurrent_login_sessions
9be3b2
@@ -368,6 +369,7 @@ selections:
9be3b2
 - var_auditd_disk_error_action=halt
9be3b2
 - var_auditd_max_log_file_action=syslog
9be3b2
 - var_auditd_disk_full_action=halt
9be3b2
+- var_accounts_authorized_local_users_regex=rhel8
9be3b2
 - var_system_crypto_policy=fips
9be3b2
 - var_sudo_timestamp_timeout=always_prompt
9be3b2
 title: DISA STIG with GUI for Red Hat Enterprise Linux 8