189 Commits
Author SHA1 Message Date
Julius Pfrommer 5bde0ea466 Merge origin/1.5 into master
Adapt the 1.5 fixes to master's discovery, alarms and conditions, session, and nodeset-loader architecture. Preserve master behavior and combine PubSub replay protection with authenticated key rollover. Enable allocation-failure regression coverage and retain both branches' relevant tests.
2026-10-28 17:37:05 +01:00
Bastian Engel 0d0b4f9268 fix(encryption): replace "DER" by "PKCS8" for private keys
Possible private key formats include "PEM", "PFX", or "PKCS8". We
reported "DER" as a supported private key format which is wrong. This
commit adds a test to check only valid key formats are presented and
fixes other tests that used invalid key formats.
2026-10-26 22:17:44 +01:00
Julius Pfrommer e0ec7f1e4a test(history): exercise allocation failures in CI coverage builds
Enable allocator hooks in the alarms coverage configuration and cover history constructor and insertion failures. Include stdlib.h explicitly in tests that use EXIT_SUCCESS and EXIT_FAILURE so the allocator-enabled build compiles without transitive standard-library includes.
2026-10-21 23:07:14 +02:00
Julius Pfrommer ac3f42dd27 Merge branch '1.4' into 1.5
Adapt the 1.4 fixes to the 1.5 PubSub, Session, discovery and utility APIs. Preserve per-ReaderGroup authentication, add bounded replay history, harden allocation error paths and widen callback lifetime regression coverage.
2026-10-21 22:53:23 +02:00
Julius Pfrommer bb896ea0d0 test(crypto): include open62541 headers before system headers
Let config.h establish POSIX feature macros before stdlib.h loads glibc feature definitions. This exposes the recursive mutex declarations required by 1.4 unit test builds in strict C99 mode.
2026-10-19 11:19:09 +02:00
Julius Pfrommer f88c83c6fc Merge remote-tracking branch 'origin/1.3' into merge_13_14 2026-10-19 09:36:10 +02:00
Julius Pfrommer a273040e96 ci: fuzz the PR checkout and report certificate verify flags 2026-10-19 08:30:44 +02:00
Daniel Opitz 0684d6df88 fix(crypto): reject invalid subject alternative names with MbedTLS 2026-10-19 08:30:44 +02:00
Niels Beier 5b7f5d1a53 test(crypto): add regression test for EccEncryptedSecret length check
Add encryption_malformed_ecc_usertoken_length, which sends an
ActivateSession request with a UserNameIdentityToken carrying an
EccEncryptedSecret whose Length field makes endOfSecret smaller than
the ECC_nistP384 signature size. Asserts the server responds with
BadIdentityTokenInvalid instead of the process being killed while
handling the request.

Internal Vulnerability Advisory: open62541-SA-2026-0043
Co-Authored-By: X1AOxiang <X1AOxiang@users.noreply.github.com>
2026-10-18 10:03:15 +02:00
Daniel Opitz 0607a658ea test(crypto): cover certificates, key derivation and trust-list lifecycle 2026-10-17 14:17:38 +02:00
Niels Beier 45ece531a0 test(encryption): keep the Basic256Sha256 config-copy test independent of the client trust list
encryption_connect configured its client with an empty trust list to
reach the server's certificate, relying on the accept-all verifier that
used to be left in place for an empty list. Request that behavior
explicitly with UA_CertificateGroup_AcceptAll() instead, since the test
is about the server config surviving being copied into the server, not
about trust-list enforcement.

Internal Vulnerability Advisory: open62541-SA-2026-0057
Co-Authored-By: Jason Huibin Wang <jasontimwong@users.noreply.github.com>
2026-10-17 14:12:21 +02:00
Niels Beier f0de937d68 test(config): cover certificate verification with an empty trust list
Add a client-side and a server-side test asserting that an empty trust
list still results in a certificate verifier that rejects an untrusted
certificate, instead of silently keeping whatever verifier was
previously configured.

Internal Vulnerability Advisory: open62541-SA-2026-0057
Co-Authored-By: Jason Huibin Wang <jasontimwong@users.noreply.github.com>
2026-10-17 14:12:21 +02:00
Andreas Ebner 54fcc04ccc fix(drivers): only warn when the GDS role setup fails
UA_GDSReceiver_start did not start when initGDSRolePermissions failed,
but left the push method callbacks installed. The RolePermissions are
one way to restrict the methods to SecurityAdmin (Part 12, 7.10). RBAC
is optional, and the AccessControl plugin can restrict the methods as
well. So a failed role setup is now logged as a warning and the receiver
starts.
2026-10-13 08:55:20 +02:00
Daniel Opitz bf65f720b0 fix(server): cleared csrLocalPrivateKey and prevent double free 2026-10-08 23:04:37 +02:00
Julius Pfrommer 3d390d26b1 Merge remote-tracking branch 'origin/1.5' into merge_15_master
# Conflicts:
#	CHANGES.md
#	src/server/ua_services_attribute.c
#	src/server/ua_transport_tcp.c
#	tests/server/check_accesscontrol.c
2026-10-08 14:33:33 +02:00
Niels Beier 444622f8f4 test(encryption): check the Basic128Rsa15 SecureChannel nonce length 2026-10-06 18:20:56 +02:00
Niels Beier edc16fb6f2 test(server): cover transfer of detached Subscriptions 2026-10-06 07:37:13 +02:00
Julius Pfrommer 6901aedc07 Merge remote-tracking branch 'origin/1.5' into merge_15_master
Port keyless certificate validation into the GDS receiver driver instead
of restoring the removed server implementation. Preserve master's timer
batching, PubSub lifecycle and client HTTP configuration handling.

Adapt Publish cancellation to response tokens and the HEL/fuzz harnesses
to the explicit TCP driver. Keep SKS policy history and custom datatype
ownership intact, including failed replacement configuration cleanup.
Retain TPM error cleanup while enforcing key-handle and nonce lengths.

Validation:
- Full mbedTLS unit-test build with full namespace, GDS, SKS and Query.
- 21 affected suites passed with ASan/UBSan, plus 9 isolated SKS ownership
  and lifecycle checks.
- OpenSSL certificate update, GDS information model and client encryption
  suites passed with sanitizers.
- OPN, MSG and binary-message fuzzers each completed 100 sanitizer runs.
- Both TPM PubSub policy sources passed compilation checks.

The full SKS client suite timed out after multicast UDP sends reported
"No route to host" on this machine; its affected ownership and lifecycle
cases passed separately. No live TPM hardware validation was performed.
2026-10-04 16:49:17 +02:00
Andreas Ebner f8a962278d fix(types): UA_Variant_setArray with length zero sets an empty array
A variant with length zero and a data pointer is a scalar. With an
array of length zero, UA_Variant_setArray kept the pointer, so the
variant became a scalar. Writing it to an array variable failed, and
clearing it freed the array as a single element.
UA_Variant_setArrayCopy already uses UA_EMPTY_ARRAY_SENTINEL in this
case. UA_Variant_setArray now does the same and does not take over the
array. NULL with length zero remains a null array.

The GDS Receiver writes its CertificateTypes with UA_Variant_setArray.
Since #8506 the list is empty on a server without an RSA endpoint. The
write failed, the receiver did not start and its methods were unbound.
2026-10-02 20:16:50 +02:00
Andreas Ebner fc0bf5614e fix(drivers): let the owning session continue its transaction with Open
Open was refused while any transaction was pending, also for the session
that owns it, so UpdateCertificate followed by a TrustList write failed.
Part 12 §7.8.2.2 says a write-mode Open continues an existing transaction.
Allow that for the owner unless ApplyChanges is queued; OpenWithMasks and
other sessions still get BadTransactionPending. Close discards only the
written data and keeps the staged changes. ApplyChanges refuses to run
while any TrustList is open for writing (§7.10.9).
2026-10-01 16:09:59 +02:00
Andreas Ebner af94d97375 fix(drivers): advertise and accept only configured certificate types
CertificateTypes always listed RsaMin and RsaSha256. With no RsaMin policy
configured (the default), an RsaMin UpdateCertificate and ApplyChanges
answered Good without changing anything, and CreateSigningRequest returned
an empty CSR. Now only types with an endpoint policy in the
DefaultApplicationGroup are advertised. UpdateCertificate and
CreateSigningRequest refuse the others with BadInvalidArgument (Part 12
7.10.5, 7.10.10), and applying a type that no policy uses is an error.
2026-10-01 16:09:59 +02:00
Andreas Ebner 7395a9d1dd fix(drivers): read the SetPosition offset as UInt64
SetPosition read its UInt64 Position argument through a UInt32 pointer.
Offsets above 4 GiB were truncated, and big-endian targets read the wrong
half. Read the argument with its declared type.
2026-10-01 16:09:59 +02:00
Andreas Ebner 128eb7868a fix(drivers): clear the transaction when RemoveCertificate fails
RemoveCertificate creates a transaction and applies it right away. When
the TrustList could not be copied into the transaction, it returned with
the transaction still pending and no session watchdog installed, so all
later TrustList changes were refused. Clear the transaction on that path.
2026-10-01 16:09:59 +02:00
Andreas Ebner b822aae1ff fix(drivers): refuse certificate updates while ApplyChanges is queued
ApplyChanges defers the completion of the transaction to a delayed
callback. An UpdateCertificate in between was accepted into the queued
transaction and then silently discarded with it. Refuse it with
BadTransactionPending until the transaction is completed.
2026-10-01 16:09:59 +02:00
Andreas Ebner 10fb09e051 fix(drivers): answer BadNothingToDo for ApplyChanges without a transaction
ApplyChanges compared the caller with the owner of the transaction before
checking its state. A fresh transaction has no owner, so every caller got
BadUserAccessDenied. Check the state first, as Part 12 §7.10.9 requires.
2026-10-01 16:09:59 +02:00
Andreas Ebner 2ecedb825c fix(drivers): update the None endpoint certificate in UpdateCertificate
After a certificate push the SecurityPolicy#None endpoint kept presenting
the replaced certificate, while the encrypted endpoints showed the new one.
A None SecurityPolicy with a replaced certificate is now updated as well.
2026-09-29 23:11:55 +02:00
Andreas Ebner a34a68357e fix(drivers): accept a null CertificateGroupId in UpdateCertificate
Part 12 says a null CertificateGroupId selects the DefaultApplicationGroup.
The GDS receiver rejected it with Bad_NotSupported, so GDS pushes failed.
An unsupported group or type now returns Bad_InvalidArgument as specified.
2026-09-29 20:31:27 +02:00
Andreas Ebner 202c6028a5 fix(server): reject an unparseable certificate in UpdateCertificate
Without a PrivateKey (after CreateSigningRequest), UpdateCertificate staged any bytes as
the new certificate and only ApplyChanges failed. Check that the certificate parses and
answer BadCertificateInvalid, also in UA_Server_updateCertificate when encryption is built.
2026-09-26 13:52:32 +02:00
Bastian Engel 370dd3532a fix(crypto): add certificate update test case, remove mbedTLS-only guard
The new test case exercises the branch that broke previously. Removing
the mbedTLS-only guard exercises the tests for OpenSSL.
2026-09-25 13:25:54 +02:00
Andreas Ebner 87f65a892e test(encryption): add AES-CTR and HMAC-SHA256 known-answer checks for the PubSub policies (Part 14 §7.2.4.4.3.2)
NIST SP 800-38A F.5 vectors with the policy's counter block and an
HMAC-SHA256 tag pin the exact bytes for every backend. A context without
keys must refuse every operation until keys are installed.
2026-09-24 16:52:03 +02:00
Julius Pfrommer 07b632a6f7 fix(client): verify selected CreateSession endpoint
Compare the selected discovery endpoint with its authenticated counterpart
from CreateSession using only the seven fields specified by Part 4. Ignore
optional metadata and the duplicated endpoint certificate, which servers may
omit. Keep the separate certificate validation unchanged.

Reject mismatches by default, with configurable warning and acceptance modes.
Skip the comparison for directly configured endpoints. Cover omitted metadata,
endpoint reordering, mismatch handling and trusted endpoint configuration.
2026-09-23 17:07:09 +02:00
Julius Pfrommer 980fe58667 fix(client): validate server certificate ApplicationUri 2026-09-22 10:29:23 +02:00
Julius Pfrommer 335cead676 test(mt): synchronize remaining threaded fixture state
Use pointer-sized atomic run flags in threaded fixtures, including dynamically
allocated discovery and browse flags. Pointer sizing supports the MSVC atomic
implementation as well as C11 and GCC atomics.

Serialize the client error-injection test with the server network callbacks
before accessing the internal session and shared send buffer.
2026-09-21 16:23:09 +02:00
Julius Pfrommer 9a43b33a4b Merge remote-tracking branch 'origin/1.5' into merge_15_master
# Conflicts:
#	plugins/crypto/mbedtls/create_certificate.c
#	plugins/crypto/mbedtls/securitypolicy_aes256sha256rsapss.c
#	plugins/crypto/mbedtls/securitypolicy_common.c
#	src/client/ua_client.c
#	src/pubsub/ua_pubsub_config.c
#	src/pubsub/ua_pubsub_keystorage.c
#	src/pubsub/ua_pubsub_keystorage.h
#	src/pubsub/ua_pubsub_ns0.c
#	src/pubsub/ua_pubsub_ns0_sks.c
#	src/pubsub/ua_pubsub_securitygroup.c
#	src/pubsub/ua_pubsub_writer.c
#	src/pubsub/ua_pubsub_writergroup.c
#	src/server/ua_server_ns0.c
#	src/server/ua_server_ns0_gds.c
#	src/server/ua_server_utils.c
#	src/server/ua_services_session.c
#	src/server/ua_subscription_alarms_conditions.c
#	src/ua_types_encoding_xml.c
#	tests/check_types_builtin_xml.c
#	tests/encryption/check_cert_generation.c
#	tests/pubsub/check_pubsub_configuration.c
#	tests/pubsub/check_pubsub_informationmodel_methods.c
#	tests/pubsub/check_pubsub_publish.c
#	tests/pubsub/check_pubsub_sks_client.c
#	tests/pubsub/check_pubsub_sks_keystorage.c
#	tests/pubsub/check_pubsub_sks_push.c
#	tests/pubsub/check_pubsub_sks_securitygroups.c
#	tests/server/check_server_alarmsconditions.c
2026-09-20 10:02:09 +02:00
Julius Pfrommer 30b54d61af fix(crypto): bound PEM certificate-chain search
Search the certificate input for the next PEM header with the haystack and needle in the correct order. Use a length-bounded helper so partial headers at the end cannot read past the input.
2026-09-18 18:16:02 +02:00
Julius Pfrommer 0677590700 fix(crypto): reject certificates without an application URI
The exact-comparison change in f4c2dc2aa made an absent URI compare equal to an empty ApplicationUri. Require a non-empty URI SAN before accepting the certificate.
2026-09-18 18:16:02 +02:00
Julius Pfrommer 3065049520 fix(securitypolicy): validate RSA-PSS signature length
The mbedTLS RSA-PSS verifier consumes one complete RSA modulus but its low-level API does not take an input length. Reject malformed ByteStrings before invoking it so a short application signature cannot cause an out-of-bounds read.
2026-09-18 18:16:02 +02:00
Julius Pfrommer 9f28ac4ac8 fix(securitypolicy): validate raw ECDSA signature lengths
Reject malformed raw ECDSA signatures before converting their r and s coordinates. Short signatures could otherwise cause out-of-bounds reads in the OpenSSL backend and an underflowing bounds check in the mbedTLS backend; oversized mbedTLS signatures could overflow the fixed DER buffer.
2026-09-18 18:16:02 +02:00
Julius Pfrommer 41ea6c9324 test: fix compatibility across CI configurations 2026-09-17 22:59:45 +02:00
Julius Pfrommer c15f297b8d Merge remote-tracking branch 'origin/1.4' into merge_14_15
# Conflicts:
#	CHANGELOG
#	CMakeLists.txt
#	plugins/crypto/openssl/securitypolicy_openssl_common.c
#	plugins/crypto/pkcs11/securitypolicy_pubsub_aes128ctr_tpm.c
#	plugins/crypto/pkcs11/securitypolicy_pubsub_aes256ctr_tpm.c
#	src/pubsub/ua_pubsub_networkmessage.c
#	src/pubsub/ua_pubsub_ns0.c
#	src/pubsub/ua_pubsub_writer.c
#	src/pubsub/ua_pubsub_writergroup.c
#	src/server/ua_services_monitoreditem.c
#	src/server/ua_services_session.c
#	src/server/ua_session.h
#	tests/CMakeLists.txt
#	tests/check_securechannel.c
#	tests/pubsub/check_pubsub_encryption.c
#	tests/pubsub/check_pubsub_publish.c
#	tests/server/check_server_alarmsconditions.c
2026-09-17 21:58:21 +02:00
Julius Pfrommer c3742e2a5b Merge remote-tracking branch 'origin/1.3' into merge_13_14 2026-09-17 19:53:50 +02:00
Julius Pfrommer 97079273bd test(server): compare method callback without pointer conversion 2026-09-16 07:12:26 +02:00
Julius Pfrommer ade0054d8e test(server): cover every GDS callback argument contract 2026-09-16 07:12:26 +02:00
Julius Pfrommer db3ff72052 fix(server): validate GDS method argument counts
GDS callbacks trusted mutable InputArguments and OutputArguments metadata without checking the concrete callback array sizes. A client allowed to manage nodes could shorten a method signature and make a later batched call consume stale arguments left by an earlier operation. Validate every GDS callback contract before accessing input or output values.
2026-09-16 07:12:26 +02:00
Niels Beier a0d58fca9e test(crypto): add regression tests for HMAC verify constant-time fix
Add check_hmac_verify_constanttime, exercising the OpenSSL
HMAC-SHA1/SHA256 verify helpers directly. A correct signature must
verify, a same-length signature with one flipped bit must be
rejected (guards the constant-time comparison), and a signature
shorter than the expected digest must be rejected without reading
past its end (guards the length check). The AddressSanitizer job in
CI will catch a regression of the latter.

Internal Vulnerability Advisory: open62541-SA-2026-0038
2026-09-15 20:31:48 +02:00
Julius Pfrommer cf76196732 fix(security): validate ECC user-token signature bounds 2026-09-14 13:50:07 +02:00
Julius Pfrommer d2bc0bccb5 fix(pubsub): validate security policy contracts early 2026-09-05 20:57:32 +02:00
Julius Pfrommer 2dc08688d3 refactor(style): keep comments focused on behavior 2026-09-03 17:49:09 +02:00
Julius Pfrommer 46a74698bb fix(plugin): generate valid filestore names for certificates and CRLs
Use the common name when available and fall back to the subject for CRLs and
certificates without a common name.

Check path formatting, propagate storage errors, and clean up trust-list data
on every exit path.
2026-09-03 17:43:01 +02:00
Julius Pfrommer e920163ec1 fix(server): extract X509 identity subject correctly
Pass the certificate and output subject in the documented order. The reversed arguments caused the mbedTLS implementation to clear the decoded certificate buffer before request cleanup, leaking the original allocation.
2026-08-12 05:44:46 +02:00