Pick the fix
A cookie-session app has POST /email/change. Which change blocks CSRF best?
Hint 1 of 1
Why does the browser send the cookie at all?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A SameSite=Lax cookies plus a per-session CSRF token checked on the POST
Correct. Two independent layers.
SameSite=Lax stops the browser attaching the cookie to most cross-site POSTs. A token tied to the session is something an attacking page can't read, so a forged form fails even if a cookie gets through.
Why not the others?
- B Strict CORS rules. Simple cross-site form POSTs don't need CORS approval.
- C Switching the endpoint to GET. Makes it worse.
- D A longer session id. The attacker never needs to know it.