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 — HAProxyMessageEncoder: Reject v2 headers longer than 65535 bytes by Raghuvardhan-Reddy78 · Pull Request #18428 · netty/netty

Conversation

@Raghuvardhan-Reddy78

@Raghuvardhan-Reddy78 Raghuvardhan-Reddy78 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Motivation:

The proxy protocol v2 header stores the length of the address and TLV section, and each TLV length, in 16 bits. HAProxyMessageEncoder.encodeV2 wrote both with writeShort without checking that they fit, then wrote every TLV byte. A TLV of 65536 bytes or more, or TLVs that together push the section past 65535 bytes, went out with truncated lengths, so the receiver parsed TLV content as further TLVs and passed the rest to the application as connection data. With a 65536-byte custom TLV whose content starts with an AUTHORITY TLV, followed by the real AUTHORITY TLV, HAProxyMessageDecoder returns the forged authority and the next handler receives the remaining 65536 bytes as payload.

Modification:

Reject messages whose address and TLV section exceeds 65535 bytes with an EncoderException. Every TLV is counted in that length, so this also bounds each individual TLV length. Tests added to HaProxyMessageEncoderTest for the exact maximum, a single oversized TLV and TLVs that only overflow together.

Result:

Oversized v2 messages fail to encode instead of producing a header the receiver parses differently. Note this is a behaviour change: such messages were previously written (incorrectly) and now raise an EncoderException.

Sorry, something went wrong.

Uh oh!

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

All reactions
@Raghuvardhan-Reddy78
HAProxyMessageEncoder: Reject v2 headers longer than 65535 bytes
bfce7f2
Motivation:

The proxy protocol v2 header stores the length of the address and TLV
section, and each TLV length, in 16 bits. HAProxyMessageEncoder.encodeV2
wrote both with writeShort without checking that they fit and then wrote
every TLV byte. A TLV of 65536 bytes or more, or TLVs that together push
the section past 65535 bytes, was sent with truncated length fields, so
the receiver parsed TLV content as further TLVs and handed the rest to
the application as connection data. For example, a 65536-byte custom TLV
whose content starts with an AUTHORITY TLV, followed by the real
AUTHORITY TLV, is decoded by HAProxyMessageDecoder with the forged
authority, and the remaining 65536 bytes reach the next handler as
payload.

Modification:

Reject messages whose address and TLV section is longer than 65535
bytes with an EncoderException. Every TLV is counted in that length, so
this also bounds each individual TLV length.

Result:

Oversized v2 messages fail to encode instead of producing a header that
the receiver parses differently. This is a behaviour change: such
messages used to be written (incorrectly) and now raise an
EncoderException.
@testlens-app

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

Uh oh!

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

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: bfce7f2
▶️ Tests: 0 executed
🟡 Checks: 25/26 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 16, 2026
normanmaurer
normanmaurer approved these changes Nov 16, 2026
View reviewed changes
@normanmaurer
normanmaurer merged commit e3cab70 into netty:4.2 Nov 16, 2026
42 of 44 checks passed

Uh oh!

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

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

netty-project-bot commented Nov 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.

@netty-project-bot netty-project-bot mentioned this pull request Nov 16, 2026
Auto-port 4.1: HAProxyMessageEncoder: Reject v2 headers longer than 65535 bytes #18430
Merged
@netty-project-bot

netty-project-bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #18430

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 16, 2026
normanmaurer pushed a commit that referenced this pull request Nov 16, 2026
@netty-project-bot @Raghuvardhan-Reddy78
Auto-port 4.1: HAProxyMessageEncoder: Reject v2 headers longer than 6…
425f52a
…5535 bytes (#18430)

Auto-port of #18428 to 4.1
Cherry-picked commit: e3cab70

---
Motivation:

The proxy protocol v2 header stores the length of the address and TLV
section, and each TLV length, in 16 bits.
`HAProxyMessageEncoder.encodeV2` wrote both with `writeShort` without
checking that they fit, then wrote every TLV byte. A TLV of 65536 bytes
or more, or TLVs that together push the section past 65535 bytes, went
out with truncated lengths, so the receiver parsed TLV content as
further TLVs and passed the rest to the application as connection data.
With a 65536-byte custom TLV whose content starts with an AUTHORITY TLV,
followed by the real AUTHORITY TLV, `HAProxyMessageDecoder` returns the
forged authority and the next handler receives the remaining 65536 bytes
as payload.

Modification:

Reject messages whose address and TLV section exceeds 65535 bytes with
an `EncoderException`. Every TLV is counted in that length, so this also
bounds each individual TLV length. Tests added to
`HaProxyMessageEncoderTest` for the exact maximum, a single oversized
TLV and TLVs that only overflow together.

Result:

Oversized v2 messages fail to encode instead of producing a header the
receiver parses differently. Note this is a behaviour change: such
messages were previously written (incorrectly) and now raise an
`EncoderException`.

Co-authored-by: Raghuvardhan-Reddy78 <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Nov 16, 2026
Port 5.0: HAProxyMessageEncoder: Reject v2 headers longer than 65535 bytes (#18428) #18431
Merged
@normanmaurer

normanmaurer commented Nov 16, 2026

Copy link
Copy Markdown
Member

Ported to 5.0: #18431

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 Nov 16, 2026
normanmaurer added a commit that referenced this pull request Nov 16, 2026
@normanmaurer @Raghuvardhan-Reddy78
Port 5.0: HAProxyMessageEncoder: Reject v2 headers longer than 65535 …
dde8c18
…bytes (#18428) (#18431)

Motivation:

Port of #18428 to 5.0.

The proxy protocol v2 header stores the length of the address and TLV
section, and each TLV length, in 16 bits.
`HAProxyMessageEncoder.encodeV2` wrote both with `writeShort` without
checking that they fit, then wrote every TLV byte. Oversized TLVs went
out with truncated lengths, so the receiver parsed TLV content as
further TLVs (e.g. a forged AUTHORITY) and passed the rest to the
application as connection data.

Modification:

Cherry-pick of e3cab70. Reject messages whose address and TLV section
exceeds 65535 bytes with an `EncoderException`. The new tests were
adapted to 5.0 (`throws Exception` on `writeOutbound`, lambdas).

Result:

Oversized v2 messages fail to encode instead of producing a header the
receiver parses differently. Note this is a behaviour change: such
messages were previously written (incorrectly) and now raise an
`EncoderException`.

Co-authored-by: Raghuvardhan-Reddy78 <[email protected]>
@lhotari lhotari mentioned this pull request Nov 17, 2026
[improve][build] Upgrade Netty to 4.2.21.Final to restore the aarch64 glibc floor and pick up bug fixes apache/pulsar#27654
Merged
1 of 11 tasks
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

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

@Raghuvardhan-Reddy78 @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.