Skip to main content
Menu
Advisories

Impact Inconsistent interpretation of HTTP requests (CWE-444, HTTP request smuggling)

GHSA-64W5-89V4-549VPublished Updated GitHub

Description

Impact

Inconsistent interpretation of HTTP requests (CWE-444, HTTP request smuggling). Proposed CVSS 3.1: 5.4 Medium, AV:N/AC:H/PR:N/UI:N/S:C/C:L/I:L/A:N: an unauthenticated client of a gateway reaches the upstream behind it (scope change), but only where the application relays requests with the JDK client to an upstream that prefers Transfer-Encoding (AC:H). Where the upstream relies on access control enforced by the gateway, I:H (7.5 High) is arguable.

The JDK RawHttpClient (RawHttpClient.exchange(request, body, ...)) copies every header of the relayed request into the java.net.http.HttpRequest it sends. The JDK client frames the body itself: for a body of known length it adds its own Content-Length and sends the bytes unchunked. Transfer-Encoding is not one of the headers the JDK client refuses (Connection, Content-Length, Expect, Host, Upgrade), so a Transfer-Encoding: chunked of the relayed request was sent as well. The upstream receives Content-Length and Transfer-Encoding: chunked together; RFC 9112 (section 6.1) gives Transfer-Encoding precedence, so an upstream that follows it parses the body, which the client controls, as chunk framing. A body such as 0\r\n\r\nGET /internal HTTP/1.1\r\n... ends the request after the zero-length chunk, and the rest is read as the next request on that connection; the JDK client pools upstream connections across all users of the gateway.

Reproduced on 5.2.x (5.2.16-SNAPSHOT; the code is unchanged since 5.2.15) with an upstream on a plain socket: (1) a raw exchange of a request carrying Transfer-Encoding: chunked with a body of known length arrives with both Content-Length and Transfer-Encoding, and the upstream reads it as chunked; (2) a route that relays a chunked server request with the raw client, after removing Host, Connection and Content-Length (which the JDK client otherwise rejects), sends the decoded body unchunked under Transfer-Encoding: chunked, and the upstream parses the body bytes as chunk sizes. Headers listed in Connection, and Keep-Alive, TE, Trailer and Proxy-Connection, were forwarded too.

Affected configurations

  • Applications that relay requests (gateways, reverse proxies) with the RawHttpClient of micronaut-http-client-jdk, i.e. with the JDK client instead of the Netty client (micronaut-http-client), passing on the headers of an incoming request.
  • The upstream must accept a request with both Content-Length and Transfer-Encoding and prefer Transfer-Encoding. Upstreams that reject such requests are not affected.
  • The raw client exists since 4.8.0: 4.8.0 to 4.10.30 and 5.0.0 to 5.2.15 are affected. The Netty client is not affected: it replaces the framing headers of the request with the framing it sends.
  • The unreleased 5.3 line adds ProxyHttpClient to the JDK client; it had the same issue and is fixed before release.
  • The regular (non-raw) JDK client does not copy the headers of another request; it still sends a Transfer-Encoding header that the application sets on the request itself.

Patches

Not yet released (patched versions TBD). The raw client no longer sends the framing headers of the relayed request (Transfer-Encoding, Content-Length) nor its hop-by-hop headers (Connection and the headers it lists, Keep-Alive, Proxy-Connection, TE, Trailer, Upgrade); the JDK client frames the body itself. Before, a relayed Connection or Content-Length header failed the exchange with IllegalArgumentException: restricted header name; now these headers are dropped.

Workarounds

  • Remove Transfer-Encoding, Content-Length, Connection and the headers it lists, Keep-Alive, TE, Trailer, Proxy-Connection and Upgrade from the request before passing it to RawHttpClient.exchange.
  • Or relay with the Netty HTTP client (micronaut-http-client).
  • Or configure the upstream to reject requests that carry both Content-Length and Transfer-Encoding, and to close the connection after a framing error.

References

  • RFC 9112, section 6.1 (Transfer-Encoding overrides Content-Length) and section 6.3 (message body length).
  • RFC 9110, section 7.6.1 (Connection; hop-by-hop fields).

Affected versions

References

GitHub · micronaut-projects/micronaut-core