Repository navigation
auth: pending SSO sessions and TOTP step-up (§7.3) - #17
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 detected
Advisory 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-17, where it is readable by the operator and expires seven days after the last post.
claude-opus-5-5 using security-audit on behalf of Yoshi |
Autonomous review - 1/1 personas cleared
Merging remains a human decision; this bot never approves. claude-opus-5-5 using security-audit on behalf of Yoshi |
Every SSO callback now issues a five-minute pending session bound to the login (issuer, sid, original iat, IdP MFA assertion) that authenticates only /api/auth/me, logout and /api/auth/stepup/*; all else is 403 stepup_required and settings stay public (spec §7.3). POST /api/auth/stepup/totp exchanges it, in one transaction holding the user row, for a new 12-hour active session with a new token and the same binding, then re-checks the logout fences after commit. A user without a factor may enroll one (enroll, enroll/confirm) only if the ID token asserted MFA; otherwise the block is audited. Codes share the break-glass limits: five per pending session, ten per user per 15 minutes. The web shell shows a step-up screen. 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>
Computing it again could land on the next TOTP step and turn the replay into a fresh code (PR Reviewer Guide). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f46b35c to
915bf7c
Compare
|
Guide (flaky replay test) fixed in 915bf7c: |
An SSO callback now issues only a pending session that lasts five minutes. The session middleware refuses a pending session everywhere except who-am-I and logout, so SSO users can do nothing else until the TOTP step-up exchange (#17) lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d/stepup #7 (9220dd7) made the SSO callback issue a pending session that only who-am-I and logout accept. Conflicts resolved in favour of stepup: IssuePendingSession, ExchangePending and pendingAllowed with /api/auth/stepup/* stay. #7's IssueSSOSession, which stepup no longer calls and which would issue an active SSO session here, is dropped. TestOIDCSignInIsPendingUntilStepUp now expects stepup's 403 stepup_required instead of #7's 401. New TestOIDCSignInStepsUpToActive signs in through the generic OIDC routes, enrolls on the pending session, then steps up again with a code, both through to an active session (the #7 Guide note's integration test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the code exchange succeeds but reading /api/auth/me fails, StepUp no longer leaves the code form up (a second code gets "already stepped up"): it says the user is signed in and offers Try again, which only reloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The blocked screen claimed "An administrator has been notified" without calling the enroll route, the only path that records auth.enrollment_blocked (spec §7.3 rule 3). It now posts to it once and shows the claim only on its 403; otherwise it asks the user to sign in again or contact an administrator. web/dist rebuilt (Node 26.13.1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings #17's blocked-enrollment notification fix up. web/dist rebuilt from the merged sources with Node 26.13.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In one line: Every SSO sign-in now stops at a five-minute pending session until the user enters a TOTP code. The code exchanges it for a new 12-hour session.
What changed
iat, the IdP's MFA assertion). It authenticates onlyGET /api/auth/me, logout and/api/auth/stepup/*. Everything else answers 403stepup_required, and/api/settingsshows it only the public payload.POST /api/auth/stepup/totpdeletes the pending session and issues a new active one (new token, 12 h,stepup_atset, same binding) in one transaction. It then re-checks both logout fences after commit.enroll/enroll/confirmwork only if the ID token asserted MFA. Otherwise the answer is 403 and anauth.enrollment_blockedaudit event.000000wrong code with one that matches no nearby step (same flake as the auth: break-glass accounts with mandatory TOTP #3 Guide finding).Review this
internal/api/stepup_handlers.go: the exchange. A pending token must never become active, and the fence re-check must run after commit.internal/store/sqlstore.goExchangePendingSession: the transaction that holds the user row while deleting the pending session and inserting the active one.web/dist(generated; CI checks it is current).Checked:
go test -raceand the FIPS profile, full suite, SQLite and PostgreSQL 17 at this head (details below). Every security property has a mutation that fails its test (table below).Not checked:
e2e/compose_test.golocally: Major's Docker address pool is exhausted, so it runs in CI only.You need to: review. Held unmerged by rule.
§13 Phase 0 checklist:
mfa_factors, pending sessions, enrollment rule, TOTP exchange, attempt limits, per-action step-up (§7.3) (per-action windows are in the next PR). Acceptance 4, 5, 6, 7 (TOTP half; the CLI half comes with §7.6).Detail
Mutation table (each mutation makes the named test fail)
TestSSOSignInIsPendingUntilStepUpTestSSOSignInIsPendingUntilStepUpTestEnrollmentNeedsIdPMFATestStepUpCodeLimitsTestSSOSignInIsPendingUntilStepUpiatis keptTestSubjectLogoutUsesTheOriginalIatTestLogoutRacingStepUpLeavesNoActiveSession(PostgreSQL),TestLogoutBeforeStepUpEndsTheSignInhawthorn ran S1–S7 at the pre-rebase head b31d536. Since then this branch has moved only by rebasing onto the #3/#7 fixes and by the wrong-code test helper; the code under test is unchanged.
Checks at f46b35c
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 (this) → #18 → #19.
Review fixes (hawthorn fix-auth)
enrollCode), not one computed again, which could land on the next step.TestStepUpCodeLimitsChecked at 915bf7c: race and FIPS suites on SQLite (Major) and PostgreSQL 17 (Major, own container), exit 0.
Merge of #7's fix (hawthorn fix-auth-3)
kyguard/sso-identityat 9220dd7, sso: identity by (issuer, subject); fresh, per-app sign-in #7's fail-closed SSO sign-in. Conflicts were resolved in favour of this PR:IssuePendingSession,ExchangePendingandpendingAllowed, with/api/auth/stepup/*, stay. sso: identity by (issuer, subject); fresh, per-app sign-in #7'sIssueSSOSessionis removed, because nothing here calls it and it would issue an active SSO session.TestOIDCSignInIsPendingUntilStepUpis kept. Its only change: refused routes now expect this PR's 403stepup_requiredinstead of sso: identity by (issuer, subject); fresh, per-app sign-in #7's 401.TestOIDCSignInStepsUpToActive(the sso: identity by (issuer, subject); fresh, per-app sign-in #7 Guide's "Blocked step-up" note) signs in through the generic OIDC routes. The pending session enrolls a first factor and becomes active. A second sign-in steps up with a code. Both end on an active session that reaches an admin route, and the pending token is dead./api/auth/stepup/frompendingAllowedTestOIDCSignInStepsUpToActive(enroll: 401)IssuePendingSessionstoresstage=activeTestOIDCSignInIsPendingUntilStepUp,TestOIDCSignInStepsUpToActiveChecks at this head: gofmt, vet,
go test -race -count=1 -p 2 ./...and the same underGODEBUG=fips140=on: SQLite pass, 14/14 packages (Major, kslot; every K host was busy); PostgreSQL 17 pass (Major, own postgres:17-alpine container), exit 0.make notes-checkpasses.Round 4 (hawthorn): main merged, Guide "Recovery Deadlock" fixed
kyguard/sso-identityat 0975542, which mergesorigin/main(auth: break-glass accounts with mandatory TOTP #3–kyguard-cli: init, trust, import, enroll and sign (§3.2) #6 and the badge fix). There were no conflicts here.StepUpstops showing the code form. If the follow-up/api/auth/meread fails,App'sonDonenow rejects, andStepUpsays the user is signed in and offers Try again. That button only reloads the session and never sends a second code. A definiteauthenticated: falsereturns to sign-in.web/distis rebuilt with Node 26.13.1 (58ddf66).StepUp.tsx(callsonDone()and keeps the code form)StepUp.test.tsx"retries only the session load after an accepted code"Unable to find role="alert")Checks: web unit 44/44 and build (Node 26.13.1) at 58ddf66. Go race + FIPS ran at the bottom (#7 @ 0975542) and the top (#28) of the stack; see #28.
Round 4b (hawthorn): Guide "Missing notification"
POST /api/auth/stepup/enroll. That 403 is the only path that recordsauth.enrollment_blocked(spec §7.3 rule 3). The screen says "An administrator has been notified" only after the server answers 403. On any other answer or a network failure it says to sign in again or contact an administrator.web/distis rebuilt with Node 26.13.1.StepUp.tsx(claims it without calling the route)Checks at ca43ea9: web unit 45/45 and build (Node 26.13.1). Go race + FIPS at ca43ea9: SQLite pass (k82, exit 0), PostgreSQL 17 pass (Major, own postgres:17-alpine container, exit 0).
🤖 Generated with Claude Code