Python CPython Use-After-Free Vulnerability in Decompressor Classes

Vulnerability

A use-after-free vulnerability has been identified in the CPython implementation of the LZMA, BZ2, and Gzip decompressor classes. This vulnerability occurs when a memory allocation fails, raising a MemoryError, and the decompressor instance is reused. Under memory pressure, this scenario can be exploited, leading to potential memory corruption. The issue is not present when using the one-shot decompression functions, as they create a new decompressor instance for each call.

Impact

Exploitation of this vulnerability can lead to memory corruption, which may be exploited to execute arbitrary code or cause a program crash.

Reproduction

To reproduce this vulnerability, create an instance of LZMADecompressor, BZ2Decompressor, or GzipFile. Under memory pressure, intentionally cause a MemoryError during decompression, then reuse the same decompressor instance for another decompression call. This will trigger the use-after-free condition, as the instance will attempt to read from a memory buffer that has already been released.

Remediation

The vulnerability has been fixed in the CPython repository. Users should update to the latest version of Python where this issue has been addressed.

Added: Apr 13, 2026, 6:38 PM
Updated: Apr 13, 2026, 6:38 PM

Vulnerability Rating

Custom Algorithm
spread
7.8
impact
7.5
exploitability
4.7
remediation
0.0
relevance
5.8
threat
4.8
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.