Denial of Service via Field Merging Argument Comparison
Description
Hot Chocolate compares the arguments of two fields that select the same response name as part of checking that they can be merged. For large arguments this comparison grows with the square of the request size, so a single request can keep a CPU core busy for tens of seconds to minutes. The work is not interrupted by the execution timeout or by the client disconnecting.
An application is affected when both of the following hold:
- It runs a Hot Chocolate server (
AddGraphQLServer(),AddGraphQL(), orAddGraphQLFunction()with Azure Functions) or a Fusion gateway (AddGraphQLGatewayServer()orAddGraphQLGateway(), orAddFusionGatewayServer()in 13.x to 15.x). - 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, and the behavior does not depend on the schema. The default configuration is affected. Versions before 13.0.0 are also affected and receive no fix on this advisory; those users should move to 13.9.20 or later.
Fixed Versions
- 16.7.4
- 15.1.21
- 14.3.5
- 13.9.20
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 one of the fixed releases. Comparing the arguments of two fields then costs time proportional to the size of the arguments rather than its square.
Affected versions
- HotChocolate.ValidationFrom 16.0.0 · fixed in 16.7.4
- HotChocolate.ValidationFrom 15.0.0 · fixed in 15.1.21
- HotChocolate.ValidationFrom 14.0.0 · fixed in 14.3.5
- HotChocolate.Validationfixed in 13.9.20
- HotChocolate.Language.SyntaxTreeFrom 16.0.0 · fixed in 16.7.4
- HotChocolate.AspNetCoreFrom 16.0.0 · fixed in 16.7.4
- HotChocolate.AspNetCoreFrom 15.0.0 · fixed in 15.1.21
- HotChocolate.AspNetCoreFrom 14.0.0 · fixed in 14.3.5
- HotChocolate.AspNetCorefixed in 13.9.20
- HotChocolate.Fusion.AspNetCoreFrom 16.0.0 · fixed in 16.7.4
- HotChocolate.FusionFrom 15.0.0 · fixed in 15.1.21
- HotChocolate.FusionFrom 14.0.0 · fixed in 14.3.5
- HotChocolate.Fusionfixed in 13.9.20