Fix: UpdateDiscoveryValues overwrites user-configured ContextName from Report PDUs#28
Open
missaak wants to merge 1 commit into
Open
Fix: UpdateDiscoveryValues overwrites user-configured ContextName from Report PDUs#28missaak wants to merge 1 commit into
missaak wants to merge 1 commit into
Conversation
…teDiscoveryValues UpdateDiscoveryValues() unconditionally overwrites _contextName and _contextEngineId with values from the incoming packet's ScopedPdu. When processing SNMPv3 Report PDUs (e.g. usmStatsNotInTimeWindows), these fields in the Report are typically empty, which destroys any user-configured context values. This causes SNMPv3 communication to fail with snmpUnavailableContexts on devices that require a non-empty context name for VACM access control. Per RFC 3414 (USM) Section 3.2 and RFC 3412 Section 7.2, the contextName is a locally-configured value that identifies the MIB view for the request. Report PDUs are administrative responses for engine synchronization and should not alter the manager's context configuration. The fix preserves user-set ContextName and ContextEngineId by only updating them from the packet when they have not been explicitly configured (length == 0).
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.
Problem
UpdateDiscoveryValues()inSecureAgentParametersandUTargetunconditionally sets
_contextNameand_contextEngineIdfrom everyincoming SNMPv3 packet's ScopedPdu (lines 540-541, 320-321).
When processing Report PDUs (e.g.
usmStatsNotInTimeWindowsfor timesynchronization), these ScopedPdu fields are typically empty. This
overwrites any user-configured context name, causing subsequent
requests to fail with
snmpUnavailableContexts.Steps to reproduce
SecureAgentParameterswith a non-emptyContextNamea
usmStatsNotInTimeWindowsReportContextNameis now empty afterUpdateDiscoveryValuessnmpUnavailableContextsFix
Only update
_contextNameand_contextEngineIdfrom the packet whenthey have not been explicitly set by the user (i.e.
Length == 0).This is consistent with RFC 3414 (USM for SNMPv3) Section 3.2 and
RFC 3412 Section 7.2: the contextName is a locally-administered value
identifying the MIB view. Report PDUs are administrative engine-sync
responses and should not override the manager's context configuration.