Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace dset with set-value for @defer and @stream #2257

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/beige-weeks-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'graphiql': patch
---

_security fix:_ replace the vulnerable `dset` dependency with `set-value`

`dset` is vulnerable to prototype pollution attacks. this is only possible if you are doing all of the following:

1. running graphiql with an experimental graphql-js release tag that supports @stream and @defer
2. executing a properly @streamed or @deferred query ala IncrementalDelivery spec, with multipart chunks
3. consuming a malicious schema that contains field names like proto, prototype, or constructor that return malicious data designed to exploit a prototype pollution attack
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"*.{js,ts,jsx,tsx}": [
"eslint --fix",
"prettier --write",
"jest"
"jest --passWithNoTests"
],
"*.{md,html,json,css}": [
"prettier --write"
Expand Down Expand Up @@ -98,6 +98,7 @@
"@types/jest": "^26.0.22",
"@types/node": "^14.14.22",
"@types/prettier": "^2.0.0",
"@types/set-value": "^4.0.1",
"@types/theme-ui": "^0.3.1",
"@types/ws": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^4.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"codemirror": "^5.58.2",
"codemirror-graphql": "^1.2.14",
"copy-to-clipboard": "^3.2.0",
"dset": "^3.1.0",
"set-value": "^4.1.0",
"entities": "^2.0.0",
"escape-html": "^1.0.3",
"graphql-language-service": "^5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { GetDefaultFieldNamesFn, fillLeafs } from '../utility/fillLeafs';
import { getLeft, getTop } from '../utility/elementPosition';
import mergeAST from '../utility/mergeAst';
import { introspectionQueryName } from '../utility/introspectionQueries';
import { dset } from 'dset/merge';
import setValue from 'set-value';

import type {
Fetcher,
Expand Down Expand Up @@ -1567,7 +1567,7 @@ export class GraphiQL extends React.Component<GraphiQLProps, GraphiQLState> {
);
}

dset(payload.data, path, data);
setValue(payload.data, path, data, { merge: true });
} else if (data) {
// If there is no path, we don't know what to do with the payload,
// so we just set it.
Expand Down
22 changes: 20 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6343,6 +6343,11 @@
"@types/mime" "^1"
"@types/node" "*"

"@types/set-value@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/set-value/-/set-value-4.0.1.tgz#7caf185556a67c2d9051080931853047423c93bd"
integrity sha512-mP/CLy6pdrhsDVrz1+Yp5Ly6Tcel2IAEejhyI5NxY6WnBUdWN+AAfGa0HHsdgCdsPWWcd/4D5J2X2TrRYcYRag==

"@types/sinonjs__fake-timers@^6.0.1":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.2.tgz#3a84cf5ec3249439015e14049bd3161419bf9eae"
Expand Down Expand Up @@ -12521,17 +12526,17 @@ grapheme-splitter@^1.0.4:
integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==

"graphiql@file:packages/graphiql":
version "1.7.2"
version "1.8.0"
dependencies:
"@graphiql/toolkit" "^0.4.2"
codemirror "^5.58.2"
codemirror-graphql "^1.2.14"
copy-to-clipboard "^3.2.0"
dset "^3.1.0"
entities "^2.0.0"
escape-html "^1.0.3"
graphql-language-service "^5.0.1"
markdown-it "^12.2.0"
set-value "^4.1.0"

graphql-config@^4.1.0:
version "4.1.0"
Expand Down Expand Up @@ -13760,6 +13765,11 @@ is-primitive@^2.0.0:
resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575"
integrity sha1-IHurkWOEmcB7Kt8kCkGochADRXU=

is-primitive@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-3.0.1.tgz#98c4db1abff185485a657fc2905052b940524d05"
integrity sha512-GljRxhWvlCNRfZyORiH77FwdFwGcMO620o37EOYC0ORWdq+WYNVqW0w2Juzew4M+L81l6/QS3t5gkkihyRqv9w==

is-promise@^2.1.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.2.2.tgz#39ab959ccbf9a774cf079f7b40c7a26f763135f1"
Expand Down Expand Up @@ -19897,6 +19907,14 @@ set-value@^2.0.0, set-value@^2.0.1:
is-plain-object "^2.0.3"
split-string "^3.0.1"

set-value@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/set-value/-/set-value-4.1.0.tgz#aa433662d87081b75ad88a4743bd450f044e7d09"
integrity sha512-zTEg4HL0RwVrqcWs3ztF+x1vkxfm0lP+MQQFPiMJTKVceBwEV0A569Ou8l9IYQG8jOZdMVI1hGsc0tmeD2o/Lw==
dependencies:
is-plain-object "^2.0.4"
is-primitive "^3.0.1"

setimmediate@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
Expand Down