Repository navigation
Port 4.1: Check the second gzip magic byte in JdkZlibDecoder (#17972) - #18007
Merged
Merged
Conversation
Auto-port of #17972 to 4.1 Cherry-picked commit: f69f14a Motivation: `JdkZlibDecoder` reads both gzip magic bytes (ID1 = 0x1f, ID2 = 0x8b, RFC 1952 section 2.3.1) but only checks ID1, so a stream with a wrong ID2 is decoded as gzip. `java.util.zip.GZIPInputStream` and netty's own `JdkZlibDecompressor` (`magic0 != 31 || magic1 != 139`) reject such a stream. Modification: - Read both bytes unsigned and check ID2, as `JdkZlibDecompressor` does. - Add `JdkZlibTest.testGzipInvalidSecondMagicByteThrows`. Result: A gzip stream with an invalid ID2 byte is rejected with a `DecompressionException`.
lltopk
pushed a commit
to lltopk/netty
that referenced
this pull request
Oct 24, 2026
…7972) (netty#18007) Auto-port of netty#17972 to 4.1 Cherry-picked commit: f69f14a Motivation: `JdkZlibDecoder` reads both gzip magic bytes (ID1 = 0x1f, ID2 = 0x8b, RFC 1952 section 2.3.1) but only checks ID1, so a stream with a wrong ID2 is decoded as gzip. `java.util.zip.GZIPInputStream` and netty's own `JdkZlibDecompressor` (`magic0 != 31 || magic1 != 139`) reject such a stream. Modification: - Read both bytes unsigned and check ID2, as `JdkZlibDecompressor` does. - Add `JdkZlibTest.testGzipInvalidSecondMagicByteThrows`. Result: A gzip stream with an invalid ID2 byte is rejected with a `DecompressionException`.
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.
Auto-port of #17972 to 4.1
Cherry-picked commit: f69f14a
Motivation:
JdkZlibDecoderreads both gzip magic bytes (ID1 = 0x1f, ID2 = 0x8b,RFC 1952 section 2.3.1) but only checks ID1, so a stream with a wrong
ID2 is decoded as gzip.
java.util.zip.GZIPInputStreamand netty's ownJdkZlibDecompressor(magic0 != 31 || magic1 != 139) reject such astream.
Modification:
JdkZlibDecompressordoes.JdkZlibTest.testGzipInvalidSecondMagicByteThrows.Result:
A gzip stream with an invalid ID2 byte is rejected with a
DecompressionException.