CSRF tokens prevent unauthorized actions by validating user requests.
A CSRF token is a secret value generated by the server for each user session. It is embedded in web forms and validated with each request, ensuring that actions are performed by the authenticated user, not an attacker. For example, when a user submits a form on an e-commerce site, the server checks the CSRF token to ensure it matches the one stored in the session, thus preventing forgery.
Additional Notes
Why does a CSRF token in web applications matter in this design?