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 — Don't count STOMP headers again when the header block is replayed by allthingssecurity · Pull Request #17664 · netty/netty

Conversation

@allthingssecurity

@allthingssecurity allthingssecurity commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Motivation:

StompSubframeDecoder is a ReplayingDecoder. When the header block of a frame is not complete, the next read parses the command and all headers again from the checkpoint. The counter that enforces maxNumHeaders (HeaderParser.numHeaders, added in #17063) is only reset by the empty line that ends the headers. So every replay adds the headers that were already counted.

As a result, whether a valid frame is rejected with "maximum number of headers exceeded" depends on how it is split into reads. After the rejection, the decoder stays in BAD_FRAME. With the default limit of 128:

Frame Reads Result
15 headers sent byte by byte, or one line at a time from a terminal rejected
40 headers 32-byte reads rejected
128 headers 2 reads rejected
90 headers one read accepted

Modification:

  • Reset the counter at the start of readHeaders(). Each attempt parses all headers of the frame again, so it counts from zero.
  • New tests in StompSubframeDecoderTest, each with maxNumHeaders = 10 and read sizes of 1, 7, about half the frame and the whole frame:
    • testMaxNumHeadersNotExceededWhenHeadersSplitAcrossReads: a frame with 10 headers is accepted.
    • testMaxNumHeadersEnforcedWhenHeadersSplitAcrossReads: a frame with 11 headers is rejected.

Result:

maxNumHeaders limits the headers of a frame, however the frame is split into reads. The limit itself is unchanged: each attempt still counts every header of the frame.

  • StompSubframeDecoderTest: 28 tests pass. Without the change to StompSubframeDecoder, testMaxNumHeadersNotExceededWhenHeadersSplitAcrossReads fails: read size 1: failure(io.netty.handler.codec.TooLongFrameException: maximum number of headers exceeded: 10).
  • codec-stomp tests: 67, 0 failures. Checkstyle passes.

The problem was found by modelling the replay behaviour of the decoder in Lean 4 and reproducing it with the real class. The change was prepared with Claude Code (Claude Opus 5.5), and the commit has a Co-Authored-By trailer.

Prepared with Claude Code on behalf of allthingssecurity.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

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

All reactions
@allthingssecurity @claude
Don't count STOMP headers again when the header block is replayed
e85f049
Motivation:

StompSubframeDecoder is a ReplayingDecoder. When the headers of a frame
are not complete yet, the next read parses all of them again from the
checkpoint. The header counter that enforces maxNumHeaders was only
reset by the empty line that ends the headers, so every replay added
the headers that were already counted. Whether a valid frame was
rejected with "maximum number of headers exceeded" depended on how it
was split into reads (for example 15 headers sent byte by byte, or a
frame at the limit in two reads), and the decoder then stayed in
BAD_FRAME.

Modification:

Reset the counter each time the header block is parsed and add tests.

Result:

maxNumHeaders applies to the headers of a frame, independent of how
the frame is split into reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
normanmaurer
normanmaurer requested changes Sep 29, 2026
View reviewed changes
Comment thread codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeDecoderTest.java Resolved

Uh oh!

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

Comment thread codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeDecoderTest.java Resolved

Uh oh!

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

@normanmaurer normanmaurer added this to the 4.2.19.Final milestone Sep 29, 2026
allthingssecurity and others added 2 commits September 30, 2026 06:39
@allthingssecurity @claude
Use parameterized tests for the STOMP header count tests
3218cea
Motivation:

The two new tests looped over the read sizes inside one test method.

Modification:

Turn them into @ParameterizedTest methods with the read sizes as a
@valuesource.

Result:

Each read size is reported as its own test case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@normanmaurer
Merge branch '4.2' into fix-stomp-header-count-replay
c716586
@testlens-app

testlens-app Bot commented Sep 30, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / linux-x86_64-java26 build > Netty/Codec/HTTP2

Test Runs Flakiness
Http2MultiplexTransportTest ❌ 1% 🟡

🏷️ Commit: c716586
▶️ Tests: 426606 executed
🟡 Checks: 31/34 completed

Test Failures

Http2MultiplexTransportTest (Netty/Codec/HTTP2 in Build PR / linux-x86_64-java26 build)
java.lang.IllegalStateException: Possible memory leak detected for resource scope 'Http2MultiplexTransportTest'. Please use paranoid leak detection to get more information, or set -Dio.netty.util.LeakPresenceDetector.trackCreationStack=true
	at io.netty.util.LeakPresenceDetector$ResourceScope.check(LeakPresenceDetector.java:308)
	at io.netty.util.LeakPresenceDetector$ResourceScope.close(LeakPresenceDetector.java:328)
	at io.netty.util.test.LeakPresenceExtension.afterAll(LeakPresenceExtension.java:140)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:511)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1450)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2019)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

Rerun Controls

Note

Checks are currently running using the configuration below.

Select tests to mute in this pull request:

🔲 Http2MultiplexTransportTest

Reuse successful test results:

🔲 ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

🔲 Rerun jobs


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 approved these changes Oct 1, 2026
View reviewed changes
@normanmaurer normanmaurer added defect 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 Oct 1, 2026
@normanmaurer
normanmaurer merged commit f364155 into netty:4.2 Oct 1, 2026
29 of 31 checks passed

Uh oh!

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

@allthingssecurity
allthingssecurity deleted the fix-stomp-header-count-replay branch October 1, 2026 15:57
@netty-project-bot

netty-project-bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer normanmaurer removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Oct 1, 2026
@normanmaurer

normanmaurer commented Oct 1, 2026

Copy link
Copy Markdown
Member

Actually this is not needed for 5.0 as it is not using ReplayingDecoder anymore .

All reactions

Sorry, something went wrong.

Uh oh!

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

@netty-project-bot

netty-project-bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17716

All reactions

Sorry, something went wrong.

Uh oh!

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

@netty-project-bot netty-project-bot mentioned this pull request Oct 1, 2026
Auto-port 4.1: Don't count STOMP headers again when the header block is replayed #17716
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Oct 1, 2026
normanmaurer added a commit that referenced this pull request Oct 2, 2026
@netty-project-bot @allthingssecurity @normanmaurer
Auto-port 4.1: Don't count STOMP headers again when the header block …
67eb4c3
…is replayed (#17716)

Auto-port of #17664 to 4.1
Cherry-picked commit: f364155

---
Motivation:

`StompSubframeDecoder` is a `ReplayingDecoder`. When the header block of
a frame is not complete, the next read parses the command and all
headers again from the checkpoint. The counter that enforces
`maxNumHeaders` (`HeaderParser.numHeaders`, added in #17063) is only
reset by the empty line that ends the headers. So every replay adds the
headers that were already counted.

As a result, whether a valid frame is rejected with "maximum number of
headers exceeded" depends on how it is split into reads. After the
rejection, the decoder stays in `BAD_FRAME`. With the default limit of
128:

| Frame | Reads | Result |
|---|---|---|
| 15 headers | sent byte by byte, or one line at a time from a terminal
| rejected |
| 40 headers | 32-byte reads | rejected |
| 128 headers | 2 reads | rejected |
| 90 headers | one read | accepted |

Modification:

- Reset the counter at the start of `readHeaders()`. Each attempt parses
all headers of the frame again, so it counts from zero.
- New tests in `StompSubframeDecoderTest`, each with `maxNumHeaders =
10` and read sizes of 1, 7, about half the frame and the whole frame:
- `testMaxNumHeadersNotExceededWhenHeadersSplitAcrossReads`: a frame
with 10 headers is accepted.
- `testMaxNumHeadersEnforcedWhenHeadersSplitAcrossReads`: a frame with
11 headers is rejected.

Result:

`maxNumHeaders` limits the headers of a frame, however the frame is
split into reads. The limit itself is unchanged: each attempt still
counts every header of the frame.


Co-authored-by: allthingssecurity <[email protected]>
Co-authored-by: Norman Maurer <[email protected]>
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
@netty-project-bot @allthingssecurity
@normanmaurer @lltopk
Auto-port 4.1: Don't count STOMP headers again when the header block …
6030815
…is replayed (netty#17716)

Auto-port of netty#17664 to 4.1
Cherry-picked commit: f364155

---
Motivation:

`StompSubframeDecoder` is a `ReplayingDecoder`. When the header block of
a frame is not complete, the next read parses the command and all
headers again from the checkpoint. The counter that enforces
`maxNumHeaders` (`HeaderParser.numHeaders`, added in netty#17063) is only
reset by the empty line that ends the headers. So every replay adds the
headers that were already counted.

As a result, whether a valid frame is rejected with "maximum number of
headers exceeded" depends on how it is split into reads. After the
rejection, the decoder stays in `BAD_FRAME`. With the default limit of
128:

| Frame | Reads | Result |
|---|---|---|
| 15 headers | sent byte by byte, or one line at a time from a terminal
| rejected |
| 40 headers | 32-byte reads | rejected |
| 128 headers | 2 reads | rejected |
| 90 headers | one read | accepted |

Modification:

- Reset the counter at the start of `readHeaders()`. Each attempt parses
all headers of the frame again, so it counts from zero.
- New tests in `StompSubframeDecoderTest`, each with `maxNumHeaders =
10` and read sizes of 1, 7, about half the frame and the whole frame:
- `testMaxNumHeadersNotExceededWhenHeadersSplitAcrossReads`: a frame
with 10 headers is accepted.
- `testMaxNumHeadersEnforcedWhenHeadersSplitAcrossReads`: a frame with
11 headers is rejected.

Result:

`maxNumHeaders` limits the headers of a frame, however the frame is
split into reads. The limit itself is unchanged: each attempt still
counts every header of the frame.


Co-authored-by: allthingssecurity <[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

@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

defect

Projects

None yet

Milestone

4.2.19.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

@allthingssecurity @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.