Sceawere
Vulnerability Detail
CVE-2026-12365UPDATED Verified Sceawere Triage Sources: NVD / CISA KEV
Zephyr Work Queue Use-After-Free
Vulnerability Metadata
- Severity
- Medium
- Score / CVSS
- 5.8
- Creation Date
- 3h ago
- Vendor
- zephyrproject
- Product
- zephyr
- Attack Type
- use-after-free
- Vector String
- CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H
- Attack Complexity
- HIGH
Narrative and Response
Description
A use-after-free exists in the Zephyr second-generation work queue (kernel/work.c) in the handling of delayable work timeouts. When a delayable work item's timeout has been dequeued and its handler work_timeout() is in flight (blocked acquiring the work-queue spinlock), a concurrent cancellation does not wait for that handler to finish. In unschedule_locked() the pre-fix code called z_abort_timeout(), which for an already-announcing record returns -EINVAL without removing it; cancel_async_locked() then observes the work as idle, so even k_work_cancel_delayable_sync() and k_work_flush_delayable() return without blocking on the in-flight handler. Because those are the APIs the kernel header documents as the safe way to cancel before freeing a k_work_delayable, a caller that frees the object immediately after a successful sync cancel can race the still-pending handler. work_timeout() subsequently dereferences the freed record: it reads to->dticks via z_is_timeout_handler_canceled() and, if the freed slot has been reused so the bail check fails, performs a read-modify-write of wp->flags (K_WORK_DELAYED_BIT) and submits work against a stale dw->queue pointer — a use-after-free read and write. The k_work API is kernel-mode only (no __syscall entry point), so this is a kernel-internal concurrency defect rather than a userspace privilege escalation. Triggering it requires an SMP build and a subsystem that schedules and then frees (or reschedules) a delayable work item in the narrow window while its timeout is announcing; an attacker able to influence the timing of such teardown (for example via connection churn driving subsystem timers) has a plausible but probabilistic path. The impact is kernel memory corruption or crash (denial of service). The fix makes unschedule_locked() wait, by spinning on z_try_abort_timeout() returning -EAGAIN while releasing and re-acquiring the work spinlock, until any in-flight handler completes before returning, and switches work_timeout() to atomic K_WORK_DELAYED_BIT ownership. This closes both the free-then-handler use-after-free and the related reschedule early-fire race.
Executive Summary
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Technical Details
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Mitigations
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
References
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Additional Metadata
{
"score": "5.8",
"pubDate": "2026-08-14T18:17:21.933Z",
"pubdate": "2026-08-14T18:17:21.933Z",
"executiveSummary": "A use-after-free vulnerability exists in the Zephyr second-generation work queue implementation within kernel/work.c concerning the handling of delayable work timeouts.\nThe vulnerability is a kernel-internal concurrency defect manifesting in SMP builds where a delayable work item's timeout is dequeued, and its handler work_timeout() is in flight while blocked acquiring the work-queue spinlock.\nConcurrent cancellation routines such as cancel_async_locked() and unschedule_locked() fail to properly wait for the in-flight handler to finish, as z_abort_timeout() returns -EINVAL for already-announcing records without removing them.\nBecause standard synchronous cancellation and flush APIs return prematurely without blocking on the active handler, a caller may free the k_work_delayable object immediately after a successful sync cancel, creating a race condition against the still-pending handler.\nSubsequent execution of work_timeout() dereferences the freed record to read to->dticks via z_is_timeout_handler_canceled() and performs a read-modify-write operation on wp->flags while submitting work against a stale dw->queue pointer.\nThe impact of this vulnerability is kernel memory corruption or a system crash leading to a denial of service.\nTriggering the defect requires an SMP build and a subsystem that schedules and subsequently frees or reschedules a delayable work item during the narrow window while its timeout is announcing.\nAn attacker capable of influencing timing through mechanisms such as connection churn driving subsystem timers possesses a probabilistic path to exploitation, although the affected k_work API is restricted to kernel-mode execution without a direct userspace syscall entry point.",
"technicalDetails": "The vulnerable component is the Zephyr second-generation work queue located in kernel/work.c, specifically within the logic governing delayable work timeouts, unschedule_locked(), cancel_async_locked(), and the work_timeout() handler.\nThe root cause stems from improper synchronization during the cancellation of delayable work items when a timeout has been dequeued and the work_timeout() handler is actively in flight, blocked waiting to acquire the work-queue spinlock.\nIn the pre-fix implementation, unschedule_locked() invoked z_abort_timeout(). For a timeout record that is already announcing, z_abort_timeout() returns -EINVAL and fails to remove the record.\nSimultaneously, cancel_async_locked() incorrectly observes the work item as idle. As a result, APIs such as k_work_cancel_delayable_sync() and k_work_flush_delayable() return to the caller without waiting for the in-flight handler to complete execution.\nBecause kernel documentation designates these APIs as the safe method to cancel work items prior to freeing a k_work_delayable, a calling subsystem may free the underlying object immediately while the handler remains pending.\nWhen work_timeout() finally acquires execution flow, it performs memory dereferences on the freed record. Specifically, it reads to->dticks via z_is_timeout_handler_canceled() to evaluate cancellation status.\nIf the freed memory slot has been reallocated and reused, the bail check fails, causing the handler to perform a read-modify-write operation on wp->flags (K_WORK_DELAYED_BIT) and submit work utilizing a stale dw->queue pointer, resulting in arbitrary or corrupted kernel memory reads and writes.\nExploitation requires an SMP architecture configuration and relies on precise timing conditions during the narrow window where a timeout is actively announcing.\nAn external attacker must induce conditions like connection churn to manipulate subsystem timer execution and increase the probability of winning the race window between asynchronous cancellation, object deallocation, and handler execution.\nBecause the k_work API is strictly kernel-mode with no exposed __syscall entry points, this issue cannot be leveraged directly via standard userspace privilege escalation, limiting its impact domain strictly to kernel-level memory integrity violations and denial of service."
}