6 Commits
Author SHA1 Message Date
ChiouYouJiaandClaude Opus 5.5 86dd0be440 fix(server): do not leak the user token secret through the ActivateSession audit
ActivateSession decrypts the UserIdentityToken in place (decryptUserToken). Afterwards
auditActivateSessionEvent put that token unchanged into the audit payload, so the
payload carried the plaintext password of a UserNameIdentityToken (also when it was
sent RSA-OAEP encrypted on a SignAndEncrypt channel) or the plaintext tokenData of an
IssuedIdentityToken.

The payload is used in two places, and both leaked the secret:
- the auditNotificationCallback / globalNotificationCallback of the application;
- the event fields of the AuditActivateSessionEventType event that is generated on
  the Server object. A MonitoredItem selecting /UserIdentityToken receives the
  password of every user who logs in. Audit events are meant to be collected by
  audit/SIEM clients, so the secret leaves the server and ends up in logs.

This affects master only (the auditing code is not in a release branch) and only
servers with auditingEnabled.

Put a shallow copy of the token without password / tokenData into the payload. The
copy lives on the stack of auditActivateSessionEvent and outlives the synchronous
auditSessionEvent call; no allocation. PolicyId, UserName and EncryptionAlgorithm
are kept for the audit trail. Other token types are unchanged.

The test logs in as user1 and checks both the audit notification and the
AuditActivateSessionEventType event received by a local event MonitoredItem on the
Server object: they name user1 and carry no password. Without the fix both carried
the password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 17:00:29 +02:00
ChiouYouJiaandClaude Opus 5.5 5ae7657e58 feat(server): add SourceNode to the write audit notification payload
The AUDIT_UPDATE_WRITE application notification carries the AttributeId,
IndexRange, NewValue and OldValue of a write, but not the NodeId of the written
node. That NodeId is only set as the SourceNode of the generated
AuditWriteUpdateEvent, so an auditNotificationCallback cannot tell which node
was written without additionally subscribing to the events.

Add /SourceNode (the BaseEventType field name) to the payload. The generated
events are unchanged: the event-field lookup already resolves /SourceNode to
the same NodeId by default, and the RBAC check uses the EventDescription.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 22:41:58 +02:00
Julius Pfrommer 10cfc1bb66 test(server): use a pointer-sized atomic auditing flag on MSVC
The MSVC atomic-store helper requires pointer-sized storage. Use uintptr_t for the threaded auditing
fixture's shutdown flag.
2026-09-21 16:23:09 +02:00
Julius Pfrommer 97f724ea19 test(mt): synchronize threaded fixtures and simulated clock
Use atomic shutdown flags and clock updates in threaded tests. Guard the auditing fixture when
thread-safe server support is disabled.
2026-09-21 16:23:09 +02:00
Andreas Ebner 148097763b fix(test): use UA_atomic helpers instead of <stdatomic.h> in check_server_auditing
tcc ships no stdatomic.h and MSVC requires /std:c11; the config.h atomics work with every compiler the library supports.
2026-07-17 14:01:24 +02:00
Andreas Ebner 979619d1a3 test(core): cover config, syslog, certificate group and auditing APIs
Add unit tests for UA_ServerConfig helpers, the syslog logger, the accept-all certificate group fallback and auditing notifications; guard encryption-only config-default APIs and use UA_ServerConfig_clear.
2026-07-14 08:21:52 +02:00