GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@Marti2203

@Marti2203 Marti2203 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

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:

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Marti2203
Reject SPDY frames that do not fit the 24-bit length field
71de6bd
Motivation:

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.
@testlens-app

testlens-app Bot commented Nov 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 71de6bd
▶️ Tests: 92599 executed
⚪️ Checks: 33/33 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.21.Final milestone Nov 14, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Nov 14, 2026
@normanmaurer
normanmaurer merged commit d2a2c48 into netty:4.2 Nov 14, 2026
29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Nov 14, 2026
Auto-port 5.0: Reject SPDY frames that do not fit the 24-bit length field #18416
Merged
@netty-project-bot

netty-project-bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #18416

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 14, 2026
@netty-project-bot

netty-project-bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #18417

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Nov 14, 2026
@netty-project-bot netty-project-bot mentioned this pull request Nov 14, 2026
Auto-port 4.1: Reject SPDY frames that do not fit the 24-bit length field #18417
Merged
normanmaurer pushed a commit that referenced this pull request Nov 14, 2026
@netty-project-bot @Marti2203
Auto-port 5.0: Reject SPDY frames that do not fit the 24-bit length f…
cac38fa
…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]>
normanmaurer added a commit that referenced this pull request Nov 14, 2026
@netty-project-bot @Marti2203 @normanmaurer
Auto-port 4.1: Reject SPDY frames that do not fit the 24-bit length f…
83c23af
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.21.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Marti2203 @netty-project-bot @normanmaurer
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.