Problem Statement
What is the most reliable mitigation for CSRF on state-changing requests?
Explanation
CSRF protection should not rely on headers that can be absent or altered. Combine server-verified anti-CSRF tokens with SameSite cookies and check content type and origin on risky endpoints.
These checks are detailed across WSTG and related OWASP guidance on input and session management.
Code Solution
SolutionRead Only
POST /transfer X-CSRF-Token: e3f... Cookie: sid=...; SameSite=Strict
