feat(desktop): #142 slice 2 — unlock failure ladder + passphrase layer (KEY-13 floor) #150

Merged
amiryahaya merged 1 commit from feat/desktop-unlock-ladder into main 2026-11-11 06:48:41 +01:00
Owner

#142 slice 2 — the unlock failure ladder (F-D4/F-M7) plus the passphrase baseline, closing #15's passphrase-floor component.

The gap: the locked screen was biometric-or-nothing — biometric re-unlock with no fallback, no counter, no recovery path. Per ADR-003 the passphrase/Argon2id baseline is the unlock foundation.

Rust — MasterKeyService passphrase unlock layer (6 new tests):

  • Set/change/remove: wraps the master key under Argon2id(passphrase, 128-bit salt) with KEY-13 floor parameters — m=65536 KiB, t=3, p=1 (RFC 9106 recommended option 2; deliberately NOT the crate default p=4). Stored as a second wrap layer alongside PR-B's keychain-KEK layer, so biometric/session unlock keeps working and the passphrase is the ladder's fallback step. The stored kdf_params string declares the profile — groundwork for KEY-13's downgrade rejection. Passphrase floor enforced at set time: >= 14 chars OR >= 4 words (SRS KEY-13).
  • unlock_with_passphrase: verification is the decrypt attempt itself (GCM auth failure = wrong passphrase — no separate verifier to leak), then loads the master key and unlocks.
  • Ladder (F-M7): persistent failure counter (keychain — survives restarts), attempt counter in errors, from the 5th failure a soft lockout (30 s, doubling per extra failure, 15 min cap) and the recovery hint. ANY successful unlock resets the ladder.

UI:

  • UnlockScreen: biometric default with a 3-strike remaining-attempts hint -> passphrase step (auto after 3 failures per F-M7) -> inline error with attempt counter -> lockout countdown disables submit -> after exhaustion the "I lost my devices" recovery escape hatch (F-M9 link). Microcopy per the error matrix ("Inline error, attempt counter; recovery after 5").
  • Settings > Security: UnlockPassphraseSection — set/change/remove with a live floor hint (TS mirror is a hint; Rust enforces authoritatively).

Note on jsdom: form submits via explicit onClick — jsdom doesn't fire implicit form submission (found by the new tests).

Tests: cargo 31/31 src-tauri (6 new: floor, set/unlock roundtrip with fresh-process load, ladder increment + lockout + recovery message, change/remove, floor rejection at set, ladder reset). vitest 1295/1skip (13 new: 6 ladder + 5 settings + existing kept). Typecheck clean; lint 0 errors.

#142 slice 2 — the unlock failure ladder (F-D4/F-M7) plus the passphrase baseline, closing #15's passphrase-floor component. **The gap**: the locked screen was biometric-or-nothing — biometric re-unlock with no fallback, no counter, no recovery path. Per ADR-003 the passphrase/Argon2id baseline is the unlock foundation. **Rust — MasterKeyService passphrase unlock layer** (6 new tests): - **Set/change/remove**: wraps the master key under Argon2id(passphrase, 128-bit salt) with **KEY-13 floor parameters — m=65536 KiB, t=3, p=1** (RFC 9106 recommended option 2; deliberately NOT the crate default p=4). Stored as a second wrap layer alongside PR-B's keychain-KEK layer, so biometric/session unlock keeps working and the passphrase is the ladder's fallback step. The stored `kdf_params` string declares the profile — groundwork for KEY-13's downgrade rejection. **Passphrase floor enforced at set time**: >= 14 chars OR >= 4 words (SRS KEY-13). - **`unlock_with_passphrase`**: verification is the decrypt attempt itself (GCM auth failure = wrong passphrase — no separate verifier to leak), then loads the master key and unlocks. - **Ladder** (F-M7): persistent failure counter (keychain — survives restarts), attempt counter in errors, from the **5th failure** a soft lockout (30 s, doubling per extra failure, 15 min cap) and the recovery hint. ANY successful unlock resets the ladder. **UI**: - **UnlockScreen**: biometric default with a 3-strike remaining-attempts hint -> passphrase step (auto after 3 failures per F-M7) -> inline error with attempt counter -> lockout countdown disables submit -> after exhaustion the **"I lost my devices" recovery escape hatch** (F-M9 link). Microcopy per the error matrix ("Inline error, attempt counter; recovery after 5"). - **Settings > Security**: UnlockPassphraseSection — set/change/remove with a live floor hint (TS mirror is a hint; Rust enforces authoritatively). **Note on jsdom**: form submits via explicit onClick — jsdom doesn't fire implicit form submission (found by the new tests). **Tests**: cargo 31/31 src-tauri (6 new: floor, set/unlock roundtrip with fresh-process load, ladder increment + lockout + recovery message, change/remove, floor rejection at set, ladder reset). vitest 1295/1skip (13 new: 6 ladder + 5 settings + existing kept). Typecheck clean; lint 0 errors.
feat(desktop): #142 slice 2 — unlock failure ladder + passphrase layer (KEY-13 floor)
All checks were successful
Security CI / security-scan (pull_request) Successful in 3m31s
99529d4082
F-D4/F-M7: the locked screen was biometric-or-nothing. This lands the
passphrase baseline with the full failure ladder, and closes #15's
passphrase-floor component.

Rust - MasterKeyService passphrase unlock layer (6 new tests):
- Set/change/remove passphrase: wraps the master key under
  Argon2id(passphrase, 128-bit salt) with KEY-13 FLOOR parameters -
  m=65536 KiB (64 MiB), t=3, p=1 (RFC 9106 option 2; deliberately not
  the crate default p=4) - stored as a second wrap layer alongside the
  PR-B keychain-KEK layer; stored kdf_params declare the profile
  ("argon2id;m=65536;t=3;p=1"), laying the KEY-13 downgrade-rejection
  groundwork. Passphrase floor enforced at set time: >= 14 chars OR
  >= 4 words (SRS KEY-13).
- unlock_with_passphrase: verify via decrypt attempt (GCM auth failure
  = wrong passphrase; no separate verifier), load master key, unlock.
- F-M7 ladder: persistent failure counter (survives restarts, keychain),
  inline attempt counter, from the 5th failure a soft lockout
  (30s doubling to 15 min cap) + the recovery message; ANY successful
  unlock (session/biometric/passphrase) resets the ladder.

UI:
- UnlockScreen ladder: biometric by default with a 3-strike hint ->
  passphrase step -> inline attempt counter -> lockout countdown ->
  "I lost my devices" recovery escape hatch (F-M9 link). Form submits
  via explicit onClick (jsdom never fires implicit form submission).
- Settings > Security: UnlockPassphraseSection (set/change/remove with
  live floor hint; TS mirror is a hint, Rust enforces).

Commands: unlock_passphrase_status, unlock_with_passphrase,
set/change/remove_unlock_passphrase. unlock_session + biometric unlock
reset the ladder on success.

cargo test 31/31 (6 new); vitest 1295/1skip (13 new); typecheck clean;
lint 0 errors.
amiryahaya deleted branch feat/desktop-unlock-ladder 2026-11-11 06:48:42 +01:00
Sign in to join this conversation.
No description provided.