-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable graphql-upload integration when it is not used (#6476)
By default, we run the graphql-upload middleware on all requests. This middleware is vulnerable to mutation CSRF attacks because it parses POST requests with `content-type: multipart/form-data`, which can happen in a non-preflighted browser request. (Without graphql-upload, Apollo Server won't process any mutations in non-preflighted requests, because mutations must be in POST requests and normally that requires `content-type: application/json` which must be preflighted.) In order to safely use graphql-upload, you should upgrade to Apollo Server v3.7 and use its new CSRF prevention feature. Because Apollo Server 2 is not under active development we do not intend to backport the full CSRF prevention feature to AS2. However, we at least want to protect the users of Apollo Server 2 who *don't* actually need graphql-upload to be enabled (which is probably most of them). This PR changes the default behavior of Apollo Server 2 when no `uploads` parameter is passed. Instead of always executing the graphql-upload middleware in this case, we only execute it if the `Upload` scalar (which may be added automatically to the schema by AS itself or may be provided by the user) is referenced somewhere in the schema other than its own definition. This should be roughly backwards-compatible; it only breaks the ability to use a `graphql-upload`-based client with Apollo Servers that don't accept uploads. We also print a warning when uploads are enabled encouraging upgrades. Part of GHSA-2p3c-p3qw-69r4
- Loading branch information
Showing
12 changed files
with
175 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v14 | ||
v12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters