Skip to content

Commit a3b768f

Browse files
committedNov 3, 2020
Merge branch 'matejak-fix_sshd_timeout' into master
2 parents 9e9be74 + 5ab82b4 commit a3b768f

File tree

27 files changed

+97
-91
lines changed

27 files changed

+97
-91
lines changed
 

‎docs/manual/developer_guide.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ auditd_lineinfile::
15251525
* Parameters:
15261526
** *parameter* - auditd configuration item
15271527
** *value* - the value of configuration item specified by parameter
1528-
** *missing_parameter_pass* - effective only in OVAL checks, if set to `"true"` and the parameter is not present in the configuration file the OVAL check will return true.
1528+
** *missing_parameter_pass* - effective only in OVAL checks, if set to `"false"` and the parameter is not present in the configuration file, the OVAL check will return `false`.
15291529
* Languages: Ansible, Bash, OVAL
15301530

15311531
audit_rules_dac_modification::
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# platform = multi_platform_wrlinux,multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle
1+
# platform = multi_platform_all
2+
23
. /usr/share/scap-security-guide/remediation_functions
4+
35
{{{ bash_instantiate_variables("sshd_idle_timeout_value") }}}
46

5-
replace_or_append '/etc/ssh/sshd_config' '^ClientAliveInterval' $sshd_idle_timeout_value '@CCENUM@' '%s %s'
7+
{{{ bash_sshd_config_set("ClientAliveInterval", "$sshd_idle_timeout_value") }}}

‎linux_os/guide/services/ssh/ssh_server/sshd_set_idle_timeout/oval/shared.xml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
{{% endif %}}
2828
<criterion comment="Check ClientAliveInterval in /etc/ssh/sshd_config"
2929
test_ref="test_sshd_idle_timeout" />
30+
<extend_definition comment="The SSH ClientAliveCountMax is set to zero" definition_ref="sshd_set_keepalive" />
3031
</criteria>
3132
</criteria>
3233
</definition>

‎linux_os/guide/services/ssh/ssh_server/sshd_set_idle_timeout/rule.yml

+6
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@ warnings:
7070
- dependency: |-
7171
SSH disconnecting idle clients will not have desired effect without also
7272
configuring ClientAliveCountMax in the SSH service configuration.
73+
- general: |-
74+
Following conditions may prevent the SSH session to time out:
75+
<ul>
76+
<li>Remote processes on the remote machine generates output. As the output has to be transferred over the network to the client, the timeout is reset every time such transfer happens.</li>
77+
<li>Any <tt>scp</tt> or <tt>sftp</tt> activity by the same user to the host resets the timeout.</li>
78+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# remediation = none
3+
4+
# The rule doesn't remediate the ClientAliveCountMax setting, we have another rule for that.
5+
6+
SSHD_CONFIG="/etc/ssh/sshd_config"
7+
8+
. "$SHARED/utilities.sh"
9+
10+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveInterval "ClientAliveInterval 10"
11+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveCountMax "# ClientAliveCountMax 0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# profiles = xccdf_org.ssgproject.content_profile_ospp
3+
SSHD_CONFIG="/etc/ssh/sshd_config"
4+
5+
. "$SHARED/utilities.sh"
6+
7+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveInterval "ClientAliveInterval 10"
8+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveCountMax "ClientAliveCountMax 0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
# remediation = none
3+
4+
# The rule doesn't remediate the ClientAliveCountMax setting, we have another rule for that.
5+
6+
sed -i "/^ClientAliveCountMax.*/d" /etc/ssh/sshd_config
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
SSHD_CONFIG="/etc/ssh/sshd_config"
4+
5+
. "$SHARED/utilities.sh"
6+
7+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveInterval "# ClientAliveInterval 10"
8+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveCountMax "ClientAliveCountMax 0"
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# remediation = none
3+
4+
# The rule doesn't remediate the ClientAliveCountMax setting, we have another rule for that.
5+
6+
sed -i "/^ClientAliveInterval.*/d" /etc/ssh/sshd_config
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# remediation = none
3+
4+
# The rule doesn't remediate the ClientAliveCountMax setting, we have another rule for that.
5+
6+
SSHD_CONFIG="/etc/ssh/sshd_config"
7+
8+
. "$SHARED/utilities.sh"
9+
10+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveInterval "ClientAliveInterval 10"
11+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveCountMax "ClientAliveCountMax 1"
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
SSHD_CONFIG="/etc/ssh/sshd_config"
4+
5+
. "$SHARED/utilities.sh"
6+
7+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveInterval "ClientAliveInterval 6000"
8+
assert_directive_in_file "$SSHD_CONFIG" ClientAliveCountMax "ClientAliveCountMax 0"

‎linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/ansible/shared.yml

-8
This file was deleted.

‎linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/bash/shared.sh

-8
This file was deleted.

‎linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/oval/shared.xml

-52
This file was deleted.

‎linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/rule.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ description: |-
1212
1313
To ensure the SSH idle timeout occurs precisely when the
1414
<tt>ClientAliveInterval</tt> is set, set the <tt>ClientAliveCountMax</tt> to
15-
value of <tt>0</tt>. This profile sets <tt>ClientAliveCountMax</tt> to
16-
<tt>{{{ xccdf_value("var_sshd_set_keepalive") }}}</tt>. To modify the
17-
<tt>ClientAliveCountMax</tt> option, edit <tt>/etc/ssh/sshd_config</tt> as
18-
follows:
19-
<pre>ClientAliveCountMax {{{ xccdf_value("var_sshd_set_keepalive") }}}</pre>
15+
value of <tt>0</tt>.
2016
2117
rationale: |-
2218
This ensures a user login will be terminated as soon as the <tt>ClientAliveInterval</tt>
@@ -59,8 +55,15 @@ ocil: |-
5955
To ensure <tt>ClientAliveInterval</tt> is set correctly, run the following command:
6056
<pre>$ sudo grep ClientAliveCountMax /etc/ssh/sshd_config</pre>
6157
If properly configured, the output should be:
62-
<pre>ClientAliveCountMax {{{ xccdf_value("var_sshd_set_keepalive") }}}</pre>
63-
If the option is set to <tt>0</tt>, then the SSH idle timeout occurs precisely when
58+
<pre>ClientAliveCountMax 0</pre>
59+
60+
In this case, the SSH idle timeout occurs precisely when
6461
the <tt>ClientAliveInterval</tt> is set.
65-
If the option is set to a number greater than <tt>0</tt>, then the idle session will be disconnected after
66-
<tt>ClientAliveInterval * ClientAliveCountMax</tt> seconds.
62+
63+
template:
64+
name: sshd_lineinfile
65+
vars:
66+
parameter: "ClientAliveCountMax"
67+
value: "0"
68+
missing_parameter_pass: "false"
69+
kubernetes: "off"

‎ol8/profiles/ospp.profile

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ selections:
5454
- sshd_disable_empty_passwords
5555
- sshd_disable_kerb_auth
5656
- sshd_disable_gssapi_auth
57-
- var_sshd_set_keepalive=0
5857
- sshd_set_keepalive
5958
- sshd_enable_warning_banner
6059
- sshd_rekey_limit

‎rhcos4/profiles/moderate.profile

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ selections:
7676
#- sshd_disable_empty_passwords
7777
#- sshd_disable_kerb_auth
7878
#- sshd_disable_gssapi_auth
79-
#- var_sshd_set_keepalive=0
8079
# AC-2(5)
8180
- sshd_set_keepalive
8281
#- sshd_enable_warning_banner

‎rhcos4/profiles/ncp.profile

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ selections:
7777
#- sshd_disable_empty_passwords
7878
#- sshd_disable_kerb_auth
7979
#- sshd_disable_gssapi_auth
80-
#- var_sshd_set_keepalive=0
8180
#- sshd_set_keepalive
8281
#- sshd_enable_warning_banner
8382
#- sshd_rekey_limit

‎rhel7/profiles/rhelh-stig.profile

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ selections:
211211
- sshd_do_not_permit_user_env
212212
- sshd_enable_strictmodes
213213
- sshd_enable_warning_banner
214-
- var_sshd_set_keepalive=3
215214
- sshd_set_keepalive
216215
- sshd_use_approved_ciphers
217216
- sshd_use_approved_macs

‎rhel8/profiles/cis.profile

-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,6 @@ selections:
827827
- sshd_set_idle_timeout
828828

829829
# ClientAliveCountMax 0
830-
- var_sshd_set_keepalive=0
831830
- sshd_set_keepalive
832831

833832
### 5.2.14 Ensure SSH LoginGraceTime is set to one minute

‎rhel8/profiles/ospp.profile

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ selections:
6363
- sshd_disable_empty_passwords
6464
- sshd_disable_kerb_auth
6565
- sshd_disable_gssapi_auth
66-
- var_sshd_set_keepalive=0
6766
- sshd_set_keepalive
6867
- sshd_enable_warning_banner
6968
- sshd_rekey_limit

‎rhv4/profiles/rhvh-stig.profile

-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ selections:
210210
- sshd_do_not_permit_user_env
211211
- sshd_enable_strictmodes
212212
- sshd_enable_warning_banner
213-
- var_sshd_set_keepalive=3
214213
- sshd_set_keepalive
215214
- sshd_use_priv_separation
216215
- var_system_crypto_policy=fips_ospp

‎sle15/profiles/cis.profile

-1
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ selections:
693693
- sshd_set_idle_timeout
694694

695695
# ClientAliveCountMax 0
696-
- var_sshd_set_keepalive=0
697696
- sshd_set_keepalive
698697

699698
### 5.2.17 Ensure SSH LoginGraceTime is set to one minute

‎tests/data/profile_stability/rhel8/ospp.profile

-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ selections:
228228
- zipl_page_poison_argument
229229
- zipl_slub_debug_argument
230230
- zipl_vsyscall_argument
231-
- var_sshd_set_keepalive=0
232231
- var_rekey_limit_size=1G
233232
- var_rekey_limit_time=1hour
234233
- var_accounts_user_umask=027

‎tests/data/profile_stability/rhel8/stig.profile

-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ selections:
243243
- timer_dnf-automatic_enabled
244244
- usbguard_allow_hid_and_hub
245245
- use_pam_wheel_for_su
246-
- var_sshd_set_keepalive=0
247246
- var_rekey_limit_size=1G
248247
- var_rekey_limit_time=1hour
249248
- var_accounts_user_umask=027

‎tests/shared/utilities.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# $1: Config file
4+
# $2: The directive beginning, e.g. ClientAliveCountMax
5+
# $3: The whole directive beginning, e.g. "ClientAliveCountMax 0". Escape slashes - the argument is used in sed.
6+
function assert_directive_in_file {
7+
if grep -q "^$2" "$1"; then
8+
sed -i "s/^$2.*/$3/" "$1"
9+
else
10+
echo "$3" >> "$1"
11+
fi
12+
}

‎ubuntu1804/profiles/cis.profile

-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ selections:
709709
- sshd_set_idle_timeout
710710

711711
# ClientAliveCountMax 0
712-
- var_sshd_set_keepalive=0
713712
- sshd_set_keepalive
714713

715714
### 5.2.13 Ensure SSH LoginGraceTime is set to one minute

0 commit comments

Comments
 (0)
Please sign in to comment.