Cross-Site Request Forgery (CSRF) tricks authenticated users into performing unintended actions on web applications. CSRF attacks forge legitimate-looking requests using the victim’s session, enabling attackers to change passwords, transfer funds, or modify account settings. This guide covers CSRF exploitation, bypass techniques for SameSite cookies and CSRF tokens, and modern attack chains.
How CSRF Attacks Work
CSRF works because browsers automatically attach cookies to same-domain requests, regardless of where the request originates. If a victim visits an attacker’s page while logged in to a target site, the malicious page can send authenticated requests in the background.
Basic CSRF Exploit
Bypassing CSRF Token Validation
Many applications implement CSRF tokens but implement them incorrectly. Common bypass techniques include: removing the token entirely, using a predictable token, using another user’s valid token, or exploiting weak validation logic.
# Test CSRF token bypass methods
# 1. Remove token parameter entirely
# 2. Set token to empty string
# 3. Use a valid token from another account (if not user-bound)
# 4. Change POST to GET (sometimes skips token check)
# 5. Change Content-Type to text/plain (bypasses CORS preflight)
# Burp Suite: use CSRF PoC Generator
# Right-click request > Engagement Tools > Generate CSRF PoCBypassing SameSite Cookie Protection
SameSite=Strict/Lax cookies are the modern defense against CSRF. However, bypass techniques exist for Lax cookies and older browser implementations.
click me
Referer Header Bypass
# Some apps validate Referer header
# Bypass 1: suppress Referer entirely
# Bypass 2: add target domain to your URL
# Host page at: https://attacker.com/https://target.com/
# Or: https://target.com.attacker.com/
# Bypass 3: use a URL that contains the target domain
# Host your page at a URL that includes the target domain in the pathReferences
See OWASP CSRF and PortSwigger CSRF Guide.