CVE-2026-85035

Use-after-free via dynamically allocated message queue retained by the CAN RX filter

Published Nov 3, 2026 CVSS 3.1 · 8.8 High EPSS < 1% KEV · Not listed
Description
The can_add_rx_filter_msgq() system call installs a CAN RX filter whose callback (can_msgq_put() in drivers/can/can_common.c) is handed the caller's struct k_msgq * as user_data. The controller driver stores that raw pointer in its filter table and dereferences it from the RX path every time a matching frame arrives. The system call verifier z_vrfy_can_add_rx_filter_msgq() in drivers/can/can_handlers.c validated the queue only with K_SYSCALL_OBJ(), which is a point-in-time check of type, initialization and caller permission and says nothing about the object's lifetime.

On a build with CONFIG_USERSPACE=y and CONFIG_DYNAMIC_OBJECTS=y, an unprivileged user-mode thread that has been granted access to a CAN device can obtain a message queue whose lifetime it fully controls: k_object_alloc(K_OBJ_MSGQ) followed by k_msgq_alloc_init(). The lifetime of such an object is driven solely by its permission bitmask, and a pointer retained by the kernel is not represented there. After registering the filter, the thread calls k_object_release() — or simply terminates — and unref_check() frees the struct k_msgq storage while the CAN driver still holds the pointer.

The next matching CAN frame causes k_msgq_put() to run in supervisor context against freed memory that the attacker can have groomed with another kernel allocation: the frame payload is memcpy()d through the reused block's write_ptr, and the queue's wait_q (and poll_events under CONFIG_POLL) list nodes are manipulated. This yields kernel-heap corruption reachable from a user-mode thread, defeating the isolation CONFIG_USERSPACE is intended to provide; the same dangling pointer also arises benignly when an application thread exits without calling can_remove_rx_filter().

The fix validates the queue with K_SYSCALL_OBJ_STATIC(), which additionally rejects objects carrying K_OBJ_FLAG_ALLOC, so only statically defined queues (CAN_MSGQ_DEFINE()) may be registered from user mode. Supervisor-mode callers bypass the verifier and must themselves keep the queue valid until the filter is removed.

Analysis

AI-generated

Technical impact

The vulnerability occurs when a user‑mode thread in a Zephyr system installs a CAN RX filter that stores a pointer to a dynamically allocated message queue in the driver’s filter table. When the thread later releases or terminates the queue, that pointer becomes invalid. The driver subsequently dereferences it during CAN reception, which results in a use‑after‑free that corrupts kernel heap memory. An attacker can control the freed block with a subsequent kernel allocation, allowing the corrupted queue to execute arbitrary code in supervisor mode, effectively bypassing userspace isolation.

Affected Systems

The flaw is present in any Zephyr build that enables CONFIG_USERSPACE and CONFIG_DYNAMIC_OBJECTS, and allows unprivileged threads to create dynamic k_msgq objects and attach them to CAN RX filters. The issue is generic across affected configurations and does not depend on a specific firmware release, so any project using an unpatched version of the kernel with these settings is vulnerable.

Risk and Exploitability

The CVSS score of 8.8 indicates high severity, and the EPSS score is currently not available, indicating that the current exploitation likelihood is uncertain. The vulnerability is not listed in CISA’s KEV catalog. Exploitation requires a user‑mode thread with CAN device access and the ability to allocate and free message queues, making the primary attack vector local to the device. If successfully exploited, the attacker could gain kernel privileges or crash the system.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply the latest Zephyr patch that changes the can_add_rx_filter_msgq() verifier to use K_SYSCALL_OBJ_STATIC() (commit 0114bee266211c72a49f3b6a914d3eaf821dd460).
  • Modify your application to replace any dynamic k_msgq created in user mode with static message queues defined at compile time via CAN_MSGQ_DEFINE().
  • If your application requires dynamic message queues, remove CAN RX filter registration from user mode, or run those threads with privileged access, or disable user‑mode access to the CAN device.

Generated by OpenCVE AI on November 3, 2026 at 14:35 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Zephyrproject
Zephyrproject zephyr
Vendors & Products Zephyrproject
Zephyrproject zephyr
Type Values Removed Values Added
Description The can_add_rx_filter_msgq() system call installs a CAN RX filter whose callback (can_msgq_put() in drivers/can/can_common.c) is handed the caller's struct k_msgq * as user_data. The controller driver stores that raw pointer in its filter table and dereferences it from the RX path every time a matching frame arrives. The system call verifier z_vrfy_can_add_rx_filter_msgq() in drivers/can/can_handlers.c validated the queue only with K_SYSCALL_OBJ(), which is a point-in-time check of type, initialization and caller permission and says nothing about the object's lifetime. On a build with CONFIG_USERSPACE=y and CONFIG_DYNAMIC_OBJECTS=y, an unprivileged user-mode thread that has been granted access to a CAN device can obtain a message queue whose lifetime it fully controls: k_object_alloc(K_OBJ_MSGQ) followed by k_msgq_alloc_init(). The lifetime of such an object is driven solely by its permission bitmask, and a pointer retained by the kernel is not represented there. After registering the filter, the thread calls k_object_release() — or simply terminates — and unref_check() frees the struct k_msgq storage while the CAN driver still holds the pointer. The next matching CAN frame causes k_msgq_put() to run in supervisor context against freed memory that the attacker can have groomed with another kernel allocation: the frame payload is memcpy()d through the reused block's write_ptr, and the queue's wait_q (and poll_events under CONFIG_POLL) list nodes are manipulated. This yields kernel-heap corruption reachable from a user-mode thread, defeating the isolation CONFIG_USERSPACE is intended to provide; the same dangling pointer also arises benignly when an application thread exits without calling can_remove_rx_filter(). The fix validates the queue with K_SYSCALL_OBJ_STATIC(), which additionally rejects objects carrying K_OBJ_FLAG_ALLOC, so only statically defined queues (CAN_MSGQ_DEFINE()) may be registered from user mode. Supervisor-mode callers bypass the verifier and must themselves keep the queue valid until the filter is removed.
Title Use-after-free via dynamically allocated message queue retained by the CAN RX filter
Weaknesses CWE-416
References
Metrics cvssV3_1

{'score': 8.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H'}

Weaknesses

Sources

Status
PUBLISHED
Assigner
zephyr
Published
Updated
Nov 3, 2026, 6:13 PM
Reserved
Sep 2, 2026, 8:23 PM
Status
Awaiting Analysis
Published
Nov 3, 2026, 2:17 PM
Modified
Nov 3, 2026, 7:18 PM