Skip to main content

CVE-2021-42553: buffer overflow in STMicroelectronics STM32Cube STM32 USB Host Library

Medium
VulnerabilityCVE-2021-42553cvecve-2021-42553
Published: Fri Oct 21 2022 (10/21/2022, 00:00:00 UTC)
Source: CVE
Vendor/Project: STMicroelectronics STM32Cube
Product: STM32 USB Host Library

Description

A buffer overflow vulnerability in stm32_mw_usb_host of STMicroelectronics in versions before 3.5.1 allows an attacker to execute arbitrary code when the descriptor contains more endpoints than USBH_MAX_NUM_ENDPOINTS. The library is typically integrated when using a RTOS such as FreeRTOS on STM32 MCUs.

AI-Powered Analysis

AILast updated: 07/05/2025, 09:25:42 UTC

Technical Analysis

CVE-2021-42553 is a buffer overflow vulnerability identified in the STM32 USB Host Library component of the STM32Cube software package developed by STMicroelectronics. This vulnerability affects all versions prior to 3.5.1 of the library. The STM32 USB Host Library is commonly used in embedded systems that utilize STM32 microcontrollers (MCUs), often integrated with real-time operating systems (RTOS) such as FreeRTOS. The vulnerability arises when the USB host stack processes a USB device descriptor containing more endpoints than the defined maximum (USBH_MAX_NUM_ENDPOINTS). Specifically, the buffer allocated to store endpoint descriptors is overflowed if the number of endpoints in the descriptor exceeds this limit, leading to a classic buffer overflow condition (CWE-120). This overflow can corrupt adjacent memory and potentially allow an attacker to execute arbitrary code on the affected device. The vulnerability is exploitable remotely via the USB interface without requiring any user interaction or prior authentication, but physical access to the USB port or the ability to connect a malicious USB device is necessary. The CVSS v3.1 base score is 6.8 (medium severity), reflecting the attack vector as physical (AV:P), low attack complexity, no privileges required, no user interaction, and high impact on confidentiality, integrity, and availability. No known exploits have been reported in the wild to date. The vulnerability is particularly relevant for embedded systems in industrial, automotive, medical, and IoT devices that rely on STM32 MCUs and the STM32Cube USB Host Library for USB connectivity and communication.

Potential Impact

For European organizations, the impact of this vulnerability can be significant in sectors that deploy STM32-based embedded systems with USB host functionality. Critical infrastructure sectors such as manufacturing automation, automotive systems, healthcare devices, and smart building controls often use STM32 MCUs due to their performance and cost-effectiveness. Exploitation of this vulnerability could allow attackers to execute arbitrary code on embedded devices, potentially leading to device malfunction, data leakage, or disruption of critical services. This could compromise operational technology (OT) environments, leading to safety risks and financial losses. Given the physical access requirement, the threat is more pronounced in environments where USB ports are accessible to untrusted personnel or where supply chain attacks could introduce malicious USB devices. The vulnerability also poses risks to organizations involved in the development and deployment of IoT devices across Europe, where compromised devices could be leveraged as entry points for broader network intrusion or lateral movement. While the vulnerability does not directly affect traditional IT infrastructure, the increasing convergence of IT and OT systems in European industries elevates the potential impact. Additionally, regulatory frameworks such as the EU Cybersecurity Act and NIS Directive emphasize the protection of critical infrastructure, making mitigation of such vulnerabilities a compliance priority.

Mitigation Recommendations

To mitigate this vulnerability effectively, European organizations should: 1) Update the STM32 USB Host Library to version 3.5.1 or later where the buffer overflow has been addressed. Since no official patch links are provided, organizations should monitor STMicroelectronics' official channels for updates and apply them promptly. 2) Implement strict physical security controls to restrict unauthorized access to USB ports on embedded devices, including port blocking, use of USB port locks, or disabling unused USB interfaces in firmware. 3) Employ USB device whitelisting or authentication mechanisms where feasible to prevent connection of unauthorized or malicious USB devices. 4) Conduct thorough security testing and code audits of embedded software that integrates the STM32 USB Host Library to identify and remediate any unsafe USB descriptor handling. 5) Incorporate runtime protections such as memory protection units (MPUs) and stack canaries in embedded firmware to mitigate the impact of buffer overflows. 6) For organizations deploying STM32-based devices in critical environments, establish monitoring and anomaly detection for unusual USB activity or device behavior. 7) Engage with device manufacturers and suppliers to ensure that embedded products incorporate the fixed library versions and adhere to secure development lifecycle practices. These measures go beyond generic advice by focusing on both software updates and operational controls tailored to embedded USB host vulnerabilities.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
NCSC.ch
Date Reserved
2021-10-15T00:00:00.000Z
Cisa Enriched
true
Cvss Version
3.1
State
PUBLISHED

Threat ID: 682d9819c4522896dcbd8d00

Added to database: 5/21/2025, 9:08:41 AM

Last enriched: 7/5/2025, 9:25:42 AM

Last updated: 8/17/2025, 10:01:36 AM

Views: 27

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