#873845 fail2ban-regex does not match with default sshd-ddos filter

#873845#5
Date:
2017-08-31 16:25:23 UTC
From:
To:

#873845#10
Date:
2017-12-20 18:55:58 UTC
From:
To:
The regex in sshd-ddos.conf is:
^%(__prefix_line)sDid not receive identification string from <HOST>\s*$
But the lines I see in auth.log are:
Did not receive identification string from A.B.C.D port 12345
So the regex need to be updated to something like:
...from <HOST>.*$
m.

#873845#15
Date:
2019-07-19 08:54:07 UTC
From:
To:
Dear Maintainer,

This attack is in active use right now and this TWO YEARS OLD bug is
preventing fail2ban from doing anything about it!

Jul 19 06:59:33 amibe sshd[32728]: Did not receive identification string from 47.96.156.238 port 54886
Jul 19 07:00:21 amibe sshd[1320]: Invalid user nathan from 47.96.156.238 port 58080
Jul 19 07:00:21 amibe sshd[1320]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=47.96.156.238
Jul 19 07:00:23 amibe sshd[1320]: Failed password for invalid user nathan from 47.96.156.238 port 58080 ssh2
Jul 19 07:10:29 amibe sshd[6777]: Connection closed by 47.96.156.238 port 43090 [preauth]


The current OpenSSH server may not be vulnerable to this attack but this
is a missed opportunity for blocking the attacker before it switches to
plain password scanning as shown above.

And yet the fix is very simple, just allow the presence of the source
port at the end of the log line:
(from /etc/fail2ban/filter.d/sshd.conf)


mdre-ddos = ^Did not receive identification string from <HOST>%(__suff)s%(__on_port_opt)s$


Note that __on_port_opt matches 0 or more characters so this does not
prevent the regexp from matching log lines that don't include the source
port number.