Repository navigation
fix: answer a request only with a Response or a Report - #49
Merged
Merged
Conversation
The fake agent can reflect a request. A reflected request carries the client's own msgID, request ID and, when authenticated, its own digest and ciphertext, and the client returns it as a successful reply: a Get at noAuthNoPriv and authNoPriv, a Set at authNoPriv and authPriv, and an SNMPv2c Get.
answers never checked the reply's PDU type, so a request sent back unchanged, which carries the client's own msgID, request ID and digest, was returned as a successful reply at every security level, a Set included. A reply that is not a Report reportKindOf maps now answers only as a Response (GetResponse), as in net-snmp; other PDU types, and a Report with more than one varbind, are read past.
The discovery request carries no varbinds, so before the PDU-type check the empty-reply rule took it, reflected, as the discovery answer, and an authenticated request then failed for want of a key. It is read past now and the retry discovers the engine.
ilyam8
marked this pull request as ready for review
October 11, 2026 16:31
stelfrag
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The client accepted a packet that is not a response as the answer to its request. A request sent back unchanged (by a
loop, a misconfigured proxy, a NAT hairpin, or any on-path sender, with no key needed) carries the client's own msgID,
request ID and, when authenticated, its own digest and ciphertext, so it passed every check and was returned as a
successful reply at every security level: a Get returned its own
Nullvarbinds, and a Set reported success althoughno agent received it.
answersnow takes a reply only as a Report or a Response, as net-snmp does (it matches only Response and Report PDUsto outstanding requests).
Behavior
GetResponse); a request PDU, atrap or any other PDU type is read past, in every SNMP version, as are Reports from SNMPv1 or SNMPv2c messages.
was taken as the discovery answer, and an authenticated request then failed for want of a key; now it is read past
and the retry discovers the engine.
was returned as a successful reply). net-snmp maps such a Report by its first varbind instead.
an error status answers before its request ID is checked; the security model, level and context of a reply are not
compared with the request's.
Commits
test:reflected requests (Get at noAuthNoPriv and authNoPriv, Set at authNoPriv and authPriv, an SNMPv2c Get),pinned on the code before the fix with the fake agent's new
reflectanswer.fix:the PDU-type check inanswers; five pinned known bugs flip (requests/answer/{not-a-response,report,v1-trap},v3/answer/report-two-varbinds{,-error-oid}).test:a reflected discovery request.Validation
walkandv3-fipsunchanged.go test -race, FIPS 140-only,GOARCH=386, the end-to-end suite against snmpd 5.9.3, golangci-lint, cross-builds,govulncheck: pass locally.