M1-audit: abandoned first-run bootstrap permanently bricks SuperAdmin setup #91

Closed
opened 2026-11-07 08:40:56 +01:00 by amiryahaya · 1 comment
Owner

Bootstrap setup creates an Active SuperAdmin candidate (Bootstrap.cs:81-92) with no expiry; setup then 403s forever (guard 67-70), confirm 401s without the secret, and /status reports required=false (42-45).

Trigger: operator closes the tab before scanning the TOTP QR → setup is dead; only DB surgery recovers a fresh install.

Fix: when no TotpEnabled SuperAdmin exists, allow setup to re-issue (overwrite the candidate's TotpSecret under the existing lock); make /status required mean 'no TotpEnabled SuperAdmin'. Test: abandoned-candidate recovery.

Part of M1 closure audit #84.

Bootstrap setup creates an Active SuperAdmin candidate (Bootstrap.cs:81-92) with no expiry; setup then 403s forever (guard 67-70), confirm 401s without the secret, and /status reports required=false (42-45). **Trigger**: operator closes the tab before scanning the TOTP QR → setup is dead; only DB surgery recovers a fresh install. **Fix**: when no TotpEnabled SuperAdmin exists, allow setup to re-issue (overwrite the candidate's TotpSecret under the existing lock); make /status `required` mean 'no TotpEnabled SuperAdmin'. Test: abandoned-candidate recovery. Part of M1 closure audit #84.
Author
Owner

Fixed in PR #117 (squash-merged as 74e8fb5; PR runs api-ci 11978 + security-ci 11979 green, suite + coverage gate 87.26% on CI).

  • /status: required now means 'no TotpEnabled SuperAdmin' — an unconfirmed candidate no longer reports required=false while setup 403s and confirm 401s. Suspended-but-enabled admins still hold the slot (bootstrap cannot reopen for a hijacker).
  • /setup: re-issues INTO the unconfirmed candidate under the existing BootstrapLock + Serializable tx — fresh secret (the lost QR dies), email/display refresh. Different-email retry takes over the slot; real users' emails stay protected (explicit 409 + unique-index backstop).
  • In-tx re-check counts only TotpEnabled SuperAdmins.

Tests: 5 new (BootstrapRecoveryTests) incl. old-secret-dead verification + confirmed-admin hijack guard + real-user email collision; 2 existing contract tests updated (Setup_AbandonedCandidate_Reissues; concurrent-setup invariant now 'at most one candidate ROW persists').

Fixed in PR #117 (squash-merged as 74e8fb5; PR runs api-ci 11978 + security-ci 11979 green, suite + coverage gate 87.26% on CI). - /status: `required` now means 'no TotpEnabled SuperAdmin' — an unconfirmed candidate no longer reports required=false while setup 403s and confirm 401s. Suspended-but-enabled admins still hold the slot (bootstrap cannot reopen for a hijacker). - /setup: re-issues INTO the unconfirmed candidate under the existing BootstrapLock + Serializable tx — fresh secret (the lost QR dies), email/display refresh. Different-email retry takes over the slot; real users' emails stay protected (explicit 409 + unique-index backstop). - In-tx re-check counts only TotpEnabled SuperAdmins. Tests: 5 new (BootstrapRecoveryTests) incl. old-secret-dead verification + confirmed-admin hijack guard + real-user email collision; 2 existing contract tests updated (Setup_AbandonedCandidate_Reissues; concurrent-setup invariant now 'at most one candidate ROW persists').
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/failsulit#91
No description provided.