Skip to main content
Menu
Advisories

Paged Projections Resolve Skipped Selections, Allowing Resource Exhaustion Within Cost Limits

GHSA-WVPJ-6H6P-PMR3Published Updated GitHub

Description

[UseProjection] turns the selections of a field into a database projection, so that only the requested members are loaded. For a field that also uses [UsePaging] or [UseOffsetPaging], the projection collects the selections below nodes, items, and edges { node } into one additional internal selection.

In affected versions, the executor also resolves that internal selection and discards its result. The internal selection does not carry the @skip and @include conditions of the selections it was built from. As a result, fields below a paged and projected field are resolved twice for each level of paging, and fields below a nodes, items, edges, or node that @skip or @include removes from the response are resolved anyway.

In 16.7.0 and later, cost analysis, which AddGraphQLServer() enables by default, evaluates @skip and @include with the request's variables and prices a skipped selection at zero, so this work is not bounded by the default cost limits. In 16.0.0 to 16.6.9, the work exceeds the priced cost by a factor of two for each level of paging.

An application is affected when it combines [UseProjection] with [UsePaging] or [UseOffsetPaging], including through HotChocolate.Data.MongoDb.

Fixed Versions

  • 16.7.8

Applications on earlier 16.x releases should upgrade to 16.7.8.

Impact

An unauthenticated client can send a single request whose resolvers run without being priced. In our tests, a 35 KB request was accepted at a field cost of 10 and ran a resolver 100,000 times, and a 414-byte request ran a resolver 1,000,000 times and allocated 1.9 GB, both within the default cost limits. Each resolver call is typically a database or service request. Repeated requests can exhaust the server's CPU and memory, and the data stores behind its resolvers, and degrade or stop the service.

The results of these resolver calls are never written to the response, so no data is disclosed.

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

Recommendation

Upgrade to a fixed version.

If an immediate upgrade is not possible, remove [UseProjection] from paged fields. Accepting only persisted operations limits the extra work to what the application's own documents select.

Affected versions

References

GitHub · ChilliCream/graphql-platform