fix(api-auth): M8 audit batch 2 — email_verified fail-closed, wallet replay bound, OIDC replay gaps (#214) #217
No reviewers
Labels
No labels
epic
phase-0
phase-1
phase-2
phase-3
phase-4
phase-5
phase-6
phase-7
phase-8
phase-9
priority/P0
priority/P1
priority/P2
type/backend
type/client
type/docs
type/ops
type/security
type/spike
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/failsulit!217
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/m8-api-auth"
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?
M8-close audit remediation batch 2 (#214 findings M8-2, M8-17, M8-18a/b/c).
M8-2 (account takeover): OidcTokenValidator treated a MISSING email_verified claim as verified (
!= "false"); IDA-09 requires reject-unless-true. Validator now fails closed; OidcCallback and OidcVerify reject unverified emails uniformly (audit event + 401) before email auto-linking; provisioning carries the real claim. FakeIdpServer mirrors real providers (always emits email_verified + iat).M8-17 (replay + lockout amplifier): PostgresSessionStore gains a per-account session cap (
Ssdid:Sessions:MaxPerAccount, default 10) with newest-wins eviction — a replay loop can no longer ride the GLOBAL MaxSessions cap into a platform-wide 503, and the real user's next login evicts an attacker's oldest session. Residual (documented): the frozen wallet VC does not sign the login challenge — challenge-bound signing lands with the wallet-flow rework.M8-18a: ConsumeChallenge deletes conditioned on the stored challenge value and requires the affected-row count — two concurrent consumers can no longer both win.
M8-18b: /oidc/verify rejects id_tokens with iat older than 5 minutes (leaked-token replay bound; no client change needed). OidcClaims gains IssuedAt (parsed from iat).
M8-18c: the PKCE verifier no longer rides the signed state through the browser (authorize redirect → callback carried verifier + code in clear to an interceptor). It is stored server-side in SessionChallenges keyed by the state nonce and consumed atomically at the callback; both authorize endpoints store it before redirecting; ChallengeTtlMinutes raised to 10 to match the state TTL.
Tests: OidcVerifyInvariants +2 (unverified rejected, stale rejected); BootstrapGateTests remain green; full suite 1084 green + coverage gate 87.61% ≥ 80% in Release.
Part of the M8-close FIX-ALL (umbrella #215, audit #214).