BIT-python-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.

Affected Software

1 affected component
Python Software Foundation CPython

Event History

May 15, 2025
CVE Published
via OSV·01:29 PM
Data Sourced
via OSV·01:29 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which applications are exposed to this issue?

Only CPython code that calls bytes.decode("unicode_escape", error="ignore") or bytes.decode("unicode_escape", error="replace") is affected. Code that does not use the unicode_escape encoding or does not use an error handler is not affected.

2

What must occur for exploitation?

An attacker would need to cause the application to process bytes through the unicode_escape decoder with the ignore or replace error handler. The reported vector is local and has high attack complexity.

3

What can be done if an update cannot be applied immediately?

Avoid using the error= handler with bytes.decode("unicode_escape"). Instead, call decode without that handler and catch DecodeError with try-except.

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