Fix/wallet encryption hardening#3
Conversation
Passphrase entropy floor + strength meter, and an Argon2id timeCost increase with no-patch KDF orchestration and upgrade-on-unlock migration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Looks good, but I think this points at an underlying issue in the SDK which we should address first. The
I had a quick go at the SDK changes, see what you think - digitalSloth/znn-typescript-sdk#20 One other note can gitignore your |
These design docs are useful locally for the PR-authoring process but shouldn't live in the repo. Ignore the directory and remove the tracked spec from version control (the file stays on disk). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Went ahead and gitignored + untracked Approach on changing the SDK makes sense. PR#20 looks good. No comments there. I can simplify this PR once the SDK is updated. I'll post my review over on that PR. |
|
@0x3639 New SDK version is available - https://github.com/digitalSloth/znn-typescript-sdk/releases/tag/v1.0.4 |
Replaces the DEFAULT_CONFIG mutation workaround and our own kdfVersion tracking with the SDK's self-describing keyfile, per PR digitalSloth#3 review. - Bump znn-typescript-sdk to ^1.0.4 - encrypt(keyStore, KDF_CONFIG): SDK persists the Argon2id params in the keyfile; decrypt reads them back (falls back to legacy DEFAULT_CONFIG for paramless keyfiles) - Gate upgrade-on-unlock on KeyFile.needsUpgrade() instead of kdfVersion - Delete src/core/kdf.ts (withKdfParams private-static hack) - Collapse config KDF version machinery to a single KDF_CONFIG target - argon2Params gains optional timeCost/memoryCost/hashLength/parallelism; drop redundant Wallet.kdfVersion Verified: legacy paramless wallets decrypt and re-encrypt to timeCost:3 (new salt) on unlock; new wallets persist strong params from creation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replaces the dependency-free entropy heuristic (which still passed keyboard walks, monotonic runs, and dictionary words) with zxcvbn-ts. - zxcvbn core + language packs are dynamically imported into their own chunk, loaded on first password keystroke - not the initial bundle. - estimatePasswordStrength is async; usePasswordStrength wraps it as a reactive ref that fails closed on every change (resets to EMPTY until the new score resolves) with a sequence token to drop stale results. - Create/Import submit handlers snapshot the submitted values up front, re-score that snapshot as the authoritative gate, set the in-flight flag before the await (no double-submit), and create/import only from the snapshot - so editing the still-enabled fields mid-await can't swap a weaker password past the gate. Verified: weak patterns (keyboard walks, monotonic runs, common words) score below the floor; strong passwords pass; zxcvbn chunks load on demand; strong->weak->submit creates no wallet; rapid double-click creates exactly one wallet; and an imported wallet unlocks only with the submitted password, not a value swapped into the fields after submit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pushed two commits that act on your SDK feedback and tighten up the password gate. 1. Self-describing keyfile (SDK v1.0.4)Adopted
Net: −86 lines in that commit. Migration verified end-to-end — a legacy paramless
2. Password strength → lazy-loaded zxcvbnReplaced the dependency-free entropy heuristic with
Verified: Out of scope (pre-existing, not from this PR)
Happy to address either in a separate PR. |
Summary
Hardens the offline brute-force boundary for encrypted wallets (a High-severity review finding). Encrypted keyfiles are persisted to browser storage, but the app only required 8-character passwords and the SDK's Argon2id KDF runs at timeCost: 1 — so an attacker who exfiltrates a keyfile can brute-force it offline, where the in-memory unlock throttling offers no protection. This PR raises both axes of that boundary: passphrase entropy (search space) and KDF cost (time per guess).
What changed
Passphrase strength
KDF cost + migration
Migration & compatibility
Testing