CVE-2026-130477 in Zephyrinfo

Summary

by MITRE • 11/29/2026

In the kernel's user-mode object management, unref_check() in kernel/userspace/userspace.c frees a dynamically allocated kernel object as soon as its permission bitmap becomes empty. It does not check the object type or whether the kernel still uses the object. k_thread_create() keeps pointers to a dynamic struct k_thread (from k_object_alloc(K_OBJ_THREAD)) and a dynamic stack (from k_object_alloc_size(K_OBJ_THREAD_STACK_ELEMENT, ...) or k_thread_stack_alloc() with K_USER) for the whole life of the thread, but nothing in the bitmap records this. z_thread_user_init() gives the new thread permission on its own thread object only, not on its stack. When the thread terminates, halt_thread() calls z_thread_release(), and its z_thread_user_exit() drops all of the thread's permissions. If that leaves the bitmap empty, the thread's own struct k_thread (and a stack it holds the last permission on) is freed before the abort path and the context switch are done with it.

Any user thread with a resource pool can trigger this through syscalls it is allowed to make. If it creates a thread on a dynamic stack and then calls k_object_release() on the stack, or exits, the stack block is freed while the child still runs on it. With CONFIG_GEN_PRIV_STACKS that block also holds the privileged stack and z_stack_data, and the child keeps user-mode access to it. Once the creator has released a dynamic thread object, the thread itself can call k_object_release() on its own thread object and free its struct k_thread while it is running. z_vrfy_k_object_release() checks only that the caller holds permission on the object. If the creator has dropped its permissions, the child's ordinary termination frees the thread object inside halt_thread(). The kernel then still reads and writes the freed memory: thread->stack_obj, the thread state, swap_retval and switch_handle, and CPUs waiting for the halt spin on it. On SMP builds, another CPU can reallocate the memory in that window. All of this needs CONFIG_USERSPACE and CONFIG_DYNAMIC_OBJECTS.

Freed blocks go back to the thread's resource pool, which also serves later kernel allocations such as other dynamic kernel objects and their metadata. A user thread can then read and write kernel heap memory it was never granted, overwrite kernel data later placed there, or control the contents of a struct k_thread that the scheduler still uses. This breaks kernel integrity (P1) and user-mode isolation (P2) from an unprivileged user thread. The supervisor-only k_object_free() states that it is not exposed to user mode because the kernel cannot tell whether an object is still in use, and k_thread_stack_free() refuses to free a stack in use. Dropping permissions gets around both.

If you want to get the best quality for vulnerability data then you always have to consider VulDB.

Analysis

by VulDB Data Team • 11/29/2026

The vulnerability resides within the Zephyr RTOS kernel's userspace object management subsystem, specifically affecting the unref_check function located in kernel/userspace/userspace.c. This flaw represents a critical race condition and logic error where dynamically allocated kernel objects are prematurely freed based solely on their permission bitmap becoming empty. The core technical failure is that the system does not verify whether the kernel itself still maintains active references to these objects before initiating deallocation. While functions like k_thread_create maintain internal pointers to dynamic structures such as struct k_thread and associated stack memory for the entire lifecycle of a thread, this usage is not reflected in the object's permission bitmap. Consequently, when permissions are revoked or released by user-space threads, the reference count drops to zero without accounting for these implicit kernel-held references, triggering immediate deallocation while the objects remain actively in use by the scheduler and execution context.

The operational impact of this flaw allows an unprivileged user thread with access to a resource pool to compromise both kernel integrity and user-mode isolation. By creating a thread on a dynamic stack and subsequently calling k_object_release on that stack, or simply allowing the thread to exit after dropping permissions, the system frees the memory block while the child thread is still executing upon it. This scenario is particularly severe when CONFIG_GEN_PRIV_STACKS is enabled, as this configuration causes the stack block to also hold privileged stack data and z_stack_data structures. In such cases, a user-mode process retains access to sensitive kernel-level memory regions even after the creator has relinquished its permissions. Furthermore, if a thread releases permission on its own thread object, it can trigger the freeing of struct k_thread while that same thread is still running. The verification function z_vrfy_k_object_release only checks for caller permissions and fails to detect whether other kernel components are actively utilizing the target object.

The consequences extend beyond simple memory corruption into severe security breaches involving arbitrary read and write capabilities within the kernel heap. Freed blocks return to the thread's resource pool, which is subsequently reused for later kernel allocations including metadata for other dynamic objects. An attacker can exploit this window of vulnerability to read sensitive kernel data or overwrite critical structures with controlled content. On symmetric multiprocessing systems, another CPU core may reallocate the freed memory during the brief interval between deallocation and the completion of abort paths or context switches, exacerbating the risk of use-after-free exploitation. The scheduler continues to access fields such as thread->stack_obj, thread state variables, swap_retval, and switch_handle in this corrupted memory space, leading to undefined behavior, system crashes, or potential privilege escalation.

This vulnerability directly contradicts the design intent documented in supervisor-only functions like k_object_free and k_thread_stack_free, which explicitly warn against exposing such operations to user mode because the kernel cannot reliably determine if an object is still in use. The current implementation allows dropping permissions to bypass these safeguards effectively rendering them obsolete for dynamically allocated objects managed through userspace APIs. To mitigate this risk, it is imperative that reference counting mechanisms are decoupled from permission bitmaps or enhanced to track implicit kernel references alongside explicit user permissions. Implementing strict checks within unref_check to verify active usage by the scheduler and execution contexts before freeing memory would prevent premature deallocation. Additionally, restricting k_object_release operations on thread-related objects until all associated resources are definitively detached from any running context is essential for maintaining system stability and security boundaries. This issue highlights a fundamental gap in how resource lifecycle management interacts with permission models in real-time operating systems handling userspace applications.

Responsible

Zephyr

Reservation

11/17/2026

Disclosure

11/29/2026

Moderation

accepted

CPE

ready

EPSS

0.00000

KEV

no

Activities

very low

Sources

Interested in the pricing of exploits?

See the underground prices here!