mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-27 07:52:03 +00:00
4.6 KiB
4.6 KiB
SeedPass Crypto & Key Management Review (Item 2)
Status: Done
Date: 2026-02-25
Scope Reviewed
src/utils/key_derivation.pysrc/seedpass/core/encryption.pysrc/seedpass/core/vault.pysrc/seedpass/core/portable_backup.pysrc/seedpass/core/manager.py(unlock/setup key paths)src/seedpass/core/config_manager.py(KDF config surface)
Crypto Inventory (Current)
- At-rest/index encryption:
- AES-GCM via
cryptography(EncryptionManager.encrypt_data/decrypt_data). - Format marker:
V3|+ 96-bit nonce + ciphertext+tag.
- AES-GCM via
- Legacy compatibility:
- Fernet legacy decrypt paths (
V2:fallback and raw legacy blobs).
- Fernet legacy decrypt paths (
- Password-to-seed key derivation:
- PBKDF2-HMAC-SHA256 (
derive_key_from_password) with fingerprint-derived salt. - Optional Argon2id path (
derive_key_from_password_argon2).
- PBKDF2-HMAC-SHA256 (
- Seed-to-storage key derivation:
- deterministic hierarchy from mnemonic seed (
derive_index_key*).
- deterministic hierarchy from mnemonic seed (
- Portable backup encryption:
- AES-GCM using key derived from parent seed (
derive_index_key).
- AES-GCM using key derived from parent seed (
- Integrity checks:
- Cipher authentication tags (AES-GCM).
- JSON checksum validation for portable backups.
Exit Criteria Check (Item 2)
- Primitive/parameter review completed:
Done - Nonce/key lifecycle reviewed:
Done - Negative tests for corruption/tampering/wrong key path:
Done
Findings (Final)
Strong / Acceptable
- AES-GCM is used for current encrypted payloads.
- Migration compatibility from legacy formats is heavily tested.
- Portable backup import verifies checksum after decrypt.
- Nostr restore paths include strict error handling and migration fallback.
Gaps / Risks
- PBKDF2 default was low for 2026 threat levels:
- Remediated: new-profile default raised to
200_000iterations. - Legacy fallback compatibility remains via
50_000and100_000.
- Remediated: new-profile default raised to
- Argon2 config drift:
argon2_time_costexists in config, but active unlock code constructsKdfConfig(salt_b64=...)without reading configuredtime_cost.- This can create false confidence that tuning is active.
- AES-GCM nonce lifecycle policy:
- CRC32 in-memory nonce tracking was removed.
- Policy now relies on fresh 96-bit random nonces per encryption call.
- Optional plaintext export mode:
encrypt=Falsecapability remains intentionally available.- Interactive export now requires explicit warning + second confirmation.
- KDF metadata consistency:
- File wrapper carries
kdfmetadata, but operational seed-unlock parameters are partly config-driven and partly hardcoded/defaulted. - Clear authoritative KDF policy per profile is not yet centralized.
- File wrapper carries
Recommended Remediation Plan (Completed / Follow-up)
P0 (Do Next)
- Wire Argon2 runtime config into active unlock paths:
- In manager setup/load paths, pass configured
argon2_time_cost(and any agreed memory/parallelism values) intoKdfConfig.params. - Progress: completed in
PasswordManager._derive_seed_keyand wired across seed-key callsites; tests added insrc/tests/test_kdf_modes.py.
- In manager setup/load paths, pass configured
- Raise PBKDF2 default for new profiles:
- Progress: completed with default baseline
200_000.
- Progress: completed with default baseline
- Add explicit warnings for plaintext export mode:
- Progress: completed in
PasswordManager.handle_export_database.
- Progress: completed in
P1
- Decide nonce lifecycle strategy:
- Completed by removing CRC guard and relying on 96-bit randomness.
- Define a single profile KDF policy object:
- Algorithm + parameters + migration behavior in one place.
- Expand negative tests to include:
- Completed in
src/tests/test_kdf_modes.py. - Coverage includes wrong Argon2 params, tampered KDF wrapper payload, and downgraded KDF policy floor enforcement.
- Completed in
P2
- Add release-time crypto policy checks:
- lint/test gate ensuring configured KDF policy is actually used in unlock paths.
Test Coverage Snapshot (Relevant)
- Legacy migration and iteration fallback tests exist.
- Encryption fuzz and corruption tests exist.
- Portable backup corruption/checksum tests exist.
- Active Argon2 parameter and KDF downgrade/tamper negatives are now covered.
Proposed Completion Criteria for Item 2
Item 2 completion check:
- Argon2 config is verifiably wired into unlock path and covered by tests.
- PBKDF2 policy baseline is explicitly set and documented for new profiles.
- Plaintext export policy is documented with explicit user safeguards.
- One nonce-lifecycle decision is implemented (improved guard or rationale for removal).
- Checklist evidence links are updated to include merged PR/tests.
Result: all criteria met on 2026-02-25.