GraphQL CSRF
Cross-site request forgery against a cookie-authenticated GraphQL endpoint that will execute operations from browser “simple requests” — GET,
application/x-www-form-urlencodedortext/plainPOST — or from cross-origin channels it fails to origin-check.
How it works
A JSON POST with Content-Type: application/json triggers a CORS preflight, so it cannot be forged cross-site as long as the server actually enforces the content type. The bug appears when the server is lenient about transport:
- GET execution —
GET /graphql?query=mutation{...}. A top-level navigation carriesSameSite=Laxcookies: in one lab a link onevil.testto a GETupdateEmailmutation executed with Alice’s Lax session in Chromium. - Form-encoded / text POST — an auto-submitting HTML form sending
query,operationNameandvariablesas fields; no preflight, cookies attached unlessSameSiteblocks them. - Non-HTTP entry points —
postMessagebridges and local dev servers without origin checks.
The GraphQL-over-HTTP draft is explicit: GET MUST NOT execute mutations (respond 4xx), and alternative media types risk “simple request” treatment and CSRF.
Detecting it
BatchQL-style probe — send a trivial query both ways and see whether it is parsed:
GET /graphql?query=query+%7B+a+%7D
POST /graphql Content-Type: application/x-www-form-urlencoded query=query+%7B+a+%7DA response like Cannot query field "a" on type "Query" means the transport is accepted. That is an indicator, not a finding: prove impact with a state-changing mutation on your own test account, check cookie SameSite attributes, and confirm the endpoint authenticates by cookie rather than a bearer header.
Notable cases
- GitLab CVE-2026-19650 (CVSS 7.1, CWE-352) — improper request validation in GraphQL multiplex query handling allowed mutations via GET; patched with CVE-2026-19478 in 18.11.11 / 19.0.8 / 19.1.6 / 19.2.4.
- Apollo Studio Embeddable Explorer & Sandbox CVE-2025-59845 — no origin validation on
window.postMessageevents, so a hostile page could drive the embedded explorer to run arbitrary operations against the victim’s GraphQL server; fixed Sandbox 2.7.2, Explorer 3.7.3. - Cypress Launchpad (GHSA-pgrh-36vg-cqj7) —
cypress openran a GraphQL server bound to all interfaces with no origin check; a network peer or a website hitting loopback could set the “preferred editor” to an arbitrary command line → code execution as the developer (Cypress ≥10.0.0; recent Chrome/Edge/Firefox now block or prompt for such loopback requests). - Facebook / business.instagram.com — CSRF-style GraphQL call against the “assigned roles and emails” feature.
- HackerOne Tray.io integration — CSRF linked victims’ third-party apps (GitHub, Jira) to the attacker’s account, then the integration’s GraphQL API reached private repositories.
- Indeed-style
changeEmailform PoC illustrates the form-encoded variant.
Defenses
- Accept operations only as JSON-encoded POST and validate that the body matches the declared content type.
- Reject mutations over GET with 4xx (and consider rejecting GET entirely where persisted GET queries aren’t needed).
- CSRF tokens or a required custom header for cookie-authenticated APIs;
SameSite=Lax/Strictas defense in depth — Lax does not cover GET mutations. - Validate
postMessageorigins in embedded IDEs; bind dev-tool GraphQL servers to loopback and checkOrigin.
Related
Sources
- GraphQL API Vulnerabilities · original
- Exploiting GraphQL · original
- Exploiting CSRF in GraphQL Applications · original
- Confirming GraphQL DAST findings: introspection, batching, depth/cost, CSRF over GET · original
- Critical and High-Severity GraphQL CVEs in GitLab: Code Injection and CSRF via One Directive · original
- GitLab Patches Critical Unauthenticated GraphQL Vulnerability · original
- Critical GitLab flaw allows attackers to modify or delete public projects · original
- CVE-2025-59845: CSRF Vulnerability in Apollo Studio Embeddable Explorer and Sandbox · original
- Cypress Launchpad GraphQL server exposed to cross-site requests allows command execution · original
- Facebook GraphQL CSRF – These aren't the access_tokens you're looking for · original
- CSRF in HackerOne Tray.io integration · original
- BatchQL: GraphQL Security Auditing for Batch Attacks · original
- GraphQL · original