Cross-Request Result Injection and Data Exposure via the nodes and _entities Fields
Description
The nodes field added by AddGlobalObjectIdentification() and the _entities field added by AddApolloFederation() can complete while node or reference resolvers they started are still running, for example when the request is cancelled or the field fails. Those resolvers then continue on resolver state that other requests reuse.
Through nodes, fields in other requests, including mutations, can return an object that a node resolver loaded for a different request instead of running their own resolver. Through _entities, a reference resolver that uses its IResolverContext after an await can act on another request.
An application is affected through the nodes field when all of the following hold:
- It uses global object identification with
AddGlobalObjectIdentification()and exposes thenodesfield. This is the default. In 16.x the field can be removed withAddNodesField = false. - At least one node resolver completes asynchronously, for example by awaiting a database query, an HTTP call, or a DataLoader.
- Clients can send a
nodesquery with IDs of their choice. This is the default. Applications that only execute persisted operations are affected only if a persisted operation selectsnodeswith the IDs passed as a variable.
An application is affected through the _entities field when all of the following hold:
- It is an Apollo Federation subgraph built with
AddApolloFederation(). - A reference resolver uses its
IResolverContextafter its firstawait, for example by callingReportErroror by reading services or state from the context. - Clients can send
_entitiesrequests directly to the subgraph, or_entitiesrequests are cancelled while reference resolvers are still running, for example when the router cancels a subgraph request.
Fixed Versions
- 16.7.3
- 15.1.20
- 14.3.4
- 13.9.19
Impact
A client that can query nodes, including an unauthenticated one, can make fields in other users' requests, including mutations, return an object it may load instead of running their resolver. It cannot choose which requests are affected and does not receive other users' data this way.
When a user's own nodes request fails or is cancelled, an object loaded for that user can be returned to another request, including an anonymous one. Authorization on the node type does not prevent this; authorization on the object's fields still applies. This depends on other users' traffic.
On an Apollo Federation subgraph, the effect depends on what a reference resolver does with its context after an await, for example reporting an error into another client's response.
This issue is classified as CWE-672: Operation on a Resource after Expiration or Release.
Recommendation
Upgrade to one of the fixed releases. A nodes or _entities field that fails or whose request is cancelled then completes only after all node and reference resolvers it started have finished. Errors and responses are otherwise unchanged. Node and reference resolvers that observe the request's cancellation token finish sooner on cancellation.
Application code that calls IResolverContext.Clone() and starts work on the copy must wait for that work before its resolver completes. The fix does not change such code.
There is no workaround. Applications must upgrade.
Affected versions
- HotChocolate.TypesFrom 16.0.0 · fixed in 16.7.3
- HotChocolate.TypesFrom 15.0.0 · fixed in 15.1.20
- HotChocolate.TypesFrom 14.0.0 · fixed in 14.3.4
- HotChocolate.TypesFrom 13.0.0 · fixed in 13.9.19
- HotChocolate.ApolloFederationFrom 16.0.0 · fixed in 16.7.3
- HotChocolate.ApolloFederationFrom 15.0.0 · fixed in 15.1.20
- HotChocolate.ApolloFederationFrom 14.0.0 · fixed in 14.3.4
- HotChocolate.ApolloFederationFrom 13.0.0 · fixed in 13.9.19
- HotChocolate.AspNetCoreFrom 16.0.0 · fixed in 16.7.3
- HotChocolate.AspNetCoreFrom 15.0.0 · fixed in 15.1.20
- HotChocolate.AspNetCoreFrom 14.0.0 · fixed in 14.3.4
- HotChocolate.AspNetCoreFrom 13.0.0 · fixed in 13.9.19