Skip to content

Fix: UpdateDiscoveryValues overwrites user-configured ContextName from Report PDUs#28

Open
missaak wants to merge 1 commit into
rqx110:masterfrom
missaak:fix/preserve-context-name
Open

Fix: UpdateDiscoveryValues overwrites user-configured ContextName from Report PDUs#28
missaak wants to merge 1 commit into
rqx110:masterfrom
missaak:fix/preserve-context-name

Conversation

@missaak

@missaak missaak commented Mar 17, 2026

Copy link
Copy Markdown

Problem

UpdateDiscoveryValues() in SecureAgentParameters and UTarget
unconditionally sets _contextName and _contextEngineId from every
incoming SNMPv3 packet's ScopedPdu (lines 540-541, 320-321).

When processing Report PDUs (e.g. usmStatsNotInTimeWindows for time
synchronization), these ScopedPdu fields are typically empty. This
overwrites any user-configured context name, causing subsequent
requests to fail with snmpUnavailableContexts.

Steps to reproduce

  1. Configure SecureAgentParameters with a non-empty ContextName
  2. Send an authenticated SNMPv3 request to a device that returns
    a usmStatsNotInTimeWindows Report
  3. Observe that ContextName is now empty after UpdateDiscoveryValues
  4. The retried request fails with snmpUnavailableContexts

Fix

Only update _contextName and _contextEngineId from the packet when
they 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.

…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant