MEDIUM Python Software Foundation Vulnerability Alert

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.

Details

Severity Base Score CVE
MEDIUM 5.9 CVE-2025-4516

Exploitation

To exploit this vulnerability, an attacker must have local access to the system and can manipulate the input to the `bytes.decode()` function using the ‘unicode_escape’ encoding. By crafting specific byte sequences, the attacker can potentially cause unexpected behavior or crashes in the application that relies on this decoding method.

Affected Products

  • CPython: The core implementation of the Python programming language, which is affected when using the specific decoding method.

Mitigation

To mitigate this issue, users should avoid using the `error=` handler with `bytes.decode()` when using ‘unicode_escape’ encoding. Instead, wrap the decoding call in a try-except block to handle potential DecodeErrors gracefully.

References