Skip to content

Zip centraldirectory Hardening - #131738

Draft
alinpahontu2912 wants to merge 2 commits into
dotnet:mainfrom
alinpahontu2912:alinpahontu2912/zip-centraldir-hardening
Draft

Zip centraldirectory Hardening#131738
alinpahontu2912 wants to merge 2 commits into
dotnet:mainfrom
alinpahontu2912:alinpahontu2912/zip-centraldir-hardening

Conversation

@alinpahontu2912

Copy link
Copy Markdown
Member

Add extra check to protect against malformed central directory metadata

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens validation when parsing central directory file headers by short-circuiting reads when the header’s variable-length tail (filename/extra/comment) claims more bytes than remain in a seekable stream, avoiding an unnecessary large ArrayPool rent in that malformed-input case.

Changes:

  • Add a seekable-stream “remaining bytes” check before renting/collating the dynamic header buffer in ZipCentralDirectoryFileHeader.TryReadBlock.
  • Return false early when the central directory header’s trailing data length exceeds what’s left in the stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants