Cross-Site Request Forgery and CORS misconfiguration testing — missing/weak/bypassable CSRF tokens, SameSite gaps, method and content-type tricks, and CORS flaws (reflected origin, null origin, wildcard+credentials, weak origin matching) that expose authenticated data cross-origin. Generates browser-loadable PoCs. Use for state-changing requests and cross-origin data access.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Web Csrf Cors?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anandjogawade-web-csrf-cors)
---
name: web-csrf-cors
description: Cross-Site Request Forgery and CORS misconfiguration testing — missing/weak/bypassable CSRF tokens, SameSite gaps, method and content-type tricks, and CORS flaws (reflected origin, null origin, wildcard+credentials, weak origin matching) that expose authenticated data cross-origin. Generates browser-loadable PoCs. Use for state-changing requests and cross-origin data access.
---
# CSRF & CORS
Two cross-origin problems: CSRF forces a victim's browser to perform state-changing actions; CORS misconfiguration lets an attacker origin *read* authenticated responses. Test both wherever cookies authenticate requests.
## Trigger phrases
`csrf, cross-site request forgery, samesite, csrf token, cors, cross-origin, access-control-allow-origin, origin reflection, preflight`
## Part A — CSRF
### 1. Identify candidates
State-changing requests authenticated by cookies (not by a header-based bearer token the attacker can't set): change email/password, transfer, delete, update settings, add user, make purchase.
### 2. Test the protections
- **No token / not validated:** remove the CSRF token or its value — does the action still succeed?
- **Token not tied to session:** use a token from another account/session; if accepted, protection is broken.
- **Token validation flaws:** empty token accepted, token only validated if present (drop the param entirely), token in body but checked loosely, predictable/static token, token leaked (GET/Referer/HTML).
- **Method bypass:** change `POST`→`GET`, use `X-HTTP-Method-Override`, or a method the check ignores.
- **Content-Type bypass:** if JSON is required, try `text/plain`/`application/x-www-form-urlencoded` (simple request, no preflight) — if the server still parses it, CSRF works.
- **SameSite reality check:** `SameSite=Lax` still allows top-level GET navigations (so GET state-change = CSRF); `Lax` has a brief default window nuance; `None` = no SameSite protection; check whether the session cookie sets it at all. Subdomain/`SameSite` + XSS-on-subdomain chains.
- **Double-submit / custom-header defenses:** can the header be set cross-origin? Is the double-submit cookie attacker-settable (subdomain cookie injection)?
- **Referer-based defense:** omit Referer (via `<meta name=referrer>`), or match a weak check (substring/attacker domain contains the allowed string).
### 3. Build the PoC
Generate an auto-submitting HTML form (or `fetch` for simple-request JSON/CORS cases) that performs the action when the victim loads it. Confirm in a real browser with a logged-in victim session. For GET-based, a single `<img>`/link suffices.
## Part B — CORS misconfiguration
Check `Access-Control-Allow-Origin` (ACAO) and `-Allow-Credentials` (ACAC) behavior by sending varied `Origin` headers:
1. **Reflected origin + credentials:** server reflects any `Origin` into ACAO and sets `ACAC: true` ⇒ any site can read authenticated responses. Critical.
2. **`null` origin + credentials:** `Origin: null` reflected with credentials ⇒ exploitable from sandboxed iframe / `data:` document.
3. **Wildcard `*`:** with credentials the browser blocks it, but `*` on authenticated non-credentialed data or internal APIs can still leak; wildcard subdomains are riskier.
4. **Weak origin matching:** `allowed.com` matched by substring/prefix/suffix — `allowed.com.attacker.com`, `attackerallowed.com`, `allowed.com.evil`, missing anchors, regex `.` treated literally; trusting all subdomains (then XSS/takeover on any subdomain → full read).
5. **Pre-flight / method gaps:** permissive `Allow-Methods`/`Allow-Headers`.
### Exploit
Host a page that `fetch`es the target with `credentials:'include'` from a malicious origin and exfiltrates the response (tokens, PII, CSRF tokens → chain to CSRF). Confirm actual cross-origin read.
## Depth & chaining
- CORS read of a CSRF token defeats token-based CSRF defense → chain to full CSRF.
- CSRF on email/password change ⇒ account takeover — demonstrate it.
## Evidence
Provide the working PoC (HTML/JS), the request/response showing the weak ACAO/ACAC or accepted forged request, and the resulting impact in a victim session.