Security · interactive
Cross-site request forgery (CSRF)
Browsers attach your cookies to every request sent to a site, no matter which page sent it. So another site can make your browser act on your behalf, using your logged-in session.
bank.example
You log in to bank.example. It sets a session cookie.
<!-- on evil.example --> <form action="https://bank.example/transfer" method="POST"> <input type="hidden" name="to" value="attacker"> <input type="hidden" name="amount" value="500"> </form> <script>document.forms[0].submit()</script>
You log in to bank.example. It sets a session cookie.
Bank's defense
The bank trusts any request that carries the session cookie.
step 1 of 5Step 1 of 4 · read left to right
In production
Tools and technologies
Frameworks and browsers now ship most CSRF defenses by default.
Not tied to one language — use these names when you search docs or design a system.