Denial of Service via Variable Coercion Lookup
Description
Hot Chocolate 16 resolves each variable an operation declares by scanning the request's variables object. For an operation that declares many variables, this makes the work of reading the variables grow with the square of the request size. A single request can keep a CPU core busy for tens of seconds, and the work is not interrupted by the execution timeout or by the client disconnecting.
An application is affected when all of the following hold:
- It runs a Hot Chocolate server (
AddGraphQLServer(),AddGraphQL(), orAddGraphQLFunction()with Azure Functions) or a Fusion gateway (AddGraphQLGatewayServer()orAddGraphQLGateway()) on 16.0.0 or later. - It accepts operation documents from clients. This is the default. Applications that only execute persisted operations are not affected.
No other server option is needed. Versions before 16.0.0 are not affected.
Fixed Versions
- 16.7.4
Impact
Any client that can send a query to the endpoint can make the server spend a large amount of CPU on a single request, before cost analysis or the concurrency limit apply. The request is not interrupted by the execution timeout or by the client closing the connection. A few such requests take all CPU of the host and keep it from serving other clients. No data is read or changed and the process stays running. Both a standalone server and a Fusion gateway are affected.
This issue is classified as CWE-407: Inefficient Algorithmic Complexity.
Recommendation
Upgrade to 16.7.4 or later. Reading the variables of an operation then costs time proportional to the request size rather than its square.