# JSON CSRF > CSRF against endpoints that expect a JSON body, exploiting the gap between "requires `application/json`" (which would force a CORS preflight) and what the server actually parses: CORS-safelisted content types, lenient body parsers, permissive credentialed CORS, or alternative body channels. ## How it works A cross-site request avoids preflight only if it is "simple": method `GET`/`HEAD`/`POST`, no custom headers, and `Content-Type` in `application/x-www-form-urlencoded`, `multipart/form-data`, `text/plain`. `fetch` with `Content-Type: application/json` or any custom header is preflighted, so a correctly strict JSON API is not reachable cross-site. The bug is the server *not* being strict: - it ignores `Content-Type` and JSON-parses whatever arrives; - it accepts form encodings on the same route (framework converts to the same model); - its CORS policy reflects `Origin` with `Access-Control-Allow-Credentials: true`, so the preflight succeeds; - it accepts the body via another channel (query parameter), or a browser feature sends a non-form content type without preflight. Cookie delivery still has to work: cross-site `POST` needs `SameSite=None` (or a same-site origin, or the Lax+POST window) — see [[SameSite Cookies]]. ## Techniques / payloads **1. `text/plain` form producing a JSON-shaped body.** `enctype="text/plain"` serializes `name=value`; split the JSON so the `=` lands inside a throwaway key: ```html <form action="https://target/api/profile" method="POST" enctype="text/plain"> <input type="hidden" name='{"email":"[email protected]","x":"' value='"}'> </form><script>history.pushState('','','/');document.forms[0].submit()</script> ``` Body: `{"email":"[email protected]","x":"="}`. Works when the parser ignores the declared type or tolerates the extra key. **2. Same route, other encodings.** Re-send as urlencoded / multipart; also try `text/plain; application/json` — some servers match on the trailing token. **3. Credentialed CORS misconfiguration.** Dynamic ACAO reflection + `ACAC: true` lets attacker JS send real `application/json` (and `PUT`/`PATCH`) with cookies. Wildcard `*` with credentials is rejected by browsers, so reflection is the bug. **4. Body via query parameter.** Apache Juneau's REST server replaced the request body with a `content` query parameter on every method including GET (CVE-2026-73099) — a top-level link delivers an arbitrary body without preflight, defeating method/content-type-based protections. **5. Hyperlink auditing (`<a ping>`).** Chromium sends a credentialed cross-origin POST with `Content-Type: text/ping` and no preflight. Middleware that only inspects form content types skips Origin/`Sec-Fetch-Site` checks (Hono `csrf()`). Body is fixed, so only path/query-driven actions are reachable. **6. Method downgrade.** `PUT`/`PATCH`/`DELETE` are preflighted; try `POST` with `_method` or override headers ([[Method Override CSRF]]). **7. Same-origin JS primitives.** With XSS on the target or a same-site sibling, `fetch` with JSON and the app's own CSRF header is trivially same-origin/same-site — this is how stored XSS turned a keyed JSON API into ATO in one Bugcrowd report. Legacy `.swf`-based delivery is historical. **GraphQL.** Mutations accepted over `GET` (`?query=mutation…`) or as `application/x-www-form-urlencoded` POST are plain CSRF; the GraphQL-over-HTTP draft says GET MUST NOT execute mutations. Verify DAST "CSRF over GET" findings by checking whether a mutation actually executes. ## Notable cases - **Argo CD (GHSA-92mw-q256-5vwg)** — entire API CSRF-able; `XMLHttpRequest` with `Content-Type: text/plain` + `withCredentials` from a same-site sibling creates an Application that deploys a privileged pod → cluster compromise. [[raw/hackerone.com/internet-bug-bounty-argo-cd-csrf-leads-to-kubernetes-cluster-compromis-4835|Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise]] - **Apache Zeppelin (CVE-2026-44613)** — default `zeppelin.server.allowed.origins=*` plus `text/plain` bodies accepted on REST and WebSocket endpoints; fixed in 0.12.1 by empty default allow-list and hard-coded `application/json`. [[raw/ox.security/cve-2026-44613-turning-a-csrf-into-silent-unauthorized-actions-11104|CVE-2026-44613: Turning a CSRF into Silent Unauthorized Actions]] - **Apache Juneau (CVE-2026-73099)** — `content` query param body override; fix 9.2.1 or `disableContentParam=true`. [[raw/github.com/apache-juneau-csrf-via-the-content-query-parameter-cve-2026-73099-13593|Apache Juneau CSRF via the content query parameter (CVE-2026-73099)]] - **Hono `csrf()` (GHSA-46wx-v44x-9hh2)** — `text/ping` requests bypass Origin and `Sec-Fetch-Site` evaluation. [[raw/github.com/hono-csrf-misses-hyperlink-auditing-text-ping-posts-13246|Hono csrf() misses hyperlink auditing text/ping POSTs]], [[raw/github.com/hono-csrf-does-not-check-hyperlink-auditing-text-ping-requests-14385|Hono csrf() does not check hyperlink auditing (text/ping) requests]] - **Canva** — JSON + `Rfcsrf` header normally; urlencoded body accepted without the header. [[raw/medium.com/critical-account-takeover-via-csrf-header-bypass-12488|Critical Account Takeover via CSRF Header Bypass]] - **"Eight Doors" ATO** — backend ignored declared `Content-Type`, so a `text/plain` body changed the recovery email without preflight. [[raw/medium.com/eight-doors-one-key-chaining-misconfigurations-into-full-account-takeo-12490|Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover]] - **Bugcrowd private program** — JSON API with `PUT`; exploited via stored XSS-driven XHR to modify admin email/password. [[raw/medium.com/account-takeover-using-csrf-json-based-943|Account takeover using CSRF JSON based]] - **HackerOne Tray.io integration** — CSRF + integration GraphQL API links victims' GitHub/Jira apps to the attacker's account. [[raw/medmahmoudi.com/csrf-in-hackerone-tray-io-integration-12611|CSRF in HackerOne Tray.io integration]] - **Facebook / business.instagram.com** — CSRF-style GraphQL query endpoint. [[raw/philippeharewood.com/facebook-graphql-csrf-these-aren-t-the-access-tokens-you-re-looking-fo-438|Facebook GraphQL CSRF – These aren't the access_tokens you're looking for]] ## Defenses - Reject any `Content-Type` other than `application/json` on JSON routes; disable simple content types where not needed (OWASP "disallowing simple requests"). - Require a custom header (`X-CSRF-Token`, `X-Requested-With`) — forces preflight — and actually enforce it on all encodings. - Never reflect arbitrary `Origin` with credentials; exact allow-list, no regex over subdomains. - Treat non-form content types (`text/ping`, unknown) as untrusted in CSRF middleware; check `Origin`/`Sec-Fetch-Site` regardless of content type. - GraphQL: no mutations over GET; require JSON POST. ## Related - [[Cross-Site Request Forgery]] - [[CSRF Token Bypasses]] - [[Method Override CSRF]] - [[SameSite Cookies]] - [[CSRF Prevention]] - [[GraphQL Security]] - [[Stored XSS]] See also: [[CORS Misconfiguration]] ## Sources - [[raw/directdefense.com/csrf-in-the-age-of-json-4250|CSRF in the Age of JSON]] - [[raw/intigriti.com/csrf-advanced-exploitation-guide-intigriti-4254|CSRF: Advanced Exploitation Guide - Intigriti]] - [[raw/cobalt.io/csrf-bypasses-cobalt-3427|CSRF & Bypasses - Cobalt]] - [[raw/medium.com/csrf-the-bug-everyone-declared-dead-and-nobody-actually-fixed-13022|CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed]] - [[raw/hackerone.com/internet-bug-bounty-argo-cd-csrf-leads-to-kubernetes-cluster-compromis-4835|Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise]] - [[raw/ox.security/cve-2026-44613-turning-a-csrf-into-silent-unauthorized-actions-11104|CVE-2026-44613: Turning a CSRF into Silent Unauthorized Actions]] - [[raw/github.com/apache-juneau-csrf-via-the-content-query-parameter-cve-2026-73099-13593|Apache Juneau CSRF via the content query parameter (CVE-2026-73099)]] - [[raw/github.com/hono-csrf-misses-hyperlink-auditing-text-ping-posts-13246|Hono csrf() misses hyperlink auditing text/ping POSTs]] - [[raw/github.com/hono-csrf-does-not-check-hyperlink-auditing-text-ping-requests-14385|Hono csrf() does not check hyperlink auditing (text/ping) requests]] - [[raw/medium.com/critical-account-takeover-via-csrf-header-bypass-12488|Critical Account Takeover via CSRF Header Bypass]] - [[raw/medium.com/eight-doors-one-key-chaining-misconfigurations-into-full-account-takeo-12490|Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover]] - [[raw/medium.com/account-takeover-using-csrf-json-based-943|Account takeover using CSRF JSON based]] - [[raw/medmahmoudi.com/csrf-in-hackerone-tray-io-integration-12611|CSRF in HackerOne Tray.io integration]] - [[raw/philippeharewood.com/facebook-graphql-csrf-these-aren-t-the-access-tokens-you-re-looking-fo-438|Facebook GraphQL CSRF – These aren't the access_tokens you're looking for]] - [[raw/dedsecops.com/confirming-graphql-dast-findings-introspection-batching-depth-cost-csr-14495|Confirming GraphQL DAST findings: introspection, batching, depth/cost, CSRF over GET]] - [[raw/developer.mozilla.org/cross-site-request-forgery-csrf-security-mdn-web-docs-2991|Cross-site request forgery (CSRF) - Security - MDN Web Docs]] - [[raw/cheatsheetseries.owasp.org/cross-site-request-forgery-prevention-cheat-sheet-owasp-2877|Cross-Site Request Forgery Prevention Cheat Sheet - OWASP]] - [[raw/github.com/0ang3el-easycsrf-958|0ang3el/EasyCSRF]]