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: In Progress (P0 partially implemented)
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:
In Progress - Nonce/key lifecycle reviewed:
In Progress - Negative tests for corruption/tampering/wrong key path:
Partially Done
Findings
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 is low for 2026 threat levels:
- Config default appears to be
50_000iterations. - Legacy fallbacks include
50_000and100_000.
- Config default appears to be
- 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 reuse guard:
- Additional guard uses CRC32 of nonce in-memory.
- CRC32 collision can create false positives under high operation counts.
- Not persisted across restarts, so not a true global nonce registry.
- Optional plaintext export mode:
encrypt=Falsein portable export intentionally permits plaintext backups.- This is a policy risk if used accidentally in production workflows.
- 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
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:
- Choose a higher baseline and keep backward compatibility via fallback.
- Add explicit warnings for plaintext export mode:
- Keep capability, but require clear confirmation and warning text.
P1
- Replace CRC32 nonce tracking with deterministic monotonic counter mode for backup/index encryption or remove CRC guard and rely on 96-bit randomness.
- Define a single profile KDF policy object:
- Algorithm + parameters + migration behavior in one place.
- Expand negative tests to include:
- wrong Argon2 params,
- tampered kdf metadata wrapper,
- downgraded KDF policy attempts.
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.
- Additional tests needed for active Argon2 parameter usage in unlock paths.
Proposed Completion Criteria for Item 2
Item 2 can move to Done when:
- 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.