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