Blame SOURCES/scap-security-guide-0.1.50-add_configure_etc_hosts_deny_PR_5332.patch

dac76a
From de575924082e17ff0e2fe537a3c72adf87942a55 Mon Sep 17 00:00:00 2001
dac76a
From: Vojtech Polasek <vpolasek@redhat.com>
dac76a
Date: Mon, 23 Mar 2020 16:02:21 +0100
dac76a
Subject: [PATCH 1/3] create rule
dac76a
dac76a
---
dac76a
 .../ansible/shared.yml                        |  7 +++++
dac76a
 .../configure_etc_hosts_deny/bash/shared.sh   |  3 ++
dac76a
 .../configure_etc_hosts_deny/oval/shared.xml  |  1 +
dac76a
 .../configure_etc_hosts_deny/rule.yml         | 31 +++++++++++++++++++
dac76a
 .../tests/correct.pass.sh                     |  6 ++++
dac76a
 .../tests/file_empty.fail.sh                  |  6 ++++
dac76a
 .../tests/file_missing.fail.sh                |  6 ++++
dac76a
 .../tests/wrong.fail.sh                       |  6 ++++
dac76a
 shared/references/cce-redhat-avail.txt        |  1 -
dac76a
 9 files changed, 66 insertions(+), 1 deletion(-)
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/ansible/shared.yml
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/bash/shared.sh
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/oval/shared.xml
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/correct.pass.sh
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_empty.fail.sh
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_missing.fail.sh
dac76a
 create mode 100644 linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/wrong.fail.sh
dac76a
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/ansible/shared.yml b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/ansible/shared.yml
dac76a
new file mode 100644
dac76a
index 0000000000..480bde9f80
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/ansible/shared.yml
dac76a
@@ -0,0 +1,7 @@
dac76a
+# platform = Red Hat Enterprise Linux 7,Oracle Linux 7
dac76a
+# reboot = false
dac76a
+# strategy = restrict
dac76a
+# complexity = low
dac76a
+# disruption = medium
dac76a
+
dac76a
+{{{ ansible_lineinfile(msg='', path='/etc/hosts.deny', regex='', new_line='ALL: ALL', create='true', state='present') }}}
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/bash/shared.sh b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/bash/shared.sh
dac76a
new file mode 100644
dac76a
index 0000000000..e1def7a9ab
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/bash/shared.sh
dac76a
@@ -0,0 +1,3 @@
dac76a
+# platform = Red Hat Enterprise Linux 7,Oracle Linux 7
dac76a
+
dac76a
+{{{ set_config_file(path="/etc/hosts.deny", parameter="ALL:", value="ALL", create=true, insert_after="EOF", insert_before="", insensitive=true, separator=" ", separator_regex="\s\+", prefix_regex="^\s*") }}}
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/oval/shared.xml b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/oval/shared.xml
dac76a
new file mode 100644
dac76a
index 0000000000..de1e7261a6
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/oval/shared.xml
dac76a
@@ -0,0 +1 @@
dac76a
+{{{ oval_check_config_file(path='/etc/hosts.deny', prefix_regex='^[ \\t]*', parameter='ALL:', separator_regex='[ \\t]+', value='ALL', missing_parameter_pass=false, missing_config_file_fail=true) }}}
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml
dac76a
new file mode 100644
dac76a
index 0000000000..f81259ab25
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml
dac76a
@@ -0,0 +1,31 @@
dac76a
+documentation_complete: true
dac76a
+
dac76a
+prodtype: ol7,rhel7
dac76a
+
dac76a
+title: 'Ensure /etc/hosts.deny is configured'
dac76a
+
dac76a
+description: |-
dac76a
+    The file <tt>/etc/hosts.deny</tt> together with <tt>/etc/hosts.allow</tt> provides a
dac76a
+    simple access control mechanism for network services supporting TCP wrappers. 
dac76a
+    The following line in the file ensures that access to services supporting this mechanism is denied to any clients
dac76a
+    not mentioned in <tt>/etc/hosts.allow</tt>:
dac76a
+    
ALL: ALL
dac76a
+
dac76a
+rationale: |-
dac76a
+    Correct configuration in <tt>/etc/hosts.deny</tt> ensures that no explicitly mentioned clients will be able to connect to services supporting this access controll mechanism. 
dac76a
+
dac76a
+severity: medium
dac76a
+
dac76a
+identifiers:
dac76a
+    cce@rhel7: 83391-3
dac76a
+
dac76a
+references:
dac76a
+    cis@rhel7: 3.4.3
dac76a
+
dac76a
+ocil_clause: 'access to services supporting TCP wrappers is not properly configured'
dac76a
+
dac76a
+ocil: |-
dac76a
+    Display contents of the file:
dac76a
+    
cat /etc/hosts.deny
dac76a
+    Verify that the output contains the following line:
dac76a
+    
ALL: ALL
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/correct.pass.sh b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/correct.pass.sh
dac76a
new file mode 100644
dac76a
index 0000000000..cbd4e9467a
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/correct.pass.sh
dac76a
@@ -0,0 +1,6 @@
dac76a
+#!/bin/bash
dac76a
+
dac76a
+# this is done to ensure that we don't lose ssh connection to the machine
dac76a
+echo "ALL: ALL" > /etc/hosts.allow
dac76a
+# this is the actual test case
dac76a
+echo "ALL: ALL" > /etc/hosts.deny
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_empty.fail.sh b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_empty.fail.sh
dac76a
new file mode 100644
dac76a
index 0000000000..d61a08a119
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_empty.fail.sh
dac76a
@@ -0,0 +1,6 @@
dac76a
+#!/bin/bash
dac76a
+
dac76a
+# this is done to ensure that we don't lose ssh connection to the machine
dac76a
+echo "ALL: ALL" > /etc/hosts.allow
dac76a
+# this is the actual test case
dac76a
+echo "" > /etc/hosts.deny
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_missing.fail.sh b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_missing.fail.sh
dac76a
new file mode 100644
dac76a
index 0000000000..78c99cc73a
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/file_missing.fail.sh
dac76a
@@ -0,0 +1,6 @@
dac76a
+#!(bin/bash
dac76a
+
dac76a
+# this is done to ensure that we don't lose ssh connection to the machine
dac76a
+echo "ALL: ALL" > /etc/hosts.allow
dac76a
+# this is the actual test case
dac76a
+rm -f /etc/hosts.deny
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/wrong.fail.sh b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/wrong.fail.sh
dac76a
new file mode 100644
dac76a
index 0000000000..efc958523d
dac76a
--- /dev/null
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/tests/wrong.fail.sh
dac76a
@@ -0,0 +1,6 @@
dac76a
+#!/bin/bash
dac76a
+
dac76a
+# this is done to ensure that we don't lose ssh connection to the machine
dac76a
+echo "ALL: ALL" > /etc/hosts.allow
dac76a
+# this is the actual test case
dac76a
+echo "something different" > /etc/hosts.deny
dac76a
diff --git a/shared/references/cce-redhat-avail.txt b/shared/references/cce-redhat-avail.txt
dac76a
index 6a2445d0bf..6c2b6aee41 100644
dac76a
--- a/shared/references/cce-redhat-avail.txt
dac76a
+++ b/shared/references/cce-redhat-avail.txt
dac76a
@@ -96,7 +96,6 @@ CCE-83387-1
dac76a
 CCE-83388-9
dac76a
 CCE-83389-7
dac76a
 CCE-83390-5
dac76a
-CCE-83391-3
dac76a
 CCE-83392-1
dac76a
 CCE-83393-9
dac76a
 CCE-83394-7
dac76a
dac76a
From bd3d76598f4790efc7d589d6f4916aa207f4aa4b Mon Sep 17 00:00:00 2001
dac76a
From: Vojtech Polasek <vpolasek@redhat.com>
dac76a
Date: Mon, 23 Mar 2020 16:02:43 +0100
dac76a
Subject: [PATCH 2/3] add rule to rhel7 cis profile
dac76a
dac76a
---
dac76a
 rhel7/profiles/cis.profile | 2 ++
dac76a
 1 file changed, 2 insertions(+)
dac76a
dac76a
diff --git a/rhel7/profiles/cis.profile b/rhel7/profiles/cis.profile
dac76a
index 486fcf9a33..4727adaaf5 100644
dac76a
--- a/rhel7/profiles/cis.profile
dac76a
+++ b/rhel7/profiles/cis.profile
dac76a
@@ -352,6 +352,8 @@ selections:
dac76a
 
dac76a
     ### 3.4.2 Ensure /etc/hosts.allow is configured (Scored)
dac76a
     ### 3.4.3 Ensure /etc/hosts.deny is configured (Scored)
dac76a
+    - configure_etc_hosts_deny
dac76a
+
dac76a
     ### 3.4.4 Ensure permissions on /etc/hosts.allow are configured (Scored)
dac76a
     ### 3.4.5 Ensure permissions on /etc/hosts.deny are configured (Scored)
dac76a
 
dac76a
dac76a
From d25cbb63a67af1ea749afda7c2fb7590de388538 Mon Sep 17 00:00:00 2001
dac76a
From: vojtapolasek <krecoun@gmail.com>
dac76a
Date: Tue, 24 Mar 2020 08:57:21 +0100
dac76a
Subject: [PATCH 3/3] fix typo
dac76a
MIME-Version: 1.0
dac76a
Content-Type: text/plain; charset=UTF-8
dac76a
Content-Transfer-Encoding: 8bit
dac76a
dac76a
Co-Authored-By: Jan Černý <jcerny@redhat.com>
dac76a
---
dac76a
 .../obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml | 2 +-
dac76a
 1 file changed, 1 insertion(+), 1 deletion(-)
dac76a
dac76a
diff --git a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml
dac76a
index f81259ab25..ea657a8f79 100644
dac76a
--- a/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml
dac76a
+++ b/linux_os/guide/services/obsolete/inetd_and_xinetd/configure_etc_hosts_deny/rule.yml
dac76a
@@ -12,7 +12,7 @@ description: |-
dac76a
     
ALL: ALL
dac76a
 
dac76a
 rationale: |-
dac76a
-    Correct configuration in <tt>/etc/hosts.deny</tt> ensures that no explicitly mentioned clients will be able to connect to services supporting this access controll mechanism. 
dac76a
+    Correct configuration in <tt>/etc/hosts.deny</tt> ensures that no explicitly mentioned clients will be able to connect to services supporting this access control mechanism. 
dac76a
 
dac76a
 severity: medium
dac76a