SameSite Cookies

The SameSite cookie attribute (RFC 6265bis) tells the browser whether to attach a cookie to cross-site requests; it is the browser-side baseline against CSRF, but it is scoped to the registrable domain, permits top-level safe-method navigations under Lax, and is a defense-in-depth layer, not a CSRF fix.

How it works

Site vs origin. A site is scheme + eTLD+1; an origin is scheme + host + port. A cross-origin request can be same-site, never the reverse. http:// → https:// on the same host is cross-site (scheme counts).

FromToSame-site?Same-origin?
https://app.example.comhttps://intranet.example.comYesNo
https://example.comhttps://example.com:8080YesNo
https://example.comhttps://example.co.ukNo (eTLD)No
https://example.comhttp://example.comNo (scheme)No

Values

ValueCookie sent cross-site whenNotes
Strictneverbreaks inbound links (user appears logged out after clicking an external link)
Laxtop-level navigation and safe method (GET, HEAD, OPTIONS, TRACE)not sent on cross-site POST, iframes, <img>, fetch/XHR
Nonealwaysrequires Secure or the cookie is rejected
(absent)Chromium: treated as Lax (since 2021). Firefox/Safari: no restrictionalways set it explicitly
Set-Cookie: __Host-session=…; Path=/; Secure; HttpOnly; SameSite=Lax

Lax+POST grace window. Chromium exempts cookies set without a SameSite attribute for ~2 minutes after they are set: they ride along on cross-site top-level POST navigations. Any action that re-issues the cookie (login, logout, OAuth/SSO refresh, a GET /logout that sets session=) reopens the window. Explicitly-set SameSite=Lax does not get the exemption.

What SameSite does not stop

  • State-changing GET. Any mutation reachable by a safe method passes Lax; OWASP calls this the single most common way SameSite-based defense fails. See Method Override CSRF.
  • Top-level POST in the grace window (above) and browsers that default to None.
  • Same-site siblings. Every host under the registrable domain is same-site: XSS, HTML upload, tenant content or a taken-over subdomain issues requests that carry even Strict cookies and get Sec-Fetch-Site: same-site.
  • Client-side redirect gadgets. A JS redirect (location = param) creates a fresh same-site request that carries Strict cookies. Server-side 30x redirects do not: the browser keeps the cross-site context.
  • Client-side CSRF / CSPT. Same-origin JS issuing attacker-steered requests is not cross-site at all.
  • Secondary auth cookies. Apps that accept a REMEMBERME-style cookie lacking SameSite alongside a Lax session cookie are still CSRF-able in browsers that default to None.
  • Non-cookie ambient credentials. HTTP Basic/Digest, client certificates and network position (loopback/intranet services) are unaffected.

Bypass techniques (overview)

RestrictionBypass primitive
Laxendpoint accepts GET; _method override on a top-level GET; HEAD routed to GET handler; GraphQL mutation over GET
Lax (default, unset)trigger cookie refresh (SSO/OAuth flow in a popup, logout-login) then POST within ~120 s
Stricton-site client-side redirect gadget (?postId=1/../../my-account/change-email?…); sibling-domain XSS
Nonenothing — classic form CSRF

Lax-bypass shape (top-level GET + override):

<script>location='https://target/my-account/change-email?email=x%40x&_method=POST'</script>

Side effects on other bug classes

Lax-by-default also degraded clickjacking (iframed target is unauthenticated), XSSI/JSONP leaks, CORS-misconfig exfiltration, XS-Leaks and cross-site WebSocket hijacking — except where sites opt back into None (JSONP, embedded widgets, SSO), which is exactly where to look.

Notable cases

Defenses

  • Set SameSite explicitly on every auth cookie (including remember-me, cookies set by legacy paths and non-default session stores); prefer __Host- prefix to block subdomain cookie writes.
  • Strict for high-value cookies where inbound-link UX allows; Lax otherwise, plus a real CSRF control.
  • Audit every GET/HEAD handler for side effects; disable method-override on safe methods.
  • SameSite alone is acceptable only if: no shared registrable domain with untrusted hosts, no state-changing safe-method endpoint, Lax/Strict + __Host-, Origin/Referer verification in place, and unsupported browsers are an accepted risk (OWASP).

See also: CORS Misconfiguration

Sources