Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2025-47917: CWE-416 Use After Free in Mbed mbedtls

0
High
VulnerabilityCVE-2025-47917cvecve-2025-47917cwe-416
Published: Sun Jul 20 2025 (07/20/2025, 00:00:00 UTC)
Source: CVE Database V5
Vendor/Project: Mbed
Product: mbedtls

Description

Mbed TLS before 3.6.4 allows a use-after-free in certain situations of applications that are developed in accordance with the documentation. The function mbedtls_x509_string_to_names() takes a head argument that is documented as an output argument. The documentation does not suggest that the function will free that pointer; however, the function does call mbedtls_asn1_free_named_data_list() on that argument, which performs a deep free(). As a result, application code that uses this function (relying only on documented behavior) is likely to still hold pointers to the memory blocks that were freed, resulting in a high risk of use-after-free or double-free. In particular, the two sample programs x509/cert_write and x509/cert_req are affected (use-after-free if the san string contains more than one DN).

AI-Powered Analysis

AILast updated: 11/03/2025, 19:39:36 UTC

Technical Analysis

CVE-2025-47917 is a use-after-free vulnerability identified in the Mbed TLS cryptographic library prior to version 3.6.4. The flaw exists in the function mbedtls_x509_string_to_names(), which is designed to parse X.509 certificate strings into internal data structures. The function takes a pointer argument 'head' intended as an output parameter. However, contrary to the documentation, the function internally calls mbedtls_asn1_free_named_data_list() on this pointer, which performs a deep free of the memory it points to. As a result, application code that retains references to this pointer after the function call ends up with dangling pointers. This discrepancy between documented behavior and actual implementation leads to use-after-free or double-free conditions when the application attempts to access or free the memory again. The vulnerability is particularly triggered when the Subject Alternative Name (SAN) string contains multiple Distinguished Names (DNs), as demonstrated in the sample programs x509/cert_write and x509/cert_req. Exploiting this vulnerability could allow attackers to cause memory corruption, leading to denial of service or potentially arbitrary code execution. The CVSS v3.1 base score is 8.9, reflecting a network attack vector with high complexity, no privileges required, no user interaction, and a scope change. No known exploits are currently in the wild, but the vulnerability poses a significant risk due to its impact on confidentiality, integrity, and availability of affected systems.

Potential Impact

For European organizations, the impact of CVE-2025-47917 can be substantial, especially for those relying on Mbed TLS in embedded systems, IoT devices, or network appliances that handle X.509 certificates for authentication and encryption. Successful exploitation could lead to memory corruption, causing application crashes or enabling attackers to execute arbitrary code remotely. This compromises the confidentiality and integrity of sensitive data and disrupts service availability. Critical infrastructure sectors such as telecommunications, manufacturing, automotive, and healthcare, which often deploy embedded devices using Mbed TLS, are particularly vulnerable. The vulnerability's network attack vector means attackers can exploit it remotely without authentication, increasing the risk of widespread exploitation. Additionally, the complexity of the attack and the need for specific certificate conditions may limit immediate exploitation but do not eliminate the threat. Organizations may face regulatory and compliance repercussions if the vulnerability leads to data breaches or service outages.

Mitigation Recommendations

The primary mitigation is to upgrade all affected Mbed TLS instances to version 3.6.4 or later, where the use-after-free issue has been corrected. Organizations should audit their codebases for usage of the mbedtls_x509_string_to_names() function, especially in contexts handling multiple Distinguished Names in SAN strings, to ensure no unsafe pointer references persist after function calls. Developers should avoid relying solely on documentation and verify actual function behaviors through code review and testing. Implementing memory safety checks and employing tools such as AddressSanitizer during development can help detect use-after-free conditions. For embedded and IoT devices where immediate upgrades are challenging, applying runtime protections like Control Flow Integrity (CFI) and deploying network-level intrusion detection systems to monitor anomalous TLS certificate processing may reduce risk. Additionally, organizations should monitor vendor advisories for patches and exploit reports and incorporate vulnerability scanning into their security operations.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
mitre
Date Reserved
2025-05-14T00:00:00.000Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 687d396ea83201eaac04070d

Added to database: 7/20/2025, 6:46:06 PM

Last enriched: 11/3/2025, 7:39:36 PM

Last updated: 11/28/2025, 11:05:07 AM

Views: 86

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

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