Response Disclosure Between Callers via Request Deduplication
Description
The Fusion gateway can deduplicate identical query requests that are in flight to a source schema at the same time. AddRequestDeduplication() adds a handler to the gateway's HTTP client, and AnnotateOperationKind marks the requests it may deduplicate. The first request is sent, and identical requests that arrive while it is in flight receive a copy of its response. Requests count as identical when their method, URL, body, and the values of the headers listed in HashHeaders, by default Authorization and Cookie, are equal.
In affected versions, AddRequestDeduplication() adds the handler in the order of the calls on the client builder. A header that a handler registered after it sets on the request, such as one forwarded by AddHeaderPropagation() or set by a custom DelegatingHandler, is not yet on the request when the handler compares it. Queries of different callers that differ only in such a header are then sent as one request, and every caller receives the response to the first.
A gateway is affected when it enables request deduplication, which is off by default, and the header that identifies the caller is set by a handler registered after AddRequestDeduplication(), in the same chain or in a later AddHttpClient call for the same client name. Headers set through DefaultRequestHeaders or the onBeforeSend callback of AddHttpClientConfiguration are compared in either order. Other HTTP clients configured with AddRequestDeduplication() from HotChocolate.Transport.Http are affected under the same conditions.
Fixed Versions
- 16.7.4
Applications on 16.6 or earlier 16.x releases should upgrade to 16.7.4.
Impact
While a caller's query is in flight to a source schema, another caller who sends the same query receives the first caller's response, including fields that resolve per caller, such as the current user's profile or cart. When the gateway leaves authentication to the source schemas, this includes callers without credentials. The second caller chooses the query but not whose response it receives.
Under concurrent load, users can receive each other's responses without anyone attempting it.
This issue is classified as CWE-488: Exposure of Data Element to Wrong Session.
Recommendation
Upgrade to 16.7.4. AddRequestDeduplication() then adds the handler behind every handler added with AddHttpMessageHandler, on the named client or through ConfigureHttpClientDefaults, whatever the order of the calls, so the HashHeaders those handlers set are compared.
Upgrading does not cover a header that identifies the caller but is not listed in HashHeaders. Make sure HashHeaders lists every such header, for example a user ID or tenant ID that the gateway derives from the caller's claims:
builder.Services
.AddHttpClient("fusion")
.AddHeaderPropagation()
.AddHttpMessageHandler<ClaimsHeaderHandler>()
.AddRequestDeduplication(options =>
{
options.HashHeaders = ["Authorization", "Cookie", "X-Tenant-Id", "X-User-Id"];
});If an immediate upgrade is not possible, register every handler that sets the caller's headers before AddRequestDeduplication(), as in the example above, or remove request deduplication. A handler pipeline built by hand with new RequestDeduplicationHandler() must place the handler after every handler that sets one of the HashHeaders, in every version.