[vault] Hands off: take over a machine-key vault, the unattended rules (v0.13.0) #15

Manually merged
mnovak merged 1 commits from feature/hands-off into main 2026-11-05 11:02:17 +01:00
Owner

Core for Custos's hands-off mode (Custos docs/12_hands_off.md): a machine-key vault Custos opens itself, then Take over the vault. v0.13.0.

What

  • Vault::take_over(password, kdf, now): only on a machine-key vault, and only once.
    • It adds the master password as a factor paired with the device key and removes the single slot in the same step, so the vault becomes an ordinary version-2 vault. The device key alone no longer opens it, and a phone or a TOTP backup is added as for any vault.
    • It ticks no-auto-connect, no-unattended and card-signing and writes taken-over.
    • On an error it puts the slots back.
  • Vault::opens_with_machine_key(): the instance twin of the existing Vault::is_machine_store(bytes).
  • security:
    • three checklist items: no-auto-connect, no-unattended, card-signing;
    • five actions: auto-connected, unattended-stored, setup-item-removed, unattended-signed, taken-over;
    • an optional detail on audit entries, written by security_note for the four notes: names, never values, 1–500 characters, no control characters.
  • Rules the app enforces (the server never decides):
    • is_setup_run;
    • auto_connect_allowed;
    • setup_on_connect;
    • unattended_provision: in Setup, a setup run, new items only; ask --generate or offer into arca/ custos/ fabrica/ aula/ gitea/, offers into the Claude Code store, TOTP unless it moved to the phone; never display;
    • unattended_sign: a machine-key vault, a run, not Hardened, not card-signing; the kinds minisign, manifest, authenticode, approval.
  • Docs: FORMAT.md (the new values and the rules), FACTORS.md (taking over).

Tests

  • tests/hands_off.rs: 12 tests, written first.
    • Against stubs that compiled but refused everything, 9 of 12 failed. The 3 that passed were the refusal-only and round-trip tests, which stubs cannot fail.
    • Take-over:
      • the release set survives, and the PC alone no longer opens the vault;
      • password plus PC opens it;
      • the items are ticked and the level is Hardened;
      • a user vault and a second take-over are refused;
      • a phone factor is refused before the take-over and works after it.
    • Notes keep their detail; other actions, control characters and over-long text are refused.
    • Every row of the unattended table: allowed and refused.
    • Signing rules.
    • The new items tick and untick.
  • Workspace: 204 passed (custos-vault 95). Clippy: the 3 warnings main already has, none new. cargo fmt --check already fails on main (CRLF in custos-keys); the touched files are formatted.

Adversarial self-review

  • Rollback: a vault with a new value does not open in a core before 0.13.0, as with 0.12.0's values. Written in FORMAT.md.
  • take_over with an error halfway: the slots and the KDF are restored; nothing is ticked before the factor is added.
  • The namespace check: arca alone, arcax/…, ../arca/…, ARCA/… and items containing .. are refused. Prefixes are compared on whole segments (arca/ with a non-empty rest).
  • The Claude store accepts any offered name in a setup run. It is never read this way: an ask from it is refused. This matches the spec, which allows the Claude store names the server offers.
  • exists is the caller's fact: the rule trusts the app to say whether the item exists. Custos reads its own vault for that, never the request.
  • Not done here: everything the app does with these rules (Custos PR).
Core for Custos's hands-off mode (Custos `docs/12_hands_off.md`): a machine-key vault Custos opens itself, then *Take over the vault*. v0.13.0. ## What - **`Vault::take_over(password, kdf, now)`**: only on a machine-key vault, and only once. - It adds the master password as a factor paired with the device key and removes the single slot in the same step, so the vault becomes an ordinary version-2 vault. The device key alone no longer opens it, and a phone or a TOTP backup is added as for any vault. - It ticks `no-auto-connect`, `no-unattended` and `card-signing` and writes `taken-over`. - On an error it puts the slots back. - **`Vault::opens_with_machine_key()`**: the instance twin of the existing `Vault::is_machine_store(bytes)`. - **`security`:** - three checklist items: `no-auto-connect`, `no-unattended`, `card-signing`; - five actions: `auto-connected`, `unattended-stored`, `setup-item-removed`, `unattended-signed`, `taken-over`; - an optional `detail` on audit entries, written by `security_note` for the four notes: names, never values, 1–500 characters, no control characters. - **Rules the app enforces** (the server never decides): - `is_setup_run`; - `auto_connect_allowed`; - `setup_on_connect`; - `unattended_provision`: in Setup, a setup run, new items only; `ask --generate` or `offer` into `arca/ custos/ fabrica/ aula/ gitea/`, offers into the Claude Code store, TOTP unless it moved to the phone; never `display`; - `unattended_sign`: a machine-key vault, a run, not Hardened, not `card-signing`; the kinds `minisign`, `manifest`, `authenticode`, `approval`. - Docs: FORMAT.md (the new values and the rules), FACTORS.md (taking over). ## Tests - `tests/hands_off.rs`: 12 tests, written first. - Against stubs that compiled but refused everything, 9 of 12 failed. The 3 that passed were the refusal-only and round-trip tests, which stubs cannot fail. - Take-over: - the release set survives, and the PC alone no longer opens the vault; - password plus PC opens it; - the items are ticked and the level is Hardened; - a user vault and a second take-over are refused; - a phone factor is refused before the take-over and works after it. - Notes keep their detail; other actions, control characters and over-long text are refused. - Every row of the unattended table: allowed and refused. - Signing rules. - The new items tick and untick. - Workspace: 204 passed (`custos-vault` 95). Clippy: the 3 warnings `main` already has, none new. `cargo fmt --check` already fails on `main` (CRLF in `custos-keys`); the touched files are formatted. ## Adversarial self-review - **Rollback:** a vault with a new value does not open in a core before 0.13.0, as with 0.12.0's values. Written in FORMAT.md. - **`take_over` with an error halfway:** the slots and the KDF are restored; nothing is ticked before the factor is added. - **The namespace check:** `arca` alone, `arcax/…`, `../arca/…`, `ARCA/…` and items containing `..` are refused. Prefixes are compared on whole segments (`arca/` with a non-empty rest). - **The Claude store accepts any offered name in a setup run.** It is never read this way: an ask from it is refused. This matches the spec, which allows the Claude store names the server offers. - **`exists`** is the caller's fact: the rule trusts the app to say whether the item exists. Custos reads its own vault for that, never the request. - **Not done here:** everything the app does with these rules (Custos PR).
mnovak added 1 commit 2026-11-05 11:02:05 +01:00
mnovak manually merged commit 82698bd9e5 into main 2026-11-05 11:02:17 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/CustosPublic#15