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 — HttpRequestDecoder silently accepts control characters in the HTTP version token · Issue #16970 · netty/netty

HttpRequestDecoder silently accepts control characters in the HTTP version token #16970

New issue
Copy link
New issue
Copy link
Closed
#16971
Closed
HttpRequestDecoder silently accepts control characters in the HTTP version token#16970
#16971
Copy link

Description

@HwangRock
HwangRock
opened on Jun 17, 2026
Issue body actions

Expected behavior

A request line whose HTTP-version token carries a boundary control byte (NUL, CR, LF, VT, FF, …) should be rejected, the same way the method token is rejected since #16723. The decoded HttpRequest should have decoderResult().isSuccess() == false.

Actual behavior

HttpVersion.valueOf(String, boolean) calls text.trim() before matching the version. String.trim() removes every character with code point <= 0x20, so a leading control byte on the version token is silently stripped and the request is decoded as a clean HTTP/1.1 request (decoderResult().isSuccess() == true, protocolVersion() == HttpVersion.HTTP_1_1).

This is the same boundary-control-character / request-smuggling class that #16723 (issue #15047) closed for the method token. The method token now rejects the byte:

java.lang.IllegalArgumentException: Illegal character in HTTP Method: 0x0

but the version token on the same request line is still normalized away.

Steps to reproduce

Send a request whose version token is prefixed with a NUL byte to any Netty HTTP server (HttpServerCodec / HttpRequestDecoder in the pipeline):

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

Minimal yet complete reproducer code (or URL to code)

// BUG: control byte in the version token is silently trimmed
EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder());
ch.writeInbound(Unpooled.copiedBuffer(
        "GET /  HTTP/1.1\r\nHost: localhost\r\n\r\n", StandardCharsets.US_ASCII));
HttpRequest req = ch.readInbound();
// current behavior — both pass, i.e. the malformed request is accepted:
assertTrue(req.decoderResult().isSuccess());
assertEquals(HttpVersion.HTTP_1_1, req.protocolVersion());

// For contrast, the same NUL on the method token is rejected since #16723:
EmbeddedChannel ch2 = new EmbeddedChannel(new HttpRequestDecoder());
ch2.writeInbound(Unpooled.copiedBuffer(
        " GET / HTTP/1.1\r\nHost: localhost\r\n\r\n", StandardCharsets.US_ASCII));
HttpRequest req2 = ch2.readInbound();
assertTrue(req2.decoderResult().isFailure()); // IllegalArgumentException: Illegal character in HTTP Method: 0x0

Root cause is text = text.trim() in HttpVersion.valueOf (codec-http/src/main/java/io/netty/handler/codec/http/HttpVersion.java); strict=true (the mode the request decoder uses via createMessage) trims before validating, so the boundary control byte never reaches the format check. The same applies to RtspVersions.valueOf.

Netty version

4.2.15.Final, 4.1.135.Final, and current 4.2 / main branch HEAD.

JVM version (e.g. java -version)

openjdk version "21.0.5" (not JVM-specific).

OS version (e.g. uname -a)

Linux x86_64 (not OS-specific).


I'd be happy to open a PR mirroring the #16723 approach for the version token (and RtspVersions) if that sounds reasonable to you.

Activity

  1. chrisvest
    closed this as completedin #16971on Jun 23, 2026
  2. chrisvest
    added a commit that references this issue on Jun 23, 2026

    Reject control characters at the boundary of the HTTP version token (#…

    This issue will close once commit 69b7851 is merged into the '4.2' branch.
    69b7851
  3. He-Pin
    added 2 commits that reference this issue on Jun 24, 2026

    test: add directional test for NUL byte in request target

    d1d9b66

    test: add directional test for NUL byte in request target (#1088)

    6a96015
  4. normanmaurer
    added 2 commits that reference this issue on Jun 24, 2026

    Auto-port 5.0: Reject control characters at the boundary of the HTTP …

    This issue will close once commit 87b6af4 is merged into the '4.2' branch.
    87b6af4

    Reject control characters at the boundary of the HTTP version token (#…

    This issue will close once commit df54c37 is merged into the '4.2' branch.
    df54c37
  5. pjfanning
    added 2 commits that reference this issue on Oct 13, 2026

    test: cover control characters around the request-line version token

    1d9f68b

    fix: reject control bytes in the request line and malformed HTTP/2 :s…

    265a6ce
  6. lltopk
    added a commit that references this issue on Oct 24, 2026

    Reject control characters at the boundary of the HTTP version token (n…

    This issue will close once commit 9d54b1a is merged into the '4.2' branch.
    9d54b1a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.