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 — Netty RtspDecoder Method-Token Smuggling via Trailing Control Byte

Netty RtspDecoder Method-Token Smuggling via Trailing Control Byte

Moderate
chrisvest published GHSA-h75q-xqrh-59rf Sep 10, 2026

Package

io.netty:netty-codec-http (Maven)

Affected versions

>=4.2.0.Final, <=4.2.17.Final
<=4.1.137.Final

Patched versions

4.2.18.Final
4.1.138.Final

Description

Summary

RtspMethods.valueOf() silently strips trailing control bytes (any character with code point <= 0x20, the full range that String.trim() removes) before performing a cache lookup against its ten pre-populated method constants. A wire-delivered RTSP request whose method token ends with a trailing control byte — for example PLAY\x00 or PLAY\r, immediately before the separating space — is decoded by RtspDecoder as a fully successful PLAY request, with decoderResult().isSuccess() == true and request.method() == RtspMethods.PLAY (same object reference as the cached singleton). The application layer cannot distinguish this from a clean
PLAY request.

This is the same root cause as #16723 and #16971, in a sibling that those fixes did not reach. The fix for HttpMethod hardened HttpMethod.valueOf() directly, but RtspMethods.valueOf() has its own independent checkNonEmptyAfterTrim() call that runs before the cache lookup — meaning a trailing-control-byte token hits the cache before the hardened HttpMethod constructor ever sees it.

Reproduction

Minimal wire-level reproduction

Send the following raw bytes to any Netty-based RTSP server using RtspDecoder:

PLAY\x00 rtsp://target/stream RTSP/1.0\r\n
CSeq: 1\r\n
\r\n

The \x00 is a literal NUL byte (0x00) immediately before the space that separates the method from the URI. \r (0x0D) produces the same outcome.

Expected (correct) behavior: decode failure, decoderResult().isSuccess() == false.
Actual behavior: successful decode, request.method() returns the RtspMethods.PLAY singleton.

Confirmed via EmbeddedChannel test

byte[] data = ("PLAY\u0000 rtsp://172.20.184.218:554/stream RTSP/1.0\r\n"
              + "CSeq: 1\r\n\r\n")
              .getBytes(StandardCharsets.ISO_8859_1);

EmbeddedChannel ch = new EmbeddedChannel(new RtspDecoder());
ch.writeInbound(Unpooled.wrappedBuffer(data));

HttpObject res = ch.readInbound();
// res instanceof HttpRequest        → true
// request.decoderResult().isSuccess() → TRUE  (should be false)
// request.method() == RtspMethods.PLAY → TRUE  (same reference — cache hit)

Run against netty/netty branch 4.2 at HEAD 775ad71:

DEBUG decoderResult = success
DEBUG method = PLAY
DEBUG method == RtspMethods.PLAY (same ref)? true

Root cause

The vulnerable path in RtspMethods.valueOf() (line 127, RtspMethods.java):

public static HttpMethod valueOf(String name) {
    name = checkNonEmptyAfterTrim(name, "name").toUpperCase(Locale.US);
    HttpMethod result = methodMap.get(name);
    if (result != null) {
        return result;   // <-- cache hit; hardened HttpMethod constructor never runs
    } else {
        return HttpMethod.valueOf(name);  // hardened path — too late for cached names
    }
}

ObjectUtil.checkNonEmptyAfterTrim() is defined as:

public static String checkNonEmptyAfterTrim(final String value, final String name) {
    String trimmed = checkNotNull(value, name).trim();
    return checkNonEmpty(trimmed, name);
}

String.trim() strips every character with code point <= 0x20 from both the leading and trailing ends. A token of "PLAY\u0000" (5 chars) becomes "PLAY" (4 chars), matches the cache key, and returns RtspMethods.PLAY without ever reaching HttpMethod's constructor, which was hardened in #16723 to reject exactly this class of byte.

Why splitInitialLine does not filter this

The base decoder's splitInitialLine tokenises the request line on space-class separators
(SP, HT, VT, FF, CR). NUL (0x00) is not in the separator table (SP_LENIENT_BYTES). A token of "PLAY\u0000" is therefore extracted as a 5-character string with the NUL fully intact, and handed verbatim to RtspDecoder.createMessage() →
RtspMethods.valueOf(). The NUL is only stripped by trim() inside checkNonEmptyAfterTrim, at which point the cache lookup has already been set up to succeed.

All ten cached RTSP method names are affected by the trailing-edge placement: DESCRIBE, ANNOUNCE, SETUP, PLAY, PAUSE, TEARDOWN, GET_PARAMETER, SET_PARAMETER, REDIRECT, RECORD.

Impact

Direct: method-based access control bypass

Any Netty-based RTSP server or proxy that makes authorization or routing decisions based on request.method() is vulnerable to having those decisions bypassed. An attacker sends SETUP\x00 or PLAY\x00 where the application's ACL layer would have rejected a clean SETUP or PLAY, but RtspDecoder delivers a successfully-decoded request carrying the trusted cached singleton.

Proxy laundering

When a Netty-based RTSP proxy receives PLAY\x00 ... and re-encodes it for forwarding, RtspEncoder calls request.method().asciiName() — which returns the clean ASCII name from the cached singleton. The backend server receives a completely clean PLAY with no trace of the original NUL. Upstream WAFs or logging infrastructure that saw the raw PLAY\x00 may flag or log it, but anything downstream of the Netty decoder sees a legitimate request and cannot reconstruct that the original token was malformed.

Not affected

HttpServerCodec / HttpRequestDecoder (Spring WebFlux and all HTTP/1.1 Netty servers):
createMessage calls HttpMethod.valueOf() directly, not through RtspMethods. Not
in scope.

HTTP/2 and HTTP/3 pipelines: independent header validation, not affected.
RtspVersions.valueOf(): correctly fixed in #16971, no trim() call present.

Keep-alive connections / pipelined requests: the SKIP_INITIAL_LINE_CHARS guard re-enters via resetNow() between messages and applies identically to every request on a keep-alive connection — confirmed by test feeding a clean first message followed by a
leading-NUL second message on the same EmbeddedChannel.

the second message is rejected
by the same InvalidLineSeparatorException path as a first-message leading-NUL. The
trailing-NUL exploit shape works on any message in the connection, not just the first.

Proposed fix

Mirror the approach used in HttpMethod's constructor (HttpMethod.checkMethodName()), which
validates the token against the RFC 7230 token character set (ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "" / "|" / "~") before accepting it. Apply that same validation in RtspMethods.valueOf()before the cache lookup, so a token containing any character outside that set is rejected outright rather than normalized into a cache hit bytrim(). The simplest structural fix is to remove the checkNonEmptyAfterTrimcall entirely and delegate toHttpMethod.valueOf(name) first — which already performs this validation and will throwIllegalArgumentExceptionon any invalid token — then perform the cache lookup only on the validated, uppercased result. This ensures no input can reach the cache that the hardenedHttpMethod constructor would have rejected.

Test suite (already passing/failing against current 4.2 HEAD)

Four unit-level tests in RtspMethodsTest.java and one wire-level test in RtspDecoderTest.java cover this finding. All five tests currently fail in the direction indicating the bug is present. After the fix is applied, all five should pass.

Unit level (RtspMethodsTest.java) — isolates RtspMethods.valueOf() directly:

@Test
void valueOfRejectsNulPaddedCachedMethodName() {
    assertThrows(IllegalArgumentException.class, () -> RtspMethods.valueOf("\u0000PLAY"));
}

@Test
void valueOfRejectsNulPaddedCachedMethodNameTrailing() {
    assertThrows(IllegalArgumentException.class, () -> RtspMethods.valueOf("SETUP\u0000"));
}

@Test
void valueOfRejectsCarriageReturnPaddedCachedMethodName() {
    assertThrows(IllegalArgumentException.class, () -> RtspMethods.valueOf("\rTEARDOWN"));
}

@Test
void valueOfDoesNotReturnCachedConstantForControlBytePaddedName() {
    try {
        HttpMethod result = RtspMethods.valueOf("\u0000PLAY");
        assertNotSame(RtspMethods.PLAY, result);
    } catch (IllegalArgumentException expected) {
        // Correct outcome.
    }
}

Wire level (RtspDecoderTest.java) — proves end-to-end exploitability:

@Test
public void testRejectsTrailingNulInMethodName() {
    byte[] data = ("PLAY\u0000 rtsp://172.20.184.218:554/stream RTSP/1.0\r\n"
                  + "CSeq: 1\r\n\r\n")
                  .getBytes(StandardCharsets.ISO_8859_1);
    EmbeddedChannel ch = new EmbeddedChannel(new RtspDecoder());
    ch.writeInbound(Unpooled.wrappedBuffer(data));
    HttpObject res = ch.readInbound();
    assertTrue(res instanceof HttpRequest);
    assertFalse(((HttpRequest) res).decoderResult().isSuccess());
    ch.finishAndReleaseAll();
}

Discovery context

Found by pattern-mining recent fix commits on the 4.2 branch: #16723 and #16971 both fixed the same checkNonEmptyAfterTrim-based control-byte stripping in HttpMethod and HttpVersion/RtspVersions respectively. Grepping for remaining callers of checkNonEmptyAfterTrim in protocol-parsing code identified RtspMethods.valueOf() as a sibling that those fixes did not reach. Wire-exploitability was then verified through iterative EmbeddedChannel testing against the real decoder before this report was filed.

I am happy to provide the full patch file, the complete test suite, or additional technical detail on request. I have not disclosed this finding publicly and will follow your 90-day coordinated disclosure timeline.

Severity

Moderate
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality Low
Integrity Low
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

CVE ID

CVE-2026-93565

Weaknesses

Weakness CWE-20

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.
Weakness CWE-180

Incorrect Behavior Order: Validate Before Canonicalize

The product validates input before it is canonicalized. Learn more on MITRE.

Credits

  • @husseinvr97 husseinvr97 Reporter
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.