CVE-2025-4516: Use-after-free in "unicode_escape" decoder with error handler
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.
Security readout for executives and security teams
Plain-English summary
A memory safety flaw can crash affected CPython processes when specific malformed bytes are decoded using the "unicode_escape" codec with "ignore" or "replace" error handling. Applications not using that exact combination are not affected. The supplied evidence indicates availability impact, not data theft or modification.
Executive priority
Use targeted, moderate-priority remediation. Quickly identify internet-facing or business-critical services using the affected pattern, then upgrade or apply the documented workaround. Systems without that pattern do not require emergency action for this CVE. Escalate if exposure to untrusted input is confirmed.
Technical view
CVE-2025-4516 is a CWE-416 use-after-free in CPython's "unicode_escape" decoder. The CVSS 4.0 score is 5.9, with local access, high complexity, prerequisite conditions, and high vulnerable-system availability impact. The source bundle lists multiple CPython branches but does not clearly identify fixed release numbers.
Likely exposure
Exposure is narrow: code must decode bytes with "unicode_escape" while specifying errors="ignore" or errors="replace". Risk increases when untrusted or attacker-influenced bytes can reach that path. Inventory results should be confirmed against Python's advisory because the supplied affected-version data is incomplete.
Exploitation context
The supplied CVSS vector describes local attack access, high complexity, and prerequisite conditions. CISA KEV status is false, and no supplied source establishes active exploitation. Treat claims of remote exploitation or code execution as unsubstantiated by this bundle.
Researcher notes
The evidence supports a narrowly triggered use-after-free and denial-of-service risk. The affected list contains ambiguous version entries, including "0" and branch starting points, so it should not be interpreted as precise fixed-release guidance. Review the linked advisory and branch commits before making version-based conclusions.
Mitigation direction
Upgrade to a vendor-supported CPython release containing the referenced corrections after confirming applicable release guidance.
As a workaround, remove the error handler and catch the decoding exception around the decode operation.
Prioritize applications where untrusted bytes reach the affected decoding pattern.
Retest decoding behavior after changing error handling or upgrading CPython.
Validation and detection
Search application and dependency code for "unicode_escape" decoding combined with "ignore" or "replace" error handling.
Record deployed CPython versions and compare them with the Python security advisory and supported fixed releases.
Trace whether untrusted bytes can reach each identified decoding call.
Run controlled regression tests covering malformed input, expected exceptions, and process stability.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-416: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-416 · source CWE mapping
Use After Free
Use After Free represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.