Concepts / Web injection and scripting

Web injection and scripting

Cross-site request forgery

Also called CSRF, XSRF, sea-surf, one-click attack

Making a victim's browser send a state-changing request to a site they are logged in to, from a page the attacker controls.

The browser adds the cookie by itself
The browser adds the cookie by itself

The attacker's page never sees the cookie or the reply. It only makes the victim's browser send the request, and the browser attaches the bank's cookie.

Cross-site request forgery (CSRF) makes a victim's browser send a state-changing request to a site they are logged into, from the attacker's page. The browser attaches the site's cookies, so the site accepts it. The attacker never sees the cookie or the response. SameSite=Lax keeps the cookie off cross-site POSTs, but a top-level GET navigation carries it. The fix: an anti-CSRF token on every state change, and none on GET.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab