CVE-2025-4516: CWE-416 Use After Free in Python Software Foundation CPython
There is an issue in CPython when using `bytes.decode("unicode_escape", error="ignore|replace")`. If you are not using the "unicode_escape" encoding or an error handler your usage is not affected. To work-around this issue you may stop using the error= handler and instead wrap the bytes.decode() call in a try-except catching the DecodeError.
AI Analysis
Technical Summary
This vulnerability in CPython arises when decoding bytes using bytes.decode("unicode_escape", error="ignore" or "replace"), leading to a use-after-free condition (CWE-416). The flaw is specific to this combination of encoding and error handlers. Users not employing "unicode_escape" encoding or error handlers are not affected. The vulnerability was published on 2025-05-15 and affects CPython versions from 0 up to 3.14.0a1. No known exploits are reported in the wild. There is no vendor advisory or patch link provided, and the vulnerability is not related to a cloud service.
Potential Impact
The vulnerability can cause use-after-free memory corruption in CPython when decoding bytes with the specified parameters, potentially leading to crashes or undefined behavior. The CVSS 4.0 vector indicates local attack vector, high attack complexity, partial attack type, no privileges required, no user interaction, and high impact on availability. There are no reports of active exploitation.
Mitigation Recommendations
Currently, no official patch or fix is documented. Users should avoid using bytes.decode() with the "unicode_escape" encoding combined with error handlers "ignore" or "replace". Instead, remove the error handler parameter and wrap the decode call in a try-except block to catch DecodeError exceptions. Monitor the Python Software Foundation advisories for any forthcoming official fixes.
CVE-2025-4516: CWE-416 Use After Free in Python Software Foundation CPython
Description
There is an issue in CPython when using `bytes.decode("unicode_escape", error="ignore|replace")`. If you are not using the "unicode_escape" encoding or an error handler your usage is not affected. To work-around this issue you may stop using the error= handler and instead wrap the bytes.decode() call in a try-except catching the DecodeError.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
This vulnerability in CPython arises when decoding bytes using bytes.decode("unicode_escape", error="ignore" or "replace"), leading to a use-after-free condition (CWE-416). The flaw is specific to this combination of encoding and error handlers. Users not employing "unicode_escape" encoding or error handlers are not affected. The vulnerability was published on 2025-05-15 and affects CPython versions from 0 up to 3.14.0a1. No known exploits are reported in the wild. There is no vendor advisory or patch link provided, and the vulnerability is not related to a cloud service.
Potential Impact
The vulnerability can cause use-after-free memory corruption in CPython when decoding bytes with the specified parameters, potentially leading to crashes or undefined behavior. The CVSS 4.0 vector indicates local attack vector, high attack complexity, partial attack type, no privileges required, no user interaction, and high impact on availability. There are no reports of active exploitation.
Mitigation Recommendations
Currently, no official patch or fix is documented. Users should avoid using bytes.decode() with the "unicode_escape" encoding combined with error handlers "ignore" or "replace". Instead, remove the error handler parameter and wrap the decode call in a try-except block to catch DecodeError exceptions. Monitor the Python Software Foundation advisories for any forthcoming official fixes.
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- PSF
- Date Reserved
- 2025-05-09T14:59:53.878Z
- Cisa Enriched
- true
- Cvss Version
- 4.0
- State
- PUBLISHED
Threat ID: 682cd0f81484d88663aeb86b
Added to database: 5/20/2025, 6:59:04 PM
Last enriched: 4/22/2026, 5:42:35 AM
Last updated: 5/9/2026, 10:18:08 PM
Views: 476
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.