GitHub advisory · Maven
Netty: Start-Line Injection in DefaultHttpRequest.setUri() Allows HTTP Request Smuggling and RTSP Request Injection
Description
Netty allows request-line validation to be bypassed when a DefaultHttpRequest or DefaultFullHttpRequest is created first and its URI is later changed via setUri().
The constructors reject CRLF and whitespace characters that would break the start-line, but setUri() does not apply the same validation. HttpRequestEncoder and RtspEncoder then write the URI into the request line verbatim. If attacker-controlled input reaches setUri(), this enables CRLF injection and insertion of additional HTTP or RTSP requests.
In practice, this leads to HTTP request smuggling / desynchronization on the HTTP side and request injection on the RTSP side.
The root issue is that URI validation exists only on the constructor path, but not on the public setter path.
io.netty.handler.codec.http.DefaultHttpRequest
HttpUtil.validateRequestLineTokens(method, uri)setUri(String uri) only performs checkNotNull and does not validateio.netty.handler.codec.http.DefaultFullHttpRequest
setUri(String uri) delegates to the parent implementationio.netty.handler.codec.http.HttpRequestEncoder
request.uri() directly into the request lineio.netty.handler.codec.rtsp.RtspEncoder
request.uri() directly into the request lineThis creates the following bypass:
DefaultHttpRequest or DefaultFullHttpRequest with a safe URIsetUri()HttpRequestEncoder or RtspEncoder encodes that value verbatimThis appears to be an incomplete fix pattern where start-line validation exists, but can still be bypassed through a mutable public API.
The following code first creates a normal request object and then injects a malicious request line using setUri().
import…
Manual fix · Maven
Sources