mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
vault: opt-in paid email recovery for the personal vault ($5 lifetime) (#298)
* vault: opt-in paid email recovery for the personal vault ($5 lifetime)
A second way back into a logicsrc personal vault when the master password and
the offline recovery key are both gone, without the server holding anything
that alone (even with the DB and server env) opens the vault.
Client (packages/opencreds): random escrow key E encrypts the user key K
(AES-256-GCM, AAD "<ns>:vault:email-escrow:v1|<createdAt>"); E is split into
S (random, to the server) and U = E XOR S (emailed once as a checksummed
Crockford recovery code, never stored). `recover --email` checks the code's
check group first, asks the server for a one-time code, claims S, recombines
E, proves K against an item, sets a new password, issues a new offline
recovery key and re-enrolls with fresh shares (warns loudly if that fails).
New `recovery status|buy|enable|disable` commands; the CLI client lives in
packages/cli/src/vault-sync.ts.
Server (apps/pwa): /api/opencreds/recovery/{checkout,enroll,start,claim} +
status/disable. S is sealed under VAULT_ESCROW_KEY (versioned for rotation,
AAD binds the user). Enrollment is pending until the email with U is sent,
else rolled back. One-time codes: 8 digits, HMAC at rest, 15 min, 5 tries,
single use, 3 starts/hour; claims are audited and announced by email.
Purchase via CoinPay checkout (purpose vault_recovery); /api/coinpay/webhook
now verifies once and dispatches by purpose, auto_rotation unchanged.
Settings card with status and a Buy button. Migration 014 in both dialects.
Docs: security.md and crypto.md "Email recovery (opt-in, paid)" sections with
the honest trade-off; cli.md command reference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* vault email recovery: state that the mailbox alone is enough
The account password resets by email, so mailbox control = sign-in + one-time
code + the enrollment code U. Say so in security.md and stop the one-time-code
email from implying the vault stays safe if someone else reads the mailbox.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* vault email recovery: leave .env.example as on master
Touching it made the credential gate re-scan the existing SESSION_SECRET
placeholder (false positive). VAULT_ESCROW_KEY / _VERSION / VAULT_RECOVERY_PRICE_USD
are documented in docs/opencreds/security.md and crypto.md; prod values live in
vault app-logicsrc-com--prod.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4e4fedd35e
commit
41ad9f0987
20 changed files with 2363 additions and 7 deletions
|
|
@ -122,6 +122,42 @@ rotating the key and re-encrypting, because the key they held is a key they may
|
|||
have kept. Partial sharing is not a feature of a shared key; it is a second
|
||||
vault.
|
||||
|
||||
## Email recovery escrow
|
||||
|
||||
Email recovery (opt-in, paid) is a LogicSRC account feature, not part of the
|
||||
format: a vault that never enrolls is untouched by it. The security trade-off is
|
||||
in [security.md](./security.md#email-recovery-opt-in-paid); the construction is:
|
||||
|
||||
```
|
||||
user key K (32 bytes)
|
||||
│
|
||||
└─ AES-256-GCM(E, K, AAD = "<ns>:vault:email-escrow:v1|<vault createdAt>") → escrow blob
|
||||
|
||||
E (32 random bytes, client-side, never sent whole)
|
||||
├─ S = 32 random bytes → server, AES-256-GCM under VAULT_ESCROW_KEY
|
||||
│ (AAD binds the user id; key_version for rotation)
|
||||
└─ U = E XOR S → emailed once as the recovery code, never stored
|
||||
```
|
||||
|
||||
- **XOR, not a threshold scheme.** Two shares, both required: a 2-of-2 split is
|
||||
XOR, and XOR with a uniformly random S makes U uniformly random too, so each
|
||||
share alone carries no information about E.
|
||||
- **The AAD carries `createdAt`.** It survives password changes and changes on
|
||||
`init`, so an escrow blob cannot be replayed against a different vault.
|
||||
- **The recovery code** is U in Crockford base32 (the alphabet of the offline
|
||||
recovery key): 55 characters for 256 bits plus 19 zero bits, then a 5-character
|
||||
check group, the first 25 bits of
|
||||
`SHA-256("opencreds:email-recovery-code:v1" || U)`. Twelve groups of five. The
|
||||
check group catches a typo before a one-time code is requested or spent;
|
||||
a well-formed but wrong code fails the GCM tag on the escrow blob instead
|
||||
("recovery code doesn't match").
|
||||
- **After recovery** the client re-wraps K under the new password, replaces the
|
||||
offline recovery key, and re-enrolls with a fresh E, S and U. K itself does not
|
||||
change, so not one item is re-encrypted.
|
||||
- **One-time codes** are 8 digits, stored as an HMAC under the server escrow key
|
||||
(a dump of the codes table alone cannot brute-force a live one), 15 minutes,
|
||||
5 attempts, single use.
|
||||
|
||||
## Randomness
|
||||
|
||||
Every IV, salt, user key and recovery key MUST come from a cryptographic RNG
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue