Repository navigation
auth: kyguard-cli login, server side (§7.6) - #27
Conversation
Spec §7.6: an SSO login started with cli_port and an S256 cli_challenge ends at the callback with no browser session. Instead a one-time code, valid 60 seconds and bound to the verified login (issuer, sid, original iat, MFA assertion), goes to http://127.0.0.1:<port>/cb. POST /api/auth/cli/exchange spends the code on its first attempt, checks the verifier and issues a pending session as a bearer token; CreateSession re-checks both fences after commit. Step-up over bearer returns the active token in the body, never to cookie callers. cli_login_codes (migration 17) is in migrationTables, expired codes are cleaned with expired sessions, and restore already deletes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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-27, 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 |
Security review P2: a CLI code issued before a TOTP reset could still buy a pending session carrying the old MFA assertion. DeleteFactor now deletes the user's codes first in its transaction, and redemption spends the code and inserts its session in one transaction, so the code row orders the two (sequential and PostgreSQL race tests). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Security P2 (CLI codes survive a factor reset) fixed in 90db0d5: |
…-login Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picks up the stack's merge commits as pushed. No content change. 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>
Migration 17 (cli_login_codes) stays; migration 16 is gone (#25 moved the intents table to migration 200). migrate_postgres keeps both lists. 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 |
In one line:
kyguard-cli loginhas its server side. An SSO login started by the CLI hands a 60-second one-time code to the CLI's loopback listener, and the CLI trades it for a pending session to step up in the terminal.What changed
/api/sso/{kysignon,oidc}/logintakes optionalcli_port(1024–65535) andcli_challenge(S256). They ride with the SSO state in a short-lived cookie.cli_login_codes), valid 60 seconds and bound to the verified login (issuer, sid, originaliat, MFA assertion) and the challenge, and redirects tohttp://127.0.0.1:<port>/cb?code=….POST /api/auth/cli/exchange(public, spec §7.5 table) spends the code on its first attempt, even a wrong one, then checks the verifier. It returns a pending session as a bearer token.CreateSessionre-checks both logout fences after commit./api/auth/stepup/totp,/enroll/confirm) returns the new active token in the body. Cookie callers never get it in the body.Review this
internal/api/cli_login.go: parameter checks, code issuance and redemption. The verifier compare and spend-on-first-attempt are the security core.internal/store/sqlstore.goTakeCLICode: the atomicDELETE … RETURNINGthat makes a code single-use.internal/api/stepup_handlers.goexchanged: the only place a session token goes into a response body.Checked: full suite with
-race, plus the FIPS profile, on SQLite (k83) and PostgreSQL 17 (k82) at ecb2439, exit 0. All 6 mutations fail their tests; the concurrent fence test fails on PostgreSQL without the re-check.Not checked: the CLI side. It is juniper's
internal/cli.Clienton the other stack (#6), and wiring it is a join task.Decided for you: loopback only on
127.0.0.1with ports from 1024; a wrong verifier burns the code (DECISIONS 19g).Review fix (90db0d5): a factor reset deletes the user's outstanding CLI codes first, and redemption spends the code and inserts its session in one transaction, so a pre-reset code redeems nothing (security P2). Checked at 90db0d5: race and FIPS suites on SQLite (k80) and PostgreSQL 17 (Major, own container), exit 0.
You need to: review. Held unmerged by rule.
§13 Phase 0 checklist: Route registry and classification table (§7.5); CLI login (§7.6): the CLI-login half, server side. Acceptance 7, the CLI-redemption clauses (sequential and concurrent).
Detail
Mutation table (each mutation makes the named test fail)
TestCLILoginHandsAPendingSessionToTheCLITestLogoutBeforeCLIRedemptionEndsTheSignIn;TestLogoutRacingCLIRedemptionLeavesNoSessionon PostgreSQL (3/3 runs)expires_atTestExpiredCLICodeIsRefusedTestCLILoginHandsAPendingSessionToTheCLITestBrowserExchangeNeverReturnsTheTokenTestCLILoginHandsAPendingSessionToTheCLITestFactorResetVoidsOutstandingCLICodes(200);TestFactorResetRacingCLIRedemptionLeavesNoSessionon PostgreSQL (round 0)Stack
#1 → #3 → #7 → #17 → #18 → #19 → #25 → #26 → this.
Stack merge (hawthorn fix-auth-3): head 30cdac4 merges
kyguard/restore(plain merge commits, no rebase; 87a06d9 merged it first, and 30cdac4 adds a content-free merge of the pushed commit below), 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): stack merged up from main
kyguard/restore, which carries main with Broker listener, CA and pairing (§4.1) #8 and backup: durable intents for pairing, pin and deposit (§9.3) #25's migration change. Migration 17 (cli_login_codes) stays, and migration 16 is gone (backup: durable intents for pairing, pin and deposit (§9.3) #25 moved the intents table to migration 200).migrate_postgres.gokeeps both table lists.Checks: 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