[openssh-commits] [openssh] 03/03: upstream: limit the number of keyboard-interactive devices accepted

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Nov 11 10:22:24 AEDT 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 268bdcb0c80876d97abdc74a1ca8992a1fdf7652
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Tue Nov 10 23:19:56 2026 +0000

    upstream: limit the number of keyboard-interactive devices accepted
    
    to 100, avoiding a small CPU DoS in sshd-auth (mitigted by MaxStartups and
    PerSourcePenalties).
    
    Reported by Lei Li (李磊) and Zhongke Guyuan (中科固源)
    
    ok markus@
    
    OpenBSD-Commit-ID: ee61d8c17137ec8cc946089337e0c3f98cc3969f
---
 auth2-chall.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/auth2-chall.c b/auth2-chall.c
index 8a23ca2dc..1a4d26438 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth2-chall.c,v 1.61 2026/07/06 07:44:48 djm Exp $ */
+/* $OpenBSD: auth2-chall.c,v 1.62 2026/11/10 23:19:56 djm Exp $ */
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  * Copyright (c) 2001 Per Allansson.  All rights reserved.
@@ -49,6 +49,9 @@
 /* import */
 extern ServerOptions options;
 
+#define SSH_CHALLENGE_MAX_RESPONSES	100
+#define SSH_CHALLENGE_MAX_DEVICES	100
+
 static int auth2_challenge_start(struct ssh *);
 static int send_userauth_info_request(struct ssh *);
 static int input_userauth_info_response(int, uint32_t, struct ssh *);
@@ -80,6 +83,7 @@ struct KbdintAuthctxt
 	KbdintDevice *device;
 	u_int nreq;
 	u_int devices_done;
+	u_int devices_tried;
 };
 
 #ifdef USE_PAM
@@ -159,6 +163,11 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
 	if (kbdintctxt->device)
 		kbdint_reset_device(kbdintctxt);
 	do {
+		if (++kbdintctxt->devices_tried > SSH_CHALLENGE_MAX_DEVICES) {
+			error_f("too many devices attempted");
+			return 0;
+		}
+
 		len = kbdintctxt->devices ?
 		    strcspn(kbdintctxt->devices, ",") : 0;
 
@@ -182,7 +191,7 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
 		t = kbdintctxt->devices;
 		kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;
 		free(t);
-		debug2("kbdint_next_device: devices %s", kbdintctxt->devices ?
+		debug2_f("devices %s", kbdintctxt->devices ?
 		    kbdintctxt->devices : "<empty>");
 	} while (kbdintctxt->devices && !kbdintctxt->device);
 
@@ -315,7 +324,7 @@ input_userauth_info_response(int type, uint32_t seq, struct ssh *ssh)
 		fatal_fr(r, "parse packet");
 	if (nresp != kbdintctxt->nreq)
 		fatal_f("wrong number of replies");
-	if (nresp > 100)
+	if (nresp > SSH_CHALLENGE_MAX_RESPONSES)
 		fatal_f("too many replies");
 	if (nresp > 0) {
 		response = xcalloc(nresp, sizeof(char *));

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list