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-Typeand JSON-parses whatever arrives; - it accepts form encodings on the same route (framework converts to the same model);
- its CORS policy reflects
OriginwithAccess-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:
<form action="https://target/api/profile" method="POST" enctype="text/plain">
<input type="hidden" name='{"email":"a@evil.tld","x":"' value='"}'>
</form><script>history.pushState('','','/');document.forms[0].submit()</script>Body: {"email":"a@evil.tld","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;
XMLHttpRequestwithContent-Type: text/plain+withCredentialsfrom a same-site sibling creates an Application that deploys a privileged pod → cluster compromise. Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise - Apache Zeppelin (CVE-2026-44613) — default
zeppelin.server.allowed.origins=*plustext/plainbodies accepted on REST and WebSocket endpoints; fixed in 0.12.1 by empty default allow-list and hard-codedapplication/json. CVE-2026-44613: Turning a CSRF into Silent Unauthorized Actions - Apache Juneau (CVE-2026-73099) —
contentquery param body override; fix 9.2.1 ordisableContentParam=true. Apache Juneau CSRF via the content query parameter (CVE-2026-73099) - Hono
csrf()(GHSA-46wx-v44x-9hh2) —text/pingrequests bypass Origin andSec-Fetch-Siteevaluation. Hono csrf() misses hyperlink auditing text/ping POSTs, Hono csrf() does not check hyperlink auditing (text/ping) requests - Canva — JSON +
Rfcsrfheader normally; urlencoded body accepted without the header. Critical Account Takeover via CSRF Header Bypass - “Eight Doors” ATO — backend ignored declared
Content-Type, so atext/plainbody changed the recovery email without preflight. 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. Account takeover using CSRF JSON based - HackerOne Tray.io integration — CSRF + integration GraphQL API links victims’ GitHub/Jira apps to the attacker’s account. CSRF in HackerOne Tray.io integration
- Facebook / business.instagram.com — CSRF-style GraphQL query endpoint. Facebook GraphQL CSRF – These aren't the access_tokens you're looking for
Defenses
- Reject any
Content-Typeother thanapplication/jsonon 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
Originwith credentials; exact allow-list, no regex over subdomains. - Treat non-form content types (
text/ping, unknown) as untrusted in CSRF middleware; checkOrigin/Sec-Fetch-Siteregardless 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
- CSRF in the Age of JSON · original
- CSRF: Advanced Exploitation Guide - Intigriti · original
- CSRF & Bypasses - Cobalt · original
- CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed · original
- Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise · original
- CVE-2026-44613: Turning a CSRF into Silent Unauthorized Actions · original
- Apache Juneau CSRF via the content query parameter (CVE-2026-73099) · original
- Hono csrf() misses hyperlink auditing text/ping POSTs · original
- Hono csrf() does not check hyperlink auditing (text/ping) requests · original
- Critical Account Takeover via CSRF Header Bypass · original
- Eight Doors, One Key: Chaining Misconfigurations into Full Account Takeover · original
- Account takeover using CSRF JSON based · original
- CSRF in HackerOne Tray.io integration · original
- Facebook GraphQL CSRF – These aren't the access_tokens you're looking for · original
- Confirming GraphQL DAST findings: introspection, batching, depth/cost, CSRF over GET · original
- Cross-site request forgery (CSRF) - Security - MDN Web Docs · original
- Cross-Site Request Forgery Prevention Cheat Sheet - OWASP · original
- 0ang3el/EasyCSRF · original