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 — Auto-port 5.0: Guard against out-of-bounds reads when parsing ClientHello SNI extension by netty-project-bot · Pull Request #17559 · netty/netty

Conversation

@netty-project-bot

@netty-project-bot netty-project-bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Auto-port of #17532 to 5.0
Cherry-picked commit: 5c44cb5


Motivation:

AbstractSniHandler.extractSniHostname() reads the session_id,
cipher_suites and compression_methods lengths from a ClientHello and
advances the parse offset by each of these attacker-controlled values,
without re-checking the offset against the buffer bounds before the
next read. A single crafted, non-fragmented ClientHello with an
oversized session_id length (e.g. 0xFF) pushes the offset past the end
of the buffer and triggers an IndexOutOfBoundsException.

Modification:

Re-validate the offset against the end of the buffer before each of
the three interior reads, symmetric to the bounds checks already used
by the extensions loop further down.

Result:

Malformed ClientHello messages no longer trigger an
IndexOutOfBoundsException while parsing the SNI extension.

Sorry, something went wrong.

Uh oh!

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

All reactions
@normanmaurer @netty-project-bot
Guard against out-of-bounds reads when parsing ClientHello SNI extens…
34f17db
…ion (#17532)

Motivation:

AbstractSniHandler.extractSniHostname() reads the session_id,
cipher_suites and compression_methods lengths from a ClientHello and
advances the parse offset by each of these attacker-controlled values,
without re-checking the offset against the buffer bounds before the
next read. A single crafted, non-fragmented ClientHello with an
oversized session_id length (e.g. 0xFF) pushes the offset past the end
of the buffer and triggers an IndexOutOfBoundsException.

Modification:

Re-validate the offset against the end of the buffer before each of
the three interior reads, symmetric to the bounds checks already used
by the extensions loop further down.

Result:

Malformed ClientHello messages no longer trigger an
IndexOutOfBoundsException while parsing the SNI extension.

(cherry picked from commit 5c44cb5)
@netty-project-bot netty-project-bot mentioned this pull request Sep 20, 2026
Guard against out-of-bounds reads when parsing ClientHello SNI extension #17532
Merged
@testlens-app

testlens-app Bot commented Sep 20, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 34f17db
▶️ Tests: 232057 executed
⚪️ Checks: 12/12 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 5.0.0.Final milestone Sep 20, 2026
@normanmaurer
normanmaurer merged commit 3afbe8b into 5.0 Sep 20, 2026
13 checks passed

Uh oh!

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

@normanmaurer
normanmaurer deleted the auto-port-pr-17532-to-5.0 branch September 20, 2026 16:58
@Marti2203 Marti2203 mentioned this pull request Oct 27, 2026
Bound the SNI host name by the server_name extension #18121
Merged
chrisvest pushed a commit that referenced this pull request Nov 17, 2026
@Marti2203 @normanmaurer
Bound the SNI host name by the server_name extension (#18121)
20dd973
Motivation:

`AbstractSniHandler.extractSniHostname(...)` bounds the `host_name`
length by `extensionsLimit`, the end of all extensions, not by the end
of the `server_name` extension (`AbstractSniHandler.java:109`). RFC 6066
requires the `ServerNameList` to fill the extension data. As a result:

1. A `host_name` whose length runs past the end of the `server_name`
extension is accepted, and the name is read from the header and data of
the following extension(s).
2. The `server_name_list` length is skipped and never checked (0 or
0xFFFF are accepted).
3. An empty `host_name` (`opaque HostName<1..2^16-1>`) is returned as
`""`.

For example, a `server_name` extension with `extension_length = 9`, list
length `0xFFFF`, `name_length = 13` and the bytes `beta`, followed by an
extension whose header and data are `.sni.test`, makes
`extractSniHostname` return `beta.sni.test`. `SniHandler` then selects
that virtual host and fires `SniCompletionEvent("beta.sni.test")`. Both
the JDK engine and BoringSSL reject the same hello afterwards with
`decode_error`, so no handshake completes, but the mapping and
`SniCompletionEvent` already ran with a name that is not in the
`server_name` extension.

This is separate from #17532 / #17558 / #17559, which added checks
before the `session_id`, `cipher_suites` and `compression_methods`
reads; the line-109 comparison was not changed there.

Modification:

- Bound the SNI parse by the end of the `server_name` extension.
- Require the `server_name_list` length to match the extension data.
- Reject an empty `host_name`.
- Add four tests to `AbstractSniHandlerTest`: a well-formed
`server_name` followed by another extension, a name crossing the
extension boundary, a list-length mismatch, and an empty name.

Result:

Only host names contained in the `server_name` extension are returned;
malformed `server_name` extensions are ignored like other malformed
input.

Tests (4.2 head `b6fad79c6a`, JDK 21): without the change three of the
new tests fail (`expected: <null> but was: <beta.sni.test>`,
`<netty.io>`, `<>`). With it, `AbstractSniHandlerTest` 8/8,
`SniHandlerTest` 19/19, `SniClientTest` 3/3 and
`SslClientHelloHandlerTest` 4/4 pass, and checkstyle passes for
`handler`. `AbstractSniHandler.java` is identical on 4.1, so the change
should apply there as is.

Host-name syntax checks (LDH, trailing dot) are deliberately not added;
underscore names are in use (#8144) and that policy belongs in the
mapping.

This issue was found by an LLM-Enhanced Static Analysis Engine and
verified manually.

---------

Co-authored-by: Norman Maurer <[email protected]>
hellboy0621 pushed a commit to hellboy0621/netty that referenced this pull request Nov 23, 2026
@Marti2203 @normanmaurer @hellboy0621
Bound the SNI host name by the server_name extension (netty#18121)
ca8c68a
Motivation:

`AbstractSniHandler.extractSniHostname(...)` bounds the `host_name`
length by `extensionsLimit`, the end of all extensions, not by the end
of the `server_name` extension (`AbstractSniHandler.java:109`). RFC 6066
requires the `ServerNameList` to fill the extension data. As a result:

1. A `host_name` whose length runs past the end of the `server_name`
extension is accepted, and the name is read from the header and data of
the following extension(s).
2. The `server_name_list` length is skipped and never checked (0 or
0xFFFF are accepted).
3. An empty `host_name` (`opaque HostName<1..2^16-1>`) is returned as
`""`.

For example, a `server_name` extension with `extension_length = 9`, list
length `0xFFFF`, `name_length = 13` and the bytes `beta`, followed by an
extension whose header and data are `.sni.test`, makes
`extractSniHostname` return `beta.sni.test`. `SniHandler` then selects
that virtual host and fires `SniCompletionEvent("beta.sni.test")`. Both
the JDK engine and BoringSSL reject the same hello afterwards with
`decode_error`, so no handshake completes, but the mapping and
`SniCompletionEvent` already ran with a name that is not in the
`server_name` extension.

This is separate from netty#17532 / netty#17558 / netty#17559, which added checks
before the `session_id`, `cipher_suites` and `compression_methods`
reads; the line-109 comparison was not changed there.

Modification:

- Bound the SNI parse by the end of the `server_name` extension.
- Require the `server_name_list` length to match the extension data.
- Reject an empty `host_name`.
- Add four tests to `AbstractSniHandlerTest`: a well-formed
`server_name` followed by another extension, a name crossing the
extension boundary, a list-length mismatch, and an empty name.

Result:

Only host names contained in the `server_name` extension are returned;
malformed `server_name` extensions are ignored like other malformed
input.

Tests (4.2 head `b6fad79c6a`, JDK 21): without the change three of the
new tests fail (`expected: <null> but was: <beta.sni.test>`,
`<netty.io>`, `<>`). With it, `AbstractSniHandlerTest` 8/8,
`SniHandlerTest` 19/19, `SniClientTest` 3/3 and
`SslClientHelloHandlerTest` 4/4 pass, and checkstyle passes for
`handler`. `AbstractSniHandler.java` is identical on 4.1, so the change
should apply there as is.

Host-name syntax checks (LDH, trailing dot) are deliberately not added;
underscore names are in use (netty#8144) and that policy belongs in the
mapping.

This issue was found by an LLM-Enhanced Static Analysis Engine and
verified manually.

---------

Co-authored-by: Norman Maurer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

5.0.0.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

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