v0.6.353: bind single sign-on to the browser, refuse cross-origin requests (#999) #1000

Merged
Cordy merged 5 commits from fix-999 into main 2026-10-24 21:10:26 +00:00
Owner

Fixes #999 (login CSRF).

  • OIDC: every sign-in and Sign in again is bound to the browser that started it, with a per-flow cookie (HttpOnly, Lax, 10 min; __Host-/Secure on https). A return without the cookie is refused. Two tabs work.
  • http.CrossOriginProtection around the main handler for unsafe methods. This covers the password sign-in CSRF (a cross-site text/plain form produced valid JSON) and logout CSRF. Header-less clients are unaffected.
  • A sign-in started on another host moves to the callback host. A moved=1 marker breaks the loop behind Host-rewriting proxies, with an hourly WARN. A foreign Host is cut to 256 bytes for the limiter and the log.
  • Docs: deployment.md "Keep the Host header, serve one scheme"; CHANGELOG v0.6.353; chart appVersion.

Reviews: .superpowers/sdd/2026-10-25-999/review.md (initial review plus re-review; S1 and S2 fixed, N7 fixed, nits documented).

Fixes #999 (login CSRF). - OIDC: every sign-in and Sign in again is bound to the browser that started it, with a per-flow cookie (`HttpOnly`, `Lax`, 10 min; `__Host-`/`Secure` on https). A return without the cookie is refused. Two tabs work. - `http.CrossOriginProtection` around the main handler for unsafe methods. This covers the password sign-in CSRF (a cross-site `text/plain` form produced valid JSON) and logout CSRF. Header-less clients are unaffected. - A sign-in started on another host moves to the callback host. A `moved=1` marker breaks the loop behind Host-rewriting proxies, with an hourly WARN. A foreign Host is cut to 256 bytes for the limiter and the log. - Docs: deployment.md "Keep the Host header, serve one scheme"; CHANGELOG v0.6.353; chart appVersion. Reviews: `.superpowers/sdd/2026-10-25-999/review.md` (initial review plus re-review; S1 and S2 fixed, N7 fixed, nits documented).
- oidclib: BeginAuth sets a per-flow binding cookie (cairn_oidc_<16 hex of
  SHA-256(state)>, __Host- and Secure on https by the session cookie's rule,
  HttpOnly, SameSite=Lax, Path=/, Max-Age 600); the state entry keeps only
  SHA-256 of its value. HandleCallback consumes the state, then requires the
  cookie (constant-time compare), refusing like an unknown state with a WARN;
  the cookie is cleared in every outcome. auth.trustedProxies reaches the flow.
- cairnd: http.CrossOriginProtection in the outer chain (after logging and
  metrics, before gRPC routing, authentication and any body read): 403
  cross-origin with a WARN at most once per path per minute. Requests without
  Sec-Fetch-Site/Origin (WebDAV, servers, CLI) and safe methods pass.
- Tests: red first (a callback without the cookie signed in; a cross-site
  text/plain form signed in to /auth/password).
Cordy merged commit 8b54afdf9e into main 2026-10-24 21:10:26 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#1000
No description provided.