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 — Backport 4.1: Fix high-order bit aliasing in HttpUtil.validateToken by netty-project-bot · Pull Request #16303 · netty/netty

Conversation

@netty-project-bot

@netty-project-bot netty-project-bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Backport of #16279 to 4.1
Cherry-picked commit: 95cc055


Motivation:

The goal of this PR is to fix a character validation bypass in HttpUtil.validateToken.

Prior to this change, the validateCharSequenceToken method was susceptible to "high-order bit aliasing." Because the logic performed a direct cast from a 16-bit char to an 8-bit byte, any Unicode character whose lower 8 bits matched a valid RFC 7230 tchar would be incorrectly validated.

For example, the character 'Š' (U+0161) has the bit pattern 00000001 01100001. A narrow cast to byte strips the high-order bits, leaving 01100001, which is the ASCII value for 'a'. Since 'a' is a valid token character, the validator would return -1 (valid), violating the strictness required by RFC 7230.

Modification:

  • Modified validateCharSequenceToken(CharSequence token) to store the character in an int variable to prevent multiple charAt lookups and maintain consistency with Netty's internal coding style.
  • Introduced an explicit range check (value > 0xFF) to catch high-order characters before they are cast to byte.
  • Updated HttpUtilTest with a new parameterized test testInvalidTokenCharsHighOrderBitAliasing that specifically tests Unicode characters known to alias into the valid tchar range (U+0161, U+0121, U+0231, U+0361).

Result:

This change ensures that HttpUtil correctly rejects non-ASCII and multi-byte characters that were previously able to bypass the token validation logic.

Sorry, something went wrong.

Uh oh!

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

All reactions
@furkanvarol @normanmaurer @netty-project-bot
Fix high-order bit aliasing in HttpUtil.validateToken (#16279)
f7ece90
Motivation:

The goal of this PR is to fix a character validation bypass in
HttpUtil.validateToken.

Prior to this change, the validateCharSequenceToken method was
susceptible to "high-order bit aliasing." Because the logic performed a
direct cast from a 16-bit char to an 8-bit byte, any Unicode character
whose lower 8 bits matched a valid RFC 7230 tchar would be incorrectly
validated.

For example, the character 'Š' (U+0161) has the bit pattern 00000001
01100001. A narrow cast to byte strips the high-order bits, leaving
01100001, which is the ASCII value for 'a'. Since 'a' is a valid token
character, the validator would return -1 (valid), violating the
strictness required by RFC 7230.

Modification:

* Modified validateCharSequenceToken(CharSequence token) to store the
character in an int variable to prevent multiple charAt lookups and
maintain consistency with Netty's internal coding style.
* Introduced an explicit range check (value > 0xFF) to catch high-order
characters before they are cast to byte.
* Updated HttpUtilTest with a new parameterized test
testInvalidTokenCharsHighOrderBitAliasing that specifically tests
Unicode characters known to alias into the valid tchar range (U+0161,
U+0121, U+0231, U+0361).

Result:

This change ensures that HttpUtil correctly rejects non-ASCII and
multi-byte characters that were previously able to bypass the token
validation logic.

Co-authored-by: Norman Maurer <[email protected]>
(cherry picked from commit 95cc055)
@netty-project-bot netty-project-bot mentioned this pull request Feb 19, 2026
Fix high-order bit aliasing in HttpUtil.validateToken #16279
Merged
@chrisvest
chrisvest enabled auto-merge (squash) February 19, 2026 01:02
@chrisvest
chrisvest merged commit 1e22fc4 into 4.1 Feb 19, 2026
18 checks passed

Uh oh!

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

@chrisvest
chrisvest deleted the backport-pr-16279-to-4.1 branch February 19, 2026 02:30
@normanmaurer normanmaurer added this to the 4.1.132.Final milestone Feb 19, 2026
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

4.1.132.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@netty-project-bot @chrisvest @normanmaurer @furkanvarol
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.