[packages/fail2ban] Rel 5. Stop sshd and pam-generic filters banning injected IPs
arekm
arekm at pld-linux.org
Thu Oct 29 08:33:05 CET 2026
commit 1d998c1fcd463f3c2b8fa39af406d797966c44da
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Wed Oct 28 23:50:44 2026 +0100
Rel 5. Stop sshd and pam-generic filters banning injected IPs
Backport upstream ddd879d (sshd "on <ip>" in username) and 789571aa
(pam-generic rhost= injected via ruser).
Fixes CVE-2026-109786.
fail2ban-CVE-2026-109786.patch | 40 ++++++++++++++++++++++++++++++++++
fail2ban-pam-generic-injection.patch | 42 ++++++++++++++++++++++++++++++++++++
fail2ban.spec | 6 +++++-
3 files changed, 87 insertions(+), 1 deletion(-)
---
diff --git a/fail2ban.spec b/fail2ban.spec
index 5fb64f6..52f734c 100644
--- a/fail2ban.spec
+++ b/fail2ban.spec
@@ -6,7 +6,7 @@ Summary: Ban IPs that make too many password failures
Summary(pl.UTF-8): Blokowanie IP powodujących zbyt dużo prób logowań z błędnym hasłem
Name: fail2ban
Version: 1.1.1
-Release: 4
+Release: 5
License: GPL
Group: Daemons
Source0: https://github.com/fail2ban/fail2ban/archive/%{version}.tar.gz
@@ -23,6 +23,8 @@ Patch7: %{name}-gil-switchinterval.patch
Patch8: %{name}-restore-idle-gate.patch
Patch10: %{name}-nginx-block-map-printf.patch
Patch11: %{name}-subnet.patch
+Patch12: %{name}-CVE-2026-109786.patch
+Patch13: %{name}-pam-generic-injection.patch
URL: http://fail2ban.sourceforge.net/
BuildRequires: python3-devel
BuildRequires: python3-modules
@@ -64,6 +66,8 @@ z sshd czy plikami logów serwera WWW Apache.
%patch -P8 -p1
%patch -P10 -p1
%patch -P11 -p1
+%patch -P12 -p1
+%patch -P13 -p1
rm setup.cfg
# jail.conf includes it (logifiles.patch), so the config has to be complete already in the build tree
diff --git a/fail2ban-CVE-2026-109786.patch b/fail2ban-CVE-2026-109786.patch
new file mode 100644
index 0000000..f73a9e0
--- /dev/null
+++ b/fail2ban-CVE-2026-109786.patch
@@ -0,0 +1,40 @@
+CVE-2026-109786: sshd filter took "on <token>" after the host, so a username like
+"x VICTIM-IP on" made fail2ban ban an arbitrary address.
+https://github.com/fail2ban/fail2ban/commit/ddd879d22664904ace24e1255ac6571808c58187
+
+---
+ config/filter.d/sshd.conf | 6 +++---
+ fail2ban/tests/files/logs/sshd | 3 +++
+ 2 files changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/config/filter.d/sshd.conf b/config/filter.d/sshd.conf
+index 80d0c3499d..e4df516e56 100644
+--- a/config/filter.d/sshd.conf
++++ b/config/filter.d/sshd.conf
+@@ -21,9 +21,9 @@ _daemon = sshd(?:-session)?
+ # optional prefix (logged from several ssh versions) like "error: ", "error: PAM: " or "fatal: "
+ __pref = (?:(?:error|fatal): (?:PAM: )?)?
+ # optional suffix (logged from several ssh versions) like " [preauth]"
+-#__suff = (?: port \d+)?(?: \[preauth\])?\s*
+-__suff = (?: (?:port \d+|on \S+|\[preauth\])){0,3}\s*
+-__on_port_opt = (?: (?:port \d+|on \S+)){0,2}
++__on_port_opt = (?: port \d+)?
++__suff = %(__on_port_opt)s(?: \[preauth\])?\s*
++
+ # close by authenticating user (don't use <HOST> after %(__authng_user)s because of catch-all `.*?`):
+ __authng_user = (?: (?:by|from))?(?: (?:invalid|authenticating) user <F-USER>\S+|.*?</F-USER>)?(?: from)?
+
+diff --git a/fail2ban/tests/files/logs/sshd b/fail2ban/tests/files/logs/sshd
+index 961cd79ec2..30cb0a79cc 100644
+--- a/fail2ban/tests/files/logs/sshd
++++ b/fail2ban/tests/files/logs/sshd
+@@ -348,6 +348,9 @@ Jun 6 04:17:04 host sshd[1189074]: Invalid user from 192.0.2.68 port 34916
+ # failJSON: { "time": "2005-06-06T04:17:09", "match": true , "host": "192.0.2.68", "dns": null, "user": "", "desc": "empty user, gh-2749" }
+ Jun 6 04:17:09 host sshd[1189074]: Connection closed by invalid user 192.0.2.68 port 34916 [preauth]
+
++# failJSON: { "time": "2005-06-06T04:17:10", "match": true , "host": "192.0.2.77", "dns": null, "user": "x 192.0.2.1 on", "desc": "Injecting on username 'x 192.0.2.1 on'" }
++Jun 6 04:17:10 host sshd[1189075]: Connection closed by invalid user x 192.0.2.1 on 192.0.2.77 port 4444 [preauth]
++
+ # failJSON: { "match": false, "desc": "ddos-failure without IP, retarded, must be triggered with next (closed) message, gh-3086"}
+ Jun 7 04:10:35 host sshd[424228]: error: kex_exchange_identification: Connection closed by remote host
+ # failJSON: { "time": "2005-06-07T04:10:35", "match": true , "host": "192.0.2.15", "desc": "kex_exchange_identification: Connection closed, gh-3086" }
diff --git a/fail2ban-pam-generic-injection.patch b/fail2ban-pam-generic-injection.patch
new file mode 100644
index 0000000..8003c64
--- /dev/null
+++ b/fail2ban-pam-generic-injection.patch
@@ -0,0 +1,42 @@
+pam-generic filter: an rhost= injected into ruser let the attacker pick the banned
+address; the user field (a real account) is no longer allowed to swallow rhost=.
+https://github.com/fail2ban/fail2ban/commit/789571aa447eb3b5e1adc26442f91619ef4bc652
+
+---
+ config/filter.d/pam-generic.conf | 2 +-
+ fail2ban/tests/files/logs/pam-generic | 12 ++++++++----
+ 2 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/config/filter.d/pam-generic.conf b/config/filter.d/pam-generic.conf
+index 0cadbeeea3..566b2f3eda 100644
+--- a/config/filter.d/pam-generic.conf
++++ b/config/filter.d/pam-generic.conf
+@@ -18,7 +18,7 @@ _daemon = \S+
+
+ prefregex = ^%(__prefix_line)s%(__pam_re)s\s+authentication failure;(?:\s+(?:(?:logname|e?uid)=\S*)){0,3} tty=%(_ttys_re)s <F-CONTENT>.+</F-CONTENT>$
+
+-failregex = ^ruser=<F-ALT_USER>(?:\S*|.*?)</F-ALT_USER> rhost=<HOST>(?:\s+user=<F-USER>(?:\S*|.*?)</F-USER>)?\s*$
++failregex = ^ruser=<F-ALT_USER>(?:\S*|.*?)</F-ALT_USER> rhost=<HOST>(?:\s+user=<F-USER>(?:\S*| +(?!rhost=))*</F-USER>)?\s*$
+
+ ignoreregex =
+
+diff --git a/fail2ban/tests/files/logs/pam-generic b/fail2ban/tests/files/logs/pam-generic
+index 1740f0c8f3..45363ead04 100644
+--- a/fail2ban/tests/files/logs/pam-generic
++++ b/fail2ban/tests/files/logs/pam-generic
+@@ -17,7 +17,11 @@ Jul 19 18:11:26 srv2 vsftpd: pam_unix(vsftpd:auth): authentication failure; logn
+ Jul 19 18:11:26 srv2 vsftpd: pam_unix: authentication failure; logname= uid=0 euid=0 tty=ftp ruser=an8767 rhost=www.google.com
+
+
+-# failJSON: { "time": "2005-07-19T18:11:50", "match": true , "host": "192.0.2.1", "user": "test rhost=192.0.2.151", "desc": "Injecting on username"}
+-Jul 19 18:11:50 srv2 daemon: pam_unix(auth): authentication failure; logname= uid=0 euid=0 tty=xxx ruser=test rhost=192.0.2.151 rhost=192.0.2.1
+-# failJSON: { "time": "2005-07-19T18:11:52", "match": true , "host": "192.0.2.2", "user": "test rhost=192.0.2.152", "desc": "Injecting on username after host"}
+-Jul 19 18:11:52 srv2 daemon: pam_unix(auth): authentication failure; logname= uid=0 euid=0 tty=xxx ruser= rhost=192.0.2.2 user=test rhost=192.0.2.152
++# failJSON: { "time": "2005-07-19T18:11:50", "match": true , "host": "192.0.2.200", "user": "test rhost=192.0.2.100", "desc": "Injecting on username"}
++Jul 19 18:11:50 srv2 daemon: pam_unix(auth): authentication failure; logname= uid=0 euid=0 tty=xxx ruser=test rhost=192.0.2.100 rhost=192.0.2.200
++# failJSON: { "time": "2005-07-19T18:11:52", "match": true , "host": "192.0.2.201", "user": " rhost=192.0.2.101 user=test", "desc": "Attempt to inject on username after host (prefer injection on the `ruser` field over the `user` field)"}
++Jul 19 18:11:52 srv2 daemon: pam_unix(auth): authentication failure; logname= uid=0 euid=0 tty=xxx ruser= rhost=192.0.2.101 user=test rhost=192.0.2.201
++# failJSON: { "time": "2005-07-19T18:11:54", "match": true , "host": "192.0.2.202", "user": "a rhost=192.0.2.102 user=a rhost=192.0.2.103 user=a", "desc": "Attempt to inject on username for both sides (prefer injection on the `ruser` field over the `user` field)"}
++Jul 19 18:11:54 host auth[4242]: pam_unix(someservice:auth): authentication failure; logname= uid=0 euid=0 tty=someservice ruser=a rhost=192.0.2.102 user=a rhost=192.0.2.103 user=a rhost=192.0.2.202 user=
++# failJSON: { "time": "2005-07-19T18:11:54", "match": true , "host": "192.0.2.202", "user": "a rhost=192.0.2.102 user=a rhost=192.0.2.103 user=a", "desc": "Attempt to inject on username for both sides (prefer injection on the `ruser` field over the `user` field), user not logged at all"}
++Jul 19 18:11:54 host auth[4242]: pam_unix(someservice:auth): authentication failure; logname= uid=0 euid=0 tty=someservice ruser=a rhost=192.0.2.102 user=a rhost=192.0.2.103 user=a rhost=192.0.2.202
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/fail2ban.git/commitdiff/1d998c1fcd463f3c2b8fa39af406d797966c44da
More information about the pld-cvs-commit
mailing list