Web App Security

What Is CSRF (Cross-Site Request Forgery)? Definition, Architecture & Defense

Quick Definition: Cross-Site Request Forgery (CSRF) is an attack that tricks an authenticated user browser into sending an unwanted state-changing HTTP request (such as changing an email or transferring funds) to a web application where they are currently signed in.

How CSRF (Cross-Site Request Forgery) Works in Practice

Browsers automatically attach session cookies to cross-site requests unless restricted by SameSite attributes. If a site relies solely on cookies to authenticate a POST /account/email change without checking a secret anti-CSRF token or custom header, a hidden form on an attacker website can submit that request silently when visited.

Defensive Mitigation & Hardening Checklist

Include cryptographically random synchronizer CSRF tokens on state-changing requests, set SameSite=Lax or SameSite=Strict on session cookies, and require re-authentication for sensitive account changes.

Hands-On Tool & Cheat Sheet


Related Security Glossary Terms