fix(identity): M2 identity-surface P1 batch — TOTP enumeration, register/verify ordering, decrypt 401s, wallet admin MFA (#110 items 4/5/7/8) #114
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!114
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/identity-p1-batch"
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?
M2 identity-surface P1 batch from the M1.5 close audit (#110, umbrella #101). Four fixes:
A — TOTP verify enumeration closed (TotpVerify.cs): unknown email / known-without-TOTP / known-with-TOTP now produce indistinguishable 401s (was: 400 'TOTP is not set up' censused accounts + mapped TOTP enrollment).
B — EmailRegisterVerify hardened: invitation validated BEFORE the OTP consumption (a wrong invitation no longer burns the victim's pending code — each burn was an unthrottled, unaudited kill of their onboarding; the response flipped 401→404 when a guess landed, confirming the code). Plus RequireRateLimiting('auth-otp') — it was the only public verify endpoint with no partition.
C — TOTP decrypt exceptions degrade to 401 + audit (security.totp_decrypt_failed): corrupt/rotated encryption material was an unhandled 500 = silent TOTP-population lockout with zero telemetry.
D — wallet sign-in applies the admin MFA gate (Authenticate.cs): a TOTP-enabled admin signing in via wallet now mints an mfa-pending session, never a full one — mirroring OidcVerify/OidcCallback.
Verification
TDD: 5 tests first — RED ×3 (enumeration, decrypt 500, OTP burn; 2 passed as controls). One pre-existing test updated (SameCodeSecondTime now expects any 4xx on replay — invitation state surfaces pre-OTP by design).
Suite 919 / 0 failed / 39 skipped (Release ×2 + Debug) · coverage gate 86.38% ≥ 80
A — TOTP verify enumeration closed (TotpVerify.cs:40-44): unknown email, known-without-TOTP, and known-with-TOTP now produce indistinguishable 401s (was: 400 'TOTP is not set up' censused accounts + mapped TOTP enrollment for phishing targets). Test asserts stable fields only (trace_id is per-request). B — EmailRegisterVerify hardened (EmailRegisterVerify.cs): - RequireRateLimiting('auth-otp') added — it was the only public verify endpoint with no partition - invitation validated BEFORE the OTP consumption — a wrong invitation no longer burns the victim's pending code (each burn was an unthrottled, unaudited kill of their onboarding; response flipped 401→404 the moment a guess landed, confirming the code) - Existing SameCodeSecondTime test updated: a spent invitation now surfaces as 404 pre-OTP — either way reuse fails, seat not granted C — TOTP decrypt/backup-code exceptions degrade to 401 + audit (security.totp_decrypt_failed) instead of unhandled 500: a rotated/ corrupt encryption key was a silent TOTP-population lockout with no telemetry. D — wallet sign-in applies the admin MFA gate (Authenticate.cs): a TOTP-enabled admin signing in via wallet now mints an mfa-pending session (never a full one), mirroring OidcVerify/OidcCallback. Wallet authenticate response gains mfa_required. Also: Authenticate handler takes ISessionStore for the mfa session mint. TDD: 5 tests first — RED ×3 (enumeration, decrypt 500, OTP burn) + 2 passed naturally (membership-count control). Suite 919 / 0 failed / 39 skipped (Release ×2 + Debug); gate 86.38% ≥ 80.