python / python/cpython

Memory exhaustion via crafted zip file

Open
#156,002 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.10 3.11 3.12 3.13 3.14 3.15 3.16 stdlib type-security
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

As reported by @tonghuaroot:

zipfile.ZipExtFile._read1() bounds the output of each decompress() call for DEFLATE members (it passes a max_length to zlib), but for bzip2 / LZMA / Zstandard members it called self._decompressor.decompress(data) with no bound. A whole compressed chunk was therefore expanded into a single allocation before the data = data[:self._left] clip ran.

Linked PRs
  • gh-156003
  • gh-156362
  • gh-156737
  • gh-156738
  • gh-156739
  • gh-156740
  • gh-156741
  • gh-157180
  • gh-157268
  • gh-157557

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at zipfile.ZipExtFile._read1() and compare its DEFLATE handling with the bzip2, LZMA, and Zstandard paths. Confirm that expanded output is bounded before clipping the remaining data, then add regression coverage for crafted members and verify the linked PRs to avoid duplicating work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.