From nobody Tue Nov 17 17:04:21 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 4jTWKx6cSXz71R5v for ; Tue, 17 Nov 2026 17:04:21 +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 4jTWKx4k4zz4Fm6 for ; Tue, 17 Nov 2026 17:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935061; 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=Kw/DhNczm4Uxt3e/BkVVJw4WmEe3F3zwjJngbkmbFLA=; b=GE3IXt4ebOx9yJl7rmb8REUuxG14Tic+AeZkL5lxpqTCVEqZ3e6p68EMwoKhZAg+vlC+Lz Y94LpK4xgv/03LlL9tIlNyU2Jk76KIZ7p/wRHnJWTmI58q2aOEM9q7JTpVvx47StncF9fA PyrI62RYW/ttoC0mDRlDNcRenWoelNj3FyI6BO2o5E7HTK9Y6N1m/bSRZ3q44SzTtrC23r xBQUMaptT4hQ2f5gVUu5ejFL0zksnPS73E8BkDGUnPLMfcu//VFMMlmIqeSirIOy1p+/e5 dqGqcBVOpUB7jBz8ovp92/VFJSmcCVIWnF9KyXGcTN70Wyg8YaF8GoY6w2IMZQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935061; b=wQm+xC1Dk7T6yQKwPOuEsbTdXkIzzPgW1OoNToI1fjoMdVBT3P8H9iXDHsVGOVxhekQ4sc nj6V3KA2ZNSmpBK6dqmREKDJ0YS3uLofud0X9dUn8w6WPcrGBSFdzt6wPKd8L1fBPnqXbQ rX7gfB7+KtWR5xS9HSO9R/rFY5qzVph1JUcGolflYU/8Q+VEaq+g4t+eq01p/NVqz3Bduc UbJySzrWHXHGHiToWhv4ZlT0js42Ql56vtbIUZrMH5dgL9EEuO4X3TEHWnXkFt/RoCulZi Q+CKw/7cLvlQxlmNOxeYNgeEo5fEk257rRNSRtiuiH7oZQ71flNQ8Bx4zfhDWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935061; 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=Kw/DhNczm4Uxt3e/BkVVJw4WmEe3F3zwjJngbkmbFLA=; b=SGEwfFBr7/XU1rnqUga8f9iTLsF6pqPPdLBjgEhCH4FvUiCJ6aMxqa1nrqMUGkV7BG3Fey Z1b/L6BIPN7b50uHLDQm8Cza9z+xu/mfbqhGJ4POlXlZKr6k6hztFqBXTZvBmswkuntlg0 h0ehIk6Q9bYqedyQStpRHfiU4Q8jc7CVT0vhkNTLULsaVr4+pw8wPNRgE4ChyhHaPXIHEB NfpmLpP8WNVKx6trndwtfPd3uWxdKUe1Ta+LAuHfjLhHiVkjy04exKiCT2pTEgODJJjRAM BibmerB3UDNMCh6z6HwERv/ccproe1htYUvhRVf5RnB2PsIawYamn/H9IesHEg== 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 4jTWKx4NRzzrRx for ; Tue, 17 Nov 2026 17:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1cee0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:04:21 +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: cfb1a82d49c5 - releng/14.4 - 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.4 X-Git-Reftype: branch X-Git-Commit: cfb1a82d49c5fa7ef32c1d9a79b160b60138b9b7 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:04:21 +0000 Message-Id: <6afc8915.1cee0.46df718c@gitrepo.freebsd.org> The branch releng/14.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cfb1a82d49c5fa7ef32c1d9a79b160b60138b9b7 commit cfb1a82d49c5fa7ef32c1d9a79b160b60138b9b7 Author: Maxim Konovalov AuthorDate: 2026-11-13 03:00:02 +0000 Commit: Mark Johnston CommitDate: 2026-11-16 21:16:22 +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);