Skip to main content

CVE-2022-39293: CWE-191: Integer Underflow (Wrap or Wraparound) in azure-rtos usbx

Medium
Published: Thu Oct 13 2022 (10/13/2022, 00:00:00 UTC)
Source: CVE
Vendor/Project: azure-rtos
Product: usbx

Description

Azure RTOS USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Azure RTOS ThreadX. The case is, in [_ux_host_class_pima_read](https://github.com/azure-rtos/usbx/blob/master/common/usbx_host_classes/src/ux_host_class_pima_read.c), there is data length from device response, returned in the very first packet, and read by [L165 code](https://github.com/azure-rtos/usbx/blob/082fd9db09a3669eca3358f10b8837a5c1635c0b/common/usbx_host_classes/src/ux_host_class_pima_read.c#L165), as header_length. Then in [L178 code](https://github.com/azure-rtos/usbx/blob/082fd9db09a3669eca3358f10b8837a5c1635c0b/common/usbx_host_classes/src/ux_host_class_pima_read.c#L178), there is a “if” branch, which check the expression of “(header_length - UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE) > data_length” where if header_length is smaller than UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE, calculation could overflow and then [L182 code](https://github.com/azure-rtos/usbx/blob/082fd9db09a3669eca3358f10b8837a5c1635c0b/common/usbx_host_classes/src/ux_host_class_pima_read.c#L182) the calculation of data_length is also overflow, this way the later [while loop start from L192](https://github.com/azure-rtos/usbx/blob/082fd9db09a3669eca3358f10b8837a5c1635c0b/common/usbx_host_classes/src/ux_host_class_pima_read.c#L192) can move data_pointer to unexpected address and cause write buffer overflow. The fix has been included in USBX release [6.1.12](https://github.com/azure-rtos/usbx/releases/tag/v6.1.12_rel). The following can be used as a workaround: Add check of `header_length`: 1. It must be greater than `UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE`. 1. It should be greater or equal to the current returned data length (`transfer_request -> ux_transfer_request_actual_length`).

AI-Powered Analysis

AILast updated: 06/22/2025, 15:38:26 UTC

Technical Analysis

CVE-2022-39293 is an integer underflow vulnerability identified in the Azure RTOS USBX stack, specifically within the PIMA (Picture Transfer Protocol) host class read function (_ux_host_class_pima_read). USBX is a high-performance embedded USB stack integrated with Azure RTOS ThreadX, used in embedded systems requiring USB host, device, or OTG functionality. The vulnerability arises from improper validation of the header_length value extracted from the first packet of a device response. The code checks if (header_length - UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE) > data_length without ensuring header_length is at least as large as UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE. If header_length is smaller, the subtraction causes an integer underflow (wraparound), leading to an incorrect, very large value. This underflow propagates to subsequent calculations, including data_length adjustments and pointer arithmetic in a while loop that processes the USB data buffer. As a result, the data pointer can move beyond the intended buffer boundaries, causing a write buffer overflow. This can lead to memory corruption, potentially allowing an attacker to execute arbitrary code or cause a denial of service by crashing the system. The vulnerability affects all USBX versions prior to 6.1.12, where the issue has been fixed by adding proper validation checks on header_length. A recommended workaround involves verifying that header_length is greater than UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE and at least equal to the actual data length returned by the transfer request. No known exploits are reported in the wild, but the vulnerability poses a significant risk in embedded devices using affected USBX versions, especially those processing untrusted USB devices or data. Given the embedded nature of USBX, exploitation requires physical or logical access to the USB interface, but the impact on device integrity and availability can be severe.

Potential Impact

For European organizations, the impact of this vulnerability primarily concerns embedded systems and IoT devices that incorporate Azure RTOS USBX stack versions prior to 6.1.12. These devices may include industrial control systems, medical devices, automotive systems, and other critical infrastructure components that rely on USB connectivity for data transfer or peripheral integration. Exploitation could lead to memory corruption, resulting in device crashes, denial of service, or potentially remote code execution if an attacker can supply malicious USB data packets. This could disrupt operational technology environments, compromise safety-critical systems, or lead to data breaches if the device controls sensitive processes. The vulnerability's exploitation requires interaction with the USB interface, which may limit remote exploitation but does not eliminate risk in environments where USB devices are connected by users or automated processes. European sectors such as manufacturing, healthcare, transportation, and energy, which increasingly deploy embedded USB-enabled devices, could face operational disruptions or safety incidents. Moreover, the potential for supply chain attacks exists if compromised USB devices are introduced into organizational environments. The lack of known exploits reduces immediate risk, but the medium severity rating and the critical role of embedded systems in European infrastructure warrant proactive mitigation.

Mitigation Recommendations

Organizations should first identify all embedded devices and systems using Azure RTOS USBX versions prior to 6.1.12. Where possible, update the USBX stack to version 6.1.12 or later to apply the official patch. For devices where firmware updates are not feasible, implement the recommended workaround by adding validation checks to ensure header_length is greater than UX_HOST_CLASS_PIMA_DATA_HEADER_SIZE and at least equal to the actual data length before processing. Additionally, restrict physical and logical access to USB ports on critical devices to trusted personnel only, and implement strict USB device whitelisting policies to prevent unauthorized or untrusted USB devices from connecting. Network segmentation and monitoring of USB-related device logs can help detect anomalous behavior indicative of exploitation attempts. For high-value or safety-critical systems, consider disabling unused USB interfaces or employing hardware-based USB port control solutions. Regularly review device firmware and software inventories to ensure timely application of security patches. Finally, raise awareness among operational technology and embedded system teams about this vulnerability to ensure rapid response and remediation.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-09-02T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9845c4522896dcbf46fe

Added to database: 5/21/2025, 9:09:25 AM

Last enriched: 6/22/2025, 3:38:26 PM

Last updated: 8/17/2025, 12:07:40 PM

Views: 12

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats