Bug 3211 - DDoS attack by using ssh-keyscan
Summary: DDoS attack by using ssh-keyscan
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 8.3p1
Hardware: Other Linux
: P5 security
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-09 19:14 AEST by kircher
Modified: 2021-03-12 15:02 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kircher 2020-09-09 19:14:31 AEST

    
Comment 1 kircher 2020-09-09 23:16:06 AEST
As we know, sshd provides the MaxStartups limit to restrict the number of connections established at the same time. The ssh-keyscan command is also used to establish connections. Multiple connections are established based on the number of host keys on the server.

Simply put, as long as the ddos attacker executes such a script:

for((i=0;i<1;));do ssh-keyscan [IP address of the attacked host] >/dev/null 2>&1  & done

The CPU usage of the attacked host becomes too high, and it is difficult to accept normal SSH connection requests.
Comment 2 kircher 2020-09-11 11:44:54 AEST
To solve this problem, add the anti-DDoS function to the sshd implementation mechanism.

For example, you are advised to add the SshDdosInterval and SshDdosCountMax parameters to the sshd configuration file. The value of this parameter is that for the client with the same identifier (which can be the IP address, MAC address, or SSH hostkey), the number of successful connections within the period specified by SshDdosInterval cannot exceed the value of SshDdosCountMax.

Adding the Ddos mechanism behind the Maxstartups mechanism is an effective solution.

These are two names that match the ssh naming rules, aren't they?
Comment 3 Darren Tucker 2021-03-12 15:02:15 AEDT
In 8.5 we added PerSourceMaxStartups and PerSourceNetBlockSize which allow limiting startups by source address, optionally grouping nearby addresses into blocks:

     PerSourceMaxStartups
             Specifies the number of unauthenticated connections allowed from
             a given source address, or "none" if there is no limit.  This
             limit is applied in addition to MaxStartups, whichever is lower.
             The default is none.

     PerSourceNetBlockSize
             Specifies the number of bits of source address that are grouped
             together for the purposes of applying PerSourceMaxStartups
             limits.  Values for IPv4 and optionally IPv6 may be specified,
             separated by a colon.  The default is 32:128, which means each
             address is considered individually.

If you set PerSourceMaxStartups to something lower that MaxStartups it will prevent any single address (or block of address if you set PerSourceNetBlockSize) from tying up all of the startups.