Understand the browser behaviour

Cross-site request forgery (CSRF) attempts to make a signed-in browser send an unwanted request. It matters when a site uses ambient credentials such as session cookies.

A request that changes an email address, payment setting or password needs protection. A public read-only page usually has different risk.

Use a framework token and safe request design

Use your framework’s CSRF protection for state-changing browser forms. Do not use GET requests to change data. Validate origin or referer information as an additional control where appropriate.

SameSite cookies can reduce some cross-site requests, but they are not a complete replacement for application-level protections in every flow.

Test every important action

Check settings changes, password changes, purchases and administrative actions. Confirm that a request without a valid token fails safely.

Review custom endpoints and API routes separately. A framework default does not protect a handler that bypasses the normal security layer.