Sign-ins finish only in the browser that started them

A Core sign-in, and a posting account's or Search Console's OAuth sign-in,
now sets a short-lived cookie whose hash the flow keeps on the server. The
callback refuses one without it (constant-time compare), clears the cookie
either way, and the flow is used up regardless. This stops login CSRF: a
callback URL brought to another browser signs nobody in.

The cookie uses the __Host- prefix over https, so its Path is "/".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 08:07:21 -07:00
co-authored by Claude Opus 5.5
parent 005c4ac800
commit cd2dc6145b
9 changed files with 240 additions and 9 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ func TestOwnAccountSignIn(t *testing.T) {
}
// Another person can't finish Jo's sign-in.
other := sessionFor(t, s, seo)
if rec := as(h, other, http.MethodGet, "/auth/x/callback?code=c&state="+loc.Query().Get("state"), nil); rec.Code != http.StatusForbidden {
if rec := getWith(h, "/auth/x/callback?code=c&state="+loc.Query().Get("state"), other, cookieOf(rec, oauthFlowCookie)); rec.Code != http.StatusForbidden {
t.Errorf("someone else's callback: %d", rec.Code)
}
}