0.7 Crypto/testing foundations — KDF floors + state signing (audit H-2/M-7) #15

Closed
opened 2026-11-03 07:12:50 +01:00 by amiryahaya · 3 comments
Owner

Argon2id floor parameters + KAT vectors (native m ≥ 64 MiB, t ≥ 3, p = 1; WASM m ≥ 32 MiB); passphrase floor component; OAuth state signing design (single-use, TTL ≤ 10 min, IKeyStore asymmetric key).

SRS: KEY-13, IDA-10
Exit: floor vectors pass; downgrade-rejection test exists.

Part of epic #1. Source: §4 (0.7)

Argon2id floor parameters + KAT vectors (native m ≥ 64 MiB, t ≥ 3, p = 1; WASM m ≥ 32 MiB); passphrase floor component; OAuth state signing design (single-use, TTL ≤ 10 min, IKeyStore asymmetric key). **SRS**: KEY-13, IDA-10 **Exit**: floor vectors pass; downgrade-rejection test exists. Part of epic #1. Source: §4 (0.7)
Author
Owner

Re-verified against main @ 7f853c8 (2026-11-11). This issue is HALF done and half re-scoped.

DONE (verified in code + tests):

  • IDA-10 signed OAuth state: IdpStateService signs base64url(payload).base64url(sig) with the server identity key (IKeyStore, asymmetric), TTL 10 min, single-use via SignedStateNonces (SHA-256 nonce hash), swept at 15 min. Landed in PR #132 (task 2.1). Tests: tamper, replay, expiry (11-min state), wrong redirect binding, flag-disabled (IdpFlowTests).
  • KEY-13 wrap-fetch limiter: policy on GET /api/keys/wraps (30/min prod, session-or-IP partition) + RateLimitSecurityTests.WrapFetch_TripsAfterLimit_Returns429.

RE-SCOPED — the KDF-floor half is a COORDINATED CLIENT+SERVER change (milestone M3), not a server-only patch:

  1. Server floor validation on the three wrap write paths (UploadWrap / AuthorizePairing / RekeyRecovery): reject NEW wraps below floors (native m >= 65536 KiB, t >= 3, p = 1 — RFC 9106 recommended option 2). Stored wraps are untouched (floor applies at write; reads stay compatible).
  2. Client profile migration BEFORE the server floor (desktop Rust symmetric.rs + iOS TieredKdf.swift): current profiles are Argon2idStandard 64 MiB/t3/p4 and Argon2idLow 19 MiB/t4/p4 — both violate the floor (p=4, and Low is below even the 32 MiB WASM floor). Migrate Standard -> p1, Low -> 32 MiB/t3/p1; tiered_kdf_derive currently SILENTLY FALLS BACK to legacy Argon2id on unknown profile bytes — that fallback must become a hard error (no downgrade path).
  3. Argon2id KAT vectors: genuine KATs exist in the Rust crate (cargo test) but bake the old p=4 parameters — regenerate with the migrated profiles. .NET-suite KATs stay deferred to M7 golden vectors (the server has no Argon2 implementation; KDF is client-side by design).
  4. Passphrase floor (>= 14 chars / >= 4 words / >= 80 bits at set time): there is NO set-time surface today (unlock is biometric/QR on all clients) — this rides the unlock-passphrase surface in phase-3 client work (SRS KEY-13).

Why the server cannot floor alone: floors reject p=4, and every current desktop/iOS wrap carries p=4 — a server-side floor without the client migration bricks wrap uploads. Sequence: client profiles first (or in the same milestone), then the server gate.

Exit criteria (updated): below-floor wrap upload rejected with 4xx + tests; clients mint only floor-conforming profiles; legacy fallback removed; KATs regenerated.

Re-verified against main @ 7f853c8 (2026-11-11). This issue is HALF done and half re-scoped. DONE (verified in code + tests): - IDA-10 signed OAuth state: IdpStateService signs base64url(payload).base64url(sig) with the server identity key (IKeyStore, asymmetric), TTL 10 min, single-use via SignedStateNonces (SHA-256 nonce hash), swept at 15 min. Landed in PR #132 (task 2.1). Tests: tamper, replay, expiry (11-min state), wrong redirect binding, flag-disabled (IdpFlowTests). - KEY-13 wrap-fetch limiter: policy on GET /api/keys/wraps (30/min prod, session-or-IP partition) + RateLimitSecurityTests.WrapFetch_TripsAfterLimit_Returns429. RE-SCOPED — the KDF-floor half is a COORDINATED CLIENT+SERVER change (milestone M3), not a server-only patch: 1. Server floor validation on the three wrap write paths (UploadWrap / AuthorizePairing / RekeyRecovery): reject NEW wraps below floors (native m >= 65536 KiB, t >= 3, p = 1 — RFC 9106 recommended option 2). Stored wraps are untouched (floor applies at write; reads stay compatible). 2. Client profile migration BEFORE the server floor (desktop Rust symmetric.rs + iOS TieredKdf.swift): current profiles are Argon2idStandard 64 MiB/t3/p4 and Argon2idLow 19 MiB/t4/p4 — both violate the floor (p=4, and Low is below even the 32 MiB WASM floor). Migrate Standard -> p1, Low -> 32 MiB/t3/p1; tiered_kdf_derive currently SILENTLY FALLS BACK to legacy Argon2id on unknown profile bytes — that fallback must become a hard error (no downgrade path). 3. Argon2id KAT vectors: genuine KATs exist in the Rust crate (cargo test) but bake the old p=4 parameters — regenerate with the migrated profiles. .NET-suite KATs stay deferred to M7 golden vectors (the server has no Argon2 implementation; KDF is client-side by design). 4. Passphrase floor (>= 14 chars / >= 4 words / >= 80 bits at set time): there is NO set-time surface today (unlock is biometric/QR on all clients) — this rides the unlock-passphrase surface in phase-3 client work (SRS KEY-13). Why the server cannot floor alone: floors reject p=4, and every current desktop/iOS wrap carries p=4 — a server-side floor without the client migration bricks wrap uploads. Sequence: client profiles first (or in the same milestone), then the server gate. Exit criteria (updated): below-floor wrap upload rejected with 4xx + tests; clients mint only floor-conforming profiles; legacy fallback removed; KATs regenerated.
Author
Owner

PASSPHRASE FLOOR COMPONENT LANDED 2026-11-11 (PR #150, #142 slice 2):

  • KEY-13 passphrase floor enforced at set time: >= 14 chars OR >= 4 words, validated in MasterKeyService.set_unlock_passphrase (server-authoritative Rust check) with a live hint mirror in the Settings UI. Tests: floor accept/reject matrix.
  • Argon2id unlock profile is floor-conforming by construction: m = 65536 KiB (64 MiB), t = 3, p = 1 (RFC 9106 recommended option 2; deliberately NOT the crate's default p=4), 128-bit per-user salt (unlock.salt), output 32 bytes. The stored wrap declares its parameters (unlock.kdf_params = 'argon2id;m=65536;t=3;p=1') — the downgrade-rejection groundwork: future wrap verification reads the declared params and refuses below-floor ones.
  • The passphrase unlock surface (F-M7/F-D4 ladder) is the consumer: unlock_with_passphrase derives the KEK from the passphrase and verifies via the AES-GCM decrypt attempt (no separate verifier at rest).

REMAINING #15 items (unchanged disposition): server-side floor validation on wrap write paths + client KDF-profile migration (desktop/iOS p=4 -> p=1, raise the 19 MiB low tier, remove the silent legacy fallback, regenerate KATs) — the coordinated client+server slice, milestone M3. The .NET-suite Argon2id KATs stay deferred to M7 golden vectors (no server-side Argon2 by design).

PASSPHRASE FLOOR COMPONENT LANDED 2026-11-11 (PR #150, #142 slice 2): - KEY-13 passphrase floor enforced at set time: >= 14 chars OR >= 4 words, validated in MasterKeyService.set_unlock_passphrase (server-authoritative Rust check) with a live hint mirror in the Settings UI. Tests: floor accept/reject matrix. - Argon2id unlock profile is floor-conforming by construction: m = 65536 KiB (64 MiB), t = 3, p = 1 (RFC 9106 recommended option 2; deliberately NOT the crate's default p=4), 128-bit per-user salt (unlock.salt), output 32 bytes. The stored wrap declares its parameters (unlock.kdf_params = 'argon2id;m=65536;t=3;p=1') — the downgrade-rejection groundwork: future wrap verification reads the declared params and refuses below-floor ones. - The passphrase unlock surface (F-M7/F-D4 ladder) is the consumer: unlock_with_passphrase derives the KEK from the passphrase and verifies via the AES-GCM decrypt attempt (no separate verifier at rest). REMAINING #15 items (unchanged disposition): server-side floor validation on wrap write paths + client KDF-profile migration (desktop/iOS p=4 -> p=1, raise the 19 MiB low tier, remove the silent legacy fallback, regenerate KATs) — the coordinated client+server slice, milestone M3. The .NET-suite Argon2id KATs stay deferred to M7 golden vectors (no server-side Argon2 by design).
Author
Owner

CLOSED by PR #197 (squash cd5b234, all three CI legs green: api-ci 12941 / desktop-ci 12942 / security-ci 12943)

Exit criteria check:

  • ✅ Floor vectors pass — two golden vectors (native 64 MiB + WASM 32 MiB floor profiles, frozen inputs) cross-verified against the C reference implementation (argon2-cffi / phc-winner-argon2, RFC 9106 suite) in a throwaway container — not self-generated. rust 38/38 native + 61/61 src-tauri.
  • ✅ Downgrade-rejection test exists — desktop: tampered/below-floor/unparseable stored kdf_params refused on every passphrase layer (real/decoy/wipe), including the unlock-flow fix so the refusal surfaces instead of counting as a wrong passphrase; server: below-floor wrap uploads → 400 + nothing stored (WrapKdfFloorTests, 5 tests).

IDA-10 (state signing) required no work — IdpStateService already ships asymmetric IKeyStore signing, TTL 10 min, atomic single-use nonce consume (landed with the IdP work; doc comment cites M-7).

Server floor values: absolute minimum = WASM tier (32 MiB / t ≥ 3) on the three wrap-write paths; native 64 MiB stays client-side per KEY-13 tier semantics. Fields remain optional (pre-#15 rows legal).

Follow-ups filed separately: #198 (iOS Argon2idLow 19 MiB is below every KEY-13 floor — mobile tier-ladder decision, dormant tier), #196 (Postgres migration smoke test).

## CLOSED by PR #197 (squash cd5b234, all three CI legs green: api-ci 12941 / desktop-ci 12942 / security-ci 12943) **Exit criteria check:** - ✅ **Floor vectors pass** — two golden vectors (native 64 MiB + WASM 32 MiB floor profiles, frozen inputs) **cross-verified against the C reference implementation** (argon2-cffi / phc-winner-argon2, RFC 9106 suite) in a throwaway container — not self-generated. rust 38/38 native + 61/61 src-tauri. - ✅ **Downgrade-rejection test exists** — desktop: tampered/below-floor/unparseable stored `kdf_params` refused on every passphrase layer (real/decoy/wipe), including the unlock-flow fix so the refusal surfaces instead of counting as a wrong passphrase; server: below-floor wrap uploads → 400 + nothing stored (`WrapKdfFloorTests`, 5 tests). **IDA-10 (state signing) required no work** — `IdpStateService` already ships asymmetric IKeyStore signing, TTL 10 min, atomic single-use nonce consume (landed with the IdP work; doc comment cites M-7). **Server floor values:** absolute minimum = WASM tier (32 MiB / t ≥ 3) on the three wrap-write paths; native 64 MiB stays client-side per KEY-13 tier semantics. Fields remain optional (pre-#15 rows legal). **Follow-ups filed separately:** #198 (iOS `Argon2idLow` 19 MiB is below every KEY-13 floor — mobile tier-ladder decision, dormant tier), #196 (Postgres migration smoke test).
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#15
No description provided.