Skip to content

Merge changes from forks (#17213) - #17218

Merged
normanmaurer merged 3 commits into
netty:5.0from
chrisvest:5.0-sec-fixes
Aug 7, 2026
Merged

normanmaurer merged 3 commits into
netty:5.0from
chrisvest:5.0-sec-fixes

Conversation

@chrisvest

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]

(cherry picked from commit 1b5abc6)

Motivation:

Explain here the context, and why you're making that change.
What is the problem you're trying to solve.

Modification:

Describe the modifications you've done.

Result:

Fixes #.

If there is no issue then describe the changes introduced by this PR.

[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]>

(cherry picked from commit 1b5abc6)
@testlens-app

testlens-app Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 82b565f
▶️ Tests: 40764 executed
⚪️ Checks: 12/12 completed


Learn more about TestLens at testlens.app.

@normanmaurer
normanmaurer merged commit ec77161 into netty:5.0 Aug 7, 2026
13 checks passed
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Aug 7, 2026
@chrisvest
chrisvest deleted the 5.0-sec-fixes branch August 7, 2026 17:26
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