chore(deps): update dependency graphiql to v1.4.7 [security] #533
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
1.4.0->1.4.7GitHub Vulnerability Alerts
CVE-2021-41248
This is a security advisory for an XSS vulnerability in
graphiql.A similar vulnerability affects
graphql-playground, a fork ofgraphiql. There is a correspondinggraphql-playgroundadvisory and Apollo Server advisory.1. Impact
All versions of
graphiqlolder than[email protected]are vulnerable to compromised HTTP schema introspection responses orschemaprop 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 vulnerable schema in
graphiql. There are a number of ways that can occur.By default, the schema URL is not attacker-controllable in
graphiqlor in its suggested implementations or examples, leaving only very complex attack vectors.If a custom implementation of
graphiql'sfetcherallows the schema URL to be set dynamically, such as a URL query parameter like?endpoint=ingraphql-playground, or a database provided value, then this customgraphiqlimplementation is vulnerable to phishing attacks, and thus much more readily available, low or no privelege level xss attacks. The URLs could look like any generic looking graphql schema URL.Because this exposes an XSS attack surface, it would be possible for a threat actor to exfiltrate user credentials, data, etc. using arbitrary malicious scripts, without it being known to the user.
2. Scope
This advisory describes the impact on the
graphiqlpackage. The vulnerability also affects other projects forked fromgraphiqlsuch asgraphql-playgroundand thegraphql-playgroundfork distributed by Apollo Server. The impact is more severe in thegraphql-playgroundimplementations; see thegraphql-playgroundadvisory and Apollo Server advisory for details.This vulnerability does not impact
codemirror-graphql,monaco-graphqlor other dependents, as it exists inonHasCompletion.tsingraphiql. It does impact all forks ofgraphiql, and every released version ofgraphiql.It should be noted that desktop clients such as Altair, Insomnia, Postwoman, do not appear to be impacted by this.
3. Patches
[email protected]addresses this issue via defense in depth.HTML-escaping text that should be treated as text rather than HTML. In most of the app, this happens automatically because React escapes all interpolated text by default. However, one vulnerable component uses the unsafe
innerHTMLAPI and interpolated type names directly into HTML. We now properly escape that type name, which fixes the known vulnerability.Validates the schema upon receiving the introspection response or schema changes. Schemas with names that violate the GraphQL spec will no longer be loaded. (This includes preventing the Doc Explorer from loading.) This change is also sufficient to fix the known vulnerability. You can disable this validation by setting
dangerouslyAssumeSchemaIsValid={true}, which means you are relying only on escaping values to protect you from this attack.Ensuring that user-generated HTML is safe. Schemas can contain Markdown in
descriptionanddeprecationReasonfields, and the web app renders them to HTML using themarkdown-itlibrary. As part of the development of[email protected], we verified that our use ofmarkdown-itprevents the inclusion of arbitrary HTML. We usemarkdown-itwithout settinghtml: true, so we are comfortable relying onmarkdown-it's HTML escaping here. We considered running a second level of sanitization over all rendered Markdown using a library such asdompurifybut believe that is unnecessary asmarkdown-it's sanitization appears to be adequate.[email protected]does update to the latest version ofmarkdown-it(v12, from v10) so that any security fixes in v11 and v12 will take effect.3.1 CDN bundle implementations may be automatically patched
Note that if your implementation is depending on a CDN version of
graphiql, and is pointed to thelatesttag (usually the default for most cdns if no version is specified) then this issue is already mitigated, in case you were vulnerable to it before.4. Workarounds for Older Versions
If you cannot use
[email protected]or laterAlways use a static URL to a trusted server that is serving a trusted GraphQL schema.
If you have a custom implementation that allows using user-provided schema URLs via a query parameter, database value, etc, you must either disable this customization, or only allow trusted URLs.
5. How to Re-create the Exploit
You can see an example on codesandbox. These are both fixed to the last
graphiqlrelease1.4.6which is the last vulnerable release; however it would work with any previous release ofgraphiql.Both of these examples are meant to demonstrate the phishing attack surface, so they are customized to accept a
urlparameter. To demonstrate the phishing attack, add?url=https://graphql-xss-schema.netlify.app/graphqlto the in-codesandbox browser.Erase the contents of the given query and type
{u. You will see an alert window open, showing that attacker-controlled code was executed.Note that when React is in development mode, a validation exception is thrown visibly; however that exception is usually buried in the browser console in a production build of
graphiql. This validation exception comes fromgetDiagnostics, which invokesgraphqlvalidate()which in turn willassertValidSchema(), asapollo-server-coredoes on executing each operation. This validation does not prevent the exploit from being successful.Note that something like the
urlparameter is not required for the attack to happen ifgraphiql'sfetcheris configured in a different way to communicate with a compromised GraphQL server.6. Credit
This vulnerability was discovered by @Ry0taK, thank you! 🥇
Others who contributed:
7. References
The vulnerability has always been present
In the first commit
And later moved to onHasCompletion.js in 2016 (now
.tsafter the typescript migration)8. For more information
If you have any questions or comments about this advisory:
Release Notes
graphql/graphiql (graphiql)
v1.4.7Compare Source
Patch Changes
130ddad6Thanks @acao! - CRITICAL SECURITY PATCH for the GraphiQL introspection schema template injection attackv1.4.6Compare Source
Patch Changes
d3a88283#1934 Thanks @tonyfromundefined! - add react 17, 18 in peerDependenciesafaa36c1#1883 Thanks @Sweetabix1! - Updating font colors for line numbers, comments & brackets from #999 to #666 for accessibility purposes. #666 passes AA accessibility standards for small text, with a contrast ratio of over 5:1.75dbb0b1#1777 Thanks @dwwoelfel! - adopt block string parsing for variables in language parserUpdated dependencies [
0e2c1a02,75dbb0b1]:v1.4.5Compare Source
Patch Changes
86795d5fThanks @acao! - Remove bad type definition fromsubscriptions-transport-ws#1992 closes #1989Updated dependencies [
86795d5f]:v1.4.4Compare Source
Patch Changes
62e786b5#1990 Thanks @acao! - Remove type definition fromsubscriptions-transport-wsUpdated dependencies [
62e786b5]:v1.4.3Compare Source
Patch Changes
6a459f4c#1968 Thanks @acao! - RemoveoptionalDependenciesentirely, removesubscriptions-transport-wswhich introduces vulnerabilities, upgrade@n1ru4l/push-pull-async-iterable-iteratorto 3.0.0, upgradegraphql-wsseveral minor versions - the[email protected]upgrade will come in a later minor release.eb2d91fa#1914 Thanks @harshithpabbati! - fix: history can now be saved even when query history panel is not opened feat: create a new maxHistoryLength prop to allow more than 20 queries in history panel04fad79c#1889 Thanks @henryqdineen! - feat: export ToolbarSelectOption and ToolbarMenuItemcd685435#1923 Thanks @cgarnier! - Fix result window themeUpdated dependencies [
6a459f4c,2fd5bf72]:v1.4.2Patch Changes
5b8a057d#1838 Thanks @acao! - Set all cross-runtime build targets to es6v1.4.1Patch Changes
9f8c78ce#1821 Thanks @harshithpabbati! - fix: render query history panel only when it's toggled, instead of hiding with CSSdd9397e4#1819 Thanks @acao! -GraphiQL.createClient()accepts customlegacyClient, exports typescript types, fixes #1800.createGraphiQLFetchernow only attempts angraphql-wsconnection when onlysubscriptionUrlis provided. In order to usegraphql-transport-ws, you'll need to provide thelegacyClientoption only, and nosubscriptionUrlorwsClientoption.1f92d1dc#1804 Thanks @maraisr! - Fixes issue where with IncrementalDelivery directives objects wouldn't deep-merge.6869ce77#1816 Thanks @acao! - improve peer resolutions for graphql 14 & 15.14.5.0minimum is for built-in typescript types, and another method only available in14.4.0Updated dependencies [
dd9397e4,6869ce77]:Configuration
📅 Schedule: Branch creation - "" in timezone GMT, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled because a matching PR was automerged previously.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.