From nobody Tue Nov 17 17:02:56 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 4jTWJK2ybhz71QsM for ; Tue, 17 Nov 2026 17:02:57 +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 4jTWJK0K11z4BLG for ; Tue, 17 Nov 2026 17:02:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934977; 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=wK+3iRXocT/3RYAEAg5ftDvKT2bD13z8RVhdvnq7GAM=; b=uRPup3jsBZBuHf7sPX8s93ntLuOzETStsN3QOYBtTmD0BESZyN4dKXFRY1Qq8m45nWXjXO DGGSw3QJY6Q/KM08rgqyunGrjjGpqxb2Jmy+3/MfSUyy6+pg2pbOaGmErUnvbNy6JoKtLc 3yeeEac5ji72HZPurdS75KCXGd+va2xCcKI4rE2Q06QrYKLV4uJUwkIlvAe5NojuKiT/rD xvSJEezBnhDYuqRvY4BbDotWfY+31BKRagDZZIoybgugUHH/BSA9S9Z8CJot889m0ZnPMg hgoTqhwSCxXLxZWIPpzyT/xZGKALJ3wmre0zBi3+R4I5vFKIJ4YjmL9ePxNFcg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794934977; b=QHVlpP9Yp64QHQDtJUudslupxqvqck7zaXBS+aNO/lhSFs/UgvqzJzKgriZZP7EtxdGlOJ 8RJ2HtWh6GOStmX71O7Z8EOwGhuCZELZFj3R4kjYgUpN74ZOdTH2yZnsTQEVrm8QCQV4KE JHuvIYYcAGpvaYP5iARs/bfAZuU9kL45CBYXcZSqg05ghxjTEc154mKsTOzPM/DZtWhxBQ RXhOIxqx6O7W480Bvx2FCDzgNVmYkWXxSwUn/zYpkhO84bUqBHDsY6Hy3Sy1Mt06elu53L gG9dg6AU4yBGQ74OC8HDTOgiYoJzBgEUL5HDtZtc2LUrL6Qa2T4mw4xCuKAbXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794934977; 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=wK+3iRXocT/3RYAEAg5ftDvKT2bD13z8RVhdvnq7GAM=; b=gTaFOv7yAaPzcc5f+TkpvmzHitqAt4jQ/doLi4ZxvU+Ccm4cqz8F95OhpcCPD0jTHAiCOT AwpysnLMXYo/MCp2OLy+iW1yK+sGjC66NWTe6FLpXU+omglmFIFkkJC7c8yjk6ZuOgTTe0 zJ0fT0ZCucm3spq2ZwWB0jVL2Smn7yTqwmB2s8t2Vv9mcRA/xWwfSVCKK+25Dj+XzITJlJ 8tzsBkrHFabWEhwB7ZxWD4qooZkC0393YTpxAS3Zskokti9aidGOFIN+DmJbfa0YBTS9D/ IaS5WRM05JEg3/kvUIHtlazoYciNM61dTLJa7PQRyW0qL8mWyrA3UBTkLHPOYg== 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 4jTWJJ74QpzrgJ for ; Tue, 17 Nov 2026 17:02:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e311 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:02:56 +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: ba50c421ea0e - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: ba50c421ea0edf7ebabd3b1ad25cebc0ade93eab Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:02:56 +0000 Message-Id: <6afc88c0.1e311.60a305fa@gitrepo.freebsd.org> The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ba50c421ea0edf7ebabd3b1ad25cebc0ade93eab commit ba50c421ea0edf7ebabd3b1ad25cebc0ade93eab Author: Maxim Konovalov AuthorDate: 2026-11-13 03:00:02 +0000 Commit: Mark Johnston CommitDate: 2026-11-17 13:24:11 +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);