upstream: fix inconsistency between unpriv hostbased code and

monitor that could be used to probe account existence when this
authentication method is enabled.

Anthropic ANT-2026-60RCCQ1O

OpenBSD-Commit-ID: 07605a647a738f383678f244926cd43e833dba8c
This commit is contained in:
djm@openbsd.org authored and Damien Miller committed 2026-10-30 20:16:30 +11:00
1 parent d62150ded3
commit 3b42f3a2f4
2 files changed
+11 -4

No files matched your search

+7 -3
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: auth2-hostbased.c,v 1.59 2026/09/16 00:31:27 djm Exp $ */
/* $OpenBSD: auth2-hostbased.c,v 1.60 2026/10/30 06:35:25 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -62,7 +62,7 @@ userauth_hostbased(struct ssh *ssh, const char *method)
Authctxt *authctxt = ssh->authctxt;
struct sshbuf *keyblob = NULL, *b = NULL;
struct sshkey *key = NULL;
char *pkalg, *cuser, *chost;
char *pkalg, *cuser, *chost, *userstyle = NULL;
u_char *sig;
size_t alen, slen;
int r, pktype, authenticated = 0;
@@ -136,9 +136,12 @@ userauth_hostbased(struct ssh *ssh, const char *method)
if ((b = sshbuf_new()) == NULL)
fatal_f("sshbuf_new failed");
/* reconstruct packet */
xasprintf(&userstyle, "%s%s%s", authctxt->user,
authctxt->style ? ":" : "",
authctxt->style ? authctxt->style : "");
if ((r = sshbuf_put_stringb(b, ssh->kex->session_id)) != 0 ||
(r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 ||
(r = sshbuf_put_cstring(b, authctxt->user)) != 0 ||
(r = sshbuf_put_cstring(b, userstyle)) != 0 ||
(r = sshbuf_put_cstring(b, authctxt->service)) != 0 ||
(r = sshbuf_put_cstring(b, method)) != 0 ||
(r = sshbuf_put_string(b, pkalg, alen)) != 0 ||
@@ -168,6 +171,7 @@ done:
sshbuf_free(b);
sshbuf_free(keyblob);
free(pkalg);
free(userstyle);
free(cuser);
free(chost);
free(sig);
+4 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: auth2.c,v 1.176 2026/09/16 00:37:07 djm Exp $ */
/* $OpenBSD: auth2.c,v 1.177 2026/10/30 06:35:25 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -292,6 +292,9 @@ input_userauth_request(int type, uint32_t seq, struct ssh *ssh)
if ((style = strchr(user, ':')) != NULL)
*style++ = 0;
/* An empty style is no style; the monitor treats it the same way. */
if (style != NULL && *style == '\0')
style = NULL;
if (authctxt->attempt >= 1024)
auth_maxtries_exceeded(ssh);