CVE-2026-104376 — Zephyrproject Zephyr — CWE-416
The kernel object core framework (kernel/obj_core.c) linked every participating kernel object (semaphores, mutexes, message queues, stacks, pipes, events, and so on) into a per-type singly linked list through a sys_snode_t embedded in the object itself. k_obj_core_link() appended the object with sys_slist_append(), and nothing ever unlinked these objects except threads. When an object's storage was freed, went out of scope, or was reused while it was the list tail, the list kept pointing into dead memory. The next k_obj_core_init_and_link() (for example from k_sem_init()) then wrote a pointer through that stale node. Re-initializing the current tail object also made the list self-referential, so k_obj_type_walk_locked() / k_obj_type_walk_unlocked() loop forever. When CONFIG_OBJ_CORE, CONFIG_USERSPACE and CONFIG_DYNAMIC_OBJECTS are all enabled, an unprivileged user-mode thread can trigger this through system calls alone. It allocates a semaphore with k_object_alloc(), initializes it with k_sem_init(), and releases it with k_object_release(). unref_check() then frees the object without unlinking it, and the thread's next k_sem_init() makes the kernel write a kernel pointer into the freed (and possibly reallocated) kernel heap chunk. In kernel-only builds with CONFIG_OBJ_CORE enabled, the same defect corrupts memory during ordinary operation, because k_work_flush() and k_work_cancel_sync() initialize semaphores on the caller's stack. The result is supervisor-mode memory corruption that crosses the userspace isolation boundary. It can crash the system, corrupt unrelated kernel objects that reuse the freed memory, or hang any walker of the object-core lists. CONFIG_OBJ_CORE is disabled by default. The fix replaces the intrusive lists with a kernel-owned registry keyed by object address, so the code no longer writes into registered objects' storage.
The kernel object core framework (kernel/obj_core.c) linked every participating kernel object (semaphores, mutexes, message queues, stacks, pipes, events, and so on) into a per-type singly linked list through a sys_snode_t embedded in the object itself. k_obj_core_link() appended the object with sys_slist_append(), and nothing ever unlinked these objects except threads. When an object's storage was freed, went out of scope, or was reused while it was the list tail, the list kept pointing into dead memory. The next k_obj_core_init_and_link() (for example from k_sem_init()) then wrote a pointer through that stale node. Re-initializing the current tail object also made the list self-referential, so k_obj_type_walk_locked() / k_obj_type_walk_unlocked() loop forever. When CONFIG_OBJ_CORE, CONFIG_USERSPACE and CONFIG_DYNAMIC_OBJECTS are all enabled, an unprivileged user-mode thread can trigger this through system calls alone. It allocates a semaphore with k_object_alloc(), initializes it with k_sem_init(), and releases it with k_object_release(). unref_check() then frees the object without unlinking it, and the thread's next k_sem_init() makes the kernel write a kernel pointer into the freed (and possibly reallocated) kernel heap chunk. In kernel-only builds with CONFIG_OBJ_CORE enabled, the same defect corrupts memory during ordinary operation, because k_work_flush() and k_work_cancel_sync() initialize semaphores on the caller's stack. The result is supervisor-mode memory corruption that crosses the userspace isolation boundary. It can crash the system, corrupt unrelated kernel objects that reuse the freed memory, or hang any walker of the object-core lists. CONFIG_OBJ_CORE is disabled by default. The fix replaces the intrusive lists with a kernel-owned registry keyed by object address, so the code no longer writes into registered objects' storage.
🎯 What is this vulnerability?
CVE-2026-104376 is a Use-After-Free (UAF) vulnerability (CWE-416) in the Zephyr RTOS kernel's object core framework (kernel/obj_core.c).
The root cause lies in the design of the kernel object registry. The framework maintains per-type singly linked lists (e.g., for semaphores, mutexes, message queues) to allow the kernel to iterate over all active objects of a specific type. This is achieved by embedding a sys_snode_t structure directly within the memory allocation of each kernel object.
The Flaw:
1. Intrusive List Design: When an object is initialized (e.g., via k_sem_init()), it is appended to the global list for its type using sys_slist_append().
2. Missing Unlink on Free: When the object's memory is freed (via k_object_release() or stack scope exit), the code fails to remove the node from the linked list.
3. Stale Pointer: The list tail (or any node in the chain) now points to memory that has been returned to the heap allocator.
4. Heap Reuse & Corruption: If that memory chunk is reallocated for a new object (or reused by another subsystem), the next call to k_obj_core_init_and_link() will write a pointer into the stale node location. Since the stale node is still part of the active list, this write corrupts the kernel's internal data structures.
5. Self-Reference Loop: Re-initializing the object that is currently the tail of the list can cause the list to become self-referential, leading to infinite loops in k_obj_type_walk_locked().
Critical Context:
- This vulnerability is only exploitable when
CONFIG_OBJ_CORE,CONFIG_USERSPACE, andCONFIG_DYNAMIC_OBJECTSare enabled. CONFIG_OBJ_COREis disabled by default in standard Zephyr builds.- The vulnerability allows an unprivileged user-mode thread to corrupt supervisor-mode (kernel) memory, breaking the isolation boundary.
- Target Identification: The attacker must identify a Zephyr-based device (IoT, embedded sensor, etc.) that has: *
- Version Check: Determine the Zephyr version. Since this is a recent CVE (2026), it likely affects versions prior to the patch that introduced the kernel-owned registry.
- Attack Surface: The attacker needs a valid user-mode thread or the ability to execute code in user mode. This could be via a legitimate application, a compromised peripheral, or a local physical access scenario.
⚡ Attack Chain
1. Discovery & Reconnaissance
CONFIG_USERSPACE enabled (allowing unprivileged threads).
* CONFIG_DYNAMIC_OBJECTS enabled (allowing runtime allocation of kernel objects).
* CONFIG_OBJ_CORE enabled (the vulnerable framework).
2. Exploitation
The attacker exploits the UAF by triggering a specific sequence of system calls to free an object while it remains in the kernel's linked list, then reusing the memory.Illustrative PoC (C Code for Zephyr User-Mode Thread):
Note: This is a conceptual PoC demonstrating the logic. Exact function signatures may vary slightly by Zephyr version.
#include <zephyr/kernel.h>
#include <zephyr/sys/cbprintf.h>
// Assume these are available in the user-mode environment
extern void *k_object_alloc(size_t size);
extern void k_object_release(void *obj);
extern int k_sem_init(struct k_sem *sem, unsigned int initial, unsigned int limit);
void exploit_uaf(void) {
// 1. Allocate a semaphore object dynamically
struct k_sem *sem = (struct k_sem *)k_object_alloc(sizeof(struct k_sem));
if (!sem) {
printk("Allocation failed\n");
return;
}
// 2. Initialize the semaphore. This links it into the kernel's
// semaphore list via k_obj_core_init_and_link().
k_sem_init(sem, 0, 1);
// 3. Release the object.
// CRITICAL: This frees the memory but DOES NOT unlink it from the list.
// The kernel's list now points to freed memory.
k_object_release(sem);
// 4. Trigger memory reuse.
// The attacker allocates a new object of the same size.
// The heap allocator is likely to return the same chunk.
struct k_sem *new_sem = (struct k_sem *)k_object_alloc(sizeof(struct k_sem));
if (new_sem) {
// 5. Initialize the new semaphore.
// This calls k_obj_core_init_and_link() again.
// It writes a pointer into the 'stale node' location (which is now
// part of new_sem's memory).
// This corrupts the kernel's linked list structure.
k_sem_init(new_sem, 0, 1);
// 6. The kernel's object list is now corrupted.
// Subsequent calls to k_obj_type_walk() may crash or loop infinitely.
// If the corrupted pointer is dereferenced, it may lead to
// arbitrary kernel memory write or code execution.
}
}Mechanism of Corruption:
1. k_object_release(sem) frees the memory chunk.
2. The kernel's semaphore list still contains a node pointing to this freed chunk.
3. k_object_alloc() returns the same chunk for new_sem.
4. k_sem_init(new_sem, ...) writes the sys_snode_t structure into new_sem's memory.
5. Because the old node is still in the list, the kernel now has a list node that points to new_sem's internal structure, but the list's internal pointers are inconsistent with the new object's state.
6. If the kernel walks the list, it may follow a pointer that is now invalid or points to a different object, leading to:
* Crash: Dereferencing a bad pointer.
* Infinite Loop: If the list becomes self-referential.
* Arbitrary Write: If the attacker can control the contents of the reused memory, they may be able to overwrite kernel function pointers or other critical structures.
3. Post-Exploitation
🌍 Real World Impact
CVSS Vector Analysis: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:L/I:H/A:H
Practical Consequences:
🛡️ Remediation & Mitigation
1. Patching
2. Workarounds
CONFIG_OBJ_CORE: Since CONFIG_OBJ_CORE is disabled by default, ensure it remains disabled if not strictly necessary. This is the most effective mitigation.CONFIG_OBJ_CORE=nCONFIG_DYNAMIC_OBJECTS: If dynamic allocation of kernel objects is not required, disable this option. This prevents the attacker from allocating and freeing objects at runtime.CONFIG_DYNAMIC_OBJECTS=nCONFIG_USERSPACE: If user-mode isolation is not required, disable user mode. This prevents unprivileged threads from triggering the vulnerability.CONFIG_USERSPACE=n3. Detection
k_obj_type_walk().ASSERTION FAIL: node != NULL IN: /zephyr/kernel/obj_core.c
* Example log: System halted: Infinite loop detected in object walk
obj_core.c.⚠️ Urgency
Priority: Medium-High
CONFIG_OBJ_CORE is disabled by default, which significantly reduces the attack surface.CONFIG_OBJ_CORE is enabled, treat this as a high-priority issue.
2. Short-Term: Disable CONFIG_OBJ_CORE if it is not required.
3. Long-Term: Upgrade to a patched version of Zephyr.Note: While the exploit complexity is high, the impact is severe (kernel memory corruption, potential RCE). In critical environments (ICS, medical devices), this should be treated as a high-priority vulnerability.
[🤖 CVE Professor AI Security Engine]
FOFA Query