Skip to main content
Menu
Advisories

Denial of Service via Cost Analysis of Recursive Input Types

GHSA-JV3Q-J8XR-P7Q8Published Updated GitHub

Description

Hot Chocolate 16.7 cost analysis estimates the cost of an input object argument that is bound to a variable from the argument's input type. For input object types that reference each other, such as the filter input types that HotChocolate.Data generates for entities with navigation properties in both directions, this estimate took time that grows exponentially with the number of such types. A single request could keep a CPU core busy for minutes, and a few requests could stop the server from responding to other clients.

An application is affected when all of the following hold:

  • It runs a Hot Chocolate server (AddGraphQLServer(), AddGraphQLFunction() with Azure Functions, or AddGraphQL() with AddCostAnalyzer()) or a Fusion gateway (AddGraphQLGatewayServer() or AddGraphQLGateway()) on 16.7.0 or later, with the cost analyzer enabled. This is the default, and it also applies when EnforceCostLimits is false.
  • Its schema has several input object types that reference each other, for example from filtering (AddFiltering() or [UseFiltering]) over entities that reference each other.
  • It accepts operation documents from clients. This is the default. Applications that only execute persisted operations are affected only if a persisted operation binds such an argument to a variable.

Versions before 16.7.0 are not affected.

Fixed Versions

  • 16.7.5

Impact

Any client that can send a query to the endpoint can make the server spend minutes of CPU on a single request, before the operation executes. The work is not interrupted by the execution timeout or by the client closing the connection. A few such requests occupy all worker threads and keep the server 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.5 or later. The cost of input object types that reference each other is then computed once when the schema is built, so analyzing an operation no longer depends on the shape of the input type graph.

If you cannot upgrade immediately, turn off the cost analyzer by setting SkipAnalyzer to true. This also turns off cost limits and cost reporting, so only use it until you can upgrade. Setting EnforceCostLimits to false does not help, because the analyzer still runs.

For a Hot Chocolate server:

builder.Services
    .AddGraphQLServer()
    .ModifyCostOptions(options => options.SkipAnalyzer = true);

For a Fusion gateway:

builder.Services
    .AddGraphQLGatewayServer()
    .ModifyCostOptions(options => options.SkipAnalyzer = true);

Affected versions

References

GitHub · ChilliCream/graphql-platform