🔒 Security
Note
For more information on the impact of the fixes in this release and how your deployment might be affected or remediated, see the corresponding GitHub Security Advisories (GHSAs) linked below. Updating to a patched Router version will resolve these vulnerabilities. The @interfaceObject and @requiresScopes/@policy fixes also require recomposing your supergraph (see their entries).
Enforce max_root_fields on root fields selected through fragments (GHSA-f2gm-xj4w-cvcv)
The limits.max_root_fields operation limit now counts root fields selected through inline and named fragments, as documented.
Previously, only root fields selected directly in the operation were counted. Root fields wrapped in an inline fragment (... { a b c }) or a named fragment spread (...RootFields) were ignored, so an operation could select any number of root fields without exceeding the limit. Such operations are now rejected with MAX_ROOT_FIELDS_LIMIT like any other operation over the limit.
Root fields are counted by response name: each alias counts separately, while a field selected more than once under the same name, for example directly and again through a fragment, counts once. The max_depth, max_height, and max_aliases limits are unchanged.
For example, the operation { a ...F } fragment F on Query { a b c } used to report a root_fields count of 1. It now reports 3, because a is counted once.
By @TylerBloom and @inanna-apollo in GHSA-f2gm-xj4w-cvcv
Verify transitive access control on each implementation of an @interfaceObject field (GHSA-fwm7-w7w6-x4wm)
Composition now correctly enforces transitive access control requirements on @interfaceObject fields that use @requires or @fromContext.
Composition checked these fields only against the access control requirements of the interface, which can come from some of its implementations. When an implementation exposed the field with fewer requirements than the data the field depends on, composition still succeeded, which could result in unauthorized access to protected data.
Composition now also checks the field on each implementation and reports MISSING_TRANSITIVE_AUTH_REQUIREMENTS for each implementation that fails, naming the @interfaceObject field and the implementation, such as Field "Node.leaked" (via implementation "PublicUser"). To fix the error, add the required @authenticated, @requiresScopes, or @policy directives to the @interfaceObject field or to the implementation types.
Schemas that composed before may now fail with this error. The check runs only during composition, so recompose your supergraph to get the fix. Upgrading the router alone doesn't fix a supergraph that's already composed.
Composition also no longer rejects some valid schemas whose @requires selection uses a type condition on an interface that the type implements, such as ... on I { x } where I's access control comes from another implementation. Composition now checks the fields that the condition selects on the type itself.
By @dariuszkuc in GHSA-fwm7-w7w6-x4wm
Connector string methods count characters instead of bytes (GHSA-j3fq-jx5v-cfv3)
->slice, ->size, ->get and ->has now count characters rather than bytes on strings, matching ->first and ->last. Results change for non-ASCII strings: "é"->size is now 1 (it was 2). A ->slice whose start is after its end now returns an empty string or array.
By @inanna-apollo, @dariuszkuc and @benjamn in GHSA-j3fq-jx5v-cfv3
Deduplicate subgraph requests after plugin hooks run (GHSA-2f9q-v356-mm6g)
When traffic_shaping query deduplication was enabled, the router decided whether two subgraph requests were the same before Rhai scripts, coprocessors, and native plugins had a chance to modify them. Changes those hooks made to the subgraph request's headers or body weren't considered, so requests that the hooks made different could be treated as identical and share a single subgraph response.
Deduplication now runs after subgraph request hooks, so it compares the request that the subgraph actually receives. Load shedding, rate limiting, and the rest of traffic shaping still run before any plugin hooks.
If you use query deduplication together with Rhai scripts, coprocessors, or native plugins that modify subgraph requests, Apollo encourages you to upgrade.
This changes how deduplicated requests behave for subgraphs that have deduplication enabled:
- Plugin hooks: Subgraph request and response hooks now run for every request instead of once per shared fetch. Coprocessors receive more calls.
- Timeout: Each joined request has its own timeout instead of sharing one.
By @inanna-apollo and @tninesling in GHSA-2f9q-v356-mm6g
Enforce @requiresScopes and @policy requirements that aren't lists of lists of strings (GHSA-273f-mp67-f4rw)
The router and composition now correctly handle @requiresScopes and @policy requirements whose scopes or policies value isn't written as a list of lists of strings.
GraphQL list input coercion lets a single value stand in for a list, so scopes: "a" and scopes: ["a", "b"] are valid values for an argument of type [[Scope!]!]!. Scope and Policy are also custom scalars, so values that aren't strings, such as an unquoted admin, can be valid too. Composition could write such values to the supergraph schema, mishandle them when merging requirements, or skip them when checking transitive access control. The router ignored any value that wasn't a list of lists, and any scope or policy that wasn't a string. Each of these could result in unauthorized access to protected data.
The router now:
- Applies list input coercion when it reads these arguments.
"a"is enforced as[["a"]], and["a", "b"]as[["a"], ["b"]], which requiresaORb. To require both, write[["a", "b"]]. Before, the router ignored values that weren't already nested under two lists, so a requirement with no inner lists was met by every request. - Denies access through any inner list that contains something other than a string, such as
[[admin]],[[1]], or[[["admin"]]], unless another inner list of the requirement is met. Before, the router ignored values that weren't strings, so an inner list with no strings was met by every request.
Composition now:
- Coerces the values of
scopesandpoliciesbefore using them, and reports anIMPLICITLY_COERCED_ACCESS_CONTROL_ARGUMENThint for each value it coerces. - Reports a
NON_STRING_AUTH_REQUIREMENTerror for a scope or policy that isn't a string.
Schemas that composed before may now fail to compose. Composition can fail with that error, and can now report MISSING_TRANSITIVE_AUTH_REQUIREMENTS where it previously missed a requirement.
Upgrading the router alone doesn't fix every supergraph that's already composed. Recompose your supergraph if a scopes or policies value that isn't a list of lists is applied to any of the following:
- A type or field that has the same directive with a different value in another subgraph.
- An object type that implements an interface, or a field of such a type, where another implementation of that interface has the same directive with a different value.
- A field of an
@interfaceObjecttype, where an implementing type has the same field with the same directive and a different value. - A field that another field reads through
@requiresor@fromContext.
Also recompose, after correcting the values, if any scope or policy isn't a quoted string. The router denies access through such values until you do.
See the composition changelog for details.
By @sachindshinde in GHSA-273f-mp67-f4rw
Don't panic when planning @skip/@include inside @defer (GHSA-h49w-hrj5-v553)
Some operations with @skip or @include inside a @defer made query planning panic with "Root nodes should have no remaining nodes unhandled", for example:
query($s: Boolean!) { ...D @defer }
fragment D on Query { ...Q @skip(if: $s) }
fragment Q on Query { t { e { a c } } }This happened when the planner merged two deferred fetches to the same subgraph and the merged fetch depended on fetches both inside and outside the deferred part. These operations now plan normally.
By @dariuszkuc in GHSA-h49w-hrj5-v553
Fix authorization plugin handling of named fragments on union members (GHSA-jgwr-x8v6-6q65)
Updates the auth plugin to correctly enforce access control requirements on union members selected through named fragments.
When a union member was protected by @authenticated, @requiresScopes, or @policy, the auth plugin correctly filtered it when selected through an inline fragment, but not when selected through a named fragment. In that case the original, unfiltered query was planned and executed, which could result in unauthorized access to protected data.
The auth plugin now filters these selections the same way as the equivalent inline fragments. Unauthorized selections are removed from the query, and the response contains an UNAUTHORIZED_FIELD_OR_TYPE error (or the request is rejected when reject_unauthorized is enabled).
By @tninesling and @inanna-malick in GHSA-jgwr-x8v6-6q65