Integrity sidecars
- Status: SHIPPED with Gate 2 corrupt plus backfill plus AEAD proof
- Spec: FR-13, D-13
- Sources:
tosv.cppreal_fhash plus fetch_v2 plus tag_check, M5 batch, ADR 0004, ADR 0005
What it is
Every blob carries a sidecar (.tag) with hash layers version
over its ciphertext, written at store time. v2 tags carry real
SHA256 with 0 2; v1 tags carry the legacy hash. Fetch and DAV
GET verify first: match serves, mismatch fails closed with 500
plus an integrity-fail (tag rot) or aead-fail (crypto tamper)
audit line, missing tag backfills silently and serves.
How TOSV does it
Store and DAV PUT hash the finished file in 64KB passes and write
the hex tag. v2 readers run one pre-pass that verifies the AEAD
stream and the tag hash together before serving a byte, so a bad
blob costs no oracle beyond the 500. v1 readers run tag_check
with the legacy hash. DAV DELETE, COPY, and MOVE carry the
sidecar along; PROPFIND hides .tag names from clients.
What it protects against
Bit-rot, torn writes, disk errors, casual tampering, and (v2) malicious blob-plus-tag rewrites: the exact "stay solid" demand from the vision text. A flipped bit anywhere in a v2 blob (or a rewritten tag over tampered bytes) fails the whole fetch loudly.
Attack realism
High for accidents and, since M7, for malice on v2 blobs: a
writer who rewrites blob plus tag still fails the secretstream
pre-pass, audited as aead-fail. v1 blobs keep the honest
stopgap (unkeyed tags close corruption only). See accepted
ADR 0005.
Pros
Backfill means no flag day: untagged blobs gain tags on first read. Double-read costs IO, never RAM (still 64KB flat). v2 tags use standard SHA256, verifiable with coreutils.
Cons and how the vault resolves them
- v1 tags are unkeyed, rewritable by blob writers. Resolved by AEAD for v2 blobs; legacy v1 blobs hold by scope honesty. The audit line still records every mismatch for forensics.
- Fetch reads each blob twice. Accepted: sequential IO, same 64KB ceiling, NFR-04 measured p95 153ms at 10MB (13x headroom).
- Sidecars double directory entries. Resolved by hiding them from PROPFIND and covering them in wipe, backup, and count logic.
Residual risk
Malicious tag-plus-blob rewrite on legacy v1 blobs only; closed for v2 by AEAD. v1 operators re-store to upgrade.