CVE-2026-12051: NULL pointer dereference in USB DFU device_next download handler (handle_download)
The USB DFU class implementation in Zephyr's new (experimental) devicenext USB device stack contains a NULL pointer dereference in handledownload() (subsys/usb/devicenext/class/usbddfu.c). The handler computes MIN(setup->wLength, buf->len) and passes buf->data to the image write callback without checking that the buf netbuf pointer is non-NULL.
The handler is reached over the USB control endpoint, driven by the USB host. For a DFUDNLOAD (download) request with no Data OUT stage — notably the zero-length terminating download that the DFU protocol uses to end a firmware transfer — the USB core invokes the class handler with a NULL buffer. After the device has been advanced to the DFUDNLOADIDLE state (by sending one valid download block and a GETSTATUS), a zero-length DFUDNLOAD reaches handledownload() with buf == NULL, dereferencing it.
The result is a NULL+offset read that triggers a fatal CPU fault, i.e. a denial of service (device crash/reset). The attacker is whatever controls the USB host the device is attached to; DFU download support must be enabled with a registered image. There is no memory corruption or information disclosure — impact is limited to availability. The fix adds an explicit if (buf != NULL) guard so the callback receives a zero-length, NULL-data transfer instead of crashing.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Zephyr subsys/usb/device_next/class/usbd_dfu.c (USB DFU device_next)to a version that resolves this vulnerability.Fixed in experimental - Configuration
Ensure DFU download support is only enabled when a DFU image is registered (DFU download support must be enabled with a registered image) to limit reachability of the affected handle_download() path from the USB host.
Zephyr USB DFU device_next DFU download support = enabled/registered image - Compensating control
Mitigate potential USB-host-triggered denial of service by restricting or filtering which USB hosts/devices can connect to the DFU-capable interface (since the handler is reached over the USB control endpoint and driven by the USB host).