Skip to content

Merge changes from forks (#17213) - #17217

Merged
normanmaurer merged 11 commits into
4.1from
merge41
Aug 6, 2026
Merged

normanmaurer merged 11 commits into
4.1from
merge41

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

CORS: Don't override vary header if it already
exists

Motivation:

Netty's CorsHandler silently overwrites existing Vary headers, enabling
cache poisoning and sensitive information disclosure.

Modifications:

  • Only set vary header if it not already exists
  • Add unit test

Result:

No more cache poisoning possible


Encoding-side validation of MQTT
fields

Motivation:
The MqttEncoder should not produce malformed messages if client id,
topics, or usernames contain illegal characters.

Modification:
Add validation of client identifier, will topic, and username to the
encoding path of CONNECT messages, and also to the topic name when
encoding PUBLISH messages.

Result:
The encoder will now throw an exception if any of these fields contain a
NUL byte.


Bound SCTP fragmented message
buffering


Correctly handle ClientHello with a handshake header split across
TLS…

… records

Motivation:

The handshake header (HandshakeType + 3-byte length = 4 bytes) may be
delivered across multiple TLS records. SslClientHelloHandler assumed
these
4 bytes were always contained in the first record and read them directly
from it, which is incorrect when the header spans records.

Modification:

  • Read the handshake header directly from the record only when the full
    4 bytes are contained in it.
  • Otherwise aggregate the record payloads into handshakeBuffer and read
    the
    handshakeType and handshakeLength from the buffer once at least 4 bytes
    are available.
  • Aggregate the handshake header together with the body and slice past
    the
    4-byte header once the full ClientHello has been buffered.
  • Add SniHandlerTest cases for fragment sizes 1-4.

Result:

ClientHello messages whose handshake header is fragmented across
multiple
TLS records are parsed correctly.


Harden the SOCKS4/5 input validation at encoding
time

Motivation:
SOCKS4 is a delimiter-based protocol, and does not support NUL bytes in
string or byte-sequence fields.
SOCKS5 is a Tag-Length-Value protocol, and does not support lengths
greater than 255.

Modification:
Add validations for NUL bytes and lengths for SOCKS4 and 5,
respectively, and ensure both client- and server-side encoders behave
correctly.
Add tests to verify the correct handling of boundary conditions.

Result:
Correct delimiter and length handling in the SOCKS4/5 encoders, even
when integrators use custom implementations of the message types.


Do not re-aggregate the ClientHello on every received TLS
record


Validate trust manager
configuration

Motivation:

Certain trust manager configurations were not being validated
against the configured endpoint identification algorithm.

Modification:

Add a check that fails fast when the configured trust manager
does not support the required verification mode.

Result:

Misconfigured trust manager setups are now rejected explicitly
instead of failing silently.


Co-authored-by: Norman Maurer [email protected]
Co-authored-by: yawkat [email protected]
Co-authored-by: multicode [email protected]
Co-authored-by: Violeta Georgieva [email protected]

chrisvest and others added 10 commits August 5, 2026 08:04
[CORS: Don't override vary header if it already
exists](1a896eb)
Motivation:

Netty's CorsHandler silently overwrites existing Vary headers, enabling
cache poisoning and sensitive information disclosure.

Modifications:

- Only set vary header if it not already exists
- Add unit test

Result:

No more cache poisoning possible

---

[Encoding-side validation of MQTT
fields](9975553)
Motivation:
The MqttEncoder should not produce malformed messages if client id,
topics, or usernames contain illegal characters.

Modification:
Add validation of client identifier, will topic, and username to the
encoding path of CONNECT messages, and also to the topic name when
encoding PUBLISH messages.

Result:
The encoder will now throw an exception if any of these fields contain a
NUL byte.

---

[Bound SCTP fragmented message
buffering](c07b97c)

---

[Correctly handle ClientHello with a handshake header split across
TLS…](a8f53f2)
… records

Motivation:

The handshake header (HandshakeType + 3-byte length = 4 bytes) may be
delivered across multiple TLS records. SslClientHelloHandler assumed
these
4 bytes were always contained in the first record and read them directly
from it, which is incorrect when the header spans records.

Modification:

- Read the handshake header directly from the record only when the full
4 bytes are contained in it.
- Otherwise aggregate the record payloads into handshakeBuffer and read
the
handshakeType and handshakeLength from the buffer once at least 4 bytes
are available.
- Aggregate the handshake header together with the body and slice past
the
4-byte header once the full ClientHello has been buffered.
- Add SniHandlerTest cases for fragment sizes 1-4.

Result:

ClientHello messages whose handshake header is fragmented across
multiple
TLS records are parsed correctly.

---

[Harden the SOCKS4/5 input validation at encoding
time](4625406)
Motivation:
SOCKS4 is a delimiter-based protocol, and does not support NUL bytes in
string or byte-sequence fields.
SOCKS5 is a Tag-Length-Value protocol, and does not support lengths
greater than 255.

Modification:
Add validations for NUL bytes and lengths for SOCKS4 and 5,
respectively, and ensure both client- and server-side encoders behave
correctly.
Add tests to verify the correct handling of boundary conditions.

Result:
Correct delimiter and length handling in the SOCKS4/5 encoders, even
when integrators use custom implementations of the message types.

---

[Do not re-aggregate the ClientHello on every received TLS
record](bb74154)

---

[Validate trust manager
configuration](5f1888e)
Motivation:

Certain trust manager configurations were not being validated
against the configured endpoint identification algorithm.

Modification:

Add a check that fails fast when the configured trust manager
does not support the required verification mode.

Result:

Misconfigured trust manager setups are now rejected explicitly
instead of failing silently.

---------

Co-authored-by: Norman Maurer <[email protected]>
Co-authored-by: yawkat <[email protected]>
Co-authored-by: multicode <[email protected]>
Co-authored-by: Violeta Georgieva <[email protected]>
@chrisvest chrisvest added this to the 4.1.137.Final milestone Aug 5, 2026
@normanmaurer
normanmaurer merged commit 9e05192 into 4.1 Aug 6, 2026
17 of 18 checks passed
@normanmaurer
normanmaurer deleted the merge41 branch August 6, 2026 07:29
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
[CORS: Don't override vary header if it already

exists](netty@1a896eb)
Motivation:

Netty's CorsHandler silently overwrites existing Vary headers, enabling
cache poisoning and sensitive information disclosure.

Modifications:

- Only set vary header if it not already exists
- Add unit test

Result:

No more cache poisoning possible

---

[Encoding-side validation of MQTT

fields](netty@9975553)
Motivation:
The MqttEncoder should not produce malformed messages if client id,
topics, or usernames contain illegal characters.

Modification:
Add validation of client identifier, will topic, and username to the
encoding path of CONNECT messages, and also to the topic name when
encoding PUBLISH messages.

Result:
The encoder will now throw an exception if any of these fields contain a
NUL byte.

---

[Bound SCTP fragmented message

buffering](netty@c07b97c)

---

[Correctly handle ClientHello with a handshake header split across

TLS…](netty@a8f53f2)
… records

Motivation:

The handshake header (HandshakeType + 3-byte length = 4 bytes) may be
delivered across multiple TLS records. SslClientHelloHandler assumed
these
4 bytes were always contained in the first record and read them directly
from it, which is incorrect when the header spans records.

Modification:

- Read the handshake header directly from the record only when the full
4 bytes are contained in it.
- Otherwise aggregate the record payloads into handshakeBuffer and read
the
handshakeType and handshakeLength from the buffer once at least 4 bytes
are available.
- Aggregate the handshake header together with the body and slice past
the
4-byte header once the full ClientHello has been buffered.
- Add SniHandlerTest cases for fragment sizes 1-4.

Result:

ClientHello messages whose handshake header is fragmented across
multiple
TLS records are parsed correctly.

---

[Harden the SOCKS4/5 input validation at encoding

time](netty@4625406)
Motivation:
SOCKS4 is a delimiter-based protocol, and does not support NUL bytes in
string or byte-sequence fields.
SOCKS5 is a Tag-Length-Value protocol, and does not support lengths
greater than 255.

Modification:
Add validations for NUL bytes and lengths for SOCKS4 and 5,
respectively, and ensure both client- and server-side encoders behave
correctly.
Add tests to verify the correct handling of boundary conditions.

Result:
Correct delimiter and length handling in the SOCKS4/5 encoders, even
when integrators use custom implementations of the message types.

---

[Do not re-aggregate the ClientHello on every received TLS

record](netty@bb74154)

---

[Validate trust manager

configuration](netty@5f1888e)
Motivation:

Certain trust manager configurations were not being validated
against the configured endpoint identification algorithm.

Modification:

Add a check that fails fast when the configured trust manager
does not support the required verification mode.

Result:

Misconfigured trust manager setups are now rejected explicitly
instead of failing silently.

---------

Co-authored-by: Norman Maurer <[email protected]>
Co-authored-by: yawkat <[email protected]>
Co-authored-by: multicode <[email protected]>
Co-authored-by: Violeta Georgieva
<[email protected]>

---------

Co-authored-by: Chris Vest <[email protected]>
Co-authored-by: yawkat <[email protected]>
Co-authored-by: multicode <[email protected]>
Co-authored-by: Violeta Georgieva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants