An attack when user using cookie:
// if jwt is sent in header (bearer), immune since do NOT auto-send Authorization headers
Server → random token
Client → include token in request (request body OR header)
Server → verify
SameSite Cookies
Strict
google.com → yoursite.com ❌ cookie NOT sent
yoursite.com → yoursite.com ✅ cookie sent
Lax (modern browser default)
Link click → yoursite.com (GET) ✅
Form POST from evil.com ❌
None
evil.com → yoursite.com ✅ cookie sent
Double Submit Cookie
Server sends this cookie: csrf = 123ABC
Browser stores it.
JS reads the cookie value (123ABC)
Sends it again inside the request
Cookie: csrf=123ABC
X-CSRF-Token: 123ABC
Server checks whether both match.