Claude skill CSRF via JSON body with text/plain content type, SameSite=Lax subdomain bypass and localStorage CSRF token in MCP skills — SA-SKL-CSRF4
Cross-Site Request Forgery in MCP skill endpoints persists through several subtle failure modes that survive even when developers believe they have addressed the problem. SA-SKL-CSRF4 covers four patterns: an Express JSON endpoint that accepts text/plain as a Content-Type because body-parser is configured to parse any MIME type, allowing a plain HTML form to submit a valid JSON payload without triggering a CORS preflight; a CSRF token that is stored in localStorage rather than an httpOnly cookie, making it readable by any same-origin XSS and defeating the purpose of the token; a GraphQL API that accepts mutations via HTTP GET requests, enabling an attacker to embed a mutation in an <img src> tag; and session cookies with SameSite=Lax that remain vulnerable when the same domain has a subdomain taken over via a dangling CNAME, since SameSite protection is applied at the registrable domain level, not the full hostname.
CSRF in JSON APIs — the text/plain vector that bypasses CORS preflight
The common belief that JSON APIs are CSRF-safe rests on the assumption that an attacker cannot send a JSON body from a cross-origin page without triggering a CORS preflight (which the server rejects if it comes from an unexpected origin). The assumption breaks when the server accepts text/plain as a Content-Type. The browser's CORS specification defines application/x-www-form-urlencoded, multipart/form-data, and text/plain as "simple" content types that do not require a preflight. An HTML form with enctype="text/plain" can craft a body that is valid JSON — for example, {"action":"delete","id":"123"} as the form field name — and submit it cross-origin without a preflight. If the server parses any body as JSON (using express.json({ type: '*/*' }) or a custom middleware that ignores Content-Type), the CSRF payload is processed.
text/plain; browser form with enctype=text/plain submits JSON body cross-origin without preflight; session cookie attached automaticallylocalStorage; any same-origin XSS reads it; attacker with XSS bypasses CSRF protection entirely/graphql?query=mutation{...} in <img src> tag in a phishing emailSameSite=Lax session cookie; subdomain takeover via dangling CNAME allows cross-origin request with cookie from subdomain of same registrable domainCSRF4-001 — Express parses text/plain body as JSON
The attack works as follows: an attacker crafts an HTML page on their domain with a form whose action points to the MCP skill's delete endpoint. The form has enctype="text/plain" and contains a single input field whose name is {"action":"deleteAudit","id":"42"}