Skip to main content

CVE-2022-29246: CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') in azure-rtos usbx

Medium
Published: Tue May 24 2022 (05/24/2022, 15:00:16 UTC)
Source: CVE
Vendor/Project: azure-rtos
Product: usbx

Description

Azure RTOS USBX is a USB host, device, and on-the-go (OTG) embedded stack. Prior to version 6.1.11, he USBX DFU UPLOAD functionality may be utilized to introduce a buffer overflow resulting in overwrite of memory contents. In particular cases this may allow an attacker to bypass security features or execute arbitrary code. The implementation of `ux_device_class_dfu_control_request` function does not assure that a buffer overflow will not occur during handling of the DFU UPLOAD command. When an attacker issues the `UX_SLAVE_CLASS_DFU_COMMAND_UPLOAD` control transfer request with `wLenght` larger than the buffer size (`UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH`, 256 bytes), depending on the actual implementation of `dfu -> ux_slave_class_dfu_read`, a buffer overflow may occur. In example `ux_slave_class_dfu_read` may read 4096 bytes (or more up to 65k) to a 256 byte buffer ultimately resulting in an overflow. Furthermore in case an attacker has some control over the read flash memory, this may result in execution of arbitrary code and platform compromise. A fix for this issue has been included in USBX release 6.1.11. As a workaround, align request and buffer size to assure that buffer boundaries are respected.

AI-Powered Analysis

AILast updated: 06/23/2025, 07:52:20 UTC

Technical Analysis

CVE-2022-29246 is a classic buffer overflow vulnerability (CWE-120) found in the Azure RTOS USBX embedded USB stack, specifically affecting versions prior to 6.1.11. USBX is a comprehensive USB host, device, and on-the-go (OTG) stack widely used in embedded systems for USB communication. The vulnerability arises in the implementation of the Device Firmware Upgrade (DFU) UPLOAD functionality, particularly within the function ux_device_class_dfu_control_request. This function handles USB control transfer requests related to DFU commands. The issue occurs because the code does not properly validate the size of the input buffer when processing the UX_SLAVE_CLASS_DFU_COMMAND_UPLOAD request. The parameter wLength, which specifies the length of the data to be uploaded, can be set by an attacker to a value larger than the allocated buffer size (UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH, 256 bytes). In some implementations, the function ux_slave_class_dfu_read may read up to 4096 bytes or even up to 65,535 bytes into this 256-byte buffer, causing a buffer overflow. This overflow can overwrite adjacent memory, potentially corrupting memory contents, bypassing security features, or enabling arbitrary code execution. If an attacker can control the data read from flash memory, they may execute malicious code on the affected platform, leading to full system compromise. The vulnerability is mitigated in USBX version 6.1.11 and later, where proper bounds checking is enforced. As a temporary workaround, developers are advised to align the request size and buffer size to ensure buffer boundaries are respected, preventing overflow. No known exploits have been reported in the wild to date.

Potential Impact

For European organizations deploying embedded devices or systems that utilize Azure RTOS USBX versions prior to 6.1.11, this vulnerability poses a significant risk. Exploitation could lead to unauthorized code execution on embedded devices, potentially compromising device integrity and confidentiality. This is particularly critical for sectors relying on embedded systems for operational technology (OT), such as manufacturing, automotive, healthcare devices, and critical infrastructure. A successful attack could allow adversaries to bypass security controls, manipulate device behavior, or disrupt availability by causing system crashes or erratic behavior. Given the embedded nature of USBX, affected devices may be difficult to patch promptly, increasing exposure. The ability to execute arbitrary code could also serve as a foothold for lateral movement within industrial or enterprise networks. Although no public exploits are known, the medium severity rating and the potential for high-impact outcomes warrant proactive mitigation. The threat is especially relevant for organizations with supply chains or products incorporating Azure RTOS USBX, as compromised devices could undermine trust and safety.

Mitigation Recommendations

1. Immediate upgrade to Azure RTOS USBX version 6.1.11 or later, which contains the official patch addressing this buffer overflow vulnerability. 2. For devices where upgrading is not immediately feasible, implement strict input validation by aligning the wLength parameter with the buffer size (256 bytes) to prevent buffer overflows during DFU UPLOAD requests. 3. Conduct thorough code audits and testing on embedded firmware to ensure no other unchecked buffer operations exist, especially in USB-related code paths. 4. Employ runtime protections such as stack canaries, memory protection units (MPUs), or execute-disable (XD) bits where hardware supports them to mitigate exploitation impact. 5. Monitor USB device activity and control transfer requests for anomalous or oversized DFU UPLOAD commands that could indicate exploitation attempts. 6. Incorporate secure boot and firmware integrity verification mechanisms to detect unauthorized code execution or firmware tampering. 7. Coordinate with device manufacturers and suppliers to confirm that embedded products in use have been updated or mitigated against this vulnerability. 8. For critical infrastructure and OT environments, isolate embedded devices from broader networks to limit attack surface and potential lateral movement.

Need more detailed analysis?Get Pro

Technical Details

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

Threat ID: 682d9843c4522896dcbf305d

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

Last enriched: 6/23/2025, 7:52:20 AM

Last updated: 7/30/2025, 9:54:59 AM

Views: 10

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