[PATCH 06/13] OVAL + remediation for sshd_set_keepalive
Shawn Wells
shawn.d.wells at gmail.com
Sat Sep 7 19:23:06 UTC 2013
-------------- next part --------------
>From 23fc5f688c760e6fd20a14fe263432e9654d0a3e Mon Sep 17 00:00:00 2001
From: Shawn Wells <shawn at redhat.com>
Date: Sat, 7 Sep 2013 11:59:02 -0400
Subject: [PATCH 06/13] OVAL + remediation for sshd_set_keepalive
- Updated OVAL names to match XCCDF
- filename --> filepath
- Added remediation
Remediation testing:
[root at rhel6 checks]# ./testcheck.py sshd_set_keepalive.xml
Evaluating with OVAL tempfile : /tmp/sshd_set_keepalive10WVzO.xml
Writing results to : /tmp/sshd_set_keepalive10WVzO.xml-results
Definition oval:scap-security-guide.testing:def:158: 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_set_keepalive.sh
[root at rhel6 checks]# ./testcheck.py sshd_set_keepalive.xml
Evaluating with OVAL tempfile : /tmp/sshd_set_keepaliveaKfHTK.xml
Writing results to : /tmp/sshd_set_keepaliveaKfHTK.xml-results
Definition oval:scap-security-guide.testing:def:158: true
Definition oval:scap-security-guide.testing:def:127: false
Definition oval:scap-security-guide.testing:def:125: false
Evaluation done.
[root at rhel6 checks]# grep AliveCountMax /etc/ssh/sshd_config
ClientAliveCountMax 0
[root at rhel6 checks]# bash ../fixes/bash/sshd_set_keepalive.sh
[root at rhel6 checks]# grep AliveCountMax /etc/ssh/sshd_config
ClientAliveCountMax 0
---
RHEL6/input/checks/sshd_clientalivecountmax.xml | 35 -----------------------
RHEL6/input/checks/sshd_set_keepalive.xml | 34 ++++++++++++++++++++++
RHEL6/input/fixes/bash/sshd_set_keepalive.sh | 5 +++
RHEL6/input/services/ssh.xml | 2 +-
4 files changed, 40 insertions(+), 36 deletions(-)
delete mode 100644 RHEL6/input/checks/sshd_clientalivecountmax.xml
create mode 100644 RHEL6/input/checks/sshd_set_keepalive.xml
create mode 100644 RHEL6/input/fixes/bash/sshd_set_keepalive.sh
diff --git a/RHEL6/input/checks/sshd_clientalivecountmax.xml b/RHEL6/input/checks/sshd_clientalivecountmax.xml
deleted file mode 100644
index 22ba8e9..0000000
--- a/RHEL6/input/checks/sshd_clientalivecountmax.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<def-group>
- <definition class="compliance" id="sshd_clientalivecountmax" version="1">
- <metadata>
- <title>Set ClientAliveCountMax for User Logins</title>
- <affected family="unix">
- <platform>Red Hat Enterprise Linux 6</platform>
- </affected>
- <description>The SSH ClientAliveCountMax should be set to an appropriate
- value (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 ClientAliveCountMax in /etc/ssh/sshd_config"
- test_ref="test_sshd_clientalivecountmax" />
- </criteria>
- </definition>
- <ind:textfilecontent54_test check="all" check_existence="all_exist"
- comment="Tests the value of the ClientAliveCountMax setting in the /etc/ssh/sshd_config file"
- id="test_sshd_clientalivecountmax" version="1">
- <ind:object object_ref="obj_sshd_clientalivecountmax" />
- <ind:state state_ref="state_sshd_clientalivecountmax" />
- </ind:textfilecontent54_test>
- <ind:textfilecontent54_state id="state_sshd_clientalivecountmax" version="1">
- <ind:subexpression datatype="int" operation="equals">0</ind:subexpression>
- </ind:textfilecontent54_state>
- <ind:textfilecontent54_object id="obj_sshd_clientalivecountmax" version="1">
- <ind:path>/etc/ssh</ind:path>
- <ind:filename>sshd_config</ind:filename>
- <ind:pattern operation="pattern match">^[\s]*(?i)ClientAliveCountMax[\s]+([\d]+)[\s]*$</ind:pattern>
- <ind:instance datatype="int">1</ind:instance>
- </ind:textfilecontent54_object>
-</def-group>
diff --git a/RHEL6/input/checks/sshd_set_keepalive.xml b/RHEL6/input/checks/sshd_set_keepalive.xml
new file mode 100644
index 0000000..539a6a9
--- /dev/null
+++ b/RHEL6/input/checks/sshd_set_keepalive.xml
@@ -0,0 +1,34 @@
+<def-group>
+ <definition class="compliance" id="sshd_set_keepalive" version="1">
+ <metadata>
+ <title>Set ClientAliveCountMax for User Logins</title>
+ <affected family="unix">
+ <platform>Red Hat Enterprise Linux 6</platform>
+ </affected>
+ <description>The SSH ClientAliveCountMax should be set to an appropriate
+ value (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 ClientAliveCountMax in /etc/ssh/sshd_config"
+ test_ref="test_sshd_clientalivecountmax" />
+ </criteria>
+ </definition>
+ <ind:textfilecontent54_test check="all" check_existence="all_exist"
+ comment="Tests the value of the ClientAliveCountMax setting in the /etc/ssh/sshd_config file"
+ id="test_sshd_clientalivecountmax" version="1">
+ <ind:object object_ref="obj_sshd_clientalivecountmax" />
+ <ind:state state_ref="state_sshd_clientalivecountmax" />
+ </ind:textfilecontent54_test>
+ <ind:textfilecontent54_state id="state_sshd_clientalivecountmax" version="1">
+ <ind:subexpression datatype="int" operation="equals">0</ind:subexpression>
+ </ind:textfilecontent54_state>
+ <ind:textfilecontent54_object id="obj_sshd_clientalivecountmax" version="1">
+ <ind:filepath>/etc/ssh/sshd_config</ind:filepath>
+ <ind:pattern operation="pattern match">^[\s]*(?i)ClientAliveCountMax[\s]+([\d]+)[\s]*$</ind:pattern>
+ <ind:instance datatype="int">1</ind:instance>
+ </ind:textfilecontent54_object>
+</def-group>
diff --git a/RHEL6/input/fixes/bash/sshd_set_keepalive.sh b/RHEL6/input/fixes/bash/sshd_set_keepalive.sh
new file mode 100644
index 0000000..d54ba21
--- /dev/null
+++ b/RHEL6/input/fixes/bash/sshd_set_keepalive.sh
@@ -0,0 +1,5 @@
+grep -q ^ClientAliveCountMax /etc/ssh/sshd_config && \
+ sed -i "s/ClientAliveCountMax.*/ClientAliveCountMax 0/g" /etc/ssh/sshd_config
+if ! [ $? -eq 0 ]; then
+ echo "ClientAliveCountMax 0" >> /etc/ssh/sshd_config
+fi
diff --git a/RHEL6/input/services/ssh.xml b/RHEL6/input/services/ssh.xml
index f2d0c86..c4a5ffc 100644
--- a/RHEL6/input/services/ssh.xml
+++ b/RHEL6/input/services/ssh.xml
@@ -192,7 +192,7 @@ This ensures a user login will be terminated as soon as the <tt>ClientAliveCount
is reached.
</rationale>
<ident cce="26282-4" />
-<oval id="sshd_clientalivecountmax" />
+<oval id="sshd_set_keepalive" />
<ref disa="879,1133"/>
<tested by="DS" on="20121024"/>
</Rule>
--
1.7.1
More information about the scap-security-guide
mailing list