35 Commits

Author SHA1 Message Date
Andreas Ebner f265859191 fix(plugins): free the parsed IndexRange in the default history read
readRaw_service_default parsed the IndexRange of each node to read, but
never freed the dimensions of the parsed range. Every raw history read with
an IndexRange leaked them. They are now freed after the backend call.
2026-10-06 18:22:49 +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 e938a497dc fix(historydata): validate circular continuation point skip
Reject circular HistoryRead continuation points whose skip exceeds the available result count, and cap the backend copy to the allocated response capacity. A forged skip could otherwise underflow the copy length and cause a heap-buffer-overflow when the response size was capped.
2026-09-14 12:54:49 +02:00
Julius Pfrommer 7e419a3c4c fix(history): enforce UserAccessLevel for history access
The default HistoryDatabase checked only the Variable node AccessLevel. Apply the session-specific AccessControl getUserAccessLevel result as well so clients denied HISTORYREAD or HISTORYWRITE cannot read, insert, replace, update or delete stored values.
2026-09-14 12:54:25 +02:00
Julius Pfrommer f4588beae7 fix(history): handle result allocation failures
Return BadOutOfMemory before invoking the read backend or writing HistoryUpdate operation results when their per-result allocations fail. This prevents null pointers from reaching the backend and avoids a null write under memory pressure.
2026-09-14 12:53:43 +02:00
Julius Pfrommer 132deca9c0 Merge remote-tracking branch 'origin/1.4' into merge_14_15 2026-09-05 09:49:43 +02:00
Julius Pfrommer 36fbc14811 Merge remote-tracking branch 'origin/1.3' into merge_13_14 2026-09-04 16:57:38 +02:00
Niels Beier 7a08139590 fix(historydata): prevent UAF in memory backend range-limited history reads
UA_DataValue_backend_copyRange() performed a shallow memcpy of the
source UA_DataValue before attempting the range copy. Because the
destination's UA_Variant fields were not reinitialized first, a
failing UA_Variant_copyRange() (for example when the client-supplied
indexRange exceeds UA_MAX_ARRAY_DIMS) left the destination value as an
uninitialized alias of the backend-owned storage instead of an
independent copy.

copyDataValues_backend_memory() also discarded the status code from
both UA_DataValue_backend_copyRange() and UA_DataValue_copy(), so the
aliased, partially-copied value was still counted as a successful
result and forwarded to the HistoryRead response. Freeing that
response later released the backend's live storage, leaving the
backend with a dangling pointer that was dereferenced on a subsequent
HistoryRead.

Reinitialize the destination variant before the range copy and clear
it again on failure, mirroring the safe pattern already used by
UA_DataValue_copyRange(). Propagate copy failures out of
copyDataValues_backend_memory() immediately instead of counting a
failed entry as provided.

Internal Vulnerability Advisory: open62541-SA-2026-0021
Co-authored-by: gff-cw <gff-cw@users.noreply.github.com>
2026-09-04 13:20:06 +02:00
Julius Pfrommer be73bbb10c Merge remote-tracking branch 'origin/1.4' into merge_14_15
# Conflicts:
#	.github/workflows/build_ubuntu2204.yml
#	CMakeLists.txt
#	src/server/ua_discovery_mdns.c
#	src/server/ua_services_nodemanagement.c
#	src/server/ua_subscription_alarms_conditions.c
#	src/ua_types_encoding_binary.c
#	tests/fuzz/CMakeLists.txt
2026-08-14 18:35:50 +02:00
Julius Pfrommer d212ffad72 Merge remote-tracking branch 'origin/1.3' into merge_13_14_2
# Conflicts:
#	.github/workflows/build_linux.yml
#	CMakeLists.txt
#	src/server/ua_server_internal.h
#	src/server/ua_services_discovery_multicast.c
#	src/server/ua_services_nodemanagement.c
#	src/server/ua_subscription_alarms_conditions.c
2026-08-14 10:23:34 +02:00
Niels Beier f828c6051d fix(historydata): validate and cap continuation point skip in HistoryRead
In getHistoryData_service_default(), the outer continuation point encodes
a skip count that was read directly from client-controlled bytes without
validation. Two independent arithmetic errors could cause a heap-buffer-
overflow in the subsequent backend copy call:

1. When skip > _resultSize, the subtraction `_resultSize - skip` wraps
   around in size_t, producing a very large value. After clamping to
   maxSize, the allocation is correct, but the wrapped large skip is
   still used to recompute valueSize for the backend call.

2. When the reconstructed valueSize exceeds the number of entries actually
   allocated in outResult, copyDataValues() writes beyond the end of the
   result array (heap-buffer-overflow write).

Fix both issues in getHistoryData_service_default():
- Reject continuation points whose skip value exceeds the computed result
  set size, returning UA_STATUSCODE_BADCONTINUATIONPOINTINVALID.
- After computing valueSize, cap it to the remaining allocated capacity in
  outResult so the backend cannot be instructed to write past the buffer.

Internal Vulnerability Advisory: open62541-SA-2026-0027
2026-08-14 10:12:35 +02:00
behrang c06b52af6d feat(server): add pause to historical data gathering (#7315)
after pausing historizing still recored data would be available
2025-06-26 13:46:55 +02:00
Julius Pfrommer 46b94266f1 fix(plugins): Create ServerTimestamp if none defined in the historical data plugin 2023-11-08 23:14:09 +01:00
Julius Pfrommer 5de6a2e7c3 Revert "Merge branch 'master' into 1.3"
This reverts commit 2f2b9fea7d, reversing
changes made to 271f3dcb01.
2021-12-18 14:34:34 +01:00
Luigi 38f453955e [REVIEW] Circular buffer implementation for historydata plugin (#4740) 2021-11-17 14:20:38 +01:00
Julius Pfrommer 5b7a3a14c3 Merge remote-tracking branch 'origin/1.1' into master 2020-11-15 23:18:48 +01:00
basyskom-jvoe bdf840f276 fix(plugin): Fix memory issues in the historical data plugins (#3992)
* Fix memory leak in UA_HistoryDataBackend_Memory

* Fix uninitialized memory in the default history data gathering plugin

After extending the memory block with realloc, the additional memory is
not initialized with null bytes.
2020-11-06 13:26:26 +01:00
Julius Pfrommer c203430d16 refactor(plugins): Use _clear instead of _deleteMembers 2020-10-18 15:21:40 +02:00
Julius Pfrommer ad610bea77 refactor(server): Remove AccessControl indirection
Today we have access to the server config. Directly use that instead.
2020-10-18 15:21:40 +02:00
Martin Lang b26c8d1998 fix(core): Remove double ";" at end of line (#3938) 2020-10-06 10:47:07 +02:00
Julius Pfrommer 1b259b75ee refactor(core): Add UA_NUMERICRANGE to parse ranges 2020-03-12 11:29:21 +01:00
Andranik Simonyan f8747cb0ae feat(server): support for readModified, readProcessed, readAtTime requests in UA_HistoryDatabase added (without default implementation) 2019-10-30 20:32:38 +01:00
Julius Pfrommer 343d4a44fe refactor(server): Rename deleteMembers to clear in UA_HistoryDatabase 2019-10-03 15:14:24 +02:00
Stefan Profanter 63f3653ff1 Additional header cleanup and consistent name of ns generated files 2019-03-21 20:16:31 +01:00
Julius Pfrommer c9c818868f Move header files to a more unix-like structure
This commit drops the 'ua_' prefix and changes the public includes
to the form `#include <open62541/server.h>` instead of the old
`#include <ua_server.h>`
2019-03-21 20:16:31 +01:00
Peter Rustler 7187811ab4 historydatabackend_memory: Fix lastIndex function. 2019-02-06 00:06:57 +01:00
Peter Rustler 2da3fa68dc historydatabase_plugin: Fix random index backend bug. 2019-02-06 00:06:57 +01:00
Mark Giraud b0b34ccbf3 Fix undefined behavior in historydatabse (memcpy called with null) 2019-02-01 09:03:45 +01:00
Peter Rustler a4c968f4c6 server_history_update: Add access control to alter historical data. 2019-01-30 17:36:23 +01:00
Peter Rustler 0d939f4762 server_historical_update: Add api to alter raw data. 2019-01-30 17:36:23 +01:00
Peter Rustler bc47ffc646 gathering: Add documentation for the enum and struct. 2019-01-09 17:19:33 +01:00
Frank Meerkoetter ef485d8bc3 Fix the type of the return
false as implicitly converted to NULL
2019-01-06 16:13:22 +01:00
Frank Meerkoetter 7be71b6a78 No need to fwd declare these structs
The typedef below is sufficient.
2019-01-05 08:57:32 +01:00
Julius Pfrommer a43604a28a Cosmetic changes; Replace "extern C" with _UA_BEGIN_DECLS 2018-09-09 16:45:34 +02:00
Peter Rustler e74af216d2 Implementation of a history data plugin 2018-08-24 14:40:28 +02:00