# 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).
| 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 `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)
| 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):
```html
<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=None` by default + no token on `admin/save.json.php` / `configurationUpdate.json.php`: cross-site POST overwrites plugin, SMTP and encoder settings. [[raw/sentinelone.com/cve-2026-34394-wwbn-avideo-csrf-vulnerability-2990|CVE-2026-34394: Wwbn Avideo CSRF Vulnerability]], [[raw/radar.offseq.com/cve-2026-40925-csrf-in-wwbn-avideo-configuration-endpoint-4832|CVE-2026-40925: CSRF in WWBN AVideo Configuration Endpoint]]
- **Rails Action Pack (GHSA-gmj8-hvj3-49mw)** — non-`CookieStore` session stores (`CacheStore`, `MemCacheStore`, …) ignored `cookies_same_site_protection` and emitted no `SameSite`; fix: `same_site: :lax` in session store config. [[raw/github.com/action-pack-missing-samesite-attribute-on-session-cookies-14077|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. [[raw/github.com/emlog-pro-ai-assistant-csrf-to-sql-execution-poc-14911|emlog pro AI Assistant CSRF to SQL execution PoC]]
- **Argo CD (GHSA-92mw-q256-5vwg)** — Lax called "useless" when attacker controls `marketing.victim.com` and target is `argocd.internal.victim.com`; `text/plain` XHR creates a privileged pod. [[raw/hackerone.com/internet-bug-bounty-argo-cd-csrf-leads-to-kubernetes-cluster-compromis-4835|Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise]]
- **Webmin 2.670 firewalld** — Referer-exempt `index.cgi` 302s into `default_zone.cgi`; Lax still sends the cookie on the top-level GET → default zone set to `trusted`. [[raw/abraxaslabs.tech/webmin-2-670-firewalld-index-cgi-csrf-sets-zone-to-trusted-14677|Webmin 2.670 firewalld index.cgi CSRF sets zone to trusted]]
- **XE-1545** — routes skipped `check_csrf`; triaged Medium because `SameSite=Lax` blocked direct exploitation absent a same-site injection. [[raw/bounty.xe.network/xe-1545-agent-note-and-patch-ref-routes-never-check-csrf-15064|XE-1545: Agent note and patch-ref routes never check CSRF]]
- **Hono `csrf()`** — workaround for the `text/ping` bypass is `SameSite=Strict`; the advisory notes default Lax limits exploitation to same-site origins or `None` cookies. [[raw/github.com/hono-csrf-does-not-check-hyperlink-auditing-text-ping-requests-14385|Hono csrf() does not check hyperlink auditing (text/ping) requests]]
## 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).
## 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
- [[raw/portswigger.net/bypassing-samesite-cookie-restrictions-csrf-portswigger-2875|Bypassing SameSite Cookie Restrictions - CSRF - PortSwigger]]
- [[raw/portswigger.net/lab-samesite-lax-bypass-via-cookie-refresh-portswigger-2870|Lab: SameSite Lax Bypass via Cookie Refresh - PortSwigger]]
- [[raw/portswigger.net/lab-samesite-lax-bypass-via-method-override-portswigger-2871|Lab: SameSite Lax Bypass via Method Override - PortSwigger]]
- [[raw/sajjapremsai.github.io/advanced-csrf-how-to-bypass-samesite-cookie-protections-3426|Advanced CSRF: How to Bypass SameSite Cookie Protections]]
- [[raw/medium.com/bypass-samesite-cookies-default-to-lax-and-get-csrf-938|Bypass SameSite Cookies Default to Lax and get CSRF]]
- [[raw/blog.reconless.com/samesite-by-default-and-what-it-means-for-bug-bounty-hunters-323|Samesite by Default and What It Means for Bug Bounty Hunters]]
- [[raw/scotthelme.co.uk/cross-site-request-forgery-is-dead-933|Cross-Site Request Forgery is dead!]]
- [[raw/medium.com/csrf-the-bug-everyone-declared-dead-and-nobody-actually-fixed-13022|CSRF: The Bug Everyone Declared Dead and Nobody Actually Fixed]]
- [[raw/cheatsheetseries.owasp.org/cross-site-request-forgery-prevention-cheat-sheet-owasp-2877|Cross-Site Request Forgery Prevention Cheat Sheet - OWASP]]
- [[raw/httpwg.org/cookies-http-state-management-mechanism-rfc-6265bis-2988|Cookies: HTTP State Management Mechanism (RFC 6265bis)]]
- [[raw/clerk.com/csrf-protection-clerk-docs-3423|CSRF Protection - Clerk Docs]]
- [[raw/invicti.com/preventing-csrf-with-the-samesite-cookie-attribute-3424|Preventing CSRF with the SameSite Cookie Attribute]]
- [[raw/medium.com/i-found-a-csrf-vulnerability-by-analyzing-cookies-when-remember-me-aut-15518|I Found a CSRF Vulnerability by Analyzing Cookies: When Remember Me Authentication Became the Weak…]]
- [[raw/sentinelone.com/cve-2026-34394-wwbn-avideo-csrf-vulnerability-2990|CVE-2026-34394: Wwbn Avideo CSRF Vulnerability]]
- [[raw/radar.offseq.com/cve-2026-40925-csrf-in-wwbn-avideo-configuration-endpoint-4832|CVE-2026-40925: CSRF in WWBN AVideo Configuration Endpoint]]
- [[raw/github.com/action-pack-missing-samesite-attribute-on-session-cookies-14077|Action Pack: missing SameSite attribute on session cookies]]
- [[raw/github.com/emlog-pro-ai-assistant-csrf-to-sql-execution-poc-14911|emlog pro AI Assistant CSRF to SQL execution PoC]]
- [[raw/hackerone.com/internet-bug-bounty-argo-cd-csrf-leads-to-kubernetes-cluster-compromis-4835|Internet Bug Bounty: Argo CD CSRF leads to Kubernetes cluster compromise]]
- [[raw/abraxaslabs.tech/webmin-2-670-firewalld-index-cgi-csrf-sets-zone-to-trusted-14677|Webmin 2.670 firewalld index.cgi CSRF sets zone to trusted]]
- [[raw/bounty.xe.network/xe-1545-agent-note-and-patch-ref-routes-never-check-csrf-15064|XE-1545: Agent note and patch-ref routes never check CSRF]]
- [[raw/github.com/hono-csrf-does-not-check-hyperlink-auditing-text-ping-requests-14385|Hono csrf() does not check hyperlink auditing (text/ping) requests]]
- [[raw/cobalt.io/csrf-bypasses-cobalt-3427|CSRF & Bypasses - Cobalt]]