⚙️ Fix a Correlation Cookie Dropped by SameSite Lax
ASP.NET Core’s OpenID Connect and OAuth handlers set a short-lived correlation cookie before redirecting to the identity provider, and read it back when the provider redirects the user home to validate that the response matches a request this app actually started. Some identity providers return control to your app via a cross-site HTTP POST (response_mode=form_post is common), and a browser enforcing SameSite=Lax on that correlation cookie — the ASP.NET Core default unless you override it — will not attach the cookie to a cross-site POST, so the handler can’t find it, and the flow fails with a “Correlation failed” error that has nothing to do with your actual login credentials.
🔎 The Problem
services.AddAuthentication()
.AddOpenIdConnect(options =>
{
options.ResponseMode = "form_post"; // IdP redirects back via
// cross-site POST
// CorrelationCookie.SameSite left at its default (Lax) -
// browser won't send it on the cross-site POST back from the IdP,
// handler can't find the correlation value it set before redirecting
});
✅ Fix: A Correlation Cookie Dropped by SameSite Lax
- Set options.CorrelationCookie.SameSite = SameSiteMode.None explicitly for any flow using form_post or another cross-site redirect back into your app, since Lax is only safe for same-site or top-level GET redirects.
- Pair SameSite=None with Secure=true on the same cookie (required by the spec, and by modern browsers), which means this fix only works correctly when your app is served over HTTPS.
- Apply the same SameSite=None adjustment to the nonce cookie if you’re using one alongside correlation, since it’s subject to exactly the same cross-site POST restriction.
🚨 Why This Is Dangerous
- A “Correlation failed” error reads like a security or configuration problem with the identity provider, which can send you chasing IdP settings for a while before you realize the actual cookie never left the browser.
SameSite=Lax protects a cookie from showing up where it shouldn’t — including, sometimes, the one cross-site redirect your own login flow actually needs it to reach.





