SameSite
A cookie attribute (Strict, Lax or None) controlling whether the browser sends the cookie on requests initiated by other sites.
SameSite=Strict sends the cookie only on same-site requests. Lax also sends it on top-level GET navigations from other sites (following a link), and is the default in Chromium when the attribute is missing. None sends it everywhere and requires Secure.
It blunts CSRF because a cross-site form POST arrives without the session cookie. But site means registrable domain (eTLD+1), so evil.example.com is same-site with app.example.com; a compromised or user-controlled subdomain bypasses it. GET endpoints that change state also bypass Lax.
Pair it with the __Host- prefix, Secure and HttpOnly, and keep a CSRF token or Fetch Metadata check for defence in depth.
Set-Cookie: __Host-session=9f2c...; Path=/; Secure; HttpOnly; SameSite=LaxLearn it properly
Also used in
- Identity: authentication, authorisation and tokensSecEng · Foundations of Security EngineeringFree
- The bugs that actually shipSecEng · Application Security & DevSecOpsFree
- Cross-origin isolation, CORS and Fetch MetadataSecEng · Browser & web platform securityFree
- Design a session managerLLD · Problems: Access controlFree
- Design a server-side session storeLLD · Problems: first security componentsFree
- Design a CSRF token serviceLLD · Problems: first security componentsFree