Use-after-free (UAF) was possible in the lzma.LZMADecompressor, bz2.BZ2Decompressor, and gzip.GzipFile when a memory allocation fails with a MemoryError and the decompression instance is re-used. This scenario can be triggered if the process is under memory pressure. The fix cleans up the dangling pointer in this specific error condition.
The vulnerability is only present if the program re-uses decompressor instances across multiple decompression calls even after a MemoryError is raised during decompression. Using the helper functions to one-shot decompress data such as lzma.decompress(), bz2.decompress(), gzip.decompress(), and zlib.decompress() are not affected as a new decompressor instance is used per call. If the decompressor instance is not re-used after an error condition, this usage is similarly not vulnerable.
{
"cwe_ids": []
}"https://github.com/psf/advisory-database/blob/main/advisories/python/PSF-2026-18.json"
[
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/6a5f79c8d7bbf22b083b240910c7a8781a59437d",
"deprecated": false,
"digest": {
"function_hash": "84589999674251724155468361044613684778",
"length": 2206.0
},
"target": {
"function": "decompress",
"file": "Modules/_bz2module.c"
},
"signature_type": "Function",
"id": "PSF-2026-18-20b48da3"
},
{
"signature_version": "v1",
"digest": {
"line_hashes": [
"94135993539252608169191539438933599202",
"104669475959108530219517263650155630981",
"99076997531218567452909478434502041422",
"333457106311082276385054253937655800853"
],
"threshold": 0.9
},
"source": "https://github.com/python/cpython/commit/8fc66aef6d7b3ae58f43f5c66f9366cc8cbbfcd2",
"target": {
"file": "Modules/_bz2module.c"
},
"deprecated": false,
"signature_type": "Line",
"id": "PSF-2026-18-22d654a2"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/8fc66aef6d7b3ae58f43f5c66f9366cc8cbbfcd2",
"target": {
"function": "decompress",
"file": "Modules/_lzmamodule.c"
},
"deprecated": false,
"digest": {
"function_hash": "274786089459037806290187256381705341170",
"length": 2221.0
},
"signature_type": "Function",
"id": "PSF-2026-18-274a173b"
},
{
"signature_version": "v1",
"digest": {
"line_hashes": [
"94135993539252608169191539438933599202",
"104669475959108530219517263650155630981",
"99076997531218567452909478434502041422",
"333457106311082276385054253937655800853"
],
"threshold": 0.9
},
"source": "https://github.com/python/cpython/commit/8fc66aef6d7b3ae58f43f5c66f9366cc8cbbfcd2",
"target": {
"file": "Modules/zlibmodule.c"
},
"deprecated": false,
"signature_type": "Line",
"id": "PSF-2026-18-27d405b9"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/47128e64f98c3a20271138a98c2922bea2a3ee0e",
"digest": {
"function_hash": "137817026754399672328269279492351081878",
"length": 2174.0
},
"target": {
"function": "decompress",
"file": "Modules/_lzmamodule.c"
},
"deprecated": false,
"signature_type": "Function",
"id": "PSF-2026-18-3f4ee08e"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/8fc66aef6d7b3ae58f43f5c66f9366cc8cbbfcd2",
"deprecated": false,
"digest": {
"line_hashes": [
"94135993539252608169191539438933599202",
"104669475959108530219517263650155630981",
"99076997531218567452909478434502041422",
"333457106311082276385054253937655800853"
],
"threshold": 0.9
},
"target": {
"file": "Modules/_lzmamodule.c"
},
"signature_type": "Line",
"id": "PSF-2026-18-42efa811"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/e20c6c9667c99ecaab96e1a2b3767082841ffc8b",
"deprecated": false,
"digest": {
"function_hash": "84589999674251724155468361044613684778",
"length": 2206.0
},
"target": {
"function": "decompress",
"file": "Modules/_bz2module.c"
},
"signature_type": "Function",
"id": "PSF-2026-18-5345bf48"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/6a5f79c8d7bbf22b083b240910c7a8781a59437d",
"target": {
"function": "decompress",
"file": "Modules/_lzmamodule.c"
},
"deprecated": false,
"digest": {
"function_hash": "137817026754399672328269279492351081878",
"length": 2174.0
},
"signature_type": "Function",
"id": "PSF-2026-18-59ee1e2b"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/c3cf71c3366fe49acb776a639405c0eea6169c20",
"target": {
"function": "decompress",
"file": "Modules/_bz2module.c"
},
"deprecated": false,
"digest": {
"function_hash": "84589999674251724155468361044613684778",
"length": 2206.0
},
"signature_type": "Function",
"id": "PSF-2026-18-643d6667"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/8fc66aef6d7b3ae58f43f5c66f9366cc8cbbfcd2",
"digest": {
"function_hash": "285947837918045169759164635510724021861",
"length": 2244.0
},
"target": {
"function": "decompress",
"file": "Modules/_bz2module.c"
},
"deprecated": false,
"signature_type": "Function",
"id": "PSF-2026-18-86dedb9f"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/47128e64f98c3a20271138a98c2922bea2a3ee0e",
"target": {
"function": "decompress",
"file": "Modules/_bz2module.c"
},
"deprecated": false,
"digest": {
"function_hash": "84589999674251724155468361044613684778",
"length": 2206.0
},
"signature_type": "Function",
"id": "PSF-2026-18-906ff074"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/e20c6c9667c99ecaab96e1a2b3767082841ffc8b",
"digest": {
"function_hash": "137817026754399672328269279492351081878",
"length": 2174.0
},
"target": {
"function": "decompress",
"file": "Modules/_lzmamodule.c"
},
"deprecated": false,
"signature_type": "Function",
"id": "PSF-2026-18-9cdcb6f4"
},
{
"source": "https://github.com/python/cpython/commit/c3cf71c3366fe49acb776a639405c0eea6169c20",
"digest": {
"function_hash": "137817026754399672328269279492351081878",
"length": 2174.0
},
"signature_version": "v1",
"target": {
"function": "decompress",
"file": "Modules/_lzmamodule.c"
},
"deprecated": false,
"signature_type": "Function",
"id": "PSF-2026-18-9e46e21d"
},
{
"source": "https://github.com/python/cpython/commit/8fc66aef6d7b3ae58f43f5c66f9366cc8cbbfcd2",
"digest": {
"function_hash": "288422572817338439511797407182616984687",
"length": 2277.0
},
"signature_version": "v1",
"target": {
"function": "decompress",
"file": "Modules/zlibmodule.c"
},
"deprecated": false,
"signature_type": "Function",
"id": "PSF-2026-18-c16b4d22"
},
{
"signature_version": "v1",
"digest": {
"function_hash": "197439806431788498051156381226726719416",
"length": 2238.0
},
"source": "https://github.com/python/cpython/commit/6a5f79c8d7bbf22b083b240910c7a8781a59437d",
"target": {
"function": "decompress",
"file": "Modules/zlibmodule.c"
},
"deprecated": false,
"signature_type": "Function",
"id": "PSF-2026-18-c46813d4"
},
{
"signature_version": "v1",
"source": "https://github.com/python/cpython/commit/c3cf71c3366fe49acb776a639405c0eea6169c20",
"target": {
"function": "decompress",
"file": "Modules/zlibmodule.c"
},
"deprecated": false,
"digest": {
"function_hash": "197439806431788498051156381226726719416",
"length": 2238.0
},
"signature_type": "Function",
"id": "PSF-2026-18-ea7af3c2"
}
]
"2026-04-15T02:03:58Z"