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 with an error handler. By crafting specific byte sequences, the attacker can potentially cause unexpected behavior or crashes in the application.

Affected Products

  • CPython: The core implementation of the Python programming language, specifically when using the `bytes.decode()` method with `unicode_escape` encoding.

Mitigation

To mitigate this issue, users should avoid using the `error=` handler with `bytes.decode()` and instead implement a try-except block to catch any potential `DecodeError`. This will help prevent unexpected behavior when decoding byte sequences.

References