GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — Check the second gzip magic byte in JdkZlibDecoder by Marti2203 · Pull Request #17972 · netty/netty Conversation
Contributor
Motivation:
Modification:
Result:
Reproduction on 4.2 (5776ebc): compress With this change This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually. 🤖 Generated with Claude Code
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: JdkZlibDecoder reads both gzip magic bytes (ID1 = 0x1f, ID2 = 0x8b, RFC 1952 section 2.3.1) but only checks the first one, so a stream with a wrong ID2 is decoded as gzip. java.util.zip.GZIPInputStream and JdkZlibDecompressor reject such a stream. Modifications: - Read both bytes unsigned and check ID2 as JdkZlibDecompressor does. - Add a test. Result: JdkZlibDecoder rejects input whose gzip header has a wrong ID2.
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
normanmaurer
added a commit
that referenced
this pull request
…8006) Auto-port of #17972 to 5.0 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: `JdkZlibDecoder` rejects input whose gzip header has a wrong ID2. Co-authored-by: Martin Mirchev <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
normanmaurer
added a commit
that referenced
this pull request
…#18007) 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
…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`.
5 tasks done
hyperxpro
pushed a commit
to AsyncHttpClient/async-http-client
that referenced
this pull request
## Summary - Upgrades Netty from 4.2.19.Final to 4.2.20.Final. Its [security fixes](https://github.com/netty/netty/releases/tag/netty-4.2.20.Final) include several in modules AHC uses: three out-of-bounds reads in `netty-buffer`, unbounded memory usage in `netty-codec-http2`, insufficient control character neutralization in `netty-codec-http`, insufficient entropy in `netty-resolver-dns`, and an mTLS bypass via session resumption in `netty-handler`. - On 4.2.20, two of AHC's tests fail, both because of Netty changes. This PR adapts AHC to them. ## Change - **Upgrade Netty to 4.2.20.Final, and check the second gzip magic byte:** `JdkZlibDecoder` now rejects a gzip header with a wrong second magic byte (netty/netty#17972). The gzip inflate loop from #2357 follows `JdkZlibDecoder`, and `Http1ContentDecompressorTest` compares the two, so it now checks that byte too. Both bytes are read unsigned, since `0x8b` is negative as a signed byte. - **Keep zstd working at a non-positive threshold:** since netty/netty#17896, the `ZstdDecoder` that `HttpContentDecompressor` creates sizes its output buffers by `io.netty.compression.defaultMaxForwardBytes`. At 0 it hands on an empty body without an error; below 0 it fails with `IllegalArgumentException: initialCapacity : -1`. AHC leaves zstd to that decoder while the property is not positive (#2362), so it now replaces it with a `ZstdDecoder` whose buffers hold `MAX_PART_SIZE`. The size limit still applies, and the body is still decompressed eagerly there, as before. At the default value of the property nothing changes. netty/netty#18289 fixes the decoder in Netty; this workaround is harmless with that fix and can go once AHC requires a Netty version that has it. ## Notes - Netty 4.2.0 to 4.2.4 have no `ZstdDecoder(int)` constructor. Overriding AHC's Netty with one of those and also setting the property to 0 or below would fail zstd responses with a `NoSuchMethodError`. ## AI disclosure Claude Code on behalf of Matthias Kurz. Both commits include `Co-Authored-By` per `AGENTS.md`. ## Test plan - [x] `main` at `5542c9fc4` with `-Dnetty.version=4.2.20.Final`: 1,857 tests, 2 failures: - `Http1ContentDecompressorTest.decodesLikeNettyForEveryBodyAndSplit`, case "gzip second magic byte ignored": Netty now fails that body, AHC did not. - `Http1ContentDecompressorForwardThresholdTest`: "the zstd body differs". - [x] `Http1ContentDecompressorForwardThresholdTest` now runs at thresholds 0 and -1, each in a fresh JVM, and also checks the size limit for zstd and that every exchange releases its input and buffers. On 4.2.20 without the zstd commit it fails at both ("the zstd body differs", "the zstd body did not end"). With it, it passes on 4.2.19 and 4.2.20. - [x] `./mvnw -B -ntp -Dgpg.skip=true clean verify` on JDK 11, on `main` `3e95ec8c2`: 1,905 tests, 0 failures, 0 errors, 11 skipped; Revapi passed. No test-skipping flags were used. - [x] `Http1ContentDecompressorForwardThresholdTest` and `Http1ContentDecompressorTest` compiled on JDK 11 and run on JDK 17, 21 and 25 (Maven Surefire's `-Djvm`): 36 tests each, 0 failures. - [x] This branch merged with #2369: `clean verify` on JDK 11, 1,914 tests, 0 failures, 0 errors, 11 skipped; Revapi passed (run before #2359, #2360 and #2361 were merged, with those three merged in as well). --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | ||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |