CSRF token
A CSRF token is an unpredictable server-issued value required on state-changing requests to verify that they originated from the intended application.
Acing the Frontend Interview
A CSRF token is an unpredictable server-issued value that verifies a state-changing request originated from an authorized application context.
- How it is used
- Protects HTML form submissions from unintended actions initiated by a malicious third-party site.
- How deep it goes
- Specifies server generation, hidden fields, and validation on every submission, but does not detail token generation or validation logic.
- Examples
- Uses the scenario of an attacker tricking an authenticated user into submitting an unintended action.
- What you can do after
- Practice/perform it by placing a server-generated token in a hidden form field and validating it on every submission.
ASP.NET Core in Action, 3e
An antiforgery token is a value paired between a form or request and a browser cookie to verify that a state-changing request originated from the legitimate application.
- How it is used
- Protects cookie-authenticated state-changing forms and requests from forged submissions made by malicious websites.
- How deep it goes
- Explains the attack, paired cookie and hidden-field tokens, framework defaults, and an opt-out attribute, but not token-generation internals.
- Examples
- Uses a banking transfer or withdrawal form with an amount field and a hidden __RequestVerificationToken field.
- What you can do after
- Apply it via Razor Pages by retaining default antiforgery validation and recognizing when disabling it requires caution.
Also covered in
- Spring Security in Action, Second Edition
- Django in Action
- Grokking Web Application Security
- Spring in Action, Sixth Edition
What to know first
- cookieAn HTTP cookie is a small piece of data stored by a client and sent with subsequent requests within its scope, often to maintain state or preferences.
Related concepts
- cross-site request forgeryaddresses · Cross-site request forgery is a web attack that induces an authenticated user’s browser to submit an unintended request to a trusted application.
- csrf protectionused by · CSRF protection is a web security mechanism that prevents forged state-changing requests from an authenticated user's browser from being accepted.
- form tag helperproduced by · The Form Tag Helper is an ASP.NET Core Tag Helper that processes Razor form elements and generates form-related HTML attributes and antiforgery content.
- synchronizer token patternimplemented by · The synchronizer token pattern is a CSRF defense pattern that validates matching user-specific tokens supplied through separate request channels such as a cookie and form field.
Questions about CSRF token
What is CSRF token?
A CSRF token is an unpredictable server-issued value required on state-changing requests to verify that they originated from the intended application.
Which Manning books explain CSRF token?
Acing the Frontend Interview and ASP.NET Core in Action, 3e.
What should I know before learning CSRF token?
Manning books that teach CSRF token usually introduce cookie first.
What kinds of CSRF token are there?
Kinds of CSRF token include DefaultCsrfToken.
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.

