aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Konovalov <maxim@FreeBSD.org>2026-11-12 00:43:06 +0000
committerMark Johnston <markj@FreeBSD.org>2026-11-17 16:57:23 +0000
commit768ca3a3d301ed38c2043cd0a49bfd14f6a3c801 (patch)
tree261e55a6d1bcb62d762379bf2049c3327b048197
parent870ce74ad739ef535c9a4870b5e5a30f7e0710b6 (diff)
bsnmp: let an SNMPv3 discovery message elicit only a Report
An SNMPv3 message with no variable bindings is treated as RFC 3414 engineID (or time-window) discovery: snmp_input_start() appends a single usmStats counter to the request, and snmp_pdu_auth_access() skips the VACM check because the AUTODISCOVER flag is set. The request's verb was then still dispatched by type. A genuine discovery is a GET and simply reads that counter back -- the intended Report -- but a zero-binding GETNEXT or GETBULK instead walks forward from the appended OID, and with VACM skipped it returns the next registered object(s): an unauthenticated read of the agent's USM and VACM configuration (objects at or after 1.3.6.1.6.3.15). Force the verb of a discovery message to GET, so the appended counter is read as-is and no walk (or SET) can run under the skipped-VACM state. Genuine discovery, which already uses GET, is unaffected. This complements the earlier change that rejects an AUTODISCOVER message carrying its own bindings; that guard is never reached on this path, because the offending binding is appended by the agent after the zero-binding test. Approved by: so Security: FreeBSD-SA-26:89.bsnmp Reviewed by: harti Fixes: 135f7de5ddb6
-rw-r--r--contrib/bsnmp/snmpd/main.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c
index add9ec680eb1..526fbb38b8f8 100644
--- a/contrib/bsnmp/snmpd/main.c
+++ b/contrib/bsnmp/snmpd/main.c
@@ -644,6 +644,15 @@ decoded:
pdu->engine.engine_boots = snmpd_engine.engine_boots;
pdu->engine.engine_time = snmpd_engine.engine_time;
}
+ /*
+ * A discovery message may only elicit a Report. Force GET
+ * so the appended usmStats counter is read back as-is: a
+ * GETNEXT or GETBULK would otherwise walk forward from it,
+ * and a SET act on it, all with VACM skipped for the
+ * AUTODISCOVER flag.
+ */
+ if ((pdu->flags & SNMP_MSG_AUTODISCOVER) != 0)
+ pdu->type = SNMP_PDU_GET;
} else if (pdu->user.auth_proto != SNMP_AUTH_NOAUTH &&
(pdu->engine.engine_boots == 0 || pdu->engine.engine_time == 0)) {
snmpd_usmstats.not_in_time_windows++;