liveBook · Manning

Cross-site request forgery

Also called CSRF

Cross-site request forgery is a web attack that induces an authenticated user’s browser to submit an unintended request to a trusted application.

How 6 Manning books explain it

Acing the Frontend Interview

Cross-site request forgery is an attack that tricks an authenticated user’s browser into sending an unintended request to a trusted site.

How it is used
Protects authenticated form submissions from unintended actions initiated by malicious third-party sites.
How deep it goes
Explains the attack and token-based defense but does not provide token-generation or validation code.
Examples
Uses an authenticated user tricked into submitting an unintended action as the attack scenario.
What you can do after
Operate/configure it by adding server-generated hidden anti-CSRF tokens and validating them on every form submission.

Read how Acing the Frontend Interview explains cross-site request forgery →

ASP.NET Core in Action, 3e

Cross-site request forgery (CSRF) is an attack in which a victim's authenticated browser is induced to submit an unintended request to a trusted application.

How it is used
Protects cookie-authenticated applications from unintended requests submitted through a victim’s browser.
How deep it goes
Explains the forged-request and two-token mechanisms, automatic Razor Pages protection, and ways to disable it.
Examples
Uses a forged bank-transfer form and a generated hidden verification field to illustrate the attack and its protection.
What you can do after
Apply protection via Razor Pages by retaining generated tokens and validation, and recognize the risks of disabling them.

Read how ASP.NET Core in Action, 3e explains cross-site request forgery →

Spring Security in Action, Second Edition

Cross-site request forgery is an attack that causes a user's authenticated browser to send an unintended state-changing request to a web application.

How it is used
Protects authenticated web applications from forged state-changing requests and explains when Spring Security's default protection applies.
How deep it goes
Explains the attack, token flow, filter integration, request testing, and extension contracts, while stopping short of broader attack theory.
Examples
Uses a file-management attack scenario, a Spring REST /hello endpoint, custom token logging, and curl requests.
What you can do after
Operate/configure Spring Security protection, test token-protected POST requests, and customize token handling through named contracts.

Read how Spring Security in Action, Second Edition explains cross-site request forgery →

Grokking Web Application Security

Cross-site request forgery is a web attack that causes a user's browser to send an unintended authenticated request to a site.

How it is used
Frames CSRF as a browser-based threat to authenticated user actions and a reason to protect state-changing endpoints.
How deep it goes
Explains CSRF through a GET comment-worm scenario and gives practical defenses, without detailing antiforgery-token implementation.
Examples
Uses a baking-forum GET comment form, a shortened redirect link, a self-replicating worm, and sensitive actions such as payments and deletions.
What you can do after
Apply it by keeping GET side-effect-free, using antiforgery tokens, and setting SameSite on sensitive cookies.

Read how Grokking Web Application Security explains cross-site request forgery →

Django in Action

Cross-site request forgery is a web attack that tricks an authenticated user’s browser into submitting an unintended state-changing request to a site.

How it is used
Protects Django forms that submit user actions, especially state-changing POST requests.
How deep it goes
Explains the attack, token flow, middleware check, and rejection condition without detailing middleware internals.
Examples
Uses a malicious comment-like form whose hidden fields secretly request a password change.
What you can do after
Apply it via Django’s {% csrf_token %} tag so submitted forms carry a value Django can validate.

Read how Django in Action explains cross-site request forgery →

Secure APIs

Cross-site request forgery is an attack in which a victim's authenticated browser is induced to send an unintended request.

How it is used
Protects OAuth authorization flows from malicious requests that exploit an authenticated identity-provider session.
How deep it goes
Traces the attack through authorization, redirection, and token exchange, then gives state and redirect-URI mitigations.
Examples
Uses malicious links, authorization URLs, active IdP sessions, redirect URIs, authorization codes, and access-token exchanges.
What you can do after
Apply state validation and constrained redirect URIs to reduce authorization-code and access-token hijacking.

Read how Secure APIs explains cross-site request forgery →

Also covered in

What to know first

Related concepts

Questions about cross-site request forgery

What is cross-site request forgery?

Cross-site request forgery is a web attack that induces an authenticated user’s browser to submit an unintended request to a trusted application.

Which Manning books explain cross-site request forgery?

Acing the Frontend Interview, ASP.NET Core in Action, 3e, Spring Security in Action, Second Edition, Grokking Web Application Security, Django in Action and Secure APIs.

What should I know before learning cross-site request forgery?

Manning books that teach cross-site request forgery usually introduce cookie, session, HTTP request and HTTP method first.

What is cross-site request forgery a kind of?

Cross-site request forgery is a kind of vulnerability. A vulnerability is a weakness or condition that makes a system, person, or group susceptible to exploitation, compromise, or other harm.

What is cross-site request forgery also called?

Cross-site request forgery is also called CSRF.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.