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 — HAProxyMessageDecoder: fix v2 header framing with a non-zero reader index by yawkat · Pull Request #17832 · netty/netty

Conversation

@yawkat

@yawkat yawkat commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Motivation:

HAProxyMessageDecoder.findEndOfHeader(ByteBuf) returns the length of a v2
header, but HeaderExtractor.extract treats the result as an absolute index
in the buffer, like the end of line of a v1 header. When the reader index
of the buffer is not 0, the decoder slices a truncated header and passes the
remaining header bytes on as payload, or calls readSlice with a negative
length and fails with an IllegalArgumentException.

The reader index is not 0 when the inbound buffer was partially read by a
handler before the decoder, and when decode is called again after the
decoder already failed: when the channel is closed, decodeLast decodes the
bytes after a header that exceeded the maximum length. As decode does not
check whether the decoder is finished, these bytes can also be decoded as
a second HAProxyMessage after the HAProxyProtocolException.

Modification:

  • Return the absolute index of the end of the header from findEndOfHeader.
  • Do not decode anything once the decoder is finished. The remaining bytes
    stay in the cumulation, to be forwarded when the decoder is removed or
    released when the channel is closed.
  • Add unit tests.

Result:

v2 headers are framed correctly, and nothing is decoded after a failure.

Discovered by fuzzing.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

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

All reactions
@yawkat @claude
HAProxyMessageDecoder: fix v2 header framing with a non-zero reader i…
9b8c9f9
…ndex

Motivation:

HAProxyMessageDecoder.findEndOfHeader(ByteBuf) returns the length of a v2
header, but HeaderExtractor.extract treats the result as an absolute index
in the buffer, like the end of line of a v1 header. When the reader index
of the buffer is not 0, the decoder slices a truncated header and passes the
remaining header bytes on as payload, or calls readSlice with a negative
length and fails with an IllegalArgumentException.

The reader index is not 0 when the inbound buffer was partially read by a
handler before the decoder, and when decode is called again after the
decoder already failed: when the channel is closed, decodeLast decodes the
bytes after a header that exceeded the maximum length. As decode does not
check whether the decoder is finished, these bytes can also be decoded as
a second HAProxyMessage after the HAProxyProtocolException.

Modification:

- Return the absolute index of the end of the header from findEndOfHeader.
- Do not decode anything once the decoder is finished. The remaining bytes
  stay in the cumulation, to be forwarded when the decoder is removed or
  released when the channel is closed.
- Add unit tests.

Result:

v2 headers are framed correctly, and nothing is decoded after a failure.

Discovered by fuzzing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yawkat yawkat added the found by fuzzing label Oct 15, 2026
This was referenced Oct 15, 2026
Add HAProxyMessageDecoder fuzzer micronaut-projects/micronaut-fuzzing#319
Merged
Add HAProxy message decoder fuzzer micronaut-projects/micronaut-fuzzing#256
Closed
@yawkat
yawkat marked this pull request as ready for review October 15, 2026 13:32
@yawkat yawkat 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 Oct 15, 2026
normanmaurer
normanmaurer requested changes Oct 15, 2026
View reviewed changes
Comment thread codec-haproxy/src/main/java/io/netty/handler/codec/haproxy/HAProxyMessageDecoder.java Resolved

Uh oh!

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

@testlens-app

testlens-app Bot commented Oct 15, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Test Summary

Tip

Inspect all details with the TestLens CLI: testlens pr 17832

Build PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithoutBind(TestInfo) ❌ 3% 🟡

🏷️ Commit: 9b8c9f9
▶️ Tests: 35882 executed
⚪️ Checks: 32/32 completed

Test Failures

KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithoutBind(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java11-boringssl build)
org.opentest4j.AssertionFailedError
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSend0(DatagramUnicastTest.java:368)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSend(DatagramUnicastTest.java:194)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithoutBind(DatagramUnicastTest.java:186)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$6.run(DatagramUnicastTest.java:180)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$6.run(DatagramUnicastTest.java:177)
	at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithoutBind(DatagramUnicastTest.java:177)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

Rerun Controls

Select tests to mute in this pull request:

  • KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithoutBind(TestInfo)

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 added this to the 4.2.20.Final milestone Oct 16, 2026
@normanmaurer
normanmaurer merged commit 27a6921 into netty:4.2 Oct 16, 2026
32 of 33 checks passed

Uh oh!

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

@netty-project-bot

netty-project-bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17882

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 16, 2026
Auto-port 4.1: HAProxyMessageDecoder: fix v2 header framing with a non-zero reader index #17882
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 16, 2026
@netty-project-bot

netty-project-bot commented Oct 16, 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 commented Oct 16, 2026

Copy link
Copy Markdown
Member

Port for 5.0 #17884

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 16, 2026
normanmaurer added a commit that referenced this pull request Oct 16, 2026
@normanmaurer @yawkat
Port 5.0: HAProxyMessageDecoder: fix v2 header framing with a non-zer…
bb05042
…o reader index (#17832) (#17884)

Motivation:

HAProxyMessageDecoder.findEndOfHeader(ByteBuf) returns the length of a
v2
header, but HeaderExtractor.extract treats the result as an absolute
index
in the buffer, like the end of line of a v1 header. When the reader
index
of the buffer is not 0, the decoder slices a truncated header and passes
the
remaining header bytes on as payload, or calls readSlice with a negative
length and fails with an IllegalArgumentException.

The reader index is not 0 when the inbound buffer was partially read by
a
handler before the decoder, and when decode is called again after the
decoder already failed: when the channel is closed, decodeLast decodes
the
bytes after a header that exceeded the maximum length. As decode does
not
check whether the decoder is finished, these bytes can also be decoded
as
a second HAProxyMessage after the HAProxyProtocolException.

Modification:

- Return the absolute index of the end of the header from
findEndOfHeader.
- Do not decode anything once the decoder is finished. The remaining
bytes
  stay in the cumulation, to be forwarded when the decoder is removed or
  released when the channel is closed.
- Add unit tests.

Result:

v2 headers are framed correctly, and nothing is decoded after a failure.

Discovered by fuzzing.

Co-authored-by: Jonas Konrad <[email protected]>
normanmaurer added a commit that referenced this pull request Oct 16, 2026
@netty-project-bot @yawkat @normanmaurer
Auto-port 4.1: HAProxyMessageDecoder: fix v2 header framing with a no…
c4a32ad
…n-zero reader index (#17882)

Auto-port of #17832 to 4.1
Cherry-picked commit: 27a6921

---
Motivation:

HAProxyMessageDecoder.findEndOfHeader(ByteBuf) returns the length of a
v2
header, but HeaderExtractor.extract treats the result as an absolute
index
in the buffer, like the end of line of a v1 header. When the reader
index
of the buffer is not 0, the decoder slices a truncated header and passes
the
remaining header bytes on as payload, or calls readSlice with a negative
length and fails with an IllegalArgumentException.

The reader index is not 0 when the inbound buffer was partially read by
a
handler before the decoder, and when decode is called again after the
decoder already failed: when the channel is closed, decodeLast decodes
the
bytes after a header that exceeded the maximum length. As decode does
not
check whether the decoder is finished, these bytes can also be decoded
as
a second HAProxyMessage after the HAProxyProtocolException.

Modification:

- Return the absolute index of the end of the header from
findEndOfHeader.
- Do not decode anything once the decoder is finished. The remaining
bytes
  stay in the cumulation, to be forwarded when the decoder is removed or
  released when the channel is closed.
- Add unit tests.

Result:

v2 headers are framed correctly, and nothing is decoded after a failure.

Discovered by fuzzing.

---------

Co-authored-by: Jonas Konrad <[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 @yawkat
@normanmaurer @lltopk
Auto-port 4.1: HAProxyMessageDecoder: fix v2 header framing with a no…
17f2650
…n-zero reader index (netty#17882)

Auto-port of netty#17832 to 4.1
Cherry-picked commit: 27a6921

---
Motivation:

HAProxyMessageDecoder.findEndOfHeader(ByteBuf) returns the length of a
v2
header, but HeaderExtractor.extract treats the result as an absolute
index
in the buffer, like the end of line of a v1 header. When the reader
index
of the buffer is not 0, the decoder slices a truncated header and passes
the
remaining header bytes on as payload, or calls readSlice with a negative
length and fails with an IllegalArgumentException.

The reader index is not 0 when the inbound buffer was partially read by
a
handler before the decoder, and when decode is called again after the
decoder already failed: when the channel is closed, decodeLast decodes
the
bytes after a header that exceeded the maximum length. As decode does
not
check whether the decoder is finished, these bytes can also be decoded
as
a second HAProxyMessage after the HAProxyProtocolException.

Modification:

- Return the absolute index of the end of the header from
findEndOfHeader.
- Do not decode anything once the decoder is finished. The remaining
bytes
  stay in the cumulation, to be forwarded when the decoder is removed or
  released when the channel is closed.
- Add unit tests.

Result:

v2 headers are framed correctly, and nothing is decoded after a failure.

Discovered by fuzzing.

---------

Co-authored-by: Jonas Konrad <[email protected]>
Co-authored-by: Norman Maurer <[email protected]>
@lhotari lhotari mentioned this pull request Nov 2, 2026
[fix][sec] Upgrade Netty to 4.2.20 and netty-tcnative to 2.0.85 to address several CVEs and bugs apache/pulsar#27310
Merged
1 of 11 tasks
@yawkat yawkat mentioned this pull request Nov 9, 2026
Remove known-bug filters for fixes released in Netty 4.2.20 micronaut-projects/micronaut-fuzzing#340
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer requested changes

Uh oh!

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

Assignees

No one assigned

Labels

found by fuzzing

Projects

None yet

Milestone

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

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