Skip to content

Add Zip Archives password support#122093

Open
alinpahontu2912 wants to merge 102 commits into
dotnet:mainfrom
alinpahontu2912:zip_password
Open

Add Zip Archives password support#122093
alinpahontu2912 wants to merge 102 commits into
dotnet:mainfrom
alinpahontu2912:zip_password

Conversation

@alinpahontu2912

@alinpahontu2912 alinpahontu2912 commented Dec 2, 2025

Copy link
Copy Markdown
Member

Fixes #1545

Big Milestones and status:

  • Read Encrypted Entries (ZipCrypto, WinZip AES)
  • Create Encrypted Entries (ZipCrypto, Winzip AES)
  • Update Mode
  • Add runtime assets for checking compat with WinRar/7zip/WinZip/etc
  • Security check for Cryptography methods
  • Final API design

@rzikm rzikm self-requested a review December 11, 2025 12:22
Copilot AI review requested due to automatic review settings June 23, 2026 08:45

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI review requested due to automatic review settings June 29, 2026 09:08

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

Copilot reviewed 42 out of 42 changed files in this pull request and generated 4 comments.

Comment thread src/libraries/System.IO.Compression/ref/System.IO.Compression.cs

@rzikm rzikm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, few ideas for making the code cleaner.

Comment thread src/libraries/Common/tests/System/IO/Compression/ZipTestHelper.cs Outdated
Comment thread src/libraries/Common/tests/System/IO/Compression/ZipTestHelper.cs Outdated
Comment thread src/libraries/Common/tests/System/IO/Compression/ZipTestHelper.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/Resources/Strings.resx Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/WinZipAesStream.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCryptoStream.cs Outdated
Comment thread src/libraries/System.IO.Compression/tests/ZipArchive/zip_ReadTests.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCryptoStream.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCryptoStream.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCryptoStream.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCryptoStream.cs Outdated
Copilot AI review requested due to automatic review settings July 1, 2026 07:36

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

Copilot reviewed 42 out of 42 changed files in this pull request and generated 4 comments.

Comment thread src/libraries/System.IO.Compression/ref/System.IO.Compression.cs
@GrabYourPitchforks GrabYourPitchforks dismissed their stale review July 2, 2026 17:18

Lifting hold.

@GrabYourPitchforks

Copy link
Copy Markdown
Member

@alinpahontu2912 We signed off earlier this week on the security design you submitted. Thanks. :)

Remember to update the public-facing docs so that consumers know what explicit promises (and non-promises!) the component intends to make here.

Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/WinZipAesStream.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs Outdated
Comment thread src/libraries/System.IO.Compression/src/System/IO/Compression/ZipCryptoStream.cs Outdated
Comment on lines +47 to +48
}
return WinZipAesKeyMaterial.GetSaltSize(keySizeBits);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
}
return WinZipAesKeyMaterial.GetSaltSize(keySizeBits);
}
return WinZipAesKeyMaterial.GetSaltSize(keySizeBits);

Comment on lines +68 to +72
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser);
}
ArgumentNullException.ThrowIfNull(baseStream);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Either a blank line after the close curly (to match the rest of the file style) or move this if/throw to a helper.

Suggested change
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser);
}
ArgumentNullException.ThrowIfNull(baseStream);
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser);
}
ArgumentNullException.ThrowIfNull(baseStream);

or

Suggested change
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser);
}
ArgumentNullException.ThrowIfNull(baseStream);
CheckPlatformSupport();
ArgumentNullException.ThrowIfNull(baseStream);

@bartonjs bartonjs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I never looked at the tests at all.

I skimmed the majority of the source code looking for places where the password might be mishandled.

I aggressively reviewed the crypto parts of WinZipAesStream and ZipCryptoStream.

Those parts LGTM.

Since I didn't do a full review I won't give a checkmark, but I also don't have any reason to hold.

Copilot AI review requested due to automatic review settings July 7, 2026 07:47

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

Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.

Comment on lines +178 to +181
public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.IO.FileAccess access, System.ReadOnlySpan<char> password, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.IO.FileAccess access, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.ReadOnlySpan<char> password, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Comment on lines +689 to +693
ZipArchiveEntry lastEntry = _entries[_entries.Count - 1];
if (lastEntry.IsEncrypted)
{
lastEntry.ReadEncryptionSaltIfNeeded();
}
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.

Add password to ZipArchive

8 participants