System Design · Middle · Question 17 of 75
How do you protect against CSRF with cookie-based authentication?
- ✓Correct answer:
SameSitecookies plus a CSRF token or anOrigincheck - 2Switch from HTTPS to HTTP so cookies aren't sent
- 3Store cookies only in
sessionStorage
Explanation
The browser attaches cookies to requests from other sites. SameSite=Lax/Strict blocks most such scenarios, and a token or Origin check covers the rest. GET must not change data, otherwise the protection breaks.