[PATCH 11/13] remediation + OVAL for sshd_disable_empty_passwords

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


-------------- next part --------------
>From 1da38d07f1e2b1138fd34d741e55397f49b3a6c6 Mon Sep 17 00:00:00 2001
From: Shawn Wells <shawn at redhat.com>
Date: Sat, 7 Sep 2013 12:37:30 -0400
Subject: [PATCH 11/13] remediation + OVAL for sshd_disable_empty_passwords
 - Updated OVAL naming to match XCCDF
 - filename --> filepath
 - Added remediation

Remediation testing:
[root at rhel6 checks]# grep PermitEmpty /etc/ssh/sshd_config
PermitEmptyPasswords yes
[root at rhel6 checks]# ./testcheck.py sshd_disable_empty_passwords.xml
Evaluating with OVAL tempfile : /tmp/sshd_disable_empty_passwordsAvErSY.xml
Writing results to : /tmp/sshd_disable_empty_passwordsAvErSY.xml-results
Definition oval:scap-security-guide.testing:def:173: 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_empty_passwords.sh
[root at rhel6 checks]# ./testcheck.py sshd_disable_empty_passwords.xml
Evaluating with OVAL tempfile : /tmp/sshd_disable_empty_passwordsDAdtaU.xml
Writing results to : /tmp/sshd_disable_empty_passwordsDAdtaU.xml-results
Definition oval:scap-security-guide.testing:def:173: true
Definition oval:scap-security-guide.testing:def:127: false
Definition oval:scap-security-guide.testing:def:125: false
Evaluation done.
---
 .../input/checks/sshd_disable_empty_passwords.xml  |   31 +++++++++++++++++++
 .../input/checks/sshd_permitemptypasswords_no.xml  |   32 --------------------
 .../fixes/bash/sshd_disable_empty_passwords.sh     |    5 +++
 RHEL6/input/services/ssh.xml                       |    2 +-
 4 files changed, 37 insertions(+), 33 deletions(-)
 create mode 100644 RHEL6/input/checks/sshd_disable_empty_passwords.xml
 delete mode 100644 RHEL6/input/checks/sshd_permitemptypasswords_no.xml
 create mode 100644 RHEL6/input/fixes/bash/sshd_disable_empty_passwords.sh

diff --git a/RHEL6/input/checks/sshd_disable_empty_passwords.xml b/RHEL6/input/checks/sshd_disable_empty_passwords.xml
new file mode 100644
index 0000000..0a9d846
--- /dev/null
+++ b/RHEL6/input/checks/sshd_disable_empty_passwords.xml
@@ -0,0 +1,31 @@
+<def-group>
+  <definition class="compliance" id="sshd_disable_empty_passwords" version="1">
+    <metadata>
+      <title>Disable Empty Passwords</title>
+      <affected family="unix">
+        <platform>Red Hat Enterprise Linux 6</platform>
+      </affected>
+      <description>Remote connections from accounts with empty passwords 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 PermitEmptyPasswords in /etc/ssh/sshd_config"
+      negate="true" test_ref="test_sshd_permitemptypasswords_no" />
+    </criteria>
+  </definition>
+  <ind:textfilecontent54_test check="all" check_existence="none_exist"
+  comment="Tests the value of the PermitEmptyPasswords[\s]*(&lt;:nocomment:&gt;*) setting in the /etc/ssh/sshd_config file"
+  id="test_sshd_permitemptypasswords_no" version="1">
+    <ind:object object_ref="obj_sshd_permitemptypasswords_no" />
+  </ind:textfilecontent54_test>
+  <ind:textfilecontent54_object id="obj_sshd_permitemptypasswords_no"
+  version="1">
+    <ind:filepath>/etc/ssh/sshd_config</ind:filepath>
+    <ind:pattern operation="pattern match">^[\s]*(?i)PermitEmptyPasswords[\s]+no[\s]*$</ind:pattern>
+    <ind:instance datatype="int">1</ind:instance>
+  </ind:textfilecontent54_object>
+</def-group>
diff --git a/RHEL6/input/checks/sshd_permitemptypasswords_no.xml b/RHEL6/input/checks/sshd_permitemptypasswords_no.xml
deleted file mode 100644
index a2abe9b..0000000
--- a/RHEL6/input/checks/sshd_permitemptypasswords_no.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<def-group>
-  <definition class="compliance" id="sshd_permitemptypasswords_no" version="1">
-    <metadata>
-      <title>Disable Empty Passwords</title>
-      <affected family="unix">
-        <platform>Red Hat Enterprise Linux 6</platform>
-      </affected>
-      <description>Remote connections from accounts with empty passwords 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 PermitEmptyPasswords in /etc/ssh/sshd_config"
-      negate="true" test_ref="test_sshd_permitemptypasswords_no" />
-    </criteria>
-  </definition>
-  <ind:textfilecontent54_test check="all" check_existence="none_exist"
-  comment="Tests the value of the PermitEmptyPasswords[\s]*(&lt;:nocomment:&gt;*) setting in the /etc/ssh/sshd_config file"
-  id="test_sshd_permitemptypasswords_no" version="1">
-    <ind:object object_ref="obj_sshd_permitemptypasswords_no" />
-  </ind:textfilecontent54_test>
-  <ind:textfilecontent54_object id="obj_sshd_permitemptypasswords_no"
-  version="1">
-    <ind:path>/etc/ssh</ind:path>
-    <ind:filename>sshd_config</ind:filename>
-    <ind:pattern operation="pattern match">^[\s]*(?i)PermitEmptyPasswords[\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_empty_passwords.sh b/RHEL6/input/fixes/bash/sshd_disable_empty_passwords.sh
new file mode 100644
index 0000000..f71fff1
--- /dev/null
+++ b/RHEL6/input/fixes/bash/sshd_disable_empty_passwords.sh
@@ -0,0 +1,5 @@
+grep -q ^PermitEmptyPasswords /etc/ssh/sshd_config && \
+  sed -i "s/PermitEmptyPasswords.*/PermitEmptyPasswords no/g" /etc/ssh/sshd_config
+if ! [ $? -eq 0 ]; then
+    echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
+fi
diff --git a/RHEL6/input/services/ssh.xml b/RHEL6/input/services/ssh.xml
index 1545b4f..b468f15 100644
--- a/RHEL6/input/services/ssh.xml
+++ b/RHEL6/input/services/ssh.xml
@@ -287,7 +287,7 @@ remote login via SSH will require a password,
 even in the event of misconfiguration elsewhere.
 </rationale>
 <ident cce="26887-0" />
-<oval id="sshd_permitemptypasswords_no" />
+<oval id="sshd_disable_empty_passwords" />
 <ref disa="765,766"/>
 <tested by="DS" on="20121024"/>
 </Rule>
-- 
1.7.1



More information about the scap-security-guide mailing list