Repository navigation
api: classified route registry and per-action step-up (§7.5, §7.3 rule 6) - #18
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process: ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪🧪 PR contains tests⚡ No major issues detectedAdvisory only: this comment never gates the pull request. |
Security review - clearedDetail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kyguard-server-18, where it is readable by the operator and expires seven days after the last post. gpt-6.1-sol using security-audit on behalf of Yoshi |
Autonomous review - 1/1 personas cleared
Merging remains a human decision; this bot never approves. gpt-6.1-sol using security-audit on behalf of Yoshi |
Every main-mux route, SCIM's included, now registers through one function with its spec §7.5 class (public, machine, pending, session); session routes get the active-session middleware there. A test fails on any Handle or HandleFunc outside the registry, pins the spec table, and walks every session route with anonymous and pending callers. Backup actions need a step-up within five minutes (spec §7.3 rule 6); an active session refreshes it with a code. Administrators can reset an SSO user's TOTP factor with a fresh code of their own; the user's sessions end and the next sign-in enrolls again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DeleteFactor now holds the same user-row lock as every session issuance, so an exchange authorized by the old factor either commits first and its session is deleted with the rest, or waits and finds the factor gone (security review P2; PostgreSQL race test). A test also pins that an enrolled user's pending session steps up with a code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f46b35c to
915bf7c
Compare
283d936 to
54bd0f2
Compare
|
Security P2 (factor reset vs exchange) fixed in 54bd0f2: |
|
Guide (pending sessions rejected), again at 54bd0f2: not reproduced. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire "Pending sessions rejected" still doesn't reproduce at 62f55c3, which now merges #7's fail-closed sign-in through #17.
|
AuthenticateRequest admits a pending session on /api/auth/stepup/*, so activeSession now refuses any non-active stage itself (403 stepup_required). The step-up handler says why it accepts both stages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merger (saltmarsh-merge): closing and reopening right away so CodeQL runs now that the base is |
Brings #8's broker routes in. server.go: both sides kept. The broker routes now register through the route registry (the TODOs #8 left here): pools and pairing tokens are session routes with the 5-minute step-up window, manifests a session route without one (DECISIONS 16a). requireAuthenticated has no callers left and is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's route registry (#18) removed requireAuthenticated. Reserving and submitting an enrollment need a five-minute step-up (§4.5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's route registry (#18) removed requireAuthenticated. Inventory and attribute writes need a five-minute step-up (decision 206). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…suer main's route registry (#18) refuses routes registered outside it, and main now stores the SSO issuer on the user (§7.2), so a principal is matched by the caller's stored issuer and subject, not only for KySignOn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's route registry (#18) refuses routes registered outside it. Saving and deleting a draft need a five-minute step-up (§7.3 rule 6, decision 212); fetching and signing need none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In one line: Every route is now registered through one classified registry, so an unclassified or stray route fails a test. Backup actions and factor resets need a fresh step-up.
What changed
s.route(class, pattern, handler, opts...)is the only way onto the main mux, SCIM's routes included. The classes arepublic,machine,pendingandsession(spec §7.5 table). Session routes get the active-session middleware (and CSRF for cookies) there.TestEveryRouteIsClassifiedparses the source and fails on anyHandle/HandleFuncoutside the registry, and pins the spec table. A route without a class panics at registration.fresh(StepupWindow)). An active session refreshes it with a code.Review this
internal/api/routes.go: the registry and every class assignment. A wrong class is an auth bypass.internal/api/routes_test.go: the AST check. If it misses a registration style, a route escapes classification.Checked:
go test -raceand the FIPS profile, full suite, SQLite and PostgreSQL 17 at this head. Mutation table below.Not checked: the compose e2e locally (CI only, see #3).
You need to: review. Held unmerged by rule.
§13 Phase 0 checklist: Route registry and classification table (§7.5), plus the per-action step-up of §7.3 rule 6. Acceptance 11.
Detail
Mutation table (each mutation makes the named test fail)
TestRouteWithoutAClassPanicsTestBackupActionsNeedAFreshStepUpmux.HandleFuncin another fileTestEveryRouteIsClassifiedaccount_type = break_glassTestAdminFactorResetNeedsAFreshCodeTestAdminFactorResetNeedsAFreshCodehawthorn ran R1–R5 at the pre-rebase head 25f8da9. Since then the branch moved only by rebasing and by one test change (the reset's wrong code no longer leans on
000000).Checks at 283d936
gofmt,go vet,go build,go test -race -count=1 -p 2 ./...and the same underGODEBUG=fips140=on: SQLite pass (Major, kslot; every K host was busy); PostgreSQL 17 pass (Major, own postgres:17-alpine container). Exit 0 on both.Stack
#1 → #3 → #7 → #17 → #18 (this) → #19.
Review fixes (hawthorn fix-auth)
DeleteFactortakes the same user-row lock as every session issuance. An exchange authorized by the old factor either commits first, and its session is deleted with the rest, or waits and finds the factor gone.AuthenticateRequestadmits pending sessions on/api/auth/stepup/*(pendingAllowed).TestEnrolledUserStepsUpAPendingSessionnow pins that an enrolled user's pending session exchanges with a code.TestFactorResetRacingAnExchangeLeavesNoSessionpendingAllowedadmits only/stepup/enroll*TestEnrolledUserStepsUpAPendingSessionChecked at 54bd0f2: race and FIPS suites on SQLite (k82) and PostgreSQL 17 (k80), exit 0; the factor-reset race also 3/3 on my own PostgreSQL container.
Stack merge (hawthorn fix-auth-3): head 62f55c3 merges
kyguard/stepup(plain merge commit, no rebase), so this PR carries #7's fail-closed SSO sign-in (9220dd7) and every fix below it. The only conflicts were indocs/DECISIONS.md, and both sides were kept. Go vet passes at this head; CI runs the suites.Round 4 (hawthorn): Guide "Pending Authentication"
activeSessionnow refuses any session whose stage is notactive, answering 403stepup_required(d737ccf). It no longer relies onAuthenticateRequest's path list alone. That list admits pending sessions on/api/auth/stepup/*by design, which is howhandleStepupTOTPserves a pending session; the handler now says so in a comment. A session-class route is therefore unreachable before step-up whatever its path./api/auth/stepup/totpstill admits a pending session, so an enrolled SSO user still completes sign-in.TestEnrolledUserStepsUpAPendingSessionandTestOIDCSignInStepsUpToActivepass at this head.activeSessionTestSessionClassChecksTheStageOnStepUpPaths(a session route registered under/api/auth/stepup/)Also merges
kyguard/stepup(main, and #17's web fix).Round 4b (hawthorn): main merged; broker routes classified
origin/main, which now has Broker listener, CA and pairing (§4.1) #8's broker routes. Broker listener, CA and pairing (§4.1) #8 registered them withs.mux.HandleFuncunderTODO(hawthorn §7.5). They now go through the registry, andTestEveryRouteIsClassifiedwould fail on the raw calls:POST /api/broker-poolsandPOST /api/broker-pools/{id}/pairing-tokens: session routes with the 5-minute step-up window (§7.3 rule 6: broker and pairing actions).POST /api/manifests: a session route with no window. Rule 6 does not list it, and the Custodian signatures are what authorize it (DECISIONS 16a).requireAuthenticatedhas no callers left and is removed.TestSessionRoutesRefusePendingSessionsnow walks the three broker routes too.fresh(StepupWindow)fromPOST /api/broker-poolsTestBrokerRoutesAreClassifiedWithTheirWindowsChecks: race + FIPS on SQLite and PostgreSQL 17, at the bottom (#18 @ bd2fb58: SQLite k81 exit 0, PostgreSQL own container exit 0) and the top (#28 @ 0cb6d83: SQLite k82 exit 0, PostgreSQL own container exit 0). Affected packages were also run at this head on k82.
🤖 Generated with Claude Code