[PATCH 09/13] OVAL + remediation

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


-------------- next part --------------
>From d7e7971bf4b7e8aae8f5f969361e7fcbadab735c Mon Sep 17 00:00:00 2001
From: Shawn Wells <shawn at redhat.com>
Date: Sat, 7 Sep 2013 12:19:33 -0400
Subject: [PATCH 09/13] OVAL + remediation: sshd_do_not_permit_user_env
 - Updated OVAL ID and filename to match XCCDF
 - filename -> filepath OVAL
 - Added remediation

Remediation testing:
[root at rhel6 checks]# vim /etc/ssh/sshd_config
[root at rhel6 checks]# grep PermitUserEnvir /etc/ssh/sshd_config ; ./testcheck.py sshd_do_not_permit_user_env.xml
PermitUserEnvironment yes
Evaluating with OVAL tempfile : /tmp/sshd_do_not_permit_user_envSWoGgf.xml
Writing results to : /tmp/sshd_do_not_permit_user_envSWoGgf.xml-results
Definition oval:scap-security-guide.testing:def:165: 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_do_not_permit_user_env.sh
[root at rhel6 checks]# grep PermitUserEnvir /etc/ssh/sshd_config ; ./testcheck.py sshd_do_not_permit_user_env.xml
PermitUserEnvironment no
Evaluating with OVAL tempfile : /tmp/sshd_do_not_permit_user_envo8hpvV.xml
Writing results to : /tmp/sshd_do_not_permit_user_envo8hpvV.xml-results
Definition oval:scap-security-guide.testing:def:165: 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_do_not_permit_user_env.xml |   29 +++++++++++++++++++
 RHEL6/input/checks/sshd_no_user_envset.xml         |   30 --------------------
 .../fixes/bash/sshd_do_not_permit_user_env.sh      |    5 +++
 RHEL6/input/services/ssh.xml                       |    2 +-
 4 files changed, 35 insertions(+), 31 deletions(-)
 create mode 100644 RHEL6/input/checks/sshd_do_not_permit_user_env.xml
 delete mode 100644 RHEL6/input/checks/sshd_no_user_envset.xml
 create mode 100644 RHEL6/input/fixes/bash/sshd_do_not_permit_user_env.sh

diff --git a/RHEL6/input/checks/sshd_do_not_permit_user_env.xml b/RHEL6/input/checks/sshd_do_not_permit_user_env.xml
new file mode 100644
index 0000000..592c00a
--- /dev/null
+++ b/RHEL6/input/checks/sshd_do_not_permit_user_env.xml
@@ -0,0 +1,29 @@
+<def-group>
+  <definition class="compliance" id="sshd_do_not_permit_user_env" version="1">
+    <metadata>
+      <title>Do Not Allow Users to Set Environment Options</title>
+      <affected family="unix">
+        <platform>Red Hat Enterprise Linux 6</platform>
+      </affected>
+      <description>PermitUserEnvironment should be disabled</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 PermitUserEnvironment in /etc/ssh/sshd_config"
+      negate="true" test_ref="test_sshd_no_user_envset" />
+    </criteria>
+  </definition>
+  <ind:textfilecontent54_test check="all" check_existence="none_exist"
+  comment="Check value of PermitUserEnvironment in /etc/ssh/sshd_config"
+  id="test_sshd_no_user_envset" version="1">
+    <ind:object object_ref="obj_sshd_no_user_envset" />
+  </ind:textfilecontent54_test>
+  <ind:textfilecontent54_object id="obj_sshd_no_user_envset" version="1">
+    <ind:filepath>/etc/ssh/sshd_config</ind:filepath>
+    <ind:pattern operation="pattern match">^[\s]*(?i)PermitUserEnvironment[\s]+no[\s]*$</ind:pattern>
+    <ind:instance datatype="int">1</ind:instance>
+  </ind:textfilecontent54_object>
+</def-group>
diff --git a/RHEL6/input/checks/sshd_no_user_envset.xml b/RHEL6/input/checks/sshd_no_user_envset.xml
deleted file mode 100644
index ce128a9..0000000
--- a/RHEL6/input/checks/sshd_no_user_envset.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<def-group>
-  <definition class="compliance" id="sshd_no_user_envset" version="1">
-    <metadata>
-      <title>Do Not Allow Users to Set Environment Options</title>
-      <affected family="unix">
-        <platform>Red Hat Enterprise Linux 6</platform>
-      </affected>
-      <description>PermitUserEnvironment should be disabled</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 PermitUserEnvironment in /etc/ssh/sshd_config"
-      negate="true" test_ref="test_sshd_no_user_envset" />
-    </criteria>
-  </definition>
-  <ind:textfilecontent54_test check="all" check_existence="none_exist"
-  comment="Check value of PermitUserEnvironment in /etc/ssh/sshd_config"
-  id="test_sshd_no_user_envset" version="1">
-    <ind:object object_ref="obj_sshd_no_user_envset" />
-  </ind:textfilecontent54_test>
-  <ind:textfilecontent54_object id="obj_sshd_no_user_envset" version="1">
-    <ind:path>/etc/ssh</ind:path>
-    <ind:filename>sshd_config</ind:filename>
-    <ind:pattern operation="pattern match">^[\s]*(?i)PermitUserEnvironment[\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_do_not_permit_user_env.sh b/RHEL6/input/fixes/bash/sshd_do_not_permit_user_env.sh
new file mode 100644
index 0000000..b886e3c
--- /dev/null
+++ b/RHEL6/input/fixes/bash/sshd_do_not_permit_user_env.sh
@@ -0,0 +1,5 @@
+grep -q ^PermitUserEnvironment /etc/ssh/sshd_config && \
+  sed -i "s/PermitUserEnvironment.*/PermitUserEnvironment no/g" /etc/ssh/sshd_config
+if ! [ $? -eq 0 ]; then
+    echo "PermitUserEnvironment no" >> /etc/ssh/sshd_config
+fi
diff --git a/RHEL6/input/services/ssh.xml b/RHEL6/input/services/ssh.xml
index cb6459b..7ca27ae 100644
--- a/RHEL6/input/services/ssh.xml
+++ b/RHEL6/input/services/ssh.xml
@@ -335,7 +335,7 @@ SSH environment options potentially allow users to bypass
 access restriction in some configurations.
 </rationale>
 <ident cce="27201-3" />
-<oval id="sshd_no_user_envset" />
+<oval id="sshd_do_not_permit_user_env" />
 <ref disa="1414" />
 <tested by="DS" on="20121024"/>
 </Rule>
-- 
1.7.1



More information about the scap-security-guide mailing list