Skip to content
Commitwise
Menu

CSRF (cross-site request forgery)

An attack where another site makes the user's browser send a request that the user's own cookies authenticate.

Definition

Because browsers attach cookies automatically, a hidden form on evil.example can post to bank.example as the logged-in user. Defences: SameSite=Lax or Strict cookies, CSRF tokens in forms, Origin or Sec-Fetch-Site checks, and never changing state on GET. Bearer tokens in the Authorization header are not sent automatically, so they avoid CSRF.

In practice

A Lax cookie still rides on a top-level GET link, so GET /transfer?to=attacker&amount=500 would be exploitable.

Related terms

Esc

Type to search the whole site.