Skip to content

fix(zip): complete ZIP64 header validation - #3546

Merged
ibgreen-openai merged 1 commit into
masterfrom
codex/fix-zip64-malformed-headers
Aug 4, 2026
Merged

fix(zip): complete ZIP64 header validation#3546
ibgreen-openai merged 1 commit into
masterfrom
codex/fix-zip64-malformed-headers

Conversation

@ibgreen

@ibgreen ibgreen commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Goals

Changes

  • Added a shared, bounds-checked ZIP64 extra-field record walker for local and central-directory headers.
  • Fixed the central-directory disk-start offset, 16-bit sentinel check, and 4-byte ZIP64 value decoding.
  • Made local-header parsing honor only the legacy fields that contain ZIP64 sentinels.
  • Added shared parser and ZipFileSystem regression tests covering missing/truncated records, unrelated records and payload bytes, field ordering, and readdir()/stat()/fetch() errors.
  • Documented the controlled Invalid ZIP archive policy for malformed ZIP64 metadata.

Validation

  • yarn
  • yarn lint fix
  • yarn build
  • yarn test-node — 1,928 passed, 81 skipped
  • yarn test-headless — 1,893 passed, 60 skipped

Fixes #3545

@ibgreen-openai
ibgreen-openai marked this pull request as ready for review August 4, 2026 20:27
@ibgreen-openai
ibgreen-openai merged commit fe575e5 into master Aug 4, 2026
10 checks passed
@ibgreen-openai
ibgreen-openai deleted the codex/fix-zip64-malformed-headers branch August 4, 2026 20:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6720fe9d6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +98 to +102
if (uncompressedSize === ZIP64_UINT32_SENTINEL) {
expectedZip64Fields.push({name: 'uncompressedSize', byteLength: 8});
}
if (compressedSize === BigInt(0xffffffff)) {
compressedSize = extraDataBuffer.getBigUint64(offsetInZip64Data, true);
offsetInZip64Data += 8;
if (compressedSize === ZIP64_UINT32_SENTINEL) {
expectedZip64Fields.push({name: 'compressedSize', byteLength: 8});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accept the mandatory local ZIP64 size pair

When a local header has only the uncompressed legacy size set to 0xffffffff (for example, a highly compressible file whose original size exceeds 4 GiB but whose compressed size still fits in 32 bits), this builds an expected ZIP64 payload containing only uncompressedSize. ZIP64 local-header entries must include both original and compressed size values (PKWARE APPNOTE 4.5.3), so those archives carry a 16-byte ZIP64 payload and now fail fetch() with unexpected payload size even though the central directory can provide the compressed length. For local headers, request both size fields whenever either legacy size uses ZIP64.

Useful? React with 👍 / 👎.

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.

fix(zip): complete ZIP64 malformed-header handling

2 participants