Skip to content

gh-155639: Reject ZIP files with inconsistent EOCD disk information - #155814

Draft
abdulm5 wants to merge 1 commit into
python:mainfrom
abdulm5:agent/gh-155639-eocd-disk-info
Draft

gh-155639: Reject ZIP files with inconsistent EOCD disk information#155814
abdulm5 wants to merge 1 commit into
python:mainfrom
abdulm5:agent/gh-155639-eocd-disk-info

Conversation

@abdulm5

@abdulm5 abdulm5 commented Aug 14, 2026

Copy link
Copy Markdown

Fixes #155639.

zipfile does not support multi-disk archives, but its end of central
directory parser accepted archives whose disk fields were inconsistent with
a single-disk archive.

Validate the classic EOCD disk fields before ZIP64 resolution, permitting the
0xFFFF ZIP64 sentinel, and require the resolved classic or ZIP64 values to
identify disk zero. This makes ZipFile reject the malformed archive and
keeps is_zipfile() consistent while preserving the position of file-like
inputs.

Regression tests cover classic EOCD records with and without comments, ZIP64
EOCD records, malformed classic fields followed by valid ZIP64 metadata, and
valid ZIP64 sentinel fields.

Tests:

  • ./python.exe -m test test_zipfile (594 tests run, 3 skipped)
  • Focused debug-build refleak run (-R 3:3)
  • Original issue reproducer and a 384-case classic/ZIP64 EOCD matrix

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.

zipfile should reject inconsistent disk information in EOCDR

1 participant