[PATCH 05/13] Updated sshd_disable_rhosts

Shawn Wells shawn.d.wells at gmail.com
Sat Sep 7 19:23:02 UTC 2013


-------------- next part --------------
>From 2a1bbe7879d6a4e5e60c93f2566f126fcc24b31d Mon Sep 17 00:00:00 2001
From: Shawn Wells <shawn at redhat.com>
Date: Sat, 7 Sep 2013 11:45:15 -0400
Subject: [PATCH 05/13] Updated sshd_disable_rhosts
 - Renamed OVAL check to match XCCDF name
 - filename -> filepath
 - Added remediation

Testing remediation:
[root at rhel6 checks]# ./testcheck.py sshd_disable_rhosts.xml
Evaluating with OVAL tempfile : /tmp/sshd_disable_rhostsbfLjiB.xml
Writing results to : /tmp/sshd_disable_rhostsbfLjiB.xml-results
Definition oval:scap-security-guide.testing:def:149: false
Definition oval:scap-security-guide.testing:def:127: false
Definition oval:scap-security-guide.testing:def:125: false
Evaluation done.

[root at rhel6 checks]# bash ../fixes/bash/sshd_disable_rhosts.sh

[root at rhel6 checks]# ./testcheck.py sshd_disable_rhosts.xml
Evaluating with OVAL tempfile : /tmp/sshd_disable_rhostsb5cKXv.xml
Writing results to : /tmp/sshd_disable_rhostsb5cKXv.xml-results
Definition oval:scap-security-guide.testing:def:149: true
Definition oval:scap-security-guide.testing:def:127: false
Definition oval:scap-security-guide.testing:def:125: false
Evaluation done.
---
 RHEL6/input/checks/sshd_disable_rhosts.xml         |   31 +++++++++++++++++++
 RHEL6/input/checks/sshd_rsh_emulation_disabled.xml |   32 --------------------
 RHEL6/input/fixes/bash/sshd_disable_rhosts.sh      |    5 +++
 RHEL6/input/services/ssh.xml                       |    2 +-
 4 files changed, 37 insertions(+), 33 deletions(-)
 create mode 100644 RHEL6/input/checks/sshd_disable_rhosts.xml
 delete mode 100644 RHEL6/input/checks/sshd_rsh_emulation_disabled.xml
 create mode 100644 RHEL6/input/fixes/bash/sshd_disable_rhosts.sh

diff --git a/RHEL6/input/checks/sshd_disable_rhosts.xml b/RHEL6/input/checks/sshd_disable_rhosts.xml
new file mode 100644
index 0000000..29db641
--- /dev/null
+++ b/RHEL6/input/checks/sshd_disable_rhosts.xml
@@ -0,0 +1,31 @@
+<def-group>
+  <definition class="compliance" id="sshd_disable_rhosts" version="1">
+    <metadata>
+      <title>Disable .rhosts Files</title>
+      <affected family="unix">
+        <platform>Red Hat Enterprise Linux 6</platform>
+      </affected>
+      <description>Emulation of the rsh command through the ssh server should
+      be disabled (and dependencies are met)</description>
+      <reference source="MED" ref_id="20130813" ref_url="test_attestation" />
+    </metadata>
+    <criteria comment="SSH is not being used or conditions are met"
+    operator="OR">
+      <extend_definition comment="sshd service is disabled"
+      definition_ref="service_sshd_disabled" />
+      <criterion comment="Check IgnoreRhosts in /etc/ssh/sshd_config"
+      test_ref="test_sshd_rsh_emulation_disabled" />
+    </criteria>
+  </definition>
+  <ind:textfilecontent54_test check="all" check_existence="none_exist"
+  comment="Tests the value of the IgnoreRhosts[\s]*(&lt;:nocomment:&gt;*) setting in the /etc/ssh/sshd_config file"
+  id="test_sshd_rsh_emulation_disabled" version="1">
+    <ind:object object_ref="obj_sshd_rsh_emulation_disabled" />
+  </ind:textfilecontent54_test>
+  <ind:textfilecontent54_object id="obj_sshd_rsh_emulation_disabled"
+  version="1">
+    <ind:filepath>/etc/ssh/sshd_config</ind:filepath>
+    <ind:pattern operation="pattern match">^[\s]*(?i)IgnoreRhosts[\s]+no[\s]*$</ind:pattern>
+    <ind:instance datatype="int">1</ind:instance>
+  </ind:textfilecontent54_object>
+</def-group>
diff --git a/RHEL6/input/checks/sshd_rsh_emulation_disabled.xml b/RHEL6/input/checks/sshd_rsh_emulation_disabled.xml
deleted file mode 100644
index fb15c10..0000000
--- a/RHEL6/input/checks/sshd_rsh_emulation_disabled.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<def-group>
-  <definition class="compliance" id="sshd_rsh_emulation_disabled" version="1">
-    <metadata>
-      <title>Disable .rhosts Files</title>
-      <affected family="unix">
-        <platform>Red Hat Enterprise Linux 6</platform>
-      </affected>
-      <description>Emulation of the rsh command through the ssh server should
-      be disabled (and dependencies are met)</description>
-      <reference source="MED" ref_id="20130813" ref_url="test_attestation" />
-    </metadata>
-    <criteria comment="SSH is not being used or conditions are met"
-    operator="OR">
-      <extend_definition comment="sshd service is disabled"
-      definition_ref="service_sshd_disabled" />
-      <criterion comment="Check IgnoreRhosts in /etc/ssh/sshd_config"
-      test_ref="test_sshd_rsh_emulation_disabled" />
-    </criteria>
-  </definition>
-  <ind:textfilecontent54_test check="all" check_existence="none_exist"
-  comment="Tests the value of the IgnoreRhosts[\s]*(&lt;:nocomment:&gt;*) setting in the /etc/ssh/sshd_config file"
-  id="test_sshd_rsh_emulation_disabled" version="1">
-    <ind:object object_ref="obj_sshd_rsh_emulation_disabled" />
-  </ind:textfilecontent54_test>
-  <ind:textfilecontent54_object id="obj_sshd_rsh_emulation_disabled"
-  version="1">
-    <ind:path>/etc/ssh</ind:path>
-    <ind:filename>sshd_config</ind:filename>
-    <ind:pattern operation="pattern match">^[\s]*(?i)IgnoreRhosts[\s]+no[\s]*$</ind:pattern>
-    <ind:instance datatype="int">1</ind:instance>
-  </ind:textfilecontent54_object>
-</def-group>
diff --git a/RHEL6/input/fixes/bash/sshd_disable_rhosts.sh b/RHEL6/input/fixes/bash/sshd_disable_rhosts.sh
new file mode 100644
index 0000000..24d22db
--- /dev/null
+++ b/RHEL6/input/fixes/bash/sshd_disable_rhosts.sh
@@ -0,0 +1,5 @@
+grep -q ^IgnoreRhosts /etc/ssh/sshd_config && \
+  sed -i "s/IgnoreRhosts.*/IgnoreRhosts yes/g" /etc/ssh/sshd_config
+if ! [ $? -eq 0 ]; then
+    echo "IgnoreRhosts yes" >> /etc/ssh/sshd_config
+fi
diff --git a/RHEL6/input/services/ssh.xml b/RHEL6/input/services/ssh.xml
index 7100584..f2d0c86 100644
--- a/RHEL6/input/services/ssh.xml
+++ b/RHEL6/input/services/ssh.xml
@@ -216,7 +216,7 @@ SSH trust relationships mean a compromise on one host
 can allow an attacker to move trivially to other hosts.
 </rationale>
 <ident cce="27124-7" />
-<oval id="sshd_rsh_emulation_disabled" />
+<oval id="sshd_disable_rhosts" />
 <ref disa="765,766"/>
 </Rule>
 
-- 
1.7.1



More information about the scap-security-guide mailing list