cross-site request forgery
An attack where another website makes the victim's browser send a request to your site, and the browser's cookie makes it look genuine.
It lets attackers perform actions as a logged-in user without their knowledge.
In more detail
CSRF stands for cross-site request forgery. Because the browser attaches cookies automatically, a hidden form on an evil page could submit a money transfer to your bank. SameSite cookies block most cases, and anti-CSRF tokens add defence in depth.
Related terms
- SameSite — A cookie attribute that limits whether the browser sends the cookie on requests started by other websites.
- CSRF token — A secret value tied to the user's session that must accompany each state-changing request, which another website cannot read or guess.
- cookie — A small named value a server asks a browser to store and send back automatically on later matching requests.
- state-changing request — A request that changes something on the server, such as a purchase, a password change or a deletion, as opposed to only reading data.
- state parameter — A random value the client sends at the start of an OAuth flow and checks when the browser returns, binding the response to its own request.
- HTTP method — The verb at the start of a web request that says what the client wants, such as GET to read or POST to create.
Taught in
- Content Security Policy (CSP), Trusted Types And XSS Defenses — Frontend Architecture & Web Platform
- CSRF Mitigations, SameSite Cookies And Subresource Integrity — Frontend Architecture & Web Platform
- Session Architecture: HTTP-Only Cookies vs Tokens — Production Full-Stack Engineering
- OAuth2 & OpenID Connect: Social Auth & PKCE Flows — Production Full-Stack Engineering
- Secure Defaults — Application Security & Threat Modeling for Engineers
- Cross-Site Request Forgery — Application Security & Threat Modeling for Engineers