liveBook · Manning

CSRF token

As explained in 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.

A CSRF token helps protect a web form from cross-site request forgery: an attacker may try to trick an authenticated user into submitting an unintended action from another site. The application generates the token on the server, includes it as a hidden form field, and validates it on every submission. section 2.4

In an interview, distinguish this check from input validation. The token helps establish that a submission came from the application’s form; server-side input validation checks whether submitted values meet expected constraints. Both belong in a secure form workflow. section 2.4

How Acing the Frontend Interview covers it

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.
How it connects
Connects cross-site request forgery to authenticated sessions, HTML forms, and server-side validation.

Also explained in

Compare how 2 books explain CSRF token →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.