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 — HAProxyMessageEncoder: Reject v2 headers longer than 65535 bytes by Raghuvardhan-Reddy78 · Pull Request #18428 · netty/netty Conversation
Contributor
Motivation: The proxy protocol v2 header stores the length of the address and TLV section, and each TLV length, in 16 bits. Modification: Reject messages whose address and TLV section exceeds 65535 bytes with an 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
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: 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.
|
There was an error while loading. Please reload this page.
✅ All tests passed ✅🏷️ Commit: bfce7f2 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.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Auto-port PR for 4.1: #18430 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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]>
|
Ported to 5.0: #18431 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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]>
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.