Skip to content

Zip64 Data Descriptor Bug on Non-Seekable Streams #127389

Description

@alinpahontu2912

When writing a ZIP archive to a non-seekable stream, entries that exceed 4GB produce a usable, but malformed archive. The local file header contains no Zip64 signals, but the data descriptor uses 8-byte (Zip64) size fields.

Root Cause
In ZipArchiveEntry.WriteLocalFileHeaderInitialize, the non-seekable branch writes the local header before compression, when sizes are unknown:

https://github.com/dotnet/runtime/blob/main/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs#L1088-L1096

This approach:
Sets sizes to 0 (not 0xFFFFFFFF)
Does not call VersionToExtractAtLeast(ZipVersionNeededValues.Zip64)
Does not write a Zip64 extra field
Later, after compression finishes, PrepareToWriteDataDescriptor checks actual sizes:

https://github.com/dotnet/runtime/blob/main/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs#L1448C12-L1454C14
If the entry exceeds 4GB, the data descriptor uses 8-byte fields, but the local header (already written to a non-seekable stream) gave no indication of this.

Impact
Any reader that relies on the local header to determine data descriptor format will misparse the archive, corrupting all subsequent entries. However, most commonly zip files rely on the Central Directory to read sizes, so the true impact is probably low, eben though the local header is not correctly created.

Activity

  1. added
    untriaged
    on Apr 24, 2026
  2. dotnet-policy-service commented on Apr 24, 2026

    @dotnet-policy-service
    Contributor

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

  3. removed
    untriaged
    on May 13, 2026
  4. added this to the Future milestone on Jun 8, 2026
  5. added theissue type on Jun 8, 2026
  6. akasakariko commented on Nov 4, 2026

    @akasakariko
    Contributor

    I'd like to work on this

  7. alinpahontu2912 commented on Nov 4, 2026

    @alinpahontu2912
    MemberAuthor

    @akasakariko highly appreciate the help, you can ping us when you have a pr ready for review

  8. akasakariko commented on Nov 4, 2026

    @akasakariko
    Contributor

    @alinpahontu2912 the fix is ready for review in #136963

    The PR includes synchronous and asynchronous regression coverage, metadata-only Update preservation, and the Zip64 compatibility impact

  9. alinpahontu2912 commented on Nov 5, 2026

    @alinpahontu2912
    MemberAuthor

    Thanks @akasakariko, we will take a look

  10. added a commit that references this issue on Nov 12, 2026
    61b01e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions