CVE-2026-12052
JSON

5.2medium

Out-of-bounds write in USB CDC NCM control handler when host wLength is smaller than the response

Severity
5.2medium CVSS:3.1 by zephyr
Exploit likelihood
0.19% (higher than 8% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
zephyr

Description

The USB device-side CDC NCM class control-to-host handler usbd_cdc_ncm_cth in subsys/usb/device_next/class/usbd_cdc_ncm.c builds a fixed-size response for the GET_NTB_PARAMETERS (28-byte struct ntb_parameters) and GET_NTB_INPUT_SIZE (8-byte struct ntb_input_size) class requests and copies the whole structure into the control DATA IN buffer with net_buf_add_mem(buf, ..., sizeof(...)), ignoring the host-supplied wLength. The control DATA IN buffer is allocated by the USB stack with a capacity of exactly wLength bytes (usbd_ep_ctrl_data_in_alloc -> udc_ctrl_data_alloc -> net_buf_alloc_len(&udc_ep_pool, wLength); no round-up is applied for the IN endpoint). Because net_buf_add_mem/net_buf_simple_add only bounds the copy with an __ASSERT_NO_MSG, which is compiled out in production builds, a host that issues one of these standard CDC NCM control requests with a wLength smaller than the response structure (e.g. wLength = 1) causes the handler to memcpy up to 27 bytes past the end of the allocated pool buffer. The request fields come straight from the USB SETUP packet, so any host (or USB interposer) the Zephyr device enumerates against can trigger the overflow with no authentication once an image built with the device_next USB stack and the CDC NCM class is connected. The out-of-bounds write corrupts adjacent allocations and metadata in the shared udc_ep_pool, primarily causing memory corruption and denial of service of the USB stack; the overflow length is bounded (<= 27 bytes) and the written content is fixed device constants, and the bug reads nothing back so there is no information disclosure. The fix clamps the copy with MIN(sizeof(...), setup->wLength), matching the existing CDC ACM handler.

Affected

Product or packageVersionsReported by
zephyrfrom 4.0.0 before 4.3.2, from 4.4.0 before 4.4.2CVE List

Classification

CWE-787

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

The USB device-side CDC NCM class control-to-host handler usbd_cdc_ncm_cth in subsys/usb/device_next/class/usbd_cdc_ncm.c builds a fixed-size response for the GET_NTB_PARAMETERS (28-byte struct ntb_parameters) and GET_NTB_INPUT_SIZE (8-byte struct ntb_input_size) class requests and copies the whole structure into the control DATA IN buffer with net_buf_add_mem(buf, ..., sizeof(...)), ignoring the host-supplied wLength. The control DATA IN buffer is allocated by the USB stack with a capacity of exactly wLength bytes (usbd_ep_ctrl_data_in_alloc -> udc_ctrl_data_alloc -> net_buf_alloc_len(&udc_ep_pool, wLength); no round-up is applied for the IN endpoint). Because net_buf_add_mem/net_buf_simple_add only bounds the copy with an __ASSERT_NO_MSG, which is compiled out in production builds, a host that issues one of these standard CDC NCM control requests with a wLength smaller than the response structure (e.g. wLength = 1) causes the handler to memcpy up to 27 bytes past the end of the allocated pool buffer. The request fields come straight from the USB SETUP packet, so any host (or USB interposer) the Zephyr device enumerates against can trigger the overflow with no authentication once an image built with the device_next USB stack and the CDC NCM class is connected. The out-of-bounds write corrupts adjacent allocations and metadata in the shared udc_ep_pool, primarily causing memory corruption and denial of service of the USB stack; the overflow length is bounded (<= 27 bytes) and the written content is fixed device constants, and the bug reads nothing back so there is no information disclosure. The fix clamps the copy with MIN(sizeof(...), setup->wLength), matching the existing CDC ACM handler.

NVD (es)

El gestor de control a host de la clase CDC NCM del lado del dispositivo USB usbd_cdc_ncm_cth en subsys/usb/device_next/class/usbd_cdc_ncm.c construye una respuesta de tamaño fijo para las solicitudes de clase GET_NTB_PARAMETERS (estructura ntb_parameters de 28 bytes) y GET_NTB_INPUT_SIZE (estructura ntb_input_size de 8 bytes) y copia la estructura completa en el búfer de control DATA IN con net_buf_add_mem(buf, ..., sizeof(...)), ignorando el wLength proporcionado por el host. El búfer de control DATA IN es asignado por la pila USB con una capacidad de exactamente wLength bytes (usbd_ep_ctrl_data_in_alloc -> udc_ctrl_data_alloc -> net_buf_alloc_len(&udc_ep_pool, wLength); no se aplica redondeo para el punto final IN). Debido a que net_buf_add_mem/net_buf_simple_add solo limita la copia con un __ASSERT_NO_MSG, que se compila fuera en las compilaciones de producción, un host que emite una de estas solicitudes de control estándar de CDC NCM con un wLength menor que la estructura de respuesta (por ejemplo, wLength = 1) hace que el gestor copie con memcpy hasta 27 bytes más allá del final del búfer de pool asignado. Los campos de la solicitud provienen directamente del paquete USB SETUP, por lo que cualquier host (o interponedor USB) contra el que el dispositivo Zephyr se enumere puede activar el desbordamiento sin autenticación una vez que se conecta una imagen construida con la pila USB device_next y la clase CDC NCM. La escritura fuera de límites corrompe las asignaciones adyacentes y los metadatos en el udc_ep_pool compartido, causando principalmente corrupción de memoria y denegación de servicio de la pila USB; la longitud del desbordamiento está limitada (menor o igual que 27 bytes) y el contenido escrito son constantes de dispositivo fijas, y el error no lee nada de vuelta, por lo que no hay revelación de información. La solución limita la copia con MIN(sizeof(...), setup -> wLength), coincidiendo con el gestor CDC ACM existente.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-12052 changed 2026-11-04CVE Terms of Use
NVDCVE-2026-12052 changed 2026-11-04Public domain