Skip to content

[M2.2d1] Persist encrypted MFA enrollment and proofs - #53

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d1-mfa-storage
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.2d1-mfa-storage

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

MFA persistence now keeps either an encrypted pending TOTP seed or an active seed. Pending enrollment lasts ten minutes, is tied to the account security version, and cannot activate after expiry, a password change or account disablement. An active seed cannot be overwritten by staging another enrollment.

TOTP counters only advance, recovery hashes are consumed once, and all mutations join the existing user transaction. Removing MFA cascades its recovery records. Schema constraints enforce paired fields, ciphertext bounds, counter range and enrollment lifetime. Commands/HTTP wiring follow in M2.2d2/d3.

Validation: API lint/typecheck and all 51 real PostgreSQL/TLS SMTP integration tests pass. Four new PostgreSQL tests cover encrypted round trips, expiry/version/disabled-account rejection, concurrent claims across connections, cascade cleanup, invalid hash batches and audit-failure rollback.

Security: raw seeds and recovery values never enter the new tables. The adapter only accepts ciphertext; envelope associated data binds it to the user. Application commands must hold the existing per-user lock. This PR introduces persistence only and does not yet enable MFA enrollment publicly. Stacked on #52; no merge requested.

  • M2.2d1 criteria met
  • Migration and concurrent claims tested on PostgreSQL
  • Audit rollback preserves proof availability
  • Plan and security parameters updated
  • No new shell invocation or secret exposure path

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d1-mfa-storage branch from 364bd8c to 7ac6663 Compare November 4, 2026 11:36
@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m2.2c5-http-secret-boundaries branch from 507e9e2 to 42f35ba Compare November 4, 2026 11:36
@samuelmbabhazi
samuelmbabhazi force-pushed the fix/m2.2c5-http-secret-boundaries branch from 42f35ba to 98423a7 Compare November 5, 2026 12:31
@samuelmbabhazi
samuelmbabhazi changed the base branch from fix/m2.2c5-http-secret-boundaries to main November 5, 2026 12:31
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.2d1-mfa-storage branch from 7ac6663 to 9304f78 Compare November 5, 2026 12:32
@samuelmbabhazi
samuelmbabhazi merged commit 4539b9a into main Nov 5, 2026
9 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.2d1-mfa-storage branch November 5, 2026 12:32
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
Login now checks the account's active second factor under the same user
lock that creates the session. TOTP counters and recovery codes are
consumed atomically; missing, invalid, ambiguous or replayed proofs
cannot grant a session. Recovery use is audited, and audit/session
failure rolls proof consumption back.

The envelope adapter binds each encrypted seed to its user. A shared
authenticated-rotation command increments the security version, revokes
older sessions and reset links, and issues a fresh session in one
audited transaction. Password reset preserves MFA. Enrollment management
and HTTP proof DTOs follow in M2.2d2b/d3.

Validation: API lint/typecheck, 94 unit tests and 56 PostgreSQL/TLS SMTP
integration tests pass. Five new tests cover missing/replayed factors,
concurrent TOTP/recovery use, audit rollback, password reset preserving
MFA, atomic rotation and stale security context.

Security: no full session exists before second-factor proof. Decrypted
seeds remain wrapped and temporary buffers are cleared; crypto/storage
failures are opaque. No new dependency or transport. Stacked on #53; no
merge requested.

- [x] M2.2d2a criteria met
- [x] Real PostgreSQL concurrency and rollback tests pass
- [x] Privilege changes invalidate previous session versions
- [x] Plan updated; no new secret exposure or shell invocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant