Skip to main content
Menu
Advisories

Cache-Control Settings Declared in Only Some Fusion Source Schemas Are Dropped, Making Per-User Responses Shareable

GHSA-FJVC-5WGJ-WR84Published Updated GitHub

Description

With cache control enabled on a Fusion gateway (AddCacheControl() and UseQueryCache()), the gateway writes Cache-Control and Vary from the @cacheControl settings in its execution schema. When several source schemas define the same type, interface, union, or field, composition merges their @cacheControl settings into the execution schema.

In affected versions, composition writes no @cacheControl for such a type, interface, union, or field unless every source schema that defines it declares the directive, and drops a maxAge or sharedMaxAge that any of them leaves out. An entity that its owning source schema declares with scope: PRIVATE and vary: ["Authorization"] loses both once another source schema references it by key, which a Hot Chocolate source schema does without a directive on its type. A response that selects the entity's fields then carries neither private nor Authorization in Vary, and takes its lifetime from the other selected fields. A shared cache in front of the gateway, such as a CDN or a reverse proxy, may store a response that holds one user's data and serve it to other users. Composition reports nothing.

A lifetime is lost the same way: a type that its owning source schema declares with maxAge: 0 no longer limits a response that reaches it through a field of another source schema.

Fixed Versions

  • HotChocolate.Fusion.Composition: 16.7.4
  • ChilliCream.Nitro.CommandLine: 16.7.4

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

Impact

An application is affected only when its gateway enables cache control, a shared cache stores its responses, and a type, interface, union, or field that one source schema declares with scope: PRIVATE, vary, or a lifetime is also defined in a source schema that does not declare it. That is the usual layout for an entity that one source schema owns and others reference or extend by key, and for a @shareable field that only some of its source schemas annotate. A query that selects such a type or field together with a cacheable field is answered with a shareable lifetime. A user who requests the same URL within that lifetime can receive the previous user's response. A field such as me, and the GET routes for persisted operations, give every user of an operation the same URL.

Under RFC 9111, a shared cache does not reuse a response to a request with an Authorization header unless the response carries public, must-revalidate, or s-maxage. Applications that authenticate with cookies or custom headers are exposed, and so are applications that use bearer tokens when a selected field or type sets sharedMaxAge.

This issue is classified as CWE-524: Use of Cache Containing Sensitive Information.

Recommendation

Upgrade the package or tool that composes the gateway's configuration to a fixed version, recompose, and deploy the new Fusion archive. Upgrading the gateway alone changes nothing, except for a gateway that composes at startup with HotChocolate.Fusion.Connectors.InMemory. After recomposing, a type or field keeps scope: PRIVATE and vary from any source schema that declares them, and a type keeps the lowest lifetime any of them declares. A field keeps a lifetime only when every source schema that defines it declares one.

If an immediate upgrade is not possible, declare the same @cacheControl settings for a type or field in every source schema that defines it, for example [CacheControl(30, Scope = CacheControlScope.Private, Vary = ["Authorization"])] on a User type that a source schema only uses as a key, and recompose. A Hot Chocolate source schema needs AddCacheControl() for this. Alternatively, call SkipQueryCaching() from an HTTP request interceptor for authenticated requests, so that their responses carry no Cache-Control header.

Affected versions

References

GitHub · ChilliCream/graphql-platform