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: Reject control characters at the boundary of the HTTP version token by netty-project-bot · Pull Request #16981 · netty/netty

Conversation

@netty-project-bot

@netty-project-bot netty-project-bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Auto-port of #16971 to 5.0
Cherry-picked commit: 69b7851


Motivation:

HttpRequestDecoder accepts a request whose HTTP-version token carries a boundary control byte (NUL, CR, LF, VT, FF, …):

printf 'GET / \x00HTTP/1.1\r\nHost: localhost\r\n\r\n' | nc <host> <port>
# decoded as a clean HTTP/1.1 request; no decoder failure

HttpVersion.valueOf(String, boolean) ran text.trim() before matching the version, and String.trim() removes every character with code point <= 0x20. The boundary control byte was therefore silently stripped and the surviving "HTTP/1.1" matched the cached constant, so the malformed request decoded as a clean HTTP/1.1 one.

The method token on the same request line already rejects such a byte since #16723 (issue #15047), so the two tokens were inconsistent — this is the same boundary-control-character / request-smuggling class, left open for the version token.

Modification:

  • HttpVersion: drop the trim() in valueOf and in the HttpVersion(String, boolean, boolean) constructor. The existing strict format check (length == 8 && startsWith("HTTP/") && charAt(6) == '.') now rejects a token padded with a control byte, and the non-strict path rejects control/whitespace in the protocol name via hasControlOrWhitespace. Without the trim(), SP/HT padding is rejected too, mirroring the method-token behaviour from Reject control characters at the boundary of HTTP method names #16723.
  • RtspVersions.valueOf: drop the trim() the same way.

HttpRequestDecoder already turns createMessage exceptions into a decoder failure, so the wire effect is decoderResult().isSuccess() == false instead of a phantom HTTP/1.1.

Result:

Before this change "GET / \x00HTTP/1.1\r\n…" decoded successfully (decoderResult().isSuccess() == true, protocolVersion() == HTTP_1_1); after it the decoder reports a failure, matching the method-token behaviour. A clean HTTP/1.1 request still decodes as before.

Test set: io.netty.handler.codec.http.HttpVersionParsingTest
Tests run: 53, Failures: 0, Errors: 0, Skipped: 0
Test set: io.netty.handler.codec.http.HttpRequestDecoderTest
Tests run: 85, Failures: 0, Errors: 0, Skipped: 0
Test set: io.netty.handler.codec.rtsp.RtspDecoderTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
Test set: io.netty.handler.codec.rtsp.RtspEncoderTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

Fixes #16970

Sorry, something went wrong.

Uh oh!

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

All reactions
@HwangRock @bryce-anderson @netty-project-bot
Reject control characters at the boundary of the HTTP version token (#…
a4f973f
…16971)

Motivation:

`HttpRequestDecoder` accepts a request whose HTTP-version token carries
a boundary control byte (`NUL`, `CR`, `LF`, `VT`, `FF`, …):

```bash
printf 'GET / \x00HTTP/1.1\r\nHost: localhost\r\n\r\n' | nc <host> <port>
# decoded as a clean HTTP/1.1 request; no decoder failure
```

`HttpVersion.valueOf(String, boolean)` ran `text.trim()` before matching
the version, and `String.trim()` removes every character with code point
`<= 0x20`. The boundary control byte was therefore silently stripped and
the surviving `"HTTP/1.1"` matched the cached constant, so the malformed
request decoded as a clean `HTTP/1.1` one.

The method token on the same request line already rejects such a byte
since #16723 (issue #15047), so the two tokens were inconsistent — this
is the same boundary-control-character / request-smuggling class, left
open for the version token.

Modification:

- `HttpVersion`: drop the `trim()` in `valueOf` and in the
`HttpVersion(String, boolean, boolean)` constructor. The existing strict
format check (`length == 8 && startsWith("HTTP/") && charAt(6) == '.'`)
now rejects a token padded with a control byte, and the non-strict path
rejects control/whitespace in the protocol name via
`hasControlOrWhitespace`. Without the `trim()`, `SP`/`HT` padding is
rejected too, mirroring the method-token behaviour from #16723.
- `RtspVersions.valueOf`: drop the `trim()` the same way.

`HttpRequestDecoder` already turns `createMessage` exceptions into a
decoder failure, so the wire effect is `decoderResult().isSuccess() ==
false` instead of a phantom `HTTP/1.1`.

Result:

Before this change `"GET / \x00HTTP/1.1\r\n…"` decoded successfully
(`decoderResult().isSuccess() == true`, `protocolVersion() ==
HTTP_1_1`); after it the decoder reports a failure, matching the
method-token behaviour. A clean `HTTP/1.1` request still decodes as
before.

```
Test set: io.netty.handler.codec.http.HttpVersionParsingTest
Tests run: 53, Failures: 0, Errors: 0, Skipped: 0
Test set: io.netty.handler.codec.http.HttpRequestDecoderTest
Tests run: 85, Failures: 0, Errors: 0, Skipped: 0
Test set: io.netty.handler.codec.rtsp.RtspDecoderTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
Test set: io.netty.handler.codec.rtsp.RtspEncoderTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
```

Fixes #16970

---------

Co-authored-by: Bryce Anderson <[email protected]>
(cherry picked from commit 69b7851)
@netty-project-bot netty-project-bot mentioned this pull request Jun 23, 2026
Reject control characters at the boundary of the HTTP version token #16971
Merged
@chrisvest
Fix compilation
ea5439d
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Jun 24, 2026
@normanmaurer
normanmaurer merged commit 87b6af4 into 5.0 Jun 24, 2026
20 of 23 checks passed

Uh oh!

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

@normanmaurer
normanmaurer deleted the auto-port-pr-16971-to-5.0 branch June 24, 2026 10:25
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.

4 participants

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