Skip to content

util/pypi: limit archive read sizes in wheel and sdist metadata parsing - #424

Open
cuixq wants to merge 1 commit into
google:mainfrom
cuixq:fix
Open

cuixq wants to merge 1 commit into
google:mainfrom
cuixq:fix

Conversation

@cuixq

@cuixq cuixq commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Prevent unbounded reads and decompression when parsing PyPI wheel and sdist metadata:

  • Cap METADATA / PKG-INFO and setup.py / setup.cfg reads at 10 MiB via readAtMost.
  • Cap buffered .zip sdists at 100 MiB and decompressed .tar.gz/.tgz sdists at 500 MiB.
  • Reject duplicate top-level PKG-INFO entries regardless of Name header, and ensure walkZipFiles closes entry readers on callback errors.

Bound the maximum sizes read from METADATA/PKG-INFO entries (10 MiB), buffered .zip sdist archives (100 MiB), and setup.py/setup.cfg files scanned for install_requires (10 MiB). Also ensure zip entry readers are closed on callback errors.
@cuixq
cuixq marked this pull request as ready for review December 2, 2026 04:44
@cuixq
cuixq requested a review from slugclub December 2, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant