{"description": "The SSH server sends at most <tt>ClientAliveCountMax</tt> messages\nduring a SSH session and waits for a response from the SSH client.\nThe option <tt>ClientAliveInterval</tt> configures timeout after\neach <tt>ClientAliveCountMax</tt> message. If the SSH server does not\nreceive a response from the client, then the connection is considered unresponsive\nand terminated.\nFor SSH earlier than v8.2, a <tt>ClientAliveCountMax</tt> value of <tt>0</tt>\ncauses a timeout precisely when the <tt>ClientAliveInterval</tt> is set.\nStarting with v8.2, a value of <tt>0</tt> disables the timeout functionality\ncompletely. If the option is set to a number greater than <tt>0</tt>, then\nthe session will be disconnected after\n<tt>ClientAliveInterval * ClientAliveCountMax</tt> seconds without receiving\na keep alive message.", "rationale": "This ensures a user login will be terminated as soon as the <tt>ClientAliveInterval</tt>\nis reached.", "severity": "medium", "references": {"cis-csc": ["1", "12", "13", "14", "15", "16", "18", "3", "5", "7", "8"], "cjis": ["5.5.6"], "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"], "cui": ["3.1.11"], "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)"], "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"], "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"], "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"], "nerc-cip": ["CIP-004-6 R2.2.3", "CIP-007-3 R5.1", "CIP-007-3 R5.2", "CIP-007-3 R5.3.1", "CIP-007-3 R5.3.2", "CIP-007-3 R5.3.3"], "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"], "cis": ["5.1.7"], "pcidss4": ["8.2.8", "8.2"], "stigid": ["UBTU-22-255030"], "stigref": ["SV-260527r986275_rule"]}, "control_references": {"cis": ["5.1.7"], "pcidss4": ["8.2.8", "8.2"], "stigid": ["UBTU-22-255030"]}, "components": [], "identifiers": {}, "ocil_clause": "it is commented out or not configured properly", "ocil": "To ensure <tt>ClientAliveInterval</tt> is set correctly, run the following command:\n<pre>$ sudo grep ClientAliveCountMax /etc/ssh/sshd_config</pre>\nIf properly configured, the output should be:\n<pre>ClientAliveCountMax <sub idref=\"var_sshd_set_keepalive\" /></pre>\nFor SSH earlier than v8.2, a <tt>ClientAliveCountMax</tt> value of <tt>0</tt> causes a timeout precisely when\nthe <tt>ClientAliveInterval</tt> is set.  Starting with v8.2, a value of <tt>0</tt> disables the timeout\nfunctionality completely.\nIf the option is set to a number greater than <tt>0</tt>, then the session will be disconnected after\n<tt>ClientAliveInterval * ClientAliveCountMax</tt> seconds without receiving a keep alive message.", "oval_external_content": null, "fixtext": "", "checktext": "", "vuldiscussion": "", "srg_requirement": "", "warnings": [], "conflicts": [], "requires": ["sshd_set_idle_timeout"], "policy_specific_content": {"stig": {"srg_requirement": "Ubuntu 22.04 Must Terminate All Network Connections Associated With A Communications Session At The End Of The Session, Or As Follows: For In-Band Management Sessions (Privileged Sessions), The Session Must Be Terminated After 10 Minutes Of Inactivity; And For User Sessions (Non-Privileged Session), The Session Must Be Terminated After 15 Minutes Of Inactivity, Except To Fulfill Documented And Validated Mission Requirements.", "vuldiscussion": "Terminating an idle SSH session within a short time period reduces the window of opportunity for unauthorized personnel to take control of a management session enabled on the console or console port that has been left unattended. In addition, quickly terminating an idle SSH session will also free up resources committed by the managed network element.\n\nTerminating network connections associated with communications sessions includes, for example, de-allocating associated TCP/IP address/port pairs at the operating system level and de-allocating networking assignments at the application level if multiple application sessions are using a single operating system-level network connection. This does not mean that the operating system terminates all sessions or network access; it only ends the inactive session and releases the resources associated with that session.\n\nUbuntu 22.04 utilizes /etc/ssh/sshd_config for configurations of OpenSSH. Within the sshd_config the product of the values of \"ClientAliveInterval\" and \"ClientAliveCountMax\" are used to establish the inactivity threshold. The \"ClientAliveInterval\" is a timeout interval in seconds after which if no data has been received from the client, sshd will send a message through the encrypted channel to request a response from the client. The \"ClientAliveCountMax\" is the number of client alive messages that may be sent without sshd receiving any messages back from the client. If this threshold is met, sshd will disconnect the client. For more information on these settings and others, refer to the sshd_config man pages.", "checktext": "Verify that the \"ClientAliveCountMax\" is set to \"<sub idref=\"var_sshd_set_keepalive\" />\" by performing the following command:\n\n$ sudo grep -i countmax /etc/ssh/sshd_config\n\nClientAliveCountMax <sub idref=\"var_sshd_set_keepalive\" />\n\nIf \"ClientAliveCountMax\" do not exist, is not set to a value of \"<sub idref=\"var_sshd_set_keepalive\" />\" in \"/etc/ssh/sshd_config\", or is commented out, this is a finding.", "fixtext": "Configure Ubuntu 22.04 to automatically terminate all network connections associated with SSH traffic at the end of a session or after 10 minutes of inactivity.\n\nModify or append the following lines in the \"/etc/ssh/sshd_config\" file:\n\nClientAliveCountMax 0\n\nIn order for the changes to take effect, the SSH daemon must be restarted.\n\n$ sudo systemctl restart sshd.service"}}, "platform": null, "platforms": [], "sce_metadata": {}, "inherited_platforms": ["system_with_kernel"], "cpe_platform_names": [], "inherited_cpe_platform_names": ["system_with_kernel"], "bash_conditional": null, "fixes": {}, "title": "Set SSH Client Alive Count Max", "definition_location": "/aptdata/openscap/scap-security-guide/linux_os/guide/services/ssh/ssh_server/sshd_set_keepalive/rule.yml", "template": {"name": "sshd_lineinfile", "vars": {"parameter": "ClientAliveCountMax", "xccdf_variable": "var_sshd_set_keepalive", "datatype": "int"}, "backends": {}}}