Vulnerability GHSA-jmqq-x5g9-9p2w
Summary
AsyncHttpClient: Replay to a different host sends the original host request and credentials to the new host
Details
Impact
When a request is replayed onto a different host, the client updates only the current request and leaves the target request pointing at the original host. Four consumers read that stale value, and each one sends the first host's request, credentials, or both to the second host.
A replay happens through documented, ordinary features: a ResponseFilter that returns a different request, which is the supported failover pattern, and the IOException retry path. The attacker does not need to induce the replay; an application that uses failover produces it by design.
- The socket to host B is filed in the connection pool under host A's key. A later request the application addresses to A is served over the connection to B, and A's
Authorizationheader goes to B. - Over a CONNECT tunnel, the client tunnels to B and negotiates TLS with B correctly, then writes A's request into that tunnel. B receives A's path, A's
Host, and A'sAuthorization. TLS does not protect against this, because the handshake really is with B, so no certificate mismatch occurs. - The replay reuses the original realm, so A's credentials are regenerated onto a replay request that carries no realm of its own. The cross-origin redirect path strips realms for exactly this reason; the replay path never did.
- The stale value also decides whether TLS is used at all. When the original request was
http://and the replay ishttps://, no SSL handler is installed and the replayed request, credentials included, is written in cleartext.
Affected versions
- 3.x: up to and including 3.0.12
- 2.x: up to and including 2.16.0
Both lines are affected identically. This is long-standing behaviour, not a recent regression.
Patches
Fixed in 3.0.13 on the 3.x line and in 2.16.1 on the 2.x line. The target request now moves when a request is replayed, and the proxy moves with it: the proxy is part of the connection pool key, so correcting only the host would convert a harmless pool miss into a hit and route a proxied connection to a direct request.
Workarounds
Do not use a ResponseFilter that replays to a different host, and disable request retries, if the client is configured with credentials or used through a proxy. Replaying to the same host is not affected.
Details
NettyRequestSender.newNettyRequestAndResponseFuture calls setCurrentRequest without setTargetRequest, and replayRequest does not move the target either. The stale target is then read by the pool key derivation in NettyResponseFuture, by ConnectSuccessInterceptor when it writes the tunnelled request, by the realm selection in NettyRequestSender, and by NettyConnectListener when it decides whether to install an SSL handler.
Existing replay tests do not cover this, because all of them replay to the same host.
Related Vulnerabilities
Other vulnerabilities affecting the same packages