The Malloc Failed, The Code Said Everything Was Fine, Then the Server Crashed | CVE-2026-90782 | S2OPC
A NULL pointer dereference in S2OPC's notification allocation function occurs when a DataChange allocation fails but a subsequent Event allocation succeeds, overwriting the shared status variable. An attacker could crash the server by inducing memory exhaustion while a session has both DataChange and Event monitored items.
Published on medium.com
Opc Ua
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
S2OPC is an OPC UA implementation built by Systerel, a French safety and security company, for environments where software failures have real consequences: nuclear facilities, railways, aerospace and industrial automation. The name stands for Safe and Secure OPC. The project is developed with B-method formal verification, the mathematical specification technique used in safety-critical software such as train control and nuclear plant software.
OPC UA (Open Platform Communications Unified Architecture) is the protocol industrial machines use to talk to each other and to the systems monitoring them: a temperature sensor on a production line sending readings to SCADA, a PLC reporting its state to a control dashboard.
The feature involved is subscriptions and notifications. A client connects to a server and creates a subscription; inside it, it creates monitored items, each watching a specific data point. When values change, the server bundles the changes into a publish response. A monitored item can produce two kinds of notification:
- DataChangeNotification: the new value of a variable that changed (a sensor reading, a process variable, a status flag).
- EventNotification: a structured event object (an alarm, a state transition, something that happened rather than something that changed value).
A single session can have both types active at once, and that combination is what the bug requires.

The article is titled "The Malloc Failed, The Code Said Everything Was Fine, Then the Server Crashed | CVE-2026-90782 | S2OPC".
Setup
The work started from someone else's advisory. CVE-2026-67865 was filed against S2OPC for an out-of-bounds read in RepublishResponse handling, a different function and a different bug. Reading through the affected file, msg_subscription_publish_bs.c, to understand the context led to another function in the same file: msg_subscription_publish_bs__alloc_notification_message_items(). Its job is to allocate the memory needed for a publish notification message that may contain both DataChange and Event notification objects.
The report links to the source at S2OPC Toolkit 1.7.3, lines 106 to 147 of that file. The test is a standalone C harness that mirrors the structure of the vulnerable loop, with controllable allocator functions so the DataChange allocation can be made to fail while the Event allocation succeeds. AddressSanitizer is used to show the crash. No crafted OPC UA packet is demonstrated; the trigger is reached through memory exhaustion.
Finding it
The function loops over the notification types it needs to allocate for. If the session has data-change items it allocates a DataChangeNotification object; if it has event items it allocates an EventNotificationList object. Both allocations go through SOPC_ExtensionObject_CreateObject(), which returns a SOPC_ReturnStatus (success or failure).
The problem is that both allocations write their result into the same status variable. The logic, simplified but structurally identical to the vulnerable source, is:
SOPC_ReturnStatus status = SOPC_STATUS_OK;
OpcUa_DataChangeNotification *dataChangeNotif = NULL;
OpcUa_EventNotificationList *eventNotifList = NULL;
for (int i = 0; i < n; i++) {
if (dataToSet) {
/* First iteration — allocate DataChangeNotification */
status = create_object(&dataChangeNotif, "DataChangeNotification");
dataToSet = false;
/* If this fails: status = SOPC_STATUS_OOM, dataChangeNotif = NULL */
/* Loop does NOT exit. It continues to the next iteration. */
} else if (eventToSet) {
/* Second iteration — allocate EventNotificationList */
status = create_object(&eventNotifList, "EventNotificationList");
eventToSet = false;
/* If THIS succeeds: status = SOPC_STATUS_OK */
/* The previous failure is now completely erased from status */
}
}
/* Post-loop: status says SOPC_STATUS_OK. It is lying. */
if (SOPC_STATUS_OK == status && hasData) {
dataChangeNotif->NoOfMonitoredItems = ...; /* dataChangeNotif is NULL */
}
The DataChange allocation fails. dataChangeNotif is set to NULL by the failure path and status is set to SOPC_STATUS_OOM. The loop moves on. The Event allocation succeeds and status is overwritten with SOPC_STATUS_OK. The original failure is gone: not handled, not logged, not checked again. The guard then passes, the code accesses dataChangeNotif->NoOfMonitoredItems, and the server crashes.
What makes it subtle is that this is not a forgotten malloc check. The return value from SOPC_ExtensionObject_CreateObject() was read and stored into status every time. It was just stored into the same variable twice, and the second result overwrote the first. A developer reading the code sees error handling and moves on, because the error handling is there; it is quietly erased by the next operation succeeding. This is a status-clobbering bug, one of the harder categories to catch in review precisely because every individual line looks right.
Exploitation
Step 1: reproduce the normal case
The harness runs the same allocation sequence, the same shared status variable, the same post-loop guard and the same dereference as the vulnerable loop. Only the allocator functions differ, so the DataChange allocation can be made to fail and the Event allocation to succeed. With both allocations succeeding:
[ALLOC] DataChangeNotification -> OK ptr=0x506000000020
[ALLOC] EventNotificationList -> OK ptr=0x506000000080
status: SOPC_STATUS_OK dataChangeNotif: valid ptr
-> Guard passed. Accessing dataChangeNotif->NoOfMonitoredItems...
-> Survived.
Status is correct and both pointers are valid, so nothing happens.
Step 2: fail the DataChange allocation, let the Event allocation succeed
[ALLOC] DataChangeNotification -> FAILED (OOM)
[ALLOC] EventNotificationList -> OK ptr=0x506000000020
status: SOPC_STATUS_OK <-- clobbered by Event success
dataChangeNotif: NULL <-- about to be dereferenced
-> Guard passed (status OK). Accessing dataChangeNotif->NoOfMonitoredItems...
The guard passes because status says success, and the NULL pointer is dereferenced. AddressSanitizer reports:
ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
The signal is caused by a READ memory access.
Hint: address points to the zero page.
#0 alloc_vulnerable — line 83 (the dereference)
#1 main
SUMMARY: AddressSanitizer: SEGV in alloc_vulnerable
Address 0x000000000000 is NULL: the pointer set to NULL when the allocation failed, dereferenced because the status said success.
Step 3: track the statuses independently
[ALLOC] DataChangeNotification -> FAILED (OOM)
dataStatus: FAILURE dataChangeNotif: NULL
-> DataChange alloc failed — dereference skipped safely.
No crash. Failure correctly propagated.
Step 4: control case, a data-only session
[ALLOC] DataChangeNotification -> FAILED (OOM)
status: SOPC_STATUS_FAILURE (correctly propagated)
-> DataChange failure propagates correctly (no second alloc)
When the session has only data-change items and no event items, there is no second allocation to clobber the status. The failure propagates correctly and the dereference never runs. The bug exists only when a session has both types of monitored items, which is a realistic and common configuration rather than an edge case.
What the trigger requires
The author is explicit about what was and was not proved. No crafted OPC UA packet that deterministically causes this from the network was demonstrated. The DataChange allocation failure path is reached through memory exhaustion: SOPC_ExtensionObject_CreateObject() fails because malloc() returns NULL under OOM conditions. Triggering it reliably therefore requires the server to be under memory pressure when a publish response for a mixed session is generated.
That is not trivial to engineer remotely, but it is not purely theoretical either: OOM conditions can be induced through memory exhaustion attacks, through repeated large subscription requests, or under resource-constrained embedded deployments. S2OPC targets constrained industrial devices as well as servers, and "this only fails under OOM" looks different on a 256MB embedded controller than on a modern server. The ASan output, a SEGV at address NULL, is what happens when that condition is met.
Root cause
The loop has no early exit on failure. When the first allocation fails, the loop continues to the next iteration, and the second allocation's success overwrites the shared status variable. The post-loop guard checks only that single variable, so it cannot distinguish "everything succeeded" from "the first allocation failed and the second succeeded". The NULL pointer left behind by the failed allocation is then dereferenced.
The existing defence, checking the return value of SOPC_ExtensionObject_CreateObject(), was present but ineffective because both results were stored in one variable. The author also notes, in the issue filed, that it might be worth checking whether the formal model has an assumption or invariant covering this failure interleaving, for example something like "if allocations are grouped in a loop, at most one can fail". The point is not that formal verification failed, but that there is a gap between proving the specification correct and proving the implementation handles every runtime failure interleaving correctly.
Impact
The impact is availability only: a server crash, with no confidentiality or integrity consequence demonstrated. The CVSS score is 6.0 Medium, vector AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H. The network-reachable path requires a session with both DataChange and Event monitored items (the AT:P, Attack Requirements Present), and a low-privilege subscribing client is enough to create such a session. The crash itself depends on the server being under memory pressure at the moment a publish response for a mixed session is generated.
In most contexts Medium is Medium. In industrial infrastructure monitoring environments, a remotely triggerable server crash on an OPC UA endpoint watching physical systems is worth more attention than the number suggests.
Fix
The fix is MR !1862, commit 8848f051. It tracks the allocation statuses independently so that a second success cannot erase a first failure:
if (hasData) {
dataStatus = create_object(&dataChangeNotif, "DataChangeNotification");
}
if (hasEvent && dataStatus == SOPC_STATUS_OK) {
eventStatus = create_object(&eventNotifList, "EventNotificationList");
}
/* Now both statuses are checked independently */
if (dataStatus == SOPC_STATUS_OK && hasData) {
dataChangeNotif->NoOfMonitoredItems = ...; /* ptr is valid */
}
When the DataChange allocation fails, the Event allocation is skipped entirely. There is no second result to clobber the first, and the failure propagates cleanly.
- Other shared-status loops in the same codebase. Search for loops that assign the return of an allocation or creation function to a single variable across iterations and check that variable only after the loop. A positive result is a path where an early failure is followed by a later success and the post-loop guard still passes.
- Mixed notification configurations. Look for code paths that handle DataChange and Event notifications together, including republish and retransmission paths. A positive result is a dereference of a pointer that a failed allocation left NULL while the status reports success.
- Failure interleavings in generated C from formal models. Where a specification assumes that at most one allocation in a group can fail, check whether the generated code enforces that assumption. A positive result is a runtime sequence the model does not cover that reaches an unchecked pointer.
- OOM paths on constrained deployments. Exercise allocation failure on embedded targets with small heaps, for example through repeated large subscription requests. A positive result is a crash or sanitizer report at a NULL address when a publish response is generated for a mixed session.
- Early-exit absence. For each allocation loop, check whether a failure breaks out or is only recorded. A positive result is a loop that continues after a failure and later overwrites the recorded status.
What happened, in plain words
A piece of software that industrial machines use to talk to each other had a small mistake in its error handling. When one part of the program ran out of memory, the code noticed the problem, wrote it down, and then a later step that worked fine overwrote that note with "everything is OK". The program then trusted the note, tried to use something that did not exist, and crashed.
The person who found it did not attack a live system. They read the code, spotted the pattern, and built a small test program that reproduced the crash on purpose. The bug is tracked as CVE-2026-90782, and the crash only happens when the server is already short of memory, which makes it hard to trigger from the outside but not impossible.
This article walks through the same story for someone who has never done security work: what the software is, what the feature does, what the code got wrong, how the crash was proved, and how it was fixed.
The software, and why it matters
S2OPC is a library. A library is a bundle of ready-made code that other programs use instead of writing everything from scratch, a bit like a set of kitchen tools you borrow rather than forge yourself. S2OPC is built by Systerel, a French company that works on safety and security. The name stands for Safe and Secure OPC.
It is used in places where software failures have real consequences: nuclear facilities, railways, aerospace and industrial automation. The project is developed with something called B-method formal verification. Formal verification means writing a mathematical description of what the software should do and proving, with maths, that the description holds. It is the same kind of technique used for train control systems and nuclear plant software. You would expect bugs to be rare in a codebase like that.
OPC UA stands for Open Platform Communications Unified Architecture. It is the language industrial machines use to talk to each other and to the systems that watch them. When a temperature sensor on a production line sends readings to the SCADA system monitoring it, that is often OPC UA. SCADA is the software that plant operators use to see and control what is happening. When a PLC, a small industrial computer that controls machinery, reports its state to a control dashboard, that is OPC UA too.

The article is titled "The Malloc Failed, The Code Said Everything Was Fine, Then the Server Crashed | CVE-2026-90782 | S2OPC".
The feature involved: subscriptions and notifications
To understand the bug you need one OPC UA idea: subscriptions and notifications.
A client (the program asking for data) connects to a server (the program holding the data) and creates a subscription. Think of a subscription as a standing order at a shop: instead of asking "is it in stock?" every minute, you say "tell me whenever it changes". Inside the subscription the client creates monitored items. Each monitored item watches one specific data point on the server, such as one sensor reading.
When values change, the server bundles the changes together and sends them to the client in a publish response. A publish response is simply the message that carries the updates.
A monitored item can produce two kinds of notification:
- DataChangeNotification: the new value of a variable that changed, such as a sensor reading, a process variable or a status flag.
- EventNotification: a structured event object, such as an alarm or a state transition. It reports something that happened, rather than something that changed value.
A single session can have both types active at the same time. That combination is exactly what the bug needs.
How the hunt started
The work began with someone else's security advisory. An advisory is a public notice that a specific piece of software has a specific problem. This one was CVE-2026-67865, filed against S2OPC for an out-of-bounds read in RepublishResponse handling. An out-of-bounds read means the program reads memory outside the area it was supposed to read, like reading past the end of a page in a book. It was a different function and a different bug from the one in this article.
CVE stands for Common Vulnerabilities and Exposures. It is a public catalogue, and each entry gets an ID number so people can refer to the same problem unambiguously.
Reading through the affected file, msg_subscription_publish_bs.c, to understand the context led to another function in the same file: msg_subscription_publish_bs__alloc_notification_message_items(). Its job is to allocate memory for a publish notification message that may contain both DataChange and Event notification objects. To allocate memory means to ask the operating system for a block of it to use; in C this is usually done with a function called malloc, short for memory allocate.
The report links to the source at S2OPC Toolkit version 1.7.3, lines 106 to 147 of that file. The test is a standalone C harness. A harness is a small program built only to test one thing, like a test rig in a workshop. It mirrors the structure of the vulnerable loop, with controllable allocator functions so the DataChange allocation can be made to fail while the Event allocation succeeds. AddressSanitizer is used to show the crash. AddressSanitizer, often shortened to ASan, is a tool that watches a program while it runs and reports memory mistakes with precise details. No crafted OPC UA packet is demonstrated; the trigger is reached through memory exhaustion, meaning the machine simply runs out of free memory.
Finding the mistake
The function loops over the notification types it needs to allocate for. A loop is a block of code that repeats, like a checkout assistant serving one customer after another. If the session has data-change items it allocates a DataChangeNotification object; if it has event items it allocates an EventNotificationList object. Both allocations go through SOPC_ExtensionObject_CreateObject(), which returns a SOPC_ReturnStatus, a value that says success or failure.
The problem is that both allocations write their result into the same status variable. A variable is a named box in the program that holds a value. Writing a new value into it replaces whatever was there before. The logic, simplified but structurally identical to the vulnerable source, is:
SOPC_ReturnStatus status = SOPC_STATUS_OK;
OpcUa_DataChangeNotification *dataChangeNotif = NULL;
OpcUa_EventNotificationList *eventNotifList = NULL;
Line by line:
SOPC_ReturnStatus status = SOPC_STATUS_OK;creates the shared status box and starts it at "OK".OpcUa_DataChangeNotification *dataChangeNotif = NULL;creates a pointer for the data-change object and sets it to NULL. A pointer is a variable that holds the address of something in memory, like a note with a house address on it. NULL means "pointing at nothing".OpcUa_EventNotificationList *eventNotifList = NULL;does the same for the event object.
Then the loop itself:
for (int i = 0; i < n; i++) {
if (dataToSet) {
/* First iteration — allocate DataChangeNotification */
status = create_object(&dataChangeNotif, "DataChangeNotification");
dataToSet = false;
/* If this fails: status = SOPC_STATUS_OOM, dataChangeNotif = NULL */
/* Loop does NOT exit. It continues to the next iteration. */
} else if (eventToSet) {
/* Second iteration — allocate EventNotificationList */
status = create_object(&eventNotifList, "EventNotificationList");
eventToSet = false;
/* If THIS succeeds: status = SOPC_STATUS_OK */
/* The previous failure is now completely erased from status */
}
}
/* Post-loop: status says SOPC_STATUS_OK. It is lying. */
if (SOPC_STATUS_OK == status && hasData) {
dataChangeNotif->NoOfMonitoredItems = ...; /* dataChangeNotif is NULL */
}
Line by line:
for (int i = 0; i < n; i++) {starts a loop that runs a fixed number of times.if (dataToSet) {asks whether a data-change object still needs to be created.status = create_object(&dataChangeNotif, "DataChangeNotification");tries to create it and stores the result in the sharedstatusbox. If memory is short, this fails and setsdataChangeNotifto NULL.dataToSet = false;marks that this job is done, so the next pass will not repeat it.- The comments spell out the trap: on failure the loop does not stop. It carries on to the next pass.
} else if (eventToSet) {on the next pass, asks whether an event object needs creating.status = create_object(&eventNotifList, "EventNotificationList");creates it and writes the result into the samestatusbox. If this succeeds, the earlier failure is overwritten with "OK".eventToSet = false;marks that job as done too.- After the loop, the comment says the status is lying: it reports success even though the first allocation failed.
if (SOPC_STATUS_OK == status && hasData) {is the guard, the check that decides whether it is safe to continue. It only looks at the single status box.dataChangeNotif->NoOfMonitoredItems = ...;then uses the data-change pointer. The arrow means "go to the object this pointer refers to and touch its field". But the pointer is NULL, so there is no object to go to.
So the DataChange allocation fails. dataChangeNotif is set to NULL by the failure path and status is set to SOPC_STATUS_OOM, where OOM means out of memory. The loop moves on. The Event allocation succeeds and status is overwritten with SOPC_STATUS_OK. The original failure is gone: not handled, not logged, not checked again. The guard then passes, the code accesses dataChangeNotif->NoOfMonitoredItems, and the server crashes.
What makes it subtle is that this is not a forgotten malloc check. The return value from SOPC_ExtensionObject_CreateObject() was read and stored into status every time. It was just stored into the same variable twice, and the second result overwrote the first. A developer reading the code sees error handling and moves on, because the error handling is there; it is quietly erased by the next operation succeeding. This is a status-clobbering bug. To clobber means to overwrite roughly, and it is one of the harder categories to catch in review precisely because every individual line looks right.
Proving it
Step 1: reproduce the normal case
The harness runs the same allocation sequence, the same shared status variable, the same post-loop guard and the same dereference as the vulnerable loop. A dereference is the act of following a pointer to reach the thing it points at. Only the allocator functions differ, so the DataChange allocation can be made to fail and the Event allocation to succeed. With both allocations succeeding:
[ALLOC] DataChangeNotification -> OK ptr=0x506000000020
[ALLOC] EventNotificationList -> OK ptr=0x506000000080
status: SOPC_STATUS_OK dataChangeNotif: valid ptr
-> Guard passed. Accessing dataChangeNotif->NoOfMonitoredItems...
-> Survived.
Line by line:
- The first line says the data-change allocation succeeded and shows the memory address it returned.
- The second line says the event allocation succeeded, with its own address.
- The status is OK and the data-change pointer is valid.
- The guard passes, as it should.
- The program accesses the field and survives, because the pointer really does point at something.
Status is correct and both pointers are valid, so nothing happens. This is the baseline: it shows the harness behaves like the real code when nothing goes wrong.
Step 2: fail the DataChange allocation, let the Event allocation succeed
[ALLOC] DataChangeNotification -> FAILED (OOM)
[ALLOC] EventNotificationList -> OK ptr=0x506000000020
status: SOPC_STATUS_OK <-- clobbered by Event success
dataChangeNotif: NULL <-- about to be dereferenced
-> Guard passed (status OK). Accessing dataChangeNotif->NoOfMonitoredItems...
Line by line:
- The data-change allocation failed because memory ran out.
- The event allocation succeeded anyway.
- The status now says OK, because the event success overwrote the failure.
- The data-change pointer is NULL, and the program is about to follow it.
- The guard passes because the status says OK, and the program tries to read the field through the NULL pointer.
The guard passes because status says success, and the NULL pointer is dereferenced. AddressSanitizer reports:
ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
The signal is caused by a READ memory access.
Hint: address points to the zero page.
#0 alloc_vulnerable — line 83 (the dereference)
#1 main
SUMMARY: AddressSanitizer: SEGV in alloc_vulnerable
Line by line:
- SEGV means segmentation fault, the operating system's way of stopping a program that touched memory it was not allowed to touch.
- The address is
0x000000000000, which is zero, which is NULL. - The signal was caused by a read, meaning the program tried to read from that address.
- The hint says the address points to the zero page, the lowest part of memory that is deliberately left unusable so that mistakes like this are caught.
- The stack trace names the function
alloc_vulnerableat line 83, the dereference, called frommain. - The summary repeats the same finding in one line.
Address 0x000000000000 is NULL: the pointer set to NULL when the allocation failed, dereferenced because the status said success.
Step 3: track the statuses independently
[ALLOC] DataChangeNotification -> FAILED (OOM)
dataStatus: FAILURE dataChangeNotif: NULL
-> DataChange alloc failed — dereference skipped safely.
No crash. Failure correctly propagated.
Line by line:
- The data-change allocation failed again.
- This time its own status box says FAILURE, and the pointer is NULL.
- The program notices the failure and skips the dereference.
- There is no crash, and the failure is passed on correctly.
This is the shape of the fix: give each allocation its own status box so one success cannot erase another failure.
Step 4: control case, a data-only session
[ALLOC] DataChangeNotification -> FAILED (OOM)
status: SOPC_STATUS_FAILURE (correctly propagated)
-> DataChange failure propagates correctly (no second alloc)
Line by line:
- The data-change allocation failed.
- The status correctly says FAILURE, because nothing came along afterwards to overwrite it.
- The failure is passed on and the second allocation never happens.
When the session has only data-change items and no event items, there is no second allocation to clobber the status. The failure propagates correctly and the dereference never runs. The bug exists only when a session has both types of monitored items, which is a realistic and common configuration rather than an edge case.
What the trigger requires
The author is explicit about what was and was not proved. No crafted OPC UA packet that deterministically causes this from the network was demonstrated. The DataChange allocation failure path is reached through memory exhaustion: SOPC_ExtensionObject_CreateObject() fails because malloc() returns NULL under OOM conditions. Triggering it reliably therefore requires the server to be under memory pressure when a publish response for a mixed session is generated.
That is not trivial to engineer remotely, but it is not purely theoretical either: OOM conditions can be induced through memory exhaustion attacks, through repeated large subscription requests, or under resource-constrained embedded deployments. An embedded device is a small computer built into a machine, often with little memory. S2OPC targets constrained industrial devices as well as servers, and "this only fails under OOM" looks different on a 256MB embedded controller than on a modern server. The ASan output, a SEGV at address NULL, is what happens when that condition is met.
Root cause
The loop has no early exit on failure. When the first allocation fails, the loop continues to the next iteration, and the second allocation's success overwrites the shared status variable. The post-loop guard checks only that single variable, so it cannot distinguish "everything succeeded" from "the first allocation failed and the second succeeded". The NULL pointer left behind by the failed allocation is then dereferenced.
The existing defence, checking the return value of SOPC_ExtensionObject_CreateObject(), was present but ineffective because both results were stored in one variable. The author also notes, in the issue filed, that it might be worth checking whether the formal model has an assumption or invariant covering this failure interleaving. An invariant is a property that is supposed to stay true at all times. The example offered is something like "if allocations are grouped in a loop, at most one can fail". The point is not that formal verification failed, but that there is a gap between proving the specification correct and proving the implementation handles every runtime failure interleaving correctly.
Impact
The impact is availability only: a server crash, with no confidentiality or integrity consequence demonstrated. In plain terms, the server stops working, but no data was shown to be stolen and nothing was shown to be altered. The CVSS score is 6.0 Medium. CVSS is a standard scoring system for the severity of a vulnerability, and the vector is a compact string that records how the score was reached:
AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H
Each part means:
AV:N: attack vector network, reachable over the network.AC:L: attack complexity low.AT:P: attack requirements present, extra conditions must hold.PR:L: privileges required low, a low-privilege client is enough.UI:N: no user interaction needed.VC:N: no confidentiality impact.VI:N: no integrity impact.VA:H: high availability impact, the server goes down.
The network-reachable path requires a session with both DataChange and Event monitored items (the AT:P, Attack Requirements Present), and a low-privilege subscribing client is enough to create such a session. The crash itself depends on the server being under memory pressure at the moment a publish response for a mixed session is generated.
In most contexts Medium is Medium. In industrial infrastructure monitoring environments, a remotely triggerable server crash on an OPC UA endpoint watching physical systems is worth more attention than the number suggests.
Fix
The fix is MR !1862, commit 8848f051. MR stands for merge request, a proposed change to the code that maintainers review before accepting it, and a commit is a recorded change in the project's history. It tracks the allocation statuses independently so that a second success cannot erase a first failure:
if (hasData) {
dataStatus = create_object(&dataChangeNotif, "DataChangeNotification");
}
if (hasEvent && dataStatus == SOPC_STATUS_OK) {
eventStatus = create_object(&eventNotifList, "EventNotificationList");
}
Line by line:
if (hasData) {checks whether a data-change object is needed.dataStatus = create_object(...)creates it and stores the result in its own box,dataStatus.if (hasEvent && dataStatus == SOPC_STATUS_OK) {only tries the event allocation if an event object is needed and the data-change step succeeded.eventStatus = create_object(...)stores the event result in a separate box,eventStatus.
/* Now both statuses are checked independently */
if (dataStatus == SOPC_STATUS_OK && hasData) {
dataChangeNotif->NoOfMonitoredItems = ...; /* ptr is valid */
}
Line by line:
- The comment says both statuses are now checked independently.
- The guard checks
dataStatusspecifically, not a shared box. - The field is only touched when the data-change allocation really succeeded, so the pointer is valid.
When the DataChange allocation fails, the Event allocation is skipped entirely. There is no second result to clobber the first, and the failure propagates cleanly.
The author lists five directions for anyone who wants to look for similar problems:
- Other shared-status loops in the same codebase. Search for loops that assign the return of an allocation or creation function to a single variable across iterations and check that variable only after the loop. A positive result is a path where an early failure is followed by a later success and the post-loop guard still passes.
- Mixed notification configurations. Look for code paths that handle DataChange and Event notifications together, including republish and retransmission paths. A positive result is a dereference of a pointer that a failed allocation left NULL while the status reports success.
- Failure interleavings in generated C from formal models. Where a specification assumes that at most one allocation in a group can fail, check whether the generated code enforces that assumption. A positive result is a runtime sequence the model does not cover that reaches an unchecked pointer.
- OOM paths on constrained deployments. Exercise allocation failure on embedded targets with small heaps, for example through repeated large subscription requests. A heap is the pool of memory a program uses for allocations like these. A positive result is a crash or sanitizer report at a NULL address when a publish response is generated for a mixed session.
- Early-exit absence. For each allocation loop, check whether a failure breaks out or is only recorded. A positive result is a loop that continues after a failure and later overwrites the recorded status.
Glossary
- AddressSanitizer (ASan): a tool that watches a running program and reports memory mistakes, such as reading through a NULL pointer, with the exact location.
- Advisory: a public notice that a specific piece of software has a specific security problem.
- Allocate: to ask the operating system for a block of memory to use.
- Attack requirements (AT): a CVSS component recording extra conditions that must hold before an attack works.
- Availability: whether a system keeps working and responding; an availability impact means it stops doing so.
- B-method: a formal, mathematical way of specifying software and proving properties about it, used in safety-critical projects.
- Client: the program that asks a server for data.
- Commit: a recorded change in a project's version history.
- Confidentiality: whether data stays secret; a confidentiality impact means data could be exposed.
- CVE: Common Vulnerabilities and Exposures, a public catalogue where each vulnerability gets an ID number.
- CVSS: a standard scoring system for the severity of a vulnerability, with a numeric score and a vector string.
- DataChangeNotification: an OPC UA notification carrying the new value of a variable that changed.
- Dereference: to follow a pointer to reach the thing it points at.
- Embedded device: a small computer built into a machine, often with limited memory.
- EventNotification: an OPC UA notification carrying a structured event object, such as an alarm or a state transition.
- Formal verification: proving with mathematics that a software specification has certain properties.
- Harness: a small test program built to exercise one specific piece of code.
- Heap: the pool of memory a program uses for allocations.
- Integrity: whether data stays unaltered; an integrity impact means data could be changed.
- Invariant: a property that is supposed to remain true at all times.
- Library: a bundle of ready-made code that other programs use.
- Loop: a block of code that repeats.
- malloc: the C function that asks the operating system for memory; short for memory allocate.
- Memory exhaustion: the condition where a machine has no free memory left to give.
- Merge request (MR): a proposed change to a codebase that maintainers review before accepting it.
- Monitored item: an OPC UA object inside a subscription that watches one specific data point.
- NULL: a pointer value meaning "pointing at nothing".
- OOM: out of memory.
- OPC UA: Open Platform Communications Unified Architecture, the protocol industrial machines use to exchange data.
- Out-of-bounds read: reading memory outside the area a program was supposed to read.
- PLC: a small industrial computer that controls machinery.
- Pointer: a variable that holds the address of something in memory.
- Proof of concept: a small demonstration that a problem is real.
- Publish response: the OPC UA message that carries updates from the server to the client.
- SCADA: the software plant operators use to monitor and control industrial systems.
- Segmentation fault (SEGV): the operating system stopping a program that touched memory it was not allowed to touch.
- Server: the program that holds data and answers clients.
- Session: a connection between a client and a server that carries a set of subscriptions and other state.
- Status-clobbering: overwriting a recorded result with a later one, so an earlier failure is lost.
- Subscription: a standing request to be told when data changes, rather than asking repeatedly.
- Variable: a named box in a program that holds a value.
- Zero page: the lowest part of memory, deliberately left unusable so that NULL pointer mistakes are caught.