Protocols
Saved & recent

Cross-site request forgery

Also called: CSRF, XSRF, cross-site request forgery

Cross-site request forgery, or CSRF, exploits the browser’s ability to attach eligible credentials automatically. An attacker induces a request to a site where the victim is signed in; a vulnerable server mistakes the attached session cookie for evidence that the user intended the action. Cookie rules affect which cross-site requests carry credentials.

For example, a malicious page submits an address-change form to a vulnerable shop. The browser may include the shop’s session cookie even though the shop did not create that form. A validated CSRF token can distinguish the legitimate workflow. SameSite cookies and origin checks provide additional defenses; blocking cross-origin response reading with CORS does not, by itself, prevent all such requests.

Read first
HTTP cookies
Related
Session, HTTP cookies, CORS
Further reading
OWASP — Cross-Site Request Forgery Prevention Cheat Sheet
browser shop server cross-site state-change request request context session cookie · conditional browser and cookie rules server checks expected CSRF token rejected · token missing shop address unchanged
An attacker induces the form request without reading the session cookie. The browser adds the shop cookie only when its rules allow it. This shop separately checks the expected CSRF token and rejects the missing-token request.

View in the full Protocols collection