Exposure of Other Requests' Data via Multipart Request Parsing
Description
Hot Chocolate 16 reads uninitialized pooled memory when it parses the operations field of some multipart GraphQL requests. Data that earlier requests and responses left in that memory can be returned to the client in an error message, so a client can read parts of other clients' requests and responses.
An application is affected when both of the following hold:
- It serves GraphQL over HTTP with Hot Chocolate 16: an endpoint mapped with
MapGraphQL()orMapGraphQLHttp(), a Fusion gateway (AddGraphQLGatewayServer()orAddGraphQLGateway()), or the Azure Functions integration (AddGraphQLFunction(), in-process or isolated worker). - Multipart requests are enabled.
EnableMultipartRequestsistrueby default, and it does not depend on theUploadscalar or any file upload setup.
The default configuration is affected. EnforceMultipartRequestsPreflightHeader does not prevent it, because a client that is not a browser sends the GraphQL-Preflight header itself.
Fixed Versions
- 16.7.3
Impact
A client can read data that the server left in memory while handling other requests. This includes the operation text and variables of other clients' requests, with any credentials written inline, and from 16.7.0 on also parts of JSON responses sent to other clients, including fields that require authorization. On a Fusion gateway, this applies to the requests and responses the gateway handles.
The attacker needs no credentials, no knowledge of the schema and no valid operation, because the request is rejected before validation and authorization. Each request returns at most a short piece of data, the attacker cannot choose whose data it receives, and whether a request returns data depends on other clients' traffic. Integrity and availability are not affected.
This issue is classified as CWE-908: Use of Uninitialized Resource.
Recommendation
Upgrade to 16.7.3 or later. A malformed operations field in a multipart request is then rejected. Valid requests behave as before, and there are no new options.
If an immediate upgrade is not possible and the application does not accept file uploads, disable multipart requests:
builder.Services
.AddGraphQLServer()
.ModifyServerOptions(o => o.EnableMultipartRequests = false);On a Fusion gateway, call ModifyServerOptions on the builder returned by AddGraphQLGatewayServer() or AddGraphQLGateway(). With Azure Functions, use ModifyFunctionOptions on the builder returned by AddGraphQLFunction(). If an endpoint sets EnableMultipartRequests with WithOptions, set it to false there as well. Applications that accept file uploads have no workaround and must upgrade.