logicsrc/docs/opencreds/security.md
Anthony Ettinger 6ff3089088
feat(recovery): assisted recovery, no old email: one-time code + passkey or CoinPay (CLI 0.18.0) (#305)
Email recovery needs the recovery code from the enrollment email. People who
delete their mail lose it, and with it the only way back in.

`logicsrc vault recovery enable --assisted` (opt-in) replaces that code with a
fresh sign-in: recovery asks for the one-time code emailed at that moment and a
confirmation in the browser with a passkey of the account or its connected
CoinPay identity (bound by subject, never by email, never creating an account,
no session made).

- Server: U is kept sealed under VAULT_ESCROW_KEY in vault_recovery_assisted
  (migration 015) only for accounts that ask. A step-up
  (vault_recovery_stepups) is single use, lives ten minutes, names no account
  and is approved only by a proof belonging to the account being recovered.
  The second proof is checked before the one-time code, so a missing
  confirmation never spends it. A claim without a confirmed step-up never
  returns U. disable and a plain re-enroll delete the stored U.
- CLI: `passwd --email` and `vault recover --email` print the link, wait for
  the confirmation, then ask for the one-time code. The re-arm keeps the mode.
- This mode is custodial: the server holds everything that opens the vault.
  docs/opencreds/security.md says so; accounts that do not opt in keep the
  split-key scheme unchanged.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:17:56 -08:00

9.7 KiB

OpenCreds security model

What the format protects

An attacker holding the storage — the database, its backups, an operator's console, a restored snapshot — learns:

  • how many items a vault holds, and how many of each type;
  • when each item was created and last changed;
  • the vault's KDF parameters, salt, and wrapped keys;
  • folder ids, and folder names in implementations that store them in the clear.

They do not learn any field of any item. The user key is never present in storage in a form the storage can open.

An attacker holding the storage and write access additionally cannot move a ciphertext between rows: the item id is bound as additional authenticated data, so a swapped ciphertext fails to decrypt rather than showing the wrong credential under a trusted name.

An attacker holding the auth hash — every one ever sent, in full — cannot derive the wrapping key. The two come out of the same master key under distinct HKDF labels.

What it does not protect

Metadata. Item counts by type are visible by design, because the type code is stored in plaintext so a server can filter and paginate without decrypting. That means a server learns you hold forty logins and two cards. Hiding it costs padding and blind indexes and buys less than it appears to; the specification states the leak rather than obscuring it.

A weak master password. PBKDF2 at 600,000 iterations raises the cost of a guess; it does not make a common password safe. Nothing in the format can.

A compromised client. Every value is decrypted somewhere. An attacker who runs code in the process that holds the user key has the vault, and no format choice changes that.

A plaintext export. It is exactly what it says. See below.

Deletion. deleted_at is a trash bin, not an erasure. A purge removes the row; whether it removes the bytes is a property of the storage engine and its backups, not of this specification.

Deliberate decisions

The type code is plaintext

So the server can paginate. The alternative — decrypting every row to answer "show me page 2 of the logins" — either moves the whole vault to the client on every read or gives the server a key. Both are worse.

Key material is base64 text

Where this travels as JSON over an HTTP API, binary round-trips as an escaped hex string and invites encoding mistakes on exactly the values that must not be corrupted. Text that is wrong is visibly wrong.

One item is one blob

Password history, custom fields and attachment keys all live inside the item's single ciphertext. That makes history encrypted by construction rather than by a second protected table someone can forget to protect. It costs a full rewrite of the item on every save, which is why history is capped — an uncapped array grows the ciphertext without bound.

One row per item

Not one blob per vault. Two devices editing two different passwords at the same moment must not cost anyone a credential, and with a single blob the later write silently discards the earlier. Per-item rows with a revision make that a detectable conflict instead of a silent loss.

The KDF floor is enforced client-side

Parameters arrive from a server. If the server is compromised, they are attacker-controlled, and iterations: 1 turns captured auth hashes into a free offline attack. The client refuses below its own floor before deriving anything, and a database-backed implementation SHOULD repeat the constraint in the schema.

The plaintext export

This is the most dangerous operation in the specification, and it is specified because the alternative is people writing worse versions of it themselves.

Requirements, restated:

  • Never the default.
  • An explicit flag, plus a confirmation.
  • "protected": false in the header so tooling can identify the file.
  • Owner-only file mode where the platform has one.
  • A warning that says what it means: this file cannot be un-leaked, and every password in it should be considered exposed if it is.

An implementation SHOULD offer to delete the file after a successful import elsewhere, and MUST NOT do so automatically — the person may still need it.

Threats specific to the team profile

Every member holding the vault key reads every item in the vault. This is a property of a shared symmetric key, not a gap in the implementation.

Consequences worth stating in a product's own docs:

  • Revocation requires rotation. Removing a member's wrapped key stops them fetching new ciphertext. It does not un-know the key they held. A member who leaves means a new vault key and a re-encryption of every item.
  • Partial sharing is a second vault. There is no way to share three items out of forty under one key. Split the vault.
  • Granting is a client-side act. An existing member unwraps and re-seals to the new member's public key. The server can add a member to a list; it cannot give them access, because it does not have the key. This is a feature, and it means a grant requires an authorized member to be online.

Email recovery (opt-in, paid)

The LogicSRC account service offers a second way back into a personal (user profile) vault: logicsrc vault recovery enable, $5 once per account. It is off unless the person turns it on, and it changes the threat model for those who do. A vault that is never enrolled stays exactly as described above: the server holds nothing that can open it.

What enrolling stores. The client draws a random 32-byte escrow key E, encrypts the user key under it, and splits E into two XOR shares, S and U. The server stores the escrowed blob and S, with S encrypted under the server's own escrow key (VAULT_ESCROW_KEY). U is rendered as a recovery code, emailed to the account address once ("keep this email"), and dropped: no table has a column for it. Each share alone is uniformly random and says nothing about E. The crypto is in crypto.md.

What recovering needs. logicsrc vault recover --email needs the recovery code from the enrollment email (U) and a fresh 8-digit one-time code the server mails at that moment (15 minutes, 5 tries, single use, 3 requests an hour), plus a signed-in LogicSRC CLI. The server releases S only against that code, logs the claim and mails a "your vault email recovery was used" notice. The client recombines E, decrypts the user key, checks it opens an item, sets a new master password, issues a new offline recovery key and re-enrolls with fresh shares, so the code just used is dead.

What this does and does not hold against, stated plainly:

  • A stolen database, even with the server's environment (the escrow key): cannot open an enrolled vault. It yields the blob and S, and E also needs U, which only the enrollment email has.
  • The enrollment email alone: cannot open the vault. It is U without S, and S is released only to a signed-in account that also receives a fresh code.
  • A live compromise of the server while a person enrolls or recovers: can open that vault. Enrollment hands U to the server in transit so it can be mailed, and a claim hands S back out; code running on the server at that moment sees what it needs.
  • Whoever controls the person's mailbox can open the vault. The mailbox holds U and receives the one-time code, and the LogicSRC account password can itself be reset by email, so the mailbox alone is enough to sign in, claim S and recombine E. The only defences are the notice emails (a claim and every account-password reset are mailed, and the owner may see them first) and disabling recovery. This is the reason the feature is opt-in: it moves the vault's safety onto the security of an email account. Enable it only on an email account with its own strong password and second factor.
  • The account operator can see that a person enrolled, when, and when they recovered; never the contents.

Turning it off (logicsrc vault recovery disable, or Settings) deletes the escrowed blob and S on the server, after which the emailed code is useless.

Assisted recovery (opt-in on top of email recovery)

logicsrc vault recovery enable --assisted is for people who do not keep old email. Recovery then asks for two things and no stored code: the one-time code emailed at that moment, and a fresh sign-in in the browser with a passkey of the account or its connected CoinPay identity (bound by the CoinPay subject, never by email).

This mode is custodial, and that is the whole trade. To make it work the server keeps the user share U as well as S, each sealed under VAULT_ESCROW_KEY. With both it can rebuild the escrow key and open the vault. So for an account that turns this on:

  • the server operator, or anyone who takes the database and the escrow key, can read the vault;
  • "the server cannot read the vault" no longer holds for that account.

It still holds for every account that did not opt in: there is no row for them in vault_recovery_assisted, U is mailed once and never stored, and a claim without a confirmed step-up never returns U.

What an outside attacker needs against an assisted account: the account's API token or session, the mailbox (for the one-time code), and the passkey or the CoinPay account. The confirmation link is single use, lives ten minutes, names no account, and is approved only by a proof that belongs to the account being recovered. The second proof is checked before the one-time code, so a missing confirmation never spends the code.

Running logicsrc vault recovery enable without the flag goes back to the split-key scheme and deletes the stored U; so does recovery disable.

Reporting

Security issues in the specification or the reference implementation: security@profullstack.com, or the security policy published at logicsrc.com/.well-known/security.txt.