Skip to main content
Menu
Advisories

Unenforced Variable Batching Limits Allow Resource Exhaustion

GHSA-JFR5-6969-5Q72Published Updated GitHub

Description

Hot Chocolate limits variable batching, where a request's variables is a list of variable sets and the operation runs once per set, with GraphQLServerOptions.Batching and GraphQLServerOptions.MaxBatchSize (1,024 sets by default). In affected versions, only some request paths apply these limits. The following paths process every variable set regardless of them:

  • A request sent over WebSocket, with the graphql-transport-ws or the graphql-ws protocol. Any application that calls UseWebSockets() and maps the WebSocket endpoint, which MapGraphQL() does, is affected in its default configuration.
  • Each entry of a POST request batch, and each operation of an operation batch (batchOperations), whose number of operation names is not limited either. These need AllowedBatching.RequestBatching, which is off by default but always on for a schema configured as a Fusion source schema with AddSourceSchemaDefaults().
  • In releases before 16.7.2, a request sent with GET or to the persisted operation routes.

The Fusion gateway is affected in the same way, and forwards the variable sets it accepts to its source schemas.

Releases 14.x and 15.x have no batching limits. A request whose variables is a list runs once for every set, on every transport, POST included, and cost analysis prices a single set, so the batch can cost as many times the cost limit as it has sets. The Fusion gateway on these releases coerces every set but executes only the first.

Fixed Versions

  • 16.7.4
  • 15.1.21
  • 14.3.5

Applications on 16.6 or earlier should upgrade to 16.7.4.

Impact

An unauthenticated client can send a single WebSocket message, within the default message size limit, that carries tens of thousands of variable sets. The server processes every set, which can take more than a gigabyte of memory and several seconds of CPU time for one message. Repeated messages can exhaust the server's memory or CPU and degrade or stop the service. Setting Batching to AllowedBatching.None or lowering MaxBatchSize does not protect this path.

Over WebSocket the client receives no results for a variable batch, but a batch that passes cost analysis still executes every set, mutations included.

Where request batching is enabled, each entry of a request batch and each operation of an operation batch can carry more variable sets than MaxBatchSize, or use variable batching while it is disabled, and an operation batch can name more operations than MaxBatchSize.

On 14.x and 15.x, the same applies to a single request over any transport, in the default configuration, and each set can run an operation up to the cost limit.

This issue is classified as CWE-770: Allocation of Resources Without Limits or Throttling.

Recommendation

Upgrade to 16.7.4. A request whose variables is a list is then refused over WebSocket with an error message for the operation, and the entries of request and operation batches are held to Batching and MaxBatchSize.

If an immediate upgrade is not possible, disable the Hot Chocolate WebSocket transport unless the application needs it. For applications using the combined GraphQL endpoint, replace MapGraphQL() with the HTTP-only endpoint:

app.MapGraphQLHttp();

If the WebSocket endpoint is mapped explicitly, remove the MapGraphQLWebSocket() registration.

Leave AllowedBatching.RequestBatching off unless clients need it, and make sure only the Fusion gateway can reach a source schema.

Releases before 16.7.2 also process variable batches sent with GET or to the persisted operation routes without the limits, so upgrading is the only complete mitigation there.

On 14.x and 15.x, upgrade to 15.1.21 or 14.3.5. A request whose variables is a list is then refused over WebSocket, and over HTTP it may carry at most MaxBatchSize variable sets, 1,024 by default. Disabling the WebSocket transport as above protects only that path, so upgrading is the only complete mitigation on those lines.

Affected versions

References

GitHub · ChilliCream/graphql-platform