CVE-2025-47917 in TLSinfo

Summary

by MITRE • 07/20/2025

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).

Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.

Analysis

by VulDB Data Team • 09/17/2025

The vulnerability described in CVE-2025-47917 represents a critical use-after-free condition within the Mbed TLS cryptographic library version 3.6.3 and earlier. This flaw manifests in the mbedtls_x509_string_to_names() function where the head argument is documented as an output parameter yet exhibits unexpected behavior by performing memory deallocation operations on the provided pointer. The function's implementation calls mbedtls_asn1_free_named_data_list() on the head argument, which executes a deep free operation that releases memory blocks that application code may still reference. This discrepancy between documented behavior and actual implementation creates a scenario where legitimate application code that follows the documented API specifications becomes vulnerable to memory safety violations.

The technical nature of this vulnerability aligns with CWE-416, which specifically addresses use-after-free conditions in software systems. The flaw operates through a classic memory management error where the library function assumes responsibility for freeing memory that was allocated by the calling application or through the documented API usage patterns. When applications rely solely on the documented behavior without anticipating this unexpected deallocation, they maintain references to freed memory locations, creating opportunities for memory corruption and potential code execution exploits. The vulnerability is particularly concerning because it affects core X.509 certificate processing functionality that is fundamental to secure communications in numerous applications.

Operational impact of this vulnerability extends beyond simple memory corruption to potentially enable remote code execution or denial of service conditions in affected systems. The specific reference to the x509/cert_write and x509/cert_req sample programs demonstrates that this flaw affects common certificate processing workflows where Subject Alternative Name (SAN) strings contain multiple Distinguished Names. When processing such inputs, the function's improper memory management causes applications to reference freed memory blocks, leading to unpredictable behavior that could be exploited by attackers. The high-risk classification stems from the fact that this vulnerability can be triggered through normal certificate processing operations without requiring special privileges or complex attack vectors.

Mitigation strategies for CVE-2025-47917 require immediate updates to Mbed TLS to version 3.6.4 or later where the function's behavior has been corrected to align with documented specifications. Organizations should conduct thorough code reviews of applications that utilize the affected function to identify potential references to freed memory that may have been previously overlooked. The fix typically involves modifying the mbedtls_x509_string_to_names() function to properly handle memory management without unexpected deallocation of caller-provided pointers. Additionally, system administrators should implement monitoring for unusual memory access patterns and consider runtime protections such as address space layout randomization and stack canaries. Security teams should also evaluate their certificate processing workflows to ensure that applications properly handle memory management when working with X.509 certificates, particularly in environments where certificate validation and generation are critical components of the security infrastructure. This vulnerability demonstrates the importance of rigorous testing of memory management behavior in cryptographic libraries and the need for clear documentation that accurately reflects actual implementation details.

Responsible

MITRE

Reservation

05/14/2025

Disclosure

07/20/2025

Moderation

accepted

CPE

ready

Exploit

Download

EPSS

0.01990

KEV

no

Activities

very low

Sources

Do you want to use VulDB in your project?

Use the official API to access entries easily!