From nobody Tue Nov 17 17:05:19 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTWM34vScz71RlZ for ; Tue, 17 Nov 2026 17:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWM33Gmhz4GyR for ; Tue, 17 Nov 2026 17:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZNLFaMOIuQ45nrLs2tFANZQPQUSXTM0s4F7CTAWli3g=; b=VZQVZZkPRhhYh9cI33bk3bYn6QRHsD3/fVdsO6b1Ie2dqj0dhsGgi7pxQv+rV06maCPIZr sUYARX3fA6MnRXbgk2m28sI5N4C88xFyyxi3hu0ZdewR4TJyfrMCi+bJuWP1hNxILXNvZn SNePFM6tsFViVum/HBBCn8fv1tm61qsqohwDDPQ0VYjE6BoRS9UNo69fJsIMSn/v86kQcm LJVcy2j+XBsiPR7TRlkMo7pRoeOogwmhfI/vTAJ/vDQ+KJL07G1npaisouzeOfh972qtlt 42I+vRyeHRV6weST+J2hju6oigjbxih+CwPkOlM+5R6JsLRMgsdDuZdygRRMAQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935119; b=tFJo9NeHiCZx+oUHmYEzaPRxDVvUNAXovUVWV3zlZ3NHH/o4UXIntPruC2z2KdfrYFfYFp bcfqJ5cjBUzzsjSIW7T1h7pFhGCVJ6epkB/ZiZVj+j5Mv+80dwFzc/4S2k/D0zqhaGlfRX tahhRAdR7nPqguRzPvdnEYKneUD5g3C19xWtaziJCl+YlS1ueCyWPlm1kn+uVilMEfMwGy YBH7bmiEy/bXY1g6jp1/Sh0hqUdtNGtQVhOHNgbkL7H4C5tIRVIvtiEQw5J6aF1ungi3tG B75mzoALB6tY40SUCuvo19KZRtz5FTP9x8VA7rCRmBRVG6PunZEr/S2OFNrsWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZNLFaMOIuQ45nrLs2tFANZQPQUSXTM0s4F7CTAWli3g=; b=apag4gU6g/PcaIkeXMpti1AgCh8nchzMMwxFt6d4R2NgcnQzLh40EemvOBcEfn71m/UBg8 dp5Rh2+4iyFBSCKTf9bGr/gwKTmSr2xsuz8+OuX7n8FMh397kPM5r+GdJlYShPgs+Hf1JB zjvn//IijarBanZbRTkClg3Ho09/XSTptB7+d2jSUfJt7yeC3ju+t+gDNcbO+xlAjBMYC8 XkpeUfosh0cz9s2XLToa/Jt9j35UKIWKfoEA0thWzgqxWk9p6MoBryzJewwPkuvBeKw88T mqe+rOvRfjax8vC73/1oO9MAsROW4xDY0S+YYc2iKYLIIMXdgoK/lgVBglZJ6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWM32ws5zrVg for ; Tue, 17 Nov 2026 17:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1fb98 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:05:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Maxim Konovalov From: Mark Johnston Subject: git: 4f68e37d9ce6 - releng/14.5 - bsnmp: do not act on an SNMPv3 discovery message that carries bindings List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.5 X-Git-Reftype: branch X-Git-Commit: 4f68e37d9ce6b39dc3175e975eec7c31dd6e8cb5 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:05:19 +0000 Message-Id: <6afc894f.1fb98.32fc70ac@gitrepo.freebsd.org> The branch releng/14.5 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4f68e37d9ce6b39dc3175e975eec7c31dd6e8cb5 commit 4f68e37d9ce6b39dc3175e975eec7c31dd6e8cb5 Author: Maxim Konovalov AuthorDate: 2026-11-13 03:00:02 +0000 Commit: Mark Johnston CommitDate: 2026-11-16 21:17:13 +0000 bsnmp: do not act on an SNMPv3 discovery message that carries bindings An SNMPv3 message with an empty engine id and empty user name is handled as snmpEngineID discovery: snmp_pdu_auth_user() sets SNMP_MSG_AUTODISCOVER and returns without a USM user, and snmp_pdu_auth_access() then grants the message access. A genuine discovery request carries no variable bindings and only elicits a Report, but a discovery PDU that did carry bindings was executed anyway -- so a GET or SET ran with no authentication and without the VACM access check. This affects two cases. With an empty user name the message is wholly unauthenticated, so anyone able to reach the agent could issue a SET. It also affects a configured noAuthNoPriv user: such a user has no digest to verify, so it too can set the AUTODISCOVER flag (an authenticated request before time synchronisation) and have a bindings-carrying PDU bypass VACM and operate outside its views. Refuse any AUTODISCOVER message that arrives with variable bindings instead of acting on it. Empty-binding discovery, the authenticated time-window exchange, and ordinary authenticated SNMPv3 are unaffected. While here, free the PDU on the SNMPD_INPUT_FAILED path of snmpd_input(). Every other path releases it, but the failed path consumed the datagram and returned without freeing the decoded bindings -- so a rejected PDU leaked any heap they held, such as the buffer for an OCTET STRING in a SET. Rejecting a bindings-carrying discovery message now reaches that path, so an unauthenticated client could otherwise grow the agent's memory without bound. For that free to be safe, snmp_input_start() must leave the PDU in a defined state on every return. It zeroed the PDU only after the initial snmp_pdu_snoop() check, so a malformed datagram that failed the snoop returned SNMPD_INPUT_FAILED with the caller's PDU uninitialised; freeing it would then walk a garbage binding count. Zero the PDU up front, before the snoop, so all of these paths leave an empty PDU that frees cleanly. Approved by: so Security: FreeBSD-SA-26:89.bsnmp Security: CVE-2026-127742 Reviewed by: harti Fixes: 135f7de5ddb6 --- contrib/bsnmp/snmpd/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c index 928b84121f82..d1377756b64e 100644 --- a/contrib/bsnmp/snmpd/main.c +++ b/contrib/bsnmp/snmpd/main.c @@ -496,6 +496,10 @@ snmp_input_start(const u_char *buf, size_t len, const char *source, ret = SNMPD_INPUT_OK; + /* Zero the PDU before anything can return, so a failure path that + * runs before the header is decoded still leaves it safe to free. */ + memset(pdu, 0, sizeof(*pdu)); + /* look whether we have enough bytes for the entire PDU. */ switch (sret = snmp_pdu_snoop(&b)) { @@ -508,7 +512,6 @@ snmp_input_start(const u_char *buf, size_t len, const char *source, } b.asn_len = *pdulen = (size_t)sret; - memset(pdu, 0, sizeof(*pdu)); if ((code = snmp_pdu_decode_header(&b, pdu)) != SNMP_CODE_OK) goto decoded; @@ -645,6 +648,17 @@ decoded: (pdu->engine.engine_boots == 0 || pdu->engine.engine_time == 0)) { snmpd_usmstats.not_in_time_windows++; ret = SNMPD_INPUT_FAILED; + } else if ((pdu->flags & SNMP_MSG_AUTODISCOVER) != 0) { + /* + * A discovery message (RFC 3414) may only elicit a Report and + * carries no variable bindings of its own. Reaching here with + * bindings means the message was not authenticated as a user + * (empty security name, or a noAuthNoPriv user): acting on it + * would run a GET or SET that bypasses USM authentication and + * the VACM access check. Refuse it. + */ + snmpd_usmstats.unknown_users++; + ret = SNMPD_INPUT_FAILED; } if ((code = snmp_pdu_auth_access(pdu, ip)) != SNMP_CODE_OK) @@ -1088,6 +1102,7 @@ snmpd_input(struct port_input *pi, struct tport *tport) * check the access first. We don't want to return an error response * to a proxy PDU with a wrong community */ if (ierr == SNMPD_INPUT_FAILED) { + snmp_pdu_free(&pdu); /* for streaming transports this is fatal */ if (pi->stream) return (-1);