CSRF Techniques & Bypass
CSRF tricks a victim’s browser into making authenticated requests to another site without their knowledge. It’s most valuable when combined with state-changing actions — password change, email update, money transfer. This post covers building CSRF exploits and bypassing common defenses.
Basic CSRF PoC
GET-based CSRF
|
POST-based CSRF
|
JSON POST CSRF
Browsers won’t send Content-Type: application/json in simple requests (requires pre-flight). But you can try:
|
Or if the server accepts both JSON and form-encoded, use form-encoded:
|
CSRF Token Bypass Techniques
1. Token not validated server-side
Simply omit the token from the request — if it still works, no server-side validation.
2. Token not tied to session
Grab a valid token from your own account, use it with another victim’s session.
3. Token in URL (Referer leakage)
|
If the token appears in the URL, it leaks via the Referer header to linked third-party sites.
4. Referer header bypass
If the server validates the Referer header instead of a token:
|
Or trick a victim to browse through a URL that looks like target.com:
|
Some servers only check if target.com appears anywhere in the Referer.
5. Token predictability
If the CSRF token is derived from time, session ID, or username — reverse-engineer it and generate a valid token without the server issuing it.
6. Same-Site Scripting
If you find XSS on any page of the same site, use it to bypass CSRF protection:
|
SameSite Cookie Bypass
SameSite=Lax bypass
Lax allows cookies on top-level GET navigation. If the state-changing endpoint accepts GET:
|
Or use a link click that the victim is tricked into making.
SameSite=Strict bypass via client-side redirect
If target.com has an open redirect, chain it:
|
Browser follows the redirect on target.com — cookies are sent with Strict.
SameSite=None without Secure (insecure contexts)
If SameSite=None but not Secure, any HTTP page can send it.
Cookie refresh trick (Chrome)
Some Chrome versions had a 2-minute window where a freshly set cookie treated as “None” before SameSite enforcement applied. Create a fresh session via login CSRF, then CSRF the action.
CORS-Assisted CSRF
If the API has both a CSRF vulnerability and a CORS misconfiguration:
|
This only works if the CORS policy allows attacker.com with credentials.
CSRF + Stored XSS Chain
- CSRF to submit content that gets stored.
- The stored content is XSS payload.
- XSS fires for all users who view it.
|
Multi-Step CSRF
Some applications require multiple steps for sensitive actions. CSRF each step:
|
Remediation
- Use unpredictable, session-tied CSRF tokens verified on every state-changing request.
- Implement
SameSite=StrictorSameSite=Laxon session cookies. - Validate the
OriginorRefererheader as secondary defense. - Use the
Double Submit Cookiepattern as an alternative. - Require re-authentication for critical actions (email change, password change, payment).
Discussion
Leave a comment · All fields required · No spam
No comments yet. Be the first.