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 — Reject SPDY frames that do not fit the 24-bit length field by Marti2203 · Pull Request #18412 · netty/netty Conversation
Contributor
Motivation: The SPDY frame length is a 24-bit field, but ByteBuf data = Unpooled.wrappedBuffer(new byte[16_777_216]); ByteBuf frame = new SpdyFrameEncoder(SpdyVersion.SPDY_3_1) .encodeDataFrame(UnpooledByteBufAllocator.DEFAULT, 1, false, data); frame.getUnsignedMedium(5); // 0, followed by all 16,777,216 bytes Longer frames get their length modulo 2^24, so the peer parses the rest of the payload as further frames. Modification: Check the frame length against Result: The encoder throws The new tests fail on current This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: The SPDY frame length is a 24-bit field, but `SpdyFrameEncoder` writes the length of a DATA frame or a header block with `writeMedium` without checking it. A 16,777,216 byte DATA frame is written with the length 0, followed by all of its bytes, and longer frames get the length modulo 2^24, so the peer parses the payload as further frames. Modification: Check the frame length against `SpdyCodecUtil.SPDY_MAX_LENGTH` before the frame buffer is allocated, in every encode method whose length depends on its input (DATA, SYN_STREAM, SYN_REPLY, SETTINGS, HEADERS and unknown frames), and add `SpdyFrameEncoderTest`. Result: The encoder throws `IllegalArgumentException` for a frame it cannot represent instead of writing a corrupt one.
|
There was an error while loading. Please reload this page.
✅ All tests passed ✅🏷️ Commit: 71de6bd Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Auto-port PR for 5.0: #18416 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Auto-port PR for 4.1: #18417 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ield (#18416) Auto-port of #18412 to 5.0 Cherry-picked commit: d2a2c48 --- Motivation: The SPDY frame length is a 24-bit field, but `SpdyFrameEncoder` writes the length of a DATA frame or of a header block with `writeMedium` without checking it: ```java ByteBuf data = Unpooled.wrappedBuffer(new byte[16_777_216]); ByteBuf frame = new SpdyFrameEncoder(SpdyVersion.SPDY_3_1) .encodeDataFrame(UnpooledByteBufAllocator.DEFAULT, 1, false, data); frame.getUnsignedMedium(5); // 0, followed by all 16,777,216 bytes ``` Longer frames get their length modulo 2^24, so the peer parses the rest of the payload as further frames. `SYN_REPLY`, `SYN_STREAM` and `HEADERS` frames with a large header block behave the same way. Modification: Check the frame length against `SpdyCodecUtil.SPDY_MAX_LENGTH` before the frame buffer is allocated, in every encode method whose length depends on its input (DATA, SYN_STREAM, SYN_REPLY, SETTINGS, HEADERS and unknown frames), and add `SpdyFrameEncoderTest`. Result: The encoder throws `IllegalArgumentException` for a frame it cannot represent instead of writing a corrupt one. The new tests fail on current `4.2` (`Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown.`). With the change the `codec-http` SPDY tests pass (115 run, 0 failures) and checkstyle passes. This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually. Co-authored-by: Martin Mirchev <[email protected]>
…ield (#18417) Auto-port of #18412 to 4.1 Cherry-picked commit: d2a2c48 --- Motivation: The SPDY frame length is a 24-bit field, but `SpdyFrameEncoder` writes the length of a DATA frame or of a header block with `writeMedium` without checking it: ```java ByteBuf data = Unpooled.wrappedBuffer(new byte[16_777_216]); ByteBuf frame = new SpdyFrameEncoder(SpdyVersion.SPDY_3_1) .encodeDataFrame(UnpooledByteBufAllocator.DEFAULT, 1, false, data); frame.getUnsignedMedium(5); // 0, followed by all 16,777,216 bytes ``` Longer frames get their length modulo 2^24, so the peer parses the rest of the payload as further frames. `SYN_REPLY`, `SYN_STREAM` and `HEADERS` frames with a large header block behave the same way. Modification: Check the frame length against `SpdyCodecUtil.SPDY_MAX_LENGTH` before the frame buffer is allocated, in every encode method whose length depends on its input (DATA, SYN_STREAM, SYN_REPLY, SETTINGS, HEADERS and unknown frames), and add `SpdyFrameEncoderTest`. Result: The encoder throws `IllegalArgumentException` for a frame it cannot represent instead of writing a corrupt one. The new tests fail on current `4.2` (`Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown.`). With the change the `codec-http` SPDY tests pass (115 run, 0 failures) and checkstyle passes. This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually. --------- Co-authored-by: Martin Mirchev <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.