CSRF Protection: How Cross-Site Request Forgery Works
CSRF attacks explained: how they work, CSRF tokens, SameSite cookies, double-submit pattern, and framework protection.
How CSRF Works
An attacker tricks a logged-in user into making a request to your site. The browser automatically includes cookies, so the server thinks it is a legitimate request.
Prevention Methods
- CSRF tokens: Unique token per session, verified on every state-changing request
- SameSite cookies:
SameSite=StrictorSameSite=Laxprevents cross-origin cookie sending - Check Origin/Referer headers
Try It Free
Use our free online tool — 100% client-side, no data leaves your browser.
Open Hash Generator