You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server: audit in the service envelope, specific audits for user management and KeyCredential push - #5226
transport (AuditOpenSecureChannel / AuditChannel / AuditCertificate*)
transport
transport
unchanged
Not audited at all (unchanged): a request that fails in ValidateRequestAsync (no session, bad token, too busy) never reaches the envelope's try, so there is no operation context and no ClientUserId; auditing them would flood the trail with unauthenticated noise.
AuditUpdateMethodEventType (Part 18 has no specific type; §6.5.9 needs this type or a subtype)
passwords → null Variant
nothing on success; only a call rejected by the dispatcher (method permissions) raised the dispatcher's AuditUpdateMethodEventType
one event per call: success, failure, RoleAuthorizationGate denial, a provider that throws, and a call MethodState rejects in argument validation (no arguments copied); ActionTimeStamp = call start
KeyCredential UpdateCredential (Part 12 §8.6.9)
KeyCredentialUpdatedAuditEventType, ResourceUri
CredentialSecret → AuditEvents.RedactedPrivateKey
nothing
one event per call (incl. a throwing store and a validation reject)
KeyCredential DeleteCredential (§8.6.10)
KeyCredentialDeletedAuditEventType, ResourceUri
none
nothing
one event per call
KeyCredential CreateCredential
AuditUpdateMethodEventType (no specific type in Part 12)
all (no secret)
nothing
one event per call
KeyCredential GetEncryptingKey
none (read-only; §6.5.9 "may")
nothing
nothing
RoleType Add/Remove Identity/Application/Endpoint
RoleMappingRuleChangedAuditEventType
2 sites per method
1 site per method, same events
Correction to the review: there is no generic success-path method audit in the server. The "generic method-call audit" is only the dispatcher's AuditUpdateMethodEventType for call items rejected before the method runs. A generic post-call audit for every method would double-emit wherever a method raises its own subtype, so it is left out (follow-up if wanted: an opt-out flag on MethodState).
Trigger consolidation
5 per-service fault lambdas in StandardServer → one ReportServiceFaultAudit(RequestType, …) switch.
RoleStateBinding 12 → 6 sites.
Left in place (domain-specific): certificate/TrustList push (ConfigurationNodeManager.PushMethods, TrustList — SS-5 area), session establishment/close/timeout, secure channel, AuditWriteUpdate/History per operation in the dispatcher/historian, Cancel success in RequestManager, TransferSubscriptions per subscription in SubscriptionManager (SB-4 area).
Everything goes through IAuditEventSink: ServerInternalData.ReportEvent/ReportEventAsync now route any AuditEventState to the sink. Before, audit events that node managers raise on nodes (conditions, programs, ConfigurationUpdated, FiniteStateMachine transitions) reached the address space but skipped a host sink. The one remaining bypass: AuditEvents.ReportTrustList*AuditEvent overloads called with a null server fall back to TrustListState.ReportEvent; in-tree TrustList always passes its server (SetAuditEventServer). Also note: the TrustList helpers do not check Auditing themselves; ServerInternalData.ReportAuditEvent does.
Behaviour changes
CloseSession that fails with a service fault raises AuditSessionEventType (Status false).
Cancel that fails with a service fault raises AuditCancelEventType with the fault status.
TransferSubscriptions that fails with a service fault raises one AuditSessionEventType (SourceNode = session).
UserManagement methods raise AuditUpdateMethodEventType on every call (passwords redacted).
KeyCredential Update/Delete raise their Part 12 types, Create raises AuditUpdateMethodEventType.
A host IAuditEventSink now also receives audit events raised through IServerInternal.ReportEvent/ReportEventAsync (conditions, programs, configuration), once per publication: an occurrence that reaches the server through several root notifiers is delivered to the sink once, as the Server object publishes it once (an independent publication of the same instance is delivered again). ReportEventAsync awaits the sink when it is an IAsyncAuditEventSink (new public interface, implemented by AddressSpaceAuditEventSink and CompositeAuditEventSink; new ServerInternalData.PublishAuditEventAsync), so a full event channel does not block the caller and the cancellation token is observed, with or without a host sink.
NodeManagement failure audits are now skipped up front when auditing is off (the helpers already returned early; no observable change).
The session-service fault audits (CloseSession, TransferSubscriptions) take ClientUserId from the request's captured identity (OperationContext.ClientUserId), not the session's current one, so a reactivation under another user during the request does not re-attribute the failure.
Method audits record the ActionTimeStamp when the call started (ReportAuditMethodCallEvent gained an optional actionTimeStamp), not when it returned.
No change to event queues, queue sizes or overflow events (CTT Auditing group).
Tests
Opc.Ua.Server.Tests/Diagnostics/ServiceAuditEnvelopeTests (in-process StandardServer with a capturing sink): Read/HistoryRead/Write/HistoryUpdate/Call faults → exactly one AuditEventType with SourceName, Status, ActionTimeStamp, ServerId, ClientAuditEntryId, ClientUserId; TransferSubscriptions fault; CloseSession fault (table); Browse/CreateMonitoredItems/Publish/AddNodes/Cancel → no generic event; AddNodes fault → only AuditAddNodesEventType; Cancel success → one AuditCancelEventType; successful Read → nothing; audit events reported as plain events reach the sink, plain events do not; auditing off → nothing at all; an audit event through two root notifiers reaches the sink once (sync and async), an independent publication again; ReportEventAsync with a waiting composite sink does not complete synchronously and is cancelled by the token; a session fault after a simulated reactivation names the original user.
UserManagementBindingTests.Audit: four methods → four AuditUpdateMethodEventType with the fields, no password in arguments; denied call → Status false with the caller's ClientUserId; auditing off → nothing; a throwing provider → Status false then rethrow; an argument-validation reject through MethodState.CallAsync → Status false without arguments and the handler never runs; ActionTimeStamp ≤ handler entry.
KeyCredential/KeyCredentialPushAuditTests: Create/Update/Delete → AuditUpdateMethod / KeyCredentialUpdated / KeyCredentialDeleted with ResourceUri and redacted secret; denied update → Status false; auditing off → nothing. A throwing store → Status false, ResourceUri, redacted secret; argument-validation rejects of Create/Update/Delete → their own types, Status false, ResourceUri on Update/Delete, no arguments.
Local runs (net10.0): Opc.Ua.Server.Tests 12575 passed (after review fixes) / 8 failed (the PhysicalFileSystemProvider symlink tests, environmental) / 7 skipped; Opc.Ua.Gds.Tests 3049 passed / 0 failed / 56 skipped (a first run overlapped RT-6's GDS run and showed the known 241 shared-PKI failures; the isolated rerun is clean); Opc.Ua.Core.Security.Tests ~Audit 95 passed / 0 failed. net48 builds Opc.Ua.Server, Opc.Ua.Server.Tests and Opc.Ua.Gds.Server with 0 warnings.
The generic service-failure audit is now a property of the StandardServer
service envelope instead of a callback each service opts into. On a service
fault, while Auditing is on, the envelope reports the service's specific
fault audit (NodeManagement, Cancel: their events carry the request) or
else the generic one for its service set (OPC 10000-4 6.5):
- Read/HistoryRead/Write/HistoryUpdate: AuditEventType, Attribute/<Service>
- Call: AuditEventType, Method/Call
- CloseSession: AuditSessionEventType, Status false (new)
- TransferSubscriptions: AuditSessionEventType, SourceNode = session (new)
- Cancel: AuditCancelEventType with the fault status (new)
- View/Query/MonitoredItem/Subscription: none (6.5.10)
The success path is unchanged and does no audit work.
ServerInternalData.ReportEvent/ReportEventAsync now hand every
AuditEventState to the IAuditEventSink (dropped while Auditing is off), so
a host sink also sees the audit events node managers raise (conditions,
programs, ConfigurationUpdated). The default sink keeps the address-space
publication and the async path unchanged.
Adds AuditEvents.ReportAuditMethodCallEvent, a shared helper for
AuditUpdateMethodEventType and its subtypes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ush (SS-6)
- UserManagement AddUser/ModifyUser/RemoveUser/ChangePassword raise one
AuditUpdateMethodEventType each, on success and failure (incl. denied
calls); OPC 10000-18 defines no specific type. Passwords are replaced by
a null Variant.
- KeyCredential push (OPC 10000-12 8.6): UpdateCredential raises
KeyCredentialUpdatedAuditEventType, DeleteCredential
KeyCredentialDeletedAuditEventType, both with ResourceUri;
CreateCredential an AuditUpdateMethodEventType. The credential secret is
redacted. GetEncryptingKey only reads and is not audited. The audit
wrappers live in a new partial file; KeyCredentialPushSubject.cs only
changes its three wiring lines and gains `partial`.
- RoleStateBinding: one audit site per method instead of two (denied and
completed calls share the exit).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
romanett
changed the title
Server: audit in the service envelope, specific audits for user management and KeyCredential push (SS-6)
Server: audit in the service envelope, specific audits for user management and KeyCredential push
Dec 1, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Composite audit delivery can block on full channels and lose cancellation, while other unresolved issues cause missing, duplicate, or incorrectly attributed audit records.
Extends the server audit infrastructure introduced in #5130 and #5187, centralizing service-fault reporting and adding user-management and KeyCredential method audits.
Changes:
Consolidates service-fault auditing and adds failure events for CloseSession, Cancel, and TransferSubscriptions.
Adds method audits with secret redaction and consolidates role-management audit sites.
Routes node-originated audit events through the configured sink and adds regression coverage.
…s, rejected calls)
- IAsyncAuditEventSink: the default and composite sinks publish asynchronously,
so ReportEventAsync of an audit event never blocks on a full event channel and
observes the caller's cancellation, with or without a host sink.
- An audit event that reaches the server through several root notifiers in one
publication is delivered to the sink once (NodeState propagation visit).
- Session-service fault audits name the user captured with the request.
- Method audits record the ActionTimeStamp when the call started.
- UserManagement and KeyCredential calls whose handler throws, or that MethodState
rejects in argument validation, are audited as failures (no unvalidated arguments).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Audit events can still misattribute an anonymous request to a later authenticated user because the captured null client identity does not overwrite the live session identity.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Anonymous caller audit attribution can use the reactivated session user
The anonymous-caller case still retains the session's current identity. OperationContext.ClientUserId legitimately captures null for an anonymous request, but InitializeAuditSessionEvent has already populated this field from the live session. If that session is reactivated as a named user before CloseSession or TransferSubscriptions fails, this condition skips the overwrite and attributes the anonymous request to the new user. Always assign the captured value, including null, and extend the reactivation regression test to cover an initially anonymous caller.
… (SS-6 review)
The captured ClientUserId of the request always replaces the session's live one, so
an anonymous request is not attributed to a user the session was reactivated under.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
❌ Patch coverage is 87.35294% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.86%. Comparing base (aa5f140) to head (3ec7274). ⚠️ Report is 7 commits behind head on master.
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
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.
Finishes finding SS-6 of the 2026-11-15 server architecture review. #5130 added the envelope, #5187 the
IAuditEventSink.Service → audit event table
Spec: OPC 10000-4 §6.5.5–§6.5.10, OPC 10000-5 §6.4 (SourceName of AuditUpdateMethodEventType is
Attribute/Call), OPC 10000-12 §8.6.9/§8.6.10.Attribute/ReadAttribute/HistoryReadAttribute/Write; per operation AuditWriteUpdateEventTypeAttribute/HistoryUpdate; per operation AuditHistory*EventTypeMethod/Call; rejected call items: AuditUpdateMethodEventTypeSession/CloseSessionSession/CloseSessionSession/TransferSubscriptions, SourceNode = session (service fault)Not audited at all (unchanged): a request that fails in
ValidateRequestAsync(no session, bad token, too busy) never reaches the envelope's try, so there is no operation context and no ClientUserId; auditing them would flood the trail with unauthenticated noise.Method audits
AuditEvents.RedactedPrivateKeyCorrection to the review: there is no generic success-path method audit in the server. The "generic method-call audit" is only the dispatcher's AuditUpdateMethodEventType for call items rejected before the method runs. A generic post-call audit for every method would double-emit wherever a method raises its own subtype, so it is left out (follow-up if wanted: an opt-out flag on MethodState).
Trigger consolidation
ReportServiceFaultAudit(RequestType, …)switch.ServerInternalData.ReportEvent/ReportEventAsyncnow route anyAuditEventStateto the sink. Before, audit events that node managers raise on nodes (conditions, programs, ConfigurationUpdated, FiniteStateMachine transitions) reached the address space but skipped a host sink. The one remaining bypass:AuditEvents.ReportTrustList*AuditEventoverloads called with a null server fall back toTrustListState.ReportEvent; in-tree TrustList always passes its server (SetAuditEventServer). Also note: the TrustList helpers do not checkAuditingthemselves;ServerInternalData.ReportAuditEventdoes.Behaviour changes
IAuditEventSinknow also receives audit events raised throughIServerInternal.ReportEvent/ReportEventAsync(conditions, programs, configuration), once per publication: an occurrence that reaches the server through several root notifiers is delivered to the sink once, as the Server object publishes it once (an independent publication of the same instance is delivered again).ReportEventAsyncawaits the sink when it is anIAsyncAuditEventSink(new public interface, implemented byAddressSpaceAuditEventSinkandCompositeAuditEventSink; newServerInternalData.PublishAuditEventAsync), so a full event channel does not block the caller and the cancellation token is observed, with or without a host sink.OperationContext.ClientUserId), not the session's current one, so a reactivation under another user during the request does not re-attribute the failure.ReportAuditMethodCallEventgained an optionalactionTimeStamp), not when it returned.No change to event queues, queue sizes or overflow events (CTT Auditing group).
Tests
Opc.Ua.Server.Tests/Diagnostics/ServiceAuditEnvelopeTests(in-process StandardServer with a capturing sink): Read/HistoryRead/Write/HistoryUpdate/Call faults → exactly one AuditEventType with SourceName, Status, ActionTimeStamp, ServerId, ClientAuditEntryId, ClientUserId; TransferSubscriptions fault; CloseSession fault (table); Browse/CreateMonitoredItems/Publish/AddNodes/Cancel → no generic event; AddNodes fault → only AuditAddNodesEventType; Cancel success → one AuditCancelEventType; successful Read → nothing; audit events reported as plain events reach the sink, plain events do not; auditing off → nothing at all; an audit event through two root notifiers reaches the sink once (sync and async), an independent publication again; ReportEventAsync with a waiting composite sink does not complete synchronously and is cancelled by the token; a session fault after a simulated reactivation names the original user.UserManagementBindingTests.Audit: four methods → four AuditUpdateMethodEventType with the fields, no password in arguments; denied call → Status false with the caller's ClientUserId; auditing off → nothing; a throwing provider → Status false then rethrow; an argument-validation reject throughMethodState.CallAsync→ Status false without arguments and the handler never runs; ActionTimeStamp ≤ handler entry.KeyCredential/KeyCredentialPushAuditTests: Create/Update/Delete → AuditUpdateMethod / KeyCredentialUpdated / KeyCredentialDeleted with ResourceUri and redacted secret; denied update → Status false; auditing off → nothing. A throwing store → Status false, ResourceUri, redacted secret; argument-validation rejects of Create/Update/Delete → their own types, Status false, ResourceUri on Update/Delete, no arguments.~Audit95 passed / 0 failed. net48 builds Opc.Ua.Server, Opc.Ua.Server.Tests and Opc.Ua.Gds.Server with 0 warnings.🤖 Generated with Claude Code