Skip to content
BENIBIX Learn

Cross-Site Request Forgery (CSRF)

Development🔐 SecurityAttacks

Also known as CSRF, XSRF, Session Riding

An attack that tricks your browser. It sends a request you never meant to send.

Think of it like

Think of it like a trick. Someone hides a cheque under a card, and you sign it.

Example

Jack is logged in to his shop admin. He opens a link from an email, and a hidden form on that page changes his account email to the attacker's.

Why it matters

It turns your own login against you. Any action a user can do by a click can be forged this way.

Definition

Cross-site request forgery tricks your browser into sending a request. You are logged in to your bank in one tab. A bad page in another tab quietly sends a form to the bank. Your browser adds your login cookie, so the bank thinks it was you. The fix is a secret token on every form, plus cookies marked SameSite.

Common mistake

Letting a GET request change data. A single image tag on another site can then fire it.

Key takeaways

  1. 1
    Your browser is tricked. Not your password stolen.
  2. 2
    Cookies ride along. So it looks like you.
  3. 3
    Tokens and SameSite. The usual fix.

Compare