git: 3de83038140e - main - bsnmp: mask reserved SNMPv3 msgFlags bits on input
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:01:59 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=3de83038140eb83ea5b74436e3730715a7bc5418
commit 3de83038140eb83ea5b74436e3730715a7bc5418
Author: Maxim Konovalov <maxim@FreeBSD.org>
AuthorDate: 2026-11-12 00:43:05 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 16:57:01 +0000
bsnmp: mask reserved SNMPv3 msgFlags bits on input
snmp_pdu_decode_header() reads the msgFlags octet straight into
pdu->flags and never sanitises it. Only bits 0..2 are defined on the
wire (authFlag, privFlag, reportableFlag). Bit 7 (0x80) is bsnmp's
internal SNMP_MSG_AUTODISCOVER marker: it shares the same field and is
tested later as "this is discovery, skip USM and VACM".
Because the byte is taken verbatim from an unauthenticated peer, a
client that sets bit 7 of msgFlags has (pdu->flags &
SNMP_MSG_AUTODISCOVER) read true straight after header decode, forging
the discovery state. A noAuthNoPriv user -- which has no digest to
verify -- can thus mark an ordinary request as discovery and have it
bypass the VACM access check, operating outside its configured views.
Keep only the three defined wire bits when decoding msgFlags, so the
internal marker can never be set from the network.
Approved by: so
Security: FreeBSD-SA-26:89.bsnmp
Reviewed by: harti
Fixes: 135f7de5ddb6
---
contrib/bsnmp/lib/snmp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/contrib/bsnmp/lib/snmp.c b/contrib/bsnmp/lib/snmp.c
index d1dabc8884a0..acdf5df0c683 100644
--- a/contrib/bsnmp/lib/snmp.c
+++ b/contrib/bsnmp/lib/snmp.c
@@ -523,6 +523,13 @@ snmp_pdu_decode_header(struct asn_buf *b, struct snmp_pdu *pdu)
snmp_error("cannot decode msg flags");
return (SNMP_CODE_FAILED);
}
+ /*
+ * msgFlags is attacker-controlled. Keep only the three
+ * defined wire bits, so a client cannot forge an internal
+ * marker that shares this byte (SNMP_MSG_AUTODISCOVER).
+ */
+ pdu->flags &= (SNMP_MSG_AUTH_FLAG | SNMP_MSG_PRIV_FLAG |
+ SNMP_MSG_REPORT_FLAG);
if (asn_get_integer(b, &pdu->security_model) != ASN_ERR_OK) {
snmp_error("cannot decode msg size");