[repo] Provisio core: a kept seal recipient, the provision audit (v0.11.0) #13
Reference in New Issue
Block a user
Delete Branch "feature/provisio-core"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The two core pieces Provisio needs (the app's docs/10_provisio.md, "The seal" and "Audit"). v0.11.0.
custos-seal: a kept recipient
generate, kept DPAPI-sealedvia
secret_bytes, and restored withfrom_secret. One-time keys stay the default (docs/SEAL.md, "A kept key").from_secretrefuses (BadKey) a secret that X25519 clamps to zero (all zeros, a wiped or never-filled buffer,and anything that differs from it only in clamped bits) and, as
sealdoes for public keys, one whose sharedsecrets would not be contributory.
DebugofRecipientnow printssecret: [redacted](it already printed only the match code).StaticSecret::from/to_bytes.custos-vault: the provision audit
A new optional body member
provision: {"audit": [...]}, besidesigning(docs/FORMAT.md, "The provision audit").atisi64Unix ms, assigning::AuditEntry::atandnow_ms().Tests (153 total, all green with
cargo test --workspace --release; 8 new)Each new test was run red before the code existed, then once more against a skeleton to see it fail for its own
reason:
a_kept_recipient_comes_back_from_its_secretfrom_secret/secret_bytes)a_known_secret_is_refusedunwrap_erronOk)a_kept_recipient_prints_redacted[redacted]the_provision_audit_records_every_outcome_and_survives_a_reopenentries_that_do_not_fit_are_refused_and_not_storedthe_audit_is_append_only_and_keeps_the_newest_entriesan_entry_has_no_member_that_could_hold_a_secretprovision::tests::an_older_reader_opens_a_vault_with_the_provision_auditBesides the unit test (which parses the decrypted body with core 0.10.0's
Bodyshape), a one-off check linked thereal v0.10.0
custos-vaultnext to this one: v0.10.0 opens a file with a provision audit (items intact), and itssave drops the member, as FORMAT.md documents for
identityandsigning.rustfmt --edition 2024ran on the changed files only (it rewrapped one pre-existing line in custos-seal's lib.rs).Clippy is clean on the new code (one pre-existing collapsible-if in signing.rs is untouched).
Self-review (adversarial)
What could misuse
from_secret/secret_bytes?secret_bytesis the first function in custos-seal that hands a recipient secret out. Anyone holding aRecipientcan now export it. Mitigation is by contract and review, not by type: the doc comments andSEAL.md say it goes only to the caller's sealed storage; one-time paths (approvals, pairing, Provisio asks)
never call it. The returned
Zeroizing<[u8; 32]>wipes on drop, but itsDebugprints the bytes: a callerthat
{:?}s it leaks it. The app must not, and its own redaction tests should cover the DPAPI path.provision.key(DPAPI, this Windows account) opensoffers recorded in transit later or earlier. The mailbox holds boxes for 5 minutes only and keeps none after
hand-out; the context binds each box to
provision-offer:<store>:<item>; the PC checks the plaintext's item,store, kind and code key; the mailbox refuses a replayed ephemeral key. Rotating the key (generate a new one,
re-register) is the app's lever after a suspected leak.
from_secretwith attacker-chosen bytes: it only builds a key the caller already holds; the refusal ofclamped-zero catches the realistic bug (a zeroed buffer after a failed unseal), which would otherwise give a
key the whole world knows. Other weak-but-valid scalars cannot be told from random ones; the key must come from
generate.*secretcopies the array to the stack while building theStaticSecret, exactly asgeneratealready does;that copy is not wiped (same as before this change).
Why the audit cannot hold a secret
an_entry_has_no_member_that_could_hold_a_secretpins the exact member list and thatnone is nested. A later member would have to change that test and FORMAT.md.
the match code of a public key. None of it is secret by construction.
patterns, host as a host name, kind at most 200 characters without control characters, code exactly six digits.
The only member that could carry arbitrary text is
kind(200 characters); it is the label the server alreadyprinted on the card and sent in the clear. The app must fill it from the offer's
kind/ the ask's--generaterecipe and nothing else.
provision_record(append) andprovision_audit(a shared slice); nothing edits orremoves an entry except the oldest dropping off past 5 000.
Format risks
signing, an older Custos dropsprovisionwhen it saves: every Custos that saves the vault must be0.11.0 or later (FORMAT.md, and the app's docs/10_provisio.md risk table).
Corrupted), as withsigning.Adding one needs the same "must be 0.x or later" note.