Skip to content

Commit af72124

Browse files
Shane32jaydensericmartinbonnin
authored
Add security and compatibility notes (#303)
* Add security and compatibility notes * Update formatting * Update GraphQLOverHTTP.md * Update cspell.yml * Update spec/GraphQLOverHTTP.md Co-authored-by: Jayden Seric <me@jaydenseric.com> * Update spec/GraphQLOverHTTP.md Co-authored-by: Martin Bonnin <martin@mbonnin.net> * format * Update compatibility note * Update spec/GraphQLOverHTTP.md * Update spec/GraphQLOverHTTP.md * Update spec/GraphQLOverHTTP.md Co-authored-by: Martin Bonnin <martin@mbonnin.net> * Reformat --------- Co-authored-by: Jayden Seric <me@jaydenseric.com> Co-authored-by: Martin Bonnin <martin@mbonnin.net>
1 parent f4d3ae4 commit af72124

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

cspell.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ words:
1515
# Software
1616
- ical
1717
- WebDAV
18+
- Protobuf
1819
# Deliberate typos
1920
- qeury
2021
- __typena

spec/GraphQLOverHTTP.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,3 +754,44 @@ payload is `application/json` then the client MUST NOT rely on the body to be a
754754
well-formed _GraphQL response_ since the source of the response may not be the
755755
server but instead some intermediary such as API gateways, proxies, firewalls,
756756
etc.
757+
758+
# Non-normative notes
759+
760+
## Security
761+
762+
In this specification, GET requests are not supported for mutations due to
763+
security concerns. GET requests expose variables to logging mechanisms and
764+
intermediaries due to the URL encoding of parameters, which can lead to
765+
sensitive data being inadvertently logged. Furthermore, GET requests are
766+
considered "simple requests" under CORS (Cross-Origin Resource Sharing), meaning
767+
they bypass preflight checks that add a layer of security.
768+
769+
On the other hand, using `application/json` for request bodies mandates a CORS
770+
preflight request, adding a security layer by ensuring the client has explicit
771+
permission from the server before sending the actual request. This is
772+
particularly important in mitigating cross-site request forgery (CSRF) attacks.
773+
774+
It's important to note that "simple requests" like those using
775+
`application/x-www-form-urlencoded` or `multipart/form-data` do not have the
776+
same CORS behavior, and thus do not undergo the same preflight checks.
777+
Implementers should be aware of the security implications of using these types
778+
of requests. While they can be secured with the right headers enforced by the
779+
server, it is crucial to understand and properly account for the security risks
780+
involved.
781+
782+
To mitigate these risks, it is recommended that servers require a custom header
783+
to ensure requests are not "simple." For instance, a `GraphQL-Require-Preflight`
784+
header can be used to indicate that a preflight check has occurred, providing an
785+
additional layer of security.
786+
787+
For more detailed security considerations, please refer to
788+
[RFC 7231](https://tools.ietf.org/html/rfc7231),
789+
[RFC 6454](https://tools.ietf.org/html/rfc6454), and other relevant RFCs.
790+
791+
## Request format compatibility
792+
793+
Supporting formats not described by this specification, such as XML or Protobuf,
794+
may have potential conflicts with future versions of this specification as
795+
ongoing development aims to standardize and ensure the security and
796+
interoperability of GraphQL over HTTP. For this reason, it is recommended to
797+
adhere to the officially recognized formats outlined here.

0 commit comments

Comments
 (0)