Cross-site request forgery (CSRF)

An attack that makes a logged-in user's browser send an unwanted request to a trusted site, which acts on it because the browser attaches the user's session cookie automatically.

Cross-site request forgery (CSRF) makes a victim’s browser send a request the victim did not intend to a site where they are already authenticated. The attacker plants a link, image tag or self-submitting form on a page the victim visits. Because the browser attaches the session cookie for the target site automatically, the site can treat the forged request as genuine and change an email address, move money or alter settings. It is catalogued as CWE-352, and the OWASP Top 10 (2025 edition) maps it under Broken Access Control.

The usual defences aim to confirm that a request came from the site’s own pages: an unpredictable anti-CSRF token in each state-changing form, checked by the server; the SameSite cookie attribute, which limits when browsers send cookies on cross-site requests; checks on the Origin header; and re-authentication for sensitive actions. CSRF is the mirror of cross-site scripting: XSS abuses the user’s trust in a site, while CSRF abuses the site’s trust in the user’s browser.

Exam relevance: a scenario in which a user, logged in to their bank, clicks a link and a transfer happens without their knowledge is likely to be describing CSRF. Candidates are expected to distinguish it from XSS and from session hijacking, where the attacker takes over the session itself.