CVE-2025-4516: Use-after-free in "unicode_escape" decoder with error handler

Published May 15, 2025
·
Updated

There is an issue in CPython when using bytes.decode("unicodeescape", error="ignore|replace"). If you are not using the "unicodeescape" 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.

Other sources

Use-after-free in "unicodeescape" decoder with error handler

Microsoft

Affected Software

4 affected componentsFixes available
pypi/cpython
Microsoft cbl2 python3 3.9.19-14<3.9.19-14
3.9.19-14
Microsoft cbl2 python3 3.9.19-13<3.9.19-14
3.9.19-14
Microsoft azl3 python3 3.12.9-2<3.12.9-2
3.12.9-2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 3.9.19-14
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 3.12.9-2

Event History

May 15, 2025
CVE Published
via MITRE·01:29 PM
Data Sourced
via MITRE·01:29 PM
DescriptionWeakness
Data Sourced
via Red Hat·02:01 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·02:15 PM
DescriptionSeverityWeakness
Jul 11, 2025
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity

Frequently Asked Questions

1

What is the severity of CVE-2025-4516?

CVE-2025-4516 is considered a medium severity vulnerability as it affects the handling of byte decoding in CPython.

2

How do I fix CVE-2025-4516?

To mitigate CVE-2025-4516, avoid using the 'unicode_escape' encoding with an error handler by wrapping the bytes in a try-except block instead.

3

Who is affected by CVE-2025-4516?

Users of CPython who utilize the 'bytes.decode' method with 'unicode_escape' encoding and specific error handlers are directly affected by CVE-2025-4516.

4

What versions of CPython are impacted by CVE-2025-4516?

CVE-2025-4516 affects all active versions of CPython that utilize the 'bytes.decode' method incorrectly with 'unicode_escape' encoding.

5

Is there a workaround for CVE-2025-4516?

Yes, a workaround for CVE-2025-4516 involves avoiding the use of the error handler in the 'bytes.decode' method.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203