Catalog My learning Blog
Browser Security Headers: CORS, CSP and Cookies Explained · Phase 4 · Lesson 19 · 6 min read

SameSite Cookies Explained: Strict, Lax, None

On this page
  1. Learning Objective
  2. Concept Explanation
  3. Worked Example: Which Attacks Each Value Stops
  4. Real-World Examples
  5. Review Questions & Answers

Learning Objective

Describe exactly what Strict, Lax, and None enforce, explain which requests Lax still permits and why that gap matters, and account for the behavior of the Lax-by-default rollout including the two-minute exception.

Concept Explanation

SameSite is a cookie attribute that tells the browser whether to include a cookie on requests initiated from a different site. It is evaluated against the site, meaning the registrable domain from this course's third lesson, and modern browsers apply a schemeful comparison, so http and https count as different sites. It is the single most effective structural CSRF mitigation available, because it applies automatically to every request without any application code.

SameSite=Strict withholds the cookie on every cross-site request, including plain top-level navigations. That is maximally safe and frequently unusable for a session cookie, because a user following a link to your site from a search engine, an email, or another site arrives logged out, sees a login page, and only appears logged in after a subsequent same-site navigation. Strict is the right value for high-sensitivity cookies where that behavior is acceptable, and a common pattern is to pair a Strict cookie used to gate dangerous operations with a Lax cookie used for general session continuity.

SameSite=Lax, the modern default, is the compromise. The cookie is sent on cross-site requests that are both top-level navigations and use a safe method, in practice a GET from clicking a link or a top-level redirect. It is withheld from all cross-site subresource requests, which covers images, iframes, script tags, and fetch, and from all cross-site POST requests including form submissions. That last clause is what makes it a broad CSRF mitigation: the classic hidden auto-submitting form that posts to a target site no longer carries the victim's cookie.

The residual gap in Lax is specific and worth stating precisely: cross-site top-level GET navigations still carry the cookie. Any endpoint that performs a state change in response to a GET is therefore still forgeable by a simple link or redirect, which is one more reason GET must remain side-effect free. Lax also does not protect against attacks that do not depend on the cookie being sent cross-site, such as a same-site attacker on a sibling subdomain, since a sibling is same-site by definition.

SameSite=None restores the old unrestricted behavior and is required for genuine third-party cookie use, such as an embedded widget or a federated identity flow. Browsers require it to be paired with Secure, and a None cookie without Secure is rejected outright. Chrome began enforcing Lax as the default for cookies with no SameSite attribute in Chrome 80 in February 2020, paused the rollout in April 2020 during the early COVID-19 period to avoid destabilizing sites, and resumed it in July 2020. Chrome also implements a compatibility carve-out sometimes called Lax-plus-POST: a cookie that is defaulted to Lax, but not one explicitly marked Lax, is still sent on a cross-site top-level POST if it was created less than two minutes ago, which exists to keep certain single sign-on flows working. Relying on a default rather than setting the attribute explicitly therefore gives you subtly weaker behavior, which is reason enough to always set it.

Request typeStrictLaxNone
Same-site request of any kindSentSentSent
Cross-site top-level navigation, GETNot sentSentSent
Cross-site top-level form POSTNot sentNot sentSent
Cross-site iframe, image, or script loadNot sentNot sentSent
Cross-site fetch or XHRNot sentNot sentSent
RequirementNoneDefault when absentMust be paired with Secure

Worked Example: Which Attacks Each Value Stops

The same three attack shapes are run against the same session cookie under each value. The pattern that emerges is that Lax stops everything except the GET navigation, which is why GET must never change state.

Code
# The cookie under test
Set-Cookie: __Host-session=abc; Secure; HttpOnly; Path=/; SameSite=Lax

# ATTACK 1 - auto-submitting cross-site form POST (classic CSRF)
<form action="https://bank.example/transfer" method="POST">...</form>
#   SameSite=Strict -> cookie NOT sent, attack fails
#   SameSite=Lax    -> cookie NOT sent, attack fails
#   SameSite=None   -> cookie sent, attack succeeds

# ATTACK 2 - cross-site image tag hitting a state-changing GET endpoint
<img src="https://bank.example/logout">
#   Strict -> not sent   Lax -> not sent (subresource)   None -> sent

# ATTACK 3 - a link or redirect to a state-changing GET endpoint
<a href="https://bank.example/transfer?to=evil&amount=5000">Click</a>
#   Strict -> cookie NOT sent, attack fails
#   Lax    -> COOKIE IS SENT. This is the residual gap.
#   None   -> cookie sent

# Recommended shape: Lax for usability, plus a token for the residual gap
Set-Cookie: __Host-session=abc; Secure; HttpOnly; Path=/; SameSite=Lax
Set-Cookie: __Host-csrf=xyz;    Secure;           Path=/; SameSite=Strict
# ...and never expose a state change on GET.
A matrix of five cross-site request types against the three SameSite values, with the single cell where Lax still sends the cookie, a top-level GET navigation, highlighted as the residual gap.
A matrix of five cross-site request types against the three SameSite values, with the single cell where Lax still sends the cookie, a top-level GET navigation, highlighted as the residual gap.

Real-World Examples

  • Chrome began treating cookies without a SameSite attribute as Lax by default in Chrome 80, released in February 2020, paused the rollout in April 2020 to avoid destabilizing sites during the early COVID-19 period, and completed it in July 2020; the change eliminated a large class of CSRF vulnerability across the web without any action by site owners, and is the clearest example of a browser default change delivering broad security improvement.
  • Chrome's Lax-plus-POST compatibility behavior, which still sends a defaulted-to-Lax cookie on a cross-site top-level POST within two minutes of the cookie being created, exists to keep certain single sign-on and payment redirect flows working; because it applies only to cookies defaulted to Lax and not to ones explicitly marked SameSite=Lax, a site that sets the attribute explicitly receives strictly stronger enforcement than one that relies on the default.
Best PracticeSet SameSite explicitly on every cookie rather than relying on the browser default. An explicitly marked Lax cookie is enforced more strictly than a cookie defaulted to Lax, because Chrome's two-minute Lax-plus-POST compatibility carve-out applies only to the defaulted case, and explicit attributes also survive differences between browsers and versions.

Review Questions & Answers

It permits the cookie on cross-site top-level navigations using a safe method, in practice a GET from clicking a link or following a redirect. The design rule that follows is absolute: GET requests must never change state. If they do, a plain link or a redirect from any site carries the victim's session and performs the action, and SameSite=Lax provides no protection at all against it.

Because it is withheld even on ordinary top-level navigations from another site, so a user arriving from a search result, an email link, or a partner site sees a logged-out page despite having a valid session. The usual resolution is to use Lax for the session cookie that provides general continuity, and to add a separate Strict cookie that is required for genuinely dangerous operations, so the strict behavior applies only where its user-experience cost is acceptable.

SameSite=None restores unrestricted cross-site sending, which is precisely the behavior that makes a cookie valuable to intercept, so browsers require it to be HTTPS-only. A cookie sent with SameSite=None and without Secure is rejected outright by modern browsers rather than being downgraded, which means a site that sets it incorrectly loses the cookie entirely and usually discovers the mistake as a functional break rather than a silent weakening.

Because Chrome applies a compatibility carve-out, Lax-plus-POST, only to cookies that were defaulted to Lax rather than explicitly marked. Such a cookie is still sent on a cross-site top-level POST within two minutes of being created, which leaves a narrow but real CSRF window for freshly issued session cookies. An explicitly marked Lax cookie receives no such exception, so setting the attribute is strictly stronger as well as clearer.