SameSite Cookies
The
SameSitecookie 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 underLax, 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).
| From | To | Same-site? | Same-origin? |
|---|---|---|---|
https://app.example.com | https://intranet.example.com | Yes | No |
https://example.com | https://example.com:8080 | Yes | No |
https://example.com | https://example.co.uk | No (eTLD) | No |
https://example.com | http://example.com | No (scheme) | No |
Values
| Value | Cookie sent cross-site when | Notes |
|---|---|---|
Strict | never | breaks inbound links (user appears logged out after clicking an external link) |
Lax | top-level navigation and safe method (GET, HEAD, OPTIONS, TRACE) | not sent on cross-site POST, iframes, <img>, fetch/XHR |
None | always | requires Secure or the cookie is rejected |
| (absent) | Chromium: treated as Lax (since 2021). Firefox/Safari: no restriction | always 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
Strictcookies and getSec-Fetch-Site: same-site. - Client-side redirect gadgets. A JS redirect (
location = param) creates a fresh same-site request that carriesStrictcookies. 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 lackingSameSitealongside aLaxsession cookie are still CSRF-able in browsers that default toNone. - Non-cookie ambient credentials. HTTP Basic/Digest, client certificates and network position (loopback/intranet services) are unaffected.
Bypass techniques (overview)
| Restriction | Bypass primitive |
|---|---|
Lax | endpoint 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 |
Strict | on-site client-side redirect gadget (?postId=1/../../my-account/change-email?…); sibling-domain XSS |
None | nothing — 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
- WWBN AVideo (CVE-2026-34394, CVE-2026-40925) —
session.cookie_samesite=Noneby default + no token onadmin/save.json.php/configurationUpdate.json.php: cross-site POST overwrites plugin, SMTP and encoder settings. CVE-2026-34394: Wwbn Avideo CSRF Vulnerability, CVE-2026-40925: CSRF in WWBN AVideo Configuration Endpoint - Rails Action Pack (GHSA-gmj8-hvj3-49mw) — non-
CookieStoresession stores (CacheStore,MemCacheStore, …) ignoredcookies_same_site_protectionand emitted noSameSite; fix:same_site: :laxin session store config. Action Pack: missing SameSite attribute on session cookies - emlog pro AI assistant — admin cookie lacks
SameSite; author notes the Lax+POST two-minute window as the only barrier to reliable cross-site SQL execution. emlog pro AI Assistant CSRF to SQL execution PoC - Argo CD (GHSA-92mw-q256-5vwg) — Lax called “useless” when attacker controls
marketing.victim.comand target isargocd.internal.victim.com;text/plainXHR creates a privileged pod. Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise - Webmin 2.670 firewalld — Referer-exempt
index.cgi302s intodefault_zone.cgi; Lax still sends the cookie on the top-level GET → default zone set totrusted. Webmin 2.670 firewalld index.cgi CSRF sets zone to trusted - XE-1545 — routes skipped
check_csrf; triaged Medium becauseSameSite=Laxblocked direct exploitation absent a same-site injection. XE-1545: Agent note and patch-ref routes never check CSRF - Hono
csrf()— workaround for thetext/pingbypass isSameSite=Strict; the advisory notes default Lax limits exploitation to same-site origins orNonecookies. Hono csrf() does not check hyperlink auditing (text/ping) requests
Defenses
- Set
SameSiteexplicitly 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. Strictfor high-value cookies where inbound-link UX allows;Laxotherwise, plus a real CSRF control.- Audit every
GET/HEADhandler 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).
Related
- Cross-Site Request Forgery
- CSRF Prevention
- Method Override CSRF
- CSRF Token Bypasses
- Referer and Origin Validation Bypasses
- Login CSRF
- Session Management
See also: CORS Misconfiguration
Sources
- Bypassing SameSite Cookie Restrictions - CSRF - PortSwigger · original
- Lab: SameSite Lax Bypass via Cookie Refresh - PortSwigger · original
- Lab: SameSite Lax Bypass via Method Override - PortSwigger · original
- Advanced CSRF: How to Bypass SameSite Cookie Protections · original
- Bypass SameSite Cookies Default to Lax and get CSRF · original
- Samesite by Default and What It Means for Bug Bounty Hunters · original
- Cross-Site Request Forgery is dead! · original
- CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed · original
- Cross-Site Request Forgery Prevention Cheat Sheet - OWASP · original
- Cookies: HTTP State Management Mechanism (RFC 6265bis) · original
- CSRF Protection - Clerk Docs · original
- Preventing CSRF with the SameSite Cookie Attribute · original
- I Found a CSRF Vulnerability by Analyzing Cookies: When Remember Me Authentication Became the Weak… · original
- CVE-2026-34394: Wwbn Avideo CSRF Vulnerability · original
- CVE-2026-40925: CSRF in WWBN AVideo Configuration Endpoint · original
- Action Pack: missing SameSite attribute on session cookies · original
- emlog pro AI Assistant CSRF to SQL execution PoC · original
- Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise · original
- Webmin 2.670 firewalld index.cgi CSRF sets zone to trusted · original
- XE-1545: Agent note and patch-ref routes never check CSRF · original
- Hono csrf() does not check hyperlink auditing (text/ping) requests · original
- CSRF & Bypasses - Cobalt · original