Correctly implement fuzzers for new encryption streams#131306
Open
alinpahontu2912 wants to merge 2 commits into
Open
Correctly implement fuzzers for new encryption streams#131306alinpahontu2912 wants to merge 2 commits into
alinpahontu2912 wants to merge 2 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-meta |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the fuzzers for the new ZIP encryption streams to exercise the actual ZipArchive encryption/decryption paths (ZipCrypto and WinZip AES) rather than constructing the internal crypto streams via reflection.
Changes:
- Replace reflection-based stream construction with
ZipArchive.CreateEntry(..., password, ZipEncryptionMethod)+Open/OpenAsync(password)round-trip workflows. - Add validation that the entry is encrypted and the expected encryption method is recorded, and verify plaintext round-trips correctly (sync + async).
- Add a “wrong password” scenario intended to ensure failures are handled as
InvalidDataException(but it currently doesn’t assert failure if no exception is thrown).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/ZipCryptoStreamFuzzer.cs | Moves from reflected ZipCryptoStream.Create to ZipArchive-based encrypt/decrypt round-trip for ZipCrypto (sync + async). |
| src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/WinZipAesStreamFuzzer.cs | Moves from reflected WinZipAesStream.Create to ZipArchive-based encrypt/decrypt round-trip for AES128/192/256 (sync + async). |
Comments suppressed due to low confidence (2)
src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/ZipCryptoStreamFuzzer.cs:101
- The “wrong password must fail” check currently passes even if decryption succeeds without throwing. Use Assert.Throws so the fuzzer reliably flags regressions where a wrong password is accepted.
// Decrypting with a wrong password must fail cleanly with InvalidDataException, never crash.
try
{
using Stream stream = readEntry.Open("wrong-password".AsSpan());
stream.CopyTo(Stream.Null);
}
catch (InvalidDataException)
{
// Expected: the header password verifier rejects the wrong key.
}
src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/WinZipAesStreamFuzzer.cs:113
- The “wrong password must fail” check currently passes even if decryption succeeds without throwing. Use Assert.Throws so the fuzzer reliably flags regressions where a wrong password is accepted.
// Decrypting with a wrong password must fail cleanly with InvalidDataException, never crash.
try
{
using Stream stream = readEntry.Open("wrong-password".AsSpan());
stream.CopyTo(Stream.Null);
}
catch (InvalidDataException)
{
// Expected: the AES password verifier / HMAC rejects the wrong key.
}
This was referenced Jul 24, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Correctly implement fuzzers fro the new encryption streams: zipcryptostream and winzipaesstream