Make every cookie host-only: __Host- names, Secure, Path=/ #11
Loading…
Reference in a new issue
No description provided.
Delete branch "heimdall/host-only-cookies"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Makes every cookie Bifrost sets host-only:
__Host-name,Secure,Path=/, noDomain.HttpOnlyandSameSiteare unchanged.Reason. The preview host is same-site with the production host. A sibling subdomain of gamecult.org can set a
Domain=gamecult.orgcookie with the same name and shadow ours (cookie tossing / session fixation). Browsers refuse a__Host-cookie that arrives with a Domain, so the planted cookie never replaces ours..AspNetCore.Cookies__Host-bifrost_session, Secure always, Path=/.AspNetCore.Correlation.*__Host-bifrost_oauth_correlation.*, Secure, Path=/.AspNetCore.Antiforgery.*__Host-bifrost_antiforgery(not in the brief; it is a cookie Razor Pages sets, so it follows the same rule)bifrost_voter, Path=/mill__Host-bifrost_voter, Path=/bifrost_heimdall_0/1, Path=/auth/heimdall__Host-bifrost_heimdall_0/1, Path=/Names live in one place,
Features/Shared/BifrostCookies.cs; every reader, writer and test uses it.Cost.
__Host-forbids a narrower Path, so the voter and attempt cookies are now sent on every request to the host, not only/milland/auth/heimdall. Both are HttpOnly, Secure and protected values; the attempt ring is still capped at two cookies (~2.4 KB worst case) so the Cookie header stays inside nginx's limit.Tests. New
CookieHardeningTestspins the literal names,Secure,Path=/and no Domain for each cookie, and checks realSet-Cookieheaders for the voter and attempt cookies (including deletion). I removed each guard in turn and the tests failed, with one exception:CorrelationCookie.SecurePolicyis alreadyAlwaysby framework default, so that explicit line pins behaviour rather than changing it. Existing voter and Heimdall tests now read the shared constants and expectpath=/.Suite on this host (a .NET 8 target run on the only installed runtime, .NET 10, via roll-forward): 508 pass, 38 fail. The same 38 fail on unmodified main (BridgeCli, ConceptTallyExport, OidcIssuer, ProviderAdvertisement, one ConceptVoteRateLimit); none touch cookies. Worth a clean CI run on the proper runtime before merge.
Deploy. Not deployed. It waits on the Bifrost lag.
🤖 Generated with Claude Code