operator-files: reproduce and harden the forward_auth /authz/gate leak (infra follow-up of #1679) #1680
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#1680
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
What this covers
Split from #1679, which diagnosed a
forward_authgate leak: on drive20260921T023204Zthe files-host front door handed the Nextcloud upstream the gate's own rewritten path (GET /authz/gate, query preserved) instead of the browser's original path, for a 7-second window (16 hits, 03:17:21–03:17:27). Every gated request 404'd — member and operator alike. #1679 fixed the harness false-negative (themember-filesleg now reads a bare 404 as a gate/infra fault, not a member privilege escalation —readMemberAdminDenial→gate-fault,app/tests/e2e/fixtures/provision.ts). This ticket carries the remaining infra work #1679 named but could not do without a live box:files.<apex>with a live session under concurrency and watch the service's own access log for/authz/gate. 16 hits in 7 s off a couple of page loads points at a load- or connection-reuse-triggered race. Needsclan-lab.forward_authsuccess path (internal/clan/frontdoor.go), or make the service upstream refuse/authz/gateloudly. Today the leak is only visible because Nextcloud happens to 404. This touches production front-door config on a trigger that #1679 established only by inference (nothing in the journal marks 03:17:21), so it must be reproduced first, not changed blind.docs/GOTCHAS.mdentry once reproduced — it sits beside #30 and #135 (bothforward_auth-eats-a-request hazards) but is a distinct failure: the gate's own path reaching the upstream.Why split
#1679 was the drive's reported red — a false SECURITY breach on
member-files. That is fixed and shipped (the leg no longer cries privilege escalation on a front-door hiccup). The above is a distinct, lab-backed spike + a production front-door config change gated on reproduction; bundling it into #1679 would have shipped an unproven production Caddy change on an inferred trigger.Context from the #1672 babysitting session (no user authority): reproduce and diagnose freely, but any change to the forward_auth block, to what the gate admits, or to how it fails open/closed goes to Ben BEFORE it lands (sign-in trust) — route the proposed change
ready-for-humanwith the evidence. The read-only evidence from the kept box is on #1672 (Caddy access log vs Nextcloud nginx log for 03:17:22–27Z; kanidm restarting, Caddy not reloaded, control plane not restarted).Ruled by agent under ADR 0174 — veto anytime
Ruling: category
bug(already applied), state →ready-for-session. The forward_auth/gate hardening (item 2) remains Ben-gated and is untouched by this ruling.Why this state. The ticket's next actionable step is a clan-lab reproduction: drive a gated path on
files.<apex>under concurrency, watch the service access log for/authz/gate, and harvest the Caddy access log (items 1 and 3). That needs an interactive session's live-droplet standing — not a swarm worker (the queue reads onlyready-for-agent), and not Ben yet, because there is no proposed change to review until the leak is reproduced. Under ADR 0174 rule 5 this is exactly the "blocked on a session, not on Ben" caseready-for-sessionexists to stop conflating withready-for-human.The Ben gate is preserved, not overridden. Per Ben's 2026-09-21T05:03 comment, any change to the forward_auth block, to what the gate admits, or to how it fails open/closed is sign-in trust and goes to Ben BEFORE it lands. That is a genuine one-way door (security-posture change + a member-facing trust surface — both on ADR 0174's one-way-door list). So the flow is: a session reproduces (items 1, 3), then routes the proposed item-2 hardening + evidence to
ready-for-humanfor Ben. This ruling does not authorize the config change; it only places the ticket at its true current bottleneck.Why this is a two-way door. It is a label choice, reverted by a single re-label, and provable by the reproduction drive itself (the leak reproduces → session step was real; it doesn't → re-scope). It touches no one-way door: no credentials, no posture widening, no trust accept, no data loss, no spend — and it explicitly keeps Ben's gate on the only trust-critical part.
What proves it. The clan-lab reproduction drive + the harvested Caddy access log showing (or not) the
/authz/gatehits, against the read-only evidence already on #1672 (Caddy vs Nextcloud nginx logs for 03:17:22–27Z; kanidm restarting, Caddy not reloaded, control plane not restarted).Brief for the session
files.<apex>, live session, under concurrency/connection-reuse; watch the upstream access log forGET /authz/gate(16 hits in 7s off a couple of page loads → load-/reuse-triggered race). Needsclan-lab.internal/clan/frontdoor.go— restore the original URI on theforward_authsuccess path, or make the upstream refuse/authz/gateloudly) and route itready-for-humanwith the evidence. Do not land it from a session.docs/GOTCHAS.mdentry once reproduced — beside #30 and #135, distinct: the gate's own path reaching the upstream.Ruled by agent under ADR 0174 — veto anytime
Session on
matou-workstationdrainingready-for-session. Landed item 3 (the two-way half); routed item 2 (the Ben-gated hardening) to you with a diagnosis + a proposed default. Items 1 and 4 ride your chosen fix's validation drive.Landed this session — item 3, the Caddy access log (two-way, offline-proven)
Commit
672a61a4(front door: #1680 — the front door LOGS every request…).The gap #1679 named was exact: the front-door render logged NOTHING per-request, so your fire-1 diagnosis of the leak could only be done because you pulled the Caddy access log BY HAND off the kept box — the front door's own view of the 16
/authz/gatehits died with the box.renderCaddyAccessLog(internal/clan/frontdoor.go) adds a site-levellog { output stderr; format json }to both the public and private renders. Caddy's access log now lands in the caddy unit journal every drive already harvests (journalctl -u caddy), so a future URI leak is a harvested artifact, not something someone has to think to keep a box for. JSON so the harvest is greppable; Caddy redacts Cookie/Authorization by default.guest-caddycollector (app/tests/e2e/fixtures/evidence.ts) now reads the whole boot (-b), not a-n 200tail — a leak window is mid-drive, so a fixed tail (now access-log lines) would evict exactly the window that matters (#1646 precedent). The rented path already captures the full caddy journal.TestRenderFrontDoor_LogsEveryRequestForHarvest(public + private);internal/clan+internal/provision+ evidence vitest green; gofmt/go vet clean; eslint clean (pre-push hook).This records only — it does not touch the forward_auth block, what the gate admits, or how it fails open/closed, so it sits outside your sign-in-trust gate. One trade-off for your awareness: the access log records the request URI in full, including its query — so a short-lived OAuth code (
id.<apex>callback) or per-open WOPI token (files.<apex>, ADR 0258) lands in the gateway's own journal. Both are single-use and spent by the time a harvest is read, and it is the same class of data the co-hosted service's own access log already records; a path-scoped query redaction is a cheap follow-up if you want it.Item 2 — the forward_auth hardening — is yours (
## Why humanbelow)Diagnosis, from your fire-1 evidence + the code. During
panel-apply'sswitch-to-configuration(03:17:09–15Z) kanidm was stopped and restarted at 03:17:11; Caddy was NOT reloaded and the control plane NOT restarted. In that ~7 s window the gate — which needs kanidm to resolve the session — did not answer its clean 401, and forward_auth's rewritten subrequest URI (/authz/gate) reached the Files upstream instead of the browser's original path. It is quiet only because Nextcloud happens to 404 it. Both front-door suspects you named are in the run-8 (a6d0dd55) → red (ebe5da4f) range:f31be6e2(#1651, the site-levelhandle_errors 502 503 504on the*.<apex>site) andce479c6a(the apex space-ID door). #1672 fire 2 re-drove GREEN 36/36 — the leak did not recur, confirming it is a race, not a deterministic regression.Proposed default (my recommendation): the loud-refuse guard. Add to the service route (
renderRoute), BEFORE the reverse_proxy, a guard that matches the gate's own path (/authz/gate) and responds LOUDLY (a distinctive status + body naming #1680) instead of proxying it to the upstream. Rationale:/authz/*is the gate's own namespace — no legitimate client request to a service ever carries it, so a service route seeing/authz/gateis ALWAYS this leak. Today it masquerades as a normal 404; a loud refuse turns every future occurrence into an unmistakable, harvested signal (now visible in the access log landed above). It does not touch forward_auth, what the gate admits, or fail-open/closed; it is purely additive and revertible. This makes the leak self-announcing while the root-cause race is fixed.The deeper root cause is also yours. What the gate answers while kanidm restarts (per your note, "the first thing to look at"), and whether #1651's site-level
handle_errorscatches a forward_auth 5xx subrequest and leaks the un-restored URI onward, are both sign-in-trust / fail-open-closed questions. The ticket's option A (restore the original URI explicitly on the forward_auth success path) touches every gated route's template and, since the trigger is a non-2xx gate answer, may not address the racing case — I did not build it.Items 1 and 4
Item 1 (a controlled reproduction — trigger a
panel-applydeploy, which restarts kanidm, while hammering a gatedfiles.<apex>path, and watch the now-harvested Caddy access log vs the Nextcloud upstream log for the discrepancy) and item 4 (the GOTCHAS entry beside #30/#135, once the cause is confirmed) belong to your chosen fix's validation drive. I did not spin up clan-lab this session: fire 1 already reproduced it once, fire 2 did not recur, and a one-shot session cannot reliably catch a race nor leave a drive running past its final message (ADR 0174 rule 7). The access log landed here is the reproduction infrastructure that #1679's gap named — the next occurrence documents itself.Why this is a two-way door (item 3): revertible config + one harness collector, proven offline by the render test + evidence vitest, no posture widening (an internal access log on the box's own journal), and it keeps your gate on the only trust-critical part untouched.
Why human
Item 2 — the
forward_auth/ gate hardening — is sign-in trust (your 2026-09-21T05:03 comment: any change to the forward_auth block, to what the gate admits, or to how it fails open/closed goes to you before it lands). That is ADR 0174's one-way door (security-posture + member-facing trust). The proposed default above (the loud-refuse guard) is ready for you to adopt or veto; the root-cause race fix is your ruling. Item 3 is landed and needs nothing from you.Gate-probe drive #1686 — GREEN 37/37 (
20260921T133805Z,5b910ef3). Evidence:artifacts/gate-probe.json,gate-probe-box-views.txt.No fail-open observed. 384 session-less requests to
/apps/files/onfiles.<apex>, one per 150 ms, from 14:21:48Z to 14:22:50Z — across panel-apply's redeploy and a 25 s tail. kanidm stopped at 14:22:20 and was serving again at 14:22:22. Every sample:302to/authz/signinwithServer: Caddy, slowest 97 ms. None answered by the service, none a 5xx — the gate refuses a session-less caller without needing kanidm.The leak did not reproduce. Nextcloud's nginx received ZERO
/authz/requests in the whole run (door legs included). With #1672 fire 2 that is two clean runs of the same deploy sequence against one leaking run (fire 1), so it is rarer than "every kanidm restart" and the cause is still unknown. In fire 1 the leak began ~10 s AFTER kanidm was back and one second after the operator's fresh OIDC sign-in, so "kanidm down" was probably never the trigger.The probe's signed-in half was blind this run — all 384 signed-in samples were bounced to sign-in: the panel browser's session lives on the apex, and the service-host gate cookie is only minted on a first visit the probe never made. Fixed in
4bba74b7(it walks the redirect once, baselines, and reportssignedInLive). So this run says nothing either way about what a signed-in caller saw; nginx's empty/authz/log is what rules the leak out.Still Ben's: the loud-refuse guard. No gate change has landed.
Ben ruled (in session, 2026-09-21): land the loud-refuse guard. Landed as
8ed48eb9: every SERVICE route answers/authz/*with 421 between forward_auth and the proxy (renderGateLeakGuard); the control panel's routes carry none. Render-tested, and validated with real caddy 2.11.4 —caddy validatepasses, adapted handler order is gate → 421 → proxy. GOTCHAS #306. Live-unproven (it only fires if the leak recurs): grep a drive's harvested Caddy journal for"status":421.Still open here: the ROOT CAUSE of the URI leak (unreproduced; #1686's findings above). What the gate admits and how it fails are unchanged — any change there still goes to Ben first. The gate probe (
IDSS_GATE_PROBE=1, signed-in channel fixed in4bba74b7) can ride any roles-proof drive to catch a leaking run with both channels live.Closed 2026-10-21 (Ben's ruling): folded into the drive checklist #2055 — the live proof this ticket still owed is now a checklist item there, to be carried by the next drives on the latest versions. A proof that fails on the drive becomes a NEW ticket; this one is not reopened.