forked from ComplianceAsCode/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ComplianceAsCode#6434 from Caligatio/revert-ssh-ke…
…epalive Revert hardcoding of ClientAliveCountMax to 0
- Loading branch information
Showing
58 changed files
with
284 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/ansible/shared.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_ubuntu | ||
# reboot = false | ||
# strategy = restrict | ||
# complexity = low | ||
# disruption = low | ||
{{{ ansible_instantiate_variables("var_sshd_set_keepalive") }}} | ||
|
||
{{{ ansible_sshd_set(parameter="ClientAliveCountMax", value="{{ var_sshd_set_keepalive }}") }}} |
8 changes: 8 additions & 0 deletions
8
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/bash/shared.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# platform = multi_platform_wrlinux,multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle,multi_platform_ubuntu | ||
|
||
# Include source function library. | ||
. /usr/share/scap-security-guide/remediation_functions | ||
|
||
{{{ bash_instantiate_variables("var_sshd_set_keepalive") }}} | ||
|
||
{{{ bash_sshd_config_set(parameter="ClientAliveCountMax", value="$var_sshd_set_keepalive") }}} |
52 changes: 52 additions & 0 deletions
52
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<def-group> | ||
<definition class="compliance" id="sshd_set_keepalive" version="1"> | ||
{{{ oval_metadata("The SSH ClientAliveCountMax should be set to an appropriate | ||
value (and dependencies are met)") }}} | ||
<criteria comment="SSH is configured correctly or is not installed" | ||
operator="OR"> | ||
<criteria comment="sshd is not installed" operator="AND"> | ||
<extend_definition comment="sshd is not required or requirement is unset" | ||
definition_ref="sshd_not_required_or_unset" /> | ||
{{% if product in ['opensuse', 'sle12'] %}} | ||
<extend_definition comment="rpm package openssh removed" | ||
definition_ref="package_openssh_removed" /> | ||
{{% else %}} | ||
<extend_definition comment="rpm package openssh-server removed" | ||
definition_ref="package_openssh-server_removed" /> | ||
{{% endif %}} | ||
</criteria> | ||
<criteria comment="sshd is installed and configured" operator="AND"> | ||
<extend_definition comment="sshd is required or requirement is unset" | ||
definition_ref="sshd_required_or_unset" /> | ||
{{% if product in ['opensuse', 'sle12'] %}} | ||
<extend_definition comment="rpm package openssh installed" | ||
definition_ref="package_openssh_installed" /> | ||
{{% else %}} | ||
<extend_definition comment="rpm package openssh-server installed" | ||
definition_ref="package_openssh-server_installed" /> | ||
{{% endif %}} | ||
<criterion comment="Check ClientAliveCountMax in /etc/ssh/sshd_config" | ||
test_ref="test_sshd_clientalivecountmax" /> | ||
</criteria> | ||
</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="less than or equal" var_check="all" | ||
var_ref="var_sshd_set_keepalive" /> | ||
</ind:textfilecontent54_state> | ||
<ind:textfilecontent54_object id="obj_sshd_clientalivecountmax" version="2"> | ||
<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> | ||
|
||
<external_variable comment="ClientAliveCountMax value" datatype="int" | ||
id="var_sshd_set_keepalive" version="1" /> | ||
|
||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive_0/kubernetes/shared.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# platform = multi_platform_ocp,multi_platform_rhcos | ||
# reboot = false | ||
# strategy = restrict | ||
# complexity = low | ||
# disruption = low | ||
{{{ kubernetes_sshd_set() }}} |
74 changes: 74 additions & 0 deletions
74
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive_0/rule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
documentation_complete: true | ||
|
||
# applicable only to products that ship OpenSSH<8.2 | ||
# prodtypes: ??? | ||
|
||
title: 'Set SSH Client Alive Count Max to zero' | ||
|
||
description: |- | ||
The SSH server sends at most <tt>ClientAliveCountMax</tt> messages | ||
during a SSH session and waits for a response from the SSH client. | ||
The option <tt>ClientAliveInterval</tt> configures timeout after | ||
each <tt>ClientAliveCountMax</tt> message. If the SSH server does not | ||
receive a response from the client, then the connection is considered idle | ||
and terminated. | ||
To ensure the SSH idle timeout occurs precisely when the | ||
<tt>ClientAliveInterval</tt> is set, set the <tt>ClientAliveCountMax</tt> to | ||
value of <tt>0</tt>. | ||
rationale: |- | ||
This ensures a user login will be terminated as soon as the <tt>ClientAliveInterval</tt> | ||
is reached. | ||
severity: medium | ||
|
||
identifiers: | ||
cce@rhel7: CCE-83399-6 | ||
cce@rhel8: CCE-83405-1 | ||
cce@rhcos4: CCE-83406-9 | ||
cce@sle12: CCE-83407-7 | ||
|
||
references: | ||
stigid@ol7: OL07-00-040340 | ||
cis@rhel7: 5.2.12 | ||
cis@rhel8: 5.2.13 | ||
cis@ubuntu2004: 5.2.15 | ||
cjis: 5.5.6 | ||
cui: 3.1.11 | ||
disa: CCI-000879,CCI-001133,CCI-002361 | ||
hipaa: 164.308(a)(4)(i),164.308(b)(1),164.308(b)(3),164.310(b),164.312(e)(1),164.312(e)(2)(ii) | ||
nist: AC-2(5),AC-12,AC-17(a),SC-10,CM-6(a) | ||
nist-csf: DE.CM-1,DE.CM-3,PR.AC-1,PR.AC-4,PR.AC-6,PR.AC-7,PR.IP-2 | ||
pcidss: Req-8.1.8 | ||
srg: SRG-OS-000163-GPOS-00072,SRG-OS-000279-GPOS-00109 | ||
vmmsrg: SRG-OS-000480-VMM-002000 | ||
stigid@rhel7: RHEL-07-040340 | ||
stigid@sle12: SLES-12-030191 | ||
isa-62443-2013: 'SR 1.1,SR 1.10,SR 1.2,SR 1.3,SR 1.4,SR 1.5,SR 1.7,SR 1.8,SR 1.9,SR 2.1,SR 6.2' | ||
isa-62443-2009: 4.3.3.2.2,4.3.3.5.1,4.3.3.5.2,4.3.3.6.1,4.3.3.6.2,4.3.3.6.3,4.3.3.6.4,4.3.3.6.5,4.3.3.6.6,4.3.3.6.7,4.3.3.6.8,4.3.3.6.9,4.3.3.7.2,4.3.3.7.3,4.3.3.7.4,4.3.4.3.3 | ||
cobit5: APO13.01,BAI03.01,BAI03.02,BAI03.03,DSS01.03,DSS03.05,DSS05.04,DSS05.05,DSS05.07,DSS05.10,DSS06.03,DSS06.10 | ||
iso27001-2013: A.12.4.1,A.12.4.3,A.14.1.1,A.14.2.1,A.14.2.5,A.18.1.4,A.6.1.2,A.6.1.5,A.7.1.1,A.9.1.2,A.9.2.1,A.9.2.2,A.9.2.3,A.9.2.4,A.9.2.6,A.9.3.1,A.9.4.1,A.9.4.2,A.9.4.3,A.9.4.4,A.9.4.5 | ||
cis-csc: 1,12,13,14,15,16,18,3,5,7,8 | ||
|
||
requires: | ||
- sshd_set_idle_timeout | ||
|
||
ocil_clause: 'it is commented out or not configured properly' | ||
|
||
ocil: |- | ||
To ensure <tt>ClientAliveInterval</tt> is set correctly, run the following command: | ||
<pre>$ sudo grep ClientAliveCountMax /etc/ssh/sshd_config</pre> | ||
If properly configured, the output should be: | ||
<pre>ClientAliveCountMax 0</pre> | ||
In this case, the SSH idle timeout occurs precisely when | ||
the <tt>ClientAliveInterval</tt> is set. | ||
template: | ||
name: sshd_lineinfile | ||
vars: | ||
parameter: "ClientAliveCountMax" | ||
value: "0" | ||
missing_parameter_pass: "false" | ||
kubernetes: "off" |
9 changes: 9 additions & 0 deletions
9
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive_0/tests/comment.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_ospp | ||
SSHD_CONFIG="/etc/ssh/sshd_config" | ||
|
||
if grep -q "^ClientAliveCountMax" $SSHD_CONFIG; then | ||
sed -i "s/^ClientAliveCountMax.*/# ClientAliveCountMax 0/" $SSHD_CONFIG | ||
else | ||
echo "# ClientAliveCountMax 0" >> $SSHD_CONFIG | ||
fi |
9 changes: 9 additions & 0 deletions
9
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive_0/tests/correct_value.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_ospp | ||
SSHD_CONFIG="/etc/ssh/sshd_config" | ||
|
||
if grep -q "^ClientAliveCountMax" $SSHD_CONFIG; then | ||
sed -i "s/^ClientAliveCountMax.*/ClientAliveCountMax 0/" $SSHD_CONFIG | ||
else | ||
echo "ClientAliveCountMax 0" >> $SSHD_CONFIG | ||
fi |
4 changes: 4 additions & 0 deletions
4
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive_0/tests/line_not_there.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_ospp | ||
|
||
sed -i "/^ClientAliveCountMax.*/d" /etc/ssh/sshd_config |
9 changes: 9 additions & 0 deletions
9
linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive_0/tests/wrong_value.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_ospp | ||
SSHD_CONFIG="/etc/ssh/sshd_config" | ||
|
||
if grep -q "^ClientAliveCountMax" $SSHD_CONFIG; then | ||
sed -i "s/^ClientAliveCountMax.*/ClientAliveCountMax 50/" $SSHD_CONFIG | ||
else | ||
echo "ClientAliveCountMax 50" >> $SSHD_CONFIG | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.