feat(keys): KEY-17 recovery-initiation anti-abuse (#136 slice 1, H-4) #137

Merged
amiryahaya merged 1 commit from feat/136-key17-anti-abuse into main 2026-11-09 19:33:17 +01:00
Owner

#136 slice 1 — KEY-17 (H-4) recovery-initiation anti-abuse, the server-side core of Phase 3 task 3.8:

  • Owner alert on both initiation paths (public DID + settings-screen): durable in-app notification (recovery_alert — lands on every enrolled device) + best-effort email via new IEmailService.SendRecoveryAlertAsync (Null + Resend impls). An initiation the owner did not make is an attack signal with a visible cancel path.
  • Per-account cool-down (15 min, RecoveryConstants): re-initiation after a cancel returns 429 recovery_cooldown + security audit — floods cannot be immediately repeated.
  • Owner cancel endpoint POST /requests/{id}/cancel: requester-only, Pending → new Cancelled status (string-stored enum = no migration), trustees notified the request was withdrawn.
  • Trustee approval recent-auth gate (IDA-07): LastLoginAt >15 min (or never) → 403 reauth_required + security audit — a phished long-lived trustee session cannot approve.

Tests: 6 new (RED ×6): owner alerts on both paths, cancel by owner sets Cancelled + notifies trustees, cancel by non-owner 403, cool-down after cancel (429 with recovery_cooldown), stale-session approval rejected + fresh passes. Plus SEC-04 matrix row; TestFixture minted sessions now stamp LastLoginAt (they model real logins).

Suite 977/0/39 (Release+Debug), coverage gate 87.62%. Slice 1 of #136; slice 2 (H-4 trustee-only ServerShare removal) next.

**#136 slice 1** — KEY-17 (H-4) recovery-initiation anti-abuse, the server-side core of Phase 3 task 3.8: - **Owner alert on both initiation paths** (public DID + settings-screen): durable in-app notification (recovery_alert — lands on every enrolled device) + best-effort email via new IEmailService.SendRecoveryAlertAsync (Null + Resend impls). An initiation the owner did not make is an attack signal with a visible cancel path. - **Per-account cool-down** (15 min, RecoveryConstants): re-initiation after a cancel returns 429 recovery_cooldown + security audit — floods cannot be immediately repeated. - **Owner cancel endpoint** POST /requests/{id}/cancel: requester-only, Pending → new Cancelled status (string-stored enum = no migration), trustees notified the request was withdrawn. - **Trustee approval recent-auth gate** (IDA-07): LastLoginAt >15 min (or never) → 403 reauth_required + security audit — a phished long-lived trustee session cannot approve. **Tests:** 6 new (RED ×6): owner alerts on both paths, cancel by owner sets Cancelled + notifies trustees, cancel by non-owner 403, cool-down after cancel (429 with recovery_cooldown), stale-session approval rejected + fresh passes. Plus SEC-04 matrix row; TestFixture minted sessions now stamp LastLoginAt (they model real logins). Suite 977/0/39 (Release+Debug), coverage gate 87.62%. Slice 1 of #136; slice 2 (H-4 trustee-only ServerShare removal) next.
feat(keys): KEY-17 recovery-initiation anti-abuse (#136 slice 1, H-4)
All checks were successful
Security CI / security-scan (pull_request) Successful in 3m30s
API CI / build-and-test (pull_request) Successful in 4m42s
21dc99a562
- Owner alert on BOTH initiation paths (public DID + settings-screen
  session): in-app durable notification (recovery_alert — visible on
  every enrolled device) + best-effort email (new
  IEmailService.SendRecoveryAlertAsync; Null + Resend impls). An
  initiation the owner did not make is an attack signal with a visible
  cancel path.
- Per-account cool-down (15 min, RecoveryConstants): an initiation is
  not immediately repeatable even after the owner cancels — 429
  recovery_cooldown + security.recovery_cooldown audit on both paths.
- Owner cancel endpoint: POST /requests/{id}/cancel — requester-only,
  Pending → new Cancelled status (enum member, string storage = no
  migration), trustees notified the request was withdrawn.
- Trustee approval recent-auth gate (IDA-07): LastLoginAt older than 15
  min (or absent) → 403 reauth_required + security audit — a phished
  long-lived session cannot approve a recovery.
- SEC-04 matrix row for the cancel route; TestFixture session minting
  now stamps LastLoginAt (minted sessions model real logins).

6 new tests (RED ×6): owner alerts on both paths, cancel by
owner/non-owner, cool-down after cancel, stale-session approval
rejection. Suite 977/0/39 Release+Debug, coverage 87.62%.
Sign in to join this conversation.
No description provided.