Security & DevSecOps Practical By Samson Tanimawo, PhD Published Oct 3, 2025 4 min read

CSRF Protection 2026

Cross-site request forgery. The defenses.

SameSite cookies

Cross-Site Request Forgery (CSRF) is the attack where a malicious site tricks a victim's browser into making authenticated requests to your application. The browser automatically attaches the user's cookies; the application processes the request as if it were legitimate. The defense is layered: SameSite cookies at the browser level, CSRF tokens at the application level, and Origin verification at the gateway level.

What SameSite cookies actually do:

SameSite cookies are the cheapest and most effective CSRF defense. The configuration is one attribute; the protection is automatic.

CSRF tokens

The traditional CSRF defense is the per-session anti-forgery token. The application generates a random token, stores it in the session, and includes it in every form. State-changing requests must include the token; requests without it are rejected. CSRF tokens predate SameSite by a decade and remain useful as a defense-in-depth layer.

CSRF tokens are the second layer. Combined with SameSite cookies, the protection is robust against current attack patterns. Either layer alone has gaps; both layers together close most of them.

Origin check

The third layer is Origin and Referer header verification at the application or gateway level. Modern browsers attach Origin to all cross-origin requests; verifying it on state-changing requests catches CSRF attempts that somehow slipped through the other layers.

SameSite cookies, CSRF tokens, and Origin verification together produce the modern CSRF defense. Nova AI Ops integrates with API gateway audit streams to surface CSRF-protection violations (requests that bypassed expected origins, missing CSRF tokens on state-changing endpoints) so the security posture stays defended over time as the application evolves.