Skip to main content
Menu
Advisories

Unbounded Entity Representations Allow Resource Exhaustion in Apollo Federation Subgraphs

GHSA-G49P-4QHX-Q29MPublished Updated GitHub

Description

AddApolloFederation() adds the _entities(representations: [_Any!]!) field that a federation router uses to fetch entities from a subgraph. The field runs the entity's reference resolver once for each representation in the list.

In affected versions, the number of representations is not limited. In 14.x and later, cost analysis, which AddGraphQLServer() enables by default, charges each _entities selection as a single entity, whatever its list holds, so neither the list's length nor the number of _entities selections that share one list variable through aliases is bounded by the default cost limits. In 13.x, the complexity analyzer is off by default, and where an application enables it, it also prices a selection without regard to its list.

An application is affected when clients can send requests to the subgraph directly, rather than only through the router.

Fixed Versions

  • 16.7.4
  • 15.1.21
  • 14.3.5
  • 13.9.20

Applications on 16.6 or earlier 16.x releases should upgrade to 16.7.4.

Impact

An unauthenticated client that can reach the subgraph can send a single request that runs the reference resolver millions of times, each typically a database lookup or a DataLoader key. In our tests, a 91 KB request ran it 1,000,000 times and a 425 KB request 5,000,000 times, taking almost 30 seconds, both within the default cost limits. Repeated requests can exhaust the server's CPU and memory, and the data store behind the reference resolvers, and degrade or stop the service.

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

Recommendation

Upgrade to a fixed version. A request then resolves at most 10,000 representations, counted across all of its _entities selections and variable sets, and a selection that would exceed the limit returns an error with the code HC0140.

If the router's entity fetches carry more than 10,000 representations in one request, raise the limit:

builder.Services
    .AddGraphQLServer()
    .AddApolloFederation(o => o.MaxAllowedRepresentations = 20_000);

If an immediate upgrade is not possible, make the subgraph reachable only from the router.

Affected versions

References

GitHub · ChilliCream/graphql-platform