Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS01OXI5LTZqcDYtamNtN80W6w

XSS vulnerability in GraphQL Playground from untrusted schemas

GraphQL Playground introspection schema template injection attack: Advisory Statement

This is a security advisory for an XSS vulnerability in graphql-playground.

A similar vulnerability affects graphiql, the package from which graphql-playground was forked. There is a corresponding graphiql advisory.

1. Impact

All versions of graphql-playground-react older than [email protected] are vulnerable to compromised HTTP schema introspection responses or schema prop values with malicious GraphQL type names, exposing a dynamic XSS attack surface that can allow code injection on operation autocomplete.

In order for the attack to take place, the user must load a malicious schema in graphql-playground. There are several ways this can occur, including by specifying the URL to a malicious schema in the endpoint query parameter. If a user clicks on a link to a GraphQL Playground installation that specifies a malicious server, arbitrary JavaScript can run in the user's browser, which can be used to exfiltrate user credentials or other harmful goals.

2. Scope

This advisory describes the impact on the graphql-playground-react package. The vulnerability also affects graphiql, the package from which graphql-playground was forked, with a less severe impact; see the graphiql advisory for details. It affects all versions of graphql-playground-react older than v1.7.28.

This vulnerability was introduced with the first public release of graphql-playground, so it impacts both the original legacy graphql-playground and the contemporary graphql-playground-react npm package. It is most easily exploited on [email protected] and newer, as that release added functionality which made it possible to override the endpoint URL via query parameter even if it is explicitly specified in the code.

graphql-playground-react is commonly loaded via the graphql-playground-html package or a middleware package that wraps it (graphql-playground-express, graphql-playground-middleware-koa, graphql-playground-middleware-hapi, or graphql-playground-middleware-lambda). By default, these packages render an HTML page which loads the latest version of graphql-playground-react through a CDN. If you are using one of these packages to install GraphQL Playground on your domain and you do not explicitly pass the version option to renderPlaygroundPage or the middleware function, then you do not need to take any action to resolve this vulnerability, as the latest version of the React app will automatically be loaded.

graphql-playground-react is also commonly loaded via HTML served by Apollo Server. Apollo Server always pins a specific version of graphql-playground-react, so if you are using Apollo Server you do need to take action to resolve this vulnerability. See the Apollo Server advisory for details.

3. Patches

[email protected] addresses this issue via defense in depth:

If you are using graphql-playground-react directly in your client app, upgrade to version 1.7.28 or later.

If you are using graphql-playground-html or a package which starts with graphql-playground-middleware- in your server and you are passing the version option to a function imported from that package, change that version option to be at least "1.7.28".

If you are using graphql-playground-html or a package which starts with graphql-playground-middleware- in your server and you are NOT passing the version option to a function imported from that package, no action is necessary; your app automatically loads the latest version of graphql-playground-react from CDN.

4. Reproducing the exploit

We are hosting a "malicious" server at https://graphql-xss-schema.netlify.app/graphql . This server has a hard-coded introspection result that includes unsafe HTML in type names.

If you manually change a GraphQL Playground installation to use that endpoint, clear the operation pane, and type {x into the operation pane, an alert will pop up; this demonstrates execution of code provided by the malicious server.

An URL like https://YOUR-PLAYGROUND-SERVER/?endpoint=https%3A%2F%2Fgraphql-xss-schema.netlify.app%2Fgraphql&query=%7B will load already configured with the endpoint in question. (This URL-based exploit works on [email protected] and newer; older versions may be protected from this particular URL-based exploit depending on their configuration.)

5. Credit

This vulnerability was discovered by @Ry0taK, thank you! 🥇

Others who contributed:

6. For more information

If you have any questions or comments about this advisory:

Permalink: https://github.com/advisories/GHSA-59r9-6jp6-jcm7
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS01OXI5LTZqcDYtamNtN80W6w
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: almost 3 years ago
Updated: over 1 year ago


CVSS Score: 7.1
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L

Identifiers: GHSA-59r9-6jp6-jcm7, CVE-2021-41249
References: Repository: https://github.com/graphql/graphql-playground
Blast Radius: 16.2

Affected Packages

npm:graphql-playground-react
Dependent packages: 17
Dependent repositories: 191
Downloads: 23,451 last month
Affected Version Ranges: < 1.7.28
Fixed in: 1.7.28
All affected versions: 1.3.18, 1.3.20, 1.3.21, 1.3.22, 1.3.23, 1.3.24, 1.3.25, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11, 1.5.12, 1.5.13, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.8, 1.7.9, 1.7.10, 1.7.11, 1.7.15, 1.7.17, 1.7.18, 1.7.19, 1.7.20, 1.7.21, 1.7.22, 1.7.23, 1.7.24, 1.7.25, 1.7.26, 1.7.27
All unaffected versions: 1.7.28