Skip to content

Commit bcd88de

Browse files
committed
upstream: kbd-interactive device names should be matched against
the full device name, not a prefix. Doesn't matter in practice as there is only one kbd-int device supported (PAM xor BSD auth), and an attacker would still need to successfully authenticate against an incorrectly-selected device. reported by ashamedbit, NobleMathews; ok deraadt@ OpenBSD-Commit-ID: cf75d4f99405fbb41354c4ae724a3b39a3b58f82
1 parent b1c4bf5 commit bcd88de

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

auth2-chall.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: auth2-chall.c,v 1.54 2020/10/18 11:32:01 djm Exp $ */
1+
/* $OpenBSD: auth2-chall.c,v 1.55 2025/09/29 02:32:15 djm Exp $ */
22
/*
33
* Copyright (c) 2001 Markus Friedl. All rights reserved.
44
* Copyright (c) 2001 Per Allansson. All rights reserved.
@@ -154,7 +154,7 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
154154
{
155155
size_t len;
156156
char *t;
157-
int i;
157+
size_t i;
158158

159159
if (kbdintctxt->device)
160160
kbdint_reset_device(kbdintctxt);
@@ -165,11 +165,14 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
165165
if (len == 0)
166166
break;
167167
for (i = 0; devices[i]; i++) {
168+
if (i >= sizeof(kbdintctxt->devices_done) * 8)
169+
fatal_f("internal error: too may devices");
168170
if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
169171
!auth2_method_allowed(authctxt,
170172
"keyboard-interactive", devices[i]->name))
171173
continue;
172-
if (strncmp(kbdintctxt->devices, devices[i]->name,
174+
if (strlen(devices[i]->name) == len &&
175+
memcmp(kbdintctxt->devices, devices[i]->name,
173176
len) == 0) {
174177
kbdintctxt->device = devices[i];
175178
kbdintctxt->devices_done |= 1 << i;

0 commit comments

Comments
 (0)