CVE-2025-47917
NoneCVSS
—
EPSS
2.4%
Published
Jul 20, 2025
CISA due date
—
Cloudanix analysis
A coding mistake in a widely used security library can let attackers take over programs that create or check digital certificates when developers follow the library's own instructions.
- Exploitation
- Other
- Attacker needs
- Low Privilege
- Complexity
- High
- Impact
- Full Compromise
- Component
- Library
- Class
- Use After Free
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
The mbedtls_x509_string_to_names function performs a deep free on its documented output-only head argument via mbedtls_asn1_free_named_data_list, leaving application-held pointers to freed memory and enabling use-after-free or double-free conditions, notably when SAN strings contain multiple DNs in affected sample programs.
Why it matters to the business
Applications relying on Mbed TLS for X.509 certificate processing face elevated risk of crashes, memory corruption, or remote code execution; the presence of public exploit code increases urgency for remediation across dependent projects.
How an attack unfolds
An attacker supplies crafted input containing multiple distinguished names in a subject alternative name string to code paths invoking mbedtls_x509_string_to_names (such as certificate signing or request handling), causing the library to free memory still referenced by the calling application and enabling subsequent use-after-free exploitation for arbitrary code execution.
How to fix it
Upgrade armmbed/mbedtls to the commit c765c831e5c2a0971410692f92f7a81d6ec65ec2 or later; rebuild all dependent applications and verify that custom callers of mbedtls_x509_string_to_names no longer rely on the pre-free pointer value.
How to confirm the fix worked
Confirm the installed commit or release contains c765c831e5c2a0971410692f92f7a81d6ec65ec2; execute the x509/cert_write and x509/cert_req sample programs with multi-DN SAN input and monitor for absence of use-after-free or double-free behavior under memory sanitizers.
Typical attack path
- Locate applications or libraries built against vulnerable Mbed TLS that invoke mbedtls_x509_string_to_names
- Craft a certificate or certificate request containing a SAN extension with multiple DNs
- Trigger certificate generation or parsing code that calls the vulnerable function
- Reuse or dereference the now-freed memory blocks to achieve code execution or denial of service
How to detect it
Search application logs and crash reports for segmentation faults or memory sanitizer reports occurring during X.509 certificate operations; inspect core dumps or heap traces for double-free or dangling pointer patterns tied to named data list structures.
What your security team should do
- Prioritize upgrade of all Mbed TLS instances to the fixed commit because public exploit code is available
- Audit source code for any direct or indirect use of mbedtls_x509_string_to_names and update callers to allocate fresh structures after the call
- Rebuild and redeploy all affected binaries; re-test certificate handling workflows with memory debugging tools
- Monitor EPSS trend and any new exploit publications for potential increase in in-the-wild activity
The record
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).
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Alpine:v3.20 | mbedtls | 0 | 3.6.4-r0 |
| Alpine:v3.21 | mbedtls | 0 | 3.6.4-r0 |
| Alpine:v3.22 | mbedtls | 0 | 3.6.4-r0 |
| Debian:11 | mbedtls | 0 | No fix |
| Debian:11 | mbedtls | 0 | 2.16.9-0.1+deb11u3 |
| Debian:12 | mbedtls | 0 | No fix |
| Debian:13 | mbedtls | 0 | 3.6.4-1 |
| Debian:14 | mbedtls | 0 | 3.6.4-1 |
| openSUSE:Leap 16.0 | mbedtls | 0 | 3.6.6-bp160.1.1 |
Related vulnerabilities
- CVE-2025-48965 Mbed TLS before 3.6.4 has a NULL pointer dereference because… Also affects mbedtls
- CVE-2025-52497 Mbed TLS before 3.6.4 has a PEM parsing one-byte heap-based buffer underflow, in… Also affects mbedtls
- CVE-2025-52496 Mbed TLS before 3.6.4 has a race condition in AESNI detection if certain compiler… Also affects mbedtls
- CVE-2025-27810 Mbed TLS before 2.28.10 and 3.x before 3.6.3, in some cases of failed memory allocation… Also affects mbedtls
- CVE-2025-27809 Mbed TLS before 2.28.10 and 3.x before 3.6.3, on the client side, accepts servers that… Also affects mbedtls
- CVE-2024-49195 Mbed TLS 3.5.x through 3.6.x before 3.6.2 has a buffer underrun in pkwrite when writing… Also affects mbedtls
- CVE-2024-45158 An issue was discovered in Mbed TLS 3.6 before 3.6.1. Also affects mbedtls
- CVE-2024-45159 An issue was discovered in Mbed TLS 3.x before 3.6.1. Also affects mbedtls