SameSite=Strict, Lax and None semantics, the site vs origin distinction, cross-site flows such as the OIDC form_post callback, ASP.NET Core cookie settings, and the browser changes that broke older apps.
SameSite tells the browser whether to send a cookie on cross-site requests. Strict: never cross-site. Lax: cross-site only on top-level GET navigations (clicking a link), not on cross-site POSTs, iframes or fetch. None: always, and it must also be Secure. 'Site' means scheme plus registrable domain, so app.example.com.au and api.example.com.au are the same site.
Chromium now treats cookies without the attribute as Lax by default, which broke flows that relied on cross-site POSTs, most famously OpenID Connect form_post callbacks: the identity provider POSTs back to /signin-oidc, so the correlation and nonce cookies must be SameSite=None; Secure, which ASP.NET Core sets for you over HTTPS. The trade-off: Strict is safest but hurts UX; None is needed for embedding and federation but loses CSRF protection.
"SameSite is a cookie attribute that decides whether the browser attaches the cookie when the request comes from another site. Strict means only same-site requests; Lax adds top-level GET navigations, so following a link from an email still sends it, but a cross-site form POST, an iframe or a
fetchfrom another site doesn't; None means always, and browsers requireSecurewith it. The subtle part is that 'site' isn't 'origin': it's the scheme plus the registrable domain, so all my subdomains are the same site as each other. That's why SameSite doesn't protect me from a compromised sibling subdomain.The big change was Chromium making Lax the default for cookies with no attribute. That quietly broke anything that depended on a cross-site POST carrying a cookie. The classic is OpenID Connect with
response_mode=form_post: Entra ID auto-posts the response back to/signin-oidcfrom its own domain, and the handler needs the correlation and nonce cookies it set before the redirect. If those are Lax, they aren't sent, and you get 'Correlation failed'. ASP.NET Core sets those cookies toSameSite=None; Secure, which means the app must be on HTTPS, or see HTTPS through forwarded headers, otherwise browsers drop them. At [company] we hit exactly this after [moving behind a TLS-terminating proxy]: [the fix was forwarded headers, not changing SameSite].For my own cookies: the session cookie is Lax by default in ASP.NET Core, or Strict if users rarely arrive from external links. I only use None for genuinely cross-site needs like an embedded widget, and then I add antiforgery, because None removes SameSite's CSRF protection. The mistake I see is setting everything to None to 'fix' a login bug; that trades a symptom for a vulnerability."
| Request from another site | Strict | Lax | None (+Secure) |
|---|---|---|---|
| Clicking a link (top-level GET) | No | Yes | Yes |
| Cross-site form POST (e.g. OIDC form_post) | No | No | Yes |
fetch/XHR with credentials |
No | No | Yes (if third-party cookies allowed) |
| Iframe of your site | No | No | Yes (if third-party cookies allowed) |
| Image or script subresource | No | No | Yes |
| A | B | Same origin? | Same site? |
|---|---|---|---|
https://app.example.com.au |
https://api.example.com.au |
No | Yes |
https://app.example.com.au |
http://app.example.com.au |
No | No (schemeful) |
https://example.com.au |
https://login.microsoftonline.com |
No | No |
| Cookie | Default SameSite | Why |
|---|---|---|
| Cookie authentication | Lax | Survives link navigation; blocks cross-site POSTs |
| OIDC correlation and nonce | None (Secure) | Must survive the IdP's cross-site POST |
| Antiforgery cookie | Strict | Only needed on same-site form posts |
Session (AddSession) |
Lax |
After TLS termination moved to the ingress, sign-in failed for about 30% of users with 'Correlation failed': the app saw HTTP, so the None cookies weren't marked Secure and Chromium rejected them. Adding UseForwardedHeaders with the ingress network restored sign-in instantly; nobody needed to touch SameSite.
Checks that the candidate knows exact SameSite semantics, the site/origin distinction, and can diagnose real breakages like OIDC correlation failures.
Green flags
Red flags
Request initiator site == target cookie's site ? -> send (all modes)
Otherwise (cross-site):
Strict -> don't send
Lax -> send only if top-level navigation AND safe method (GET)
None -> send (requires Secure; subject to third-party cookie policy)
The browser compares the site of the top-level page that initiated the request with the cookie's site, using the Public Suffix List to find the registrable domain (example.com.au, because com.au is a public suffix). Since 2021 browsers compare schemefully, so http:// and https:// versions are different sites.
Chromium (2020) changed cookies with no SameSite attribute to behave as Lax, with a temporary 'Lax+POST' allowance for top-level cross-site POSTs within two minutes of the cookie being set, kept to avoid breaking sign-in flows. Firefox and Safari did not ship Lax-by-default broadly, but both block or partition third-party cookies anyway. So: never rely on the default, set the attribute explicitly.
1. App (example.com.au) -> 302 to IdP; sets .AspNetCore.Correlation + Nonce cookies (SameSite=None; Secure)
2. User signs in at login.microsoftonline.com
3. IdP returns an auto-submitting HTML form: POST https://example.com.au/signin-oidc
-> cross-site, top-level POST
4. Browser sends cookies only if SameSite=None (Lax wouldn't send on POST)
5. Handler validates correlation (CSRF protection for the flow) and nonce (replay protection)
With response_mode=query (code in the query string, a GET), Lax cookies would be sent, but form_post is the default in the ASP.NET Core OpenID Connect handler because it keeps codes out of URLs and logs.
CookieOptions.SameSite per cookie; CookieAuthenticationOptions.Cookie.SameSite for the auth cookie.SameSiteMode.Unspecified omits the attribute (browser default applies). It was introduced for the 2019–2020 transition when some older browsers (notably iOS 12 Safari) mishandled None.CookiePolicyOptions.MinimumSameSitePolicy and OnAppendCookie let you enforce or adjust policy globally via UseCookiePolicy().Secure; behind a TLS-terminating proxy that requires UseForwardedHeaders so the app knows the request is HTTPS.SameSite=None is necessary but no longer sufficient for third-party contexts: Safari (ITP) blocks third-party cookies, Firefox partitions them per top-level site (Total Cookie Protection), and Chrome, which dropped its plan to remove them, supports CHIPS (Partitioned attribute) for embedded widgets that need per-embedder state. Designs that depend on third-party cookies (silent token renewal in hidden iframes, cross-site embedded sessions) should move to first-party alternatives such as a BFF on the same site.
CookiePolicyOptions.OnAppendCookie to log every cookie's SameSite value at startup.chrome://settings/cookies behaviour with third-party cookies blocked and test an embedded iframe.Partitioned to a None cookie in an embedded test page and compare behaviour across browsers.Explicit SameSite settings for each cookie in an ASP.NET Core app that signs in with Microsoft Entra ID and runs behind a TLS-terminating proxy.
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.HttpOverrides;
var builder = WebApplication.CreateBuilder(args);
builder.Services.Configure<ForwardedHeadersOptions>(o =>
{
// None cookies must be Secure; the app must know the original request was HTTPS
o.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
o.KnownNetworks.Add(new Microsoft.AspNetCore.HttpOverrides.IPNetwork(System.Net.IPAddress.Parse("10.240.0.0"), 16));
});
builder.Services.AddAuthentication(o =>
{
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie(o =>
{
o.Cookie.HttpOnly = true;
o.Cookie.SecurePolicy = CookieSecurePolicy.Always;
o.Cookie.SameSite = SameSiteMode.Lax; // survives links from email; blocks cross-site POSTs
})
.AddOpenIdConnect(o =>
{
builder.Configuration.Bind("EntraId", o);
o.ResponseType = "code";
// form_post is the default: the IdP POSTs back cross-site, so the handler's
// correlation and nonce cookies are SameSite=None; Secure. Don't downgrade them.
o.CorrelationCookie.SameSite = SameSiteMode.None;
o.NonceCookie.SameSite = SameSiteMode.None;
});
builder.Services.AddAntiforgery(o => o.Cookie.SameSite = SameSiteMode.Strict);
var app = builder.Build();
app.UseForwardedHeaders(); // first, so Request.IsHttps is correct for Secure cookies
app.UseAuthentication();
app.UseAuthorization();
app.Run();
// An embedded widget that genuinely needs a cross-site cookie: None + Secure + Partitioned (CHIPS)
context.Response.Headers.Append("Set-Cookie",
"widget_state=abc; Path=/; Secure; HttpOnly; SameSite=None; Partitioned");
SameSite=None to fix a sign-in error. Why it is wrong: it removes SameSite's CSRF protection from the session cookie. Instead: only the OIDC correlation and nonce cookies need None; fix the real cause (often HTTPS or forwarded headers).SameSite=None without Secure. Why it is wrong: modern browsers reject the cookie entirely. Instead: always pair None with Secure, and make sure the app sees HTTPS behind proxies.SameSite=None to make third-party cookies work everywhere. Why it is wrong: Safari blocks and Firefox partitions third-party cookies by default. Instead: design first-party flows (same-site BFF) or use Partitioned for embedded state.The senior understanding is that SameSite is a browser-side policy on ambient credentials that interacts with everything else: CSRF defences, federation flows, embedding and third-party cookie restrictions. Getting it right means being explicit per cookie and knowing which flows are cross-site by design.
| Setting | When it fits | Cost | When not to |
|---|---|---|---|
| Strict | Antiforgery cookies, high-value admin sessions | Users from external links seem logged out initially | General session cookies on consumer sites |
| Lax | Most session cookies | Allows top-level GET from other sites | Cookies needed in cross-site POSTs or iframes |
| None + Secure | OIDC correlation/nonce, embedded widgets | No CSRF protection from SameSite; third-party blocking | Session cookies of normal apps |
| None + Secure + Partitioned | Embedded widgets needing per-embedder state | Per-site state only | Cross-site single sign-on state |
Measure: sign-in failure rate ('Correlation failed' in logs), cookie attributes asserted in integration tests, and browser-matrix testing of embedded flows.
CSRF makes a victim's browser send a state-changing request to your site from another site; it works because the browser attaches cookies automatically. If you authenticate with cookies, you're exposed; if callers send a bearer token in the Authorization header, a cross-site page can't add it, so classic CSRF doesn't apply.
ASP.NET Core's antiforgery uses a synchroniser token: a cookie token plus a token in the form or a header, validated together. MVC forms get it from the form tag helper with [ValidateAntiForgeryToken] or the global auto-validate filter; Razor Pages validate POSTs by default; Minimal APIs need AddAntiforgery/UseAntiforgery and validate form-bound endpoints. SameSite=Lax (the default for ASP.NET Core auth cookies) blocks most cross-site POSTs, but not attacks from a sibling subdomain or GETs that change state, so keep tokens.
After a successful login the app calls HttpContext.SignInAsync: the cookie handler serialises the ClaimsPrincipal into an authentication ticket, encrypts and signs it with Data Protection, and sends it as a cookie. On each request the handler decrypts the cookie and rebuilds HttpContext.User, with no database call.
HttpOnly (JavaScript can't read it), Secure (HTTPS only), SameSite=Lax by default (not sent on most cross-site requests).ExpireTimeSpan (default 14 days) with sliding expiration that reissues the cookie once half the window has passed; IsPersistent decides whether it survives closing the browser.The trade-off: a self-contained cookie is fast and stateless, but you can't revoke it without extra checks or a server-side ticket store.
How to tell it (STAR)
**S:** At [company], after we moved [our apps] to a new TLS-terminating ingress, about [30]% of staff couldn't sign in and saw 'Correlation failed'. **T:** I had to restore sign-in fast without weakening cookie security. **A:** In dev tools I saw Chrome rejecting the correlation cookie because it was SameSite=None without Secure. Logging the request scheme showed the app thought every request was HTTP, because forwarded headers weren't processed. I added `UseForwardedHeaders` with the ingress network, so cookies were marked Secure again, and forced Secure on all cookies. **R:** Sign-in failures dropped to zero within [minutes] of the deploy, and a synthetic sign-in check now runs after every infrastructure change.
Last updated 23 Nov 2026.