Implementation Risk Register
UnauditedThe rest of the threat model bounds what a faulty or hostile client can do to the server and to other clients. This page bounds a different fault: Capsule’s own code computing the wrong value consistently. A wrong value that the client and the server compute the same way passes every server check, every custody receipt and every durability gate, because those gates check that the server holds what the client described, not that the description is right (assumption A7 of Threat Model — Assumptions).
Each row is a fault class, not a known bug. A row is closed only when its mitigation runs in CI. A new mechanism whose correctness rests on two pieces of code agreeing MUST add a row here.
- One implementation per value. The content address, the STREAM geometry, the blob header and commitment, every HKDF derivation and canonical CBOR are computed only by
capsule-coreand reached from Swift, Kotlin and the browser through UniFFI and wasm. A client MUST NOT re-implement any of them. A second implementation exists only in tests, and there it must be independent. - A vector generated by the code under test proves determinism, not correctness. The guest-drop fixture (
xtask/src/drop_kat.rs) is produced by Rust and reproduced by the same Rust compiled to wasm, so it pinned a hex-encoded passphrase proof that the server, which decodes base64 (capsule-server/src/routes/drop.rs), refuses for every honest guest. A fixture that both sides of a boundary consume MUST be checked by the consuming side, the server route included. - Agreement between client and server is not evidence. Wherever the server re-checks a client value with the same crate, the register names an independent check.
Required Test Infrastructure
Section titled “Required Test Infrastructure”The mitigations below name these by tag. Each is a MUST for the rows that cite it.
| Tag | Requirement |
|---|---|
| T1: Independent golden vectors | Known-answer vectors generated once by an implementation that shares no code with Capsule (Python cryptography for AES-256-GCM, STREAM and HKDF-SHA512, as capsule-core/src/crypto/encryption/stream/tests.rs already does for headerless STREAM; Python hashlib for SHA-256), committed as fixtures, and never regenerated by the code under test. CI runs them against every implementation that produces or consumes the value: Rust, Swift and Kotlin through their bindings, wasm, and the server’s decoders. They cover the content address of whole blobs, header included; STREAM ciphertext at the first, last and a middle chunk, an empty plaintext, and a plaintext one byte either side of a chunk boundary; ranged reads at 56 + i × ciphertext_chunk; the header bytes and the key commitment; every HKDF label with its salt layout; canonical CBOR of each signed record type; and every value one crate encodes and another decodes. |
| T2: Differential hashing | A property test feeds generated inputs through every production hashing path (one-shot, streaming at arbitrary read sizes, incremental during sealing, file hashing) and compares each with a SHA-256 implementation from a different crate than the one under test. The existing check compares the streaming path with capsule-core’s own one-shot hash (capsule-library/src/utils/tests.rs), which shares its sha2 core and so cannot disagree with it. |
| T3: Open after seal | The sealing pass decrypts every chunk it has just produced, with the header as associated data and at the offsets a reader will use, and compares the plaintext digest with the source’s before the manifest is signed. A failure aborts the write. Together with the address and the deep verify, this proves that the server holds bytes that open to the original, which is what verify-before-destroy (Durability — Verify Before Destroy) needs and no server-side check can show. |
| T4: Property and fuzz tests | Per Testing and Validation — Rules: seeded proptest for every round-trip and every geometry formula; cargo-fuzz for every decoder and every file the client maps or parses; mutation testing on the modules a row names. |
| T5: Fault and interleaving tests | Faults injected through the storage and clock ports (an fsync returning EIO, a wall clock stepped forward or back) and forced interleavings of concurrent operations at named points, run in the server’s conformance suites. |
Register
Section titled “Register”| # | Risk | Consequence | Why existing checks miss it | Detection | Mitigation (MUST) | Owner | Status |
|---|---|---|---|---|---|---|---|
| R1 | Wrong content address. A blob is hashed over the wrong bytes (plaintext for ciphertext, the header left out) or by a hasher that mishandles a partial final block. | Wrong input: finalize refuses, which is transient. A hasher bug both sides share: the server stores and receipts an address that is not the SHA-256 of its bytes; every independent reader classifies the blob corrupt; the original was already released on custody. Irreparable. | Invariant 14 recomputes with the same capsule-core Sha256Hasher the client uses (capsule-server/src/upload/finalize.rs); deep verify and the scrub reuse it. Verify-before-destroy proves custody of the address the client computed, not that the address is right. |
A reader on another implementation reports corrupt for a blob with a valid receipt; it MUST be reported as an address disagreement, not discarded silently. | T1 (whole-blob addresses), T2. One address function in core. | Asset and Metadata Encryption — Content Address | Open: no address vectors; T2 absent. |
| R2 | Sealed bytes that do not open. The writer emits ciphertext under the wrong key, AAD or nonce, so every tag fails. | The blob is sealed bad at source. Address, receipt, deep verify and verify_asset all pass, so the original is released. Irreparable. |
Every custody check is over ciphertext identity and signatures. The server holds no key and cannot open the blob. | Classification state 6 on the first read (Asset and Metadata Encryption — Reading a Blob), after release. | T3 before signing; T1 for the seal. A release MUST rest on a T3 record for the exact bytes whose address the receipt names. | Asset and Metadata Encryption — Encryption Workflow | Open: no open-after-seal step. |
| R3 | STREAM geometry wrong. The ciphertext stride is used as the plaintext stride or the reverse, or the 56-byte header offset is omitted, in a reader, a ranged fetch or an upload’s re-derived range. | A symmetric bug round-trips on its own implementation and fails on every other, so the asset is unreadable off the writing platform. A ranged read decrypts the wrong window and reports corruption. | Round-trip tests inside one implementation pass any self-consistent geometry. Today’s vectors are headerless and cover whole-blob sealing only. | Tag failures on ranged reads of blobs whose whole-blob check passes. | T1 (ranged offsets, boundary plaintexts), T4 (stitched ranges equal sequential decryption). One geometry function in core. | Asset and Metadata Encryption — Encryption Workflow | Open: no header exists yet. |
| R4 | Nonce prefix reuse. A CSPRNG failure (a forked process, a restored VM snapshot, a misconfigured wasm getrandom), or a changed source re-sealed under a held prefix. |
Two plaintexts under one key and nonce: the GCM keystream and authentication key leak, and that file key’s tags can be forged. | Random nonces never collide in tests. The writer’s refusal of an emitted prefix (Asset and Metadata Encryption — Re-keying on Rewrite) is per device. | The header’s nonce is visible without a key: the server can see one (asset_id, amk_version, nonce_prefix) under two ciphertext hashes. |
The server MUST refuse a manifest that repeats a prior manifest’s (asset_id, amk_version, nonce_prefix) with a different ciphertext hash, and log it at ERROR; an identical hash is a deterministic re-seal (Transfer Protocol — Repairing a Lost or Corrupt Blob) and passes. Prefixes come only from the OS CSPRNG (Cryptographic Primitives — Randomness); a test pins the source. |
Asset and Metadata Encryption — Asset Key Derivation | Open: no keyless repeat check. |
| R5 | Key derivation mismatch across implementations. A different HKDF hash, label, salt layout (file_id as 16 raw bytes or as text) or output length. |
Blobs one implementation sealed are wrong key on another. A divergence may start a needless re-keying ceremony; if the writer released its original, the asset is unreadable on every other platform. | Only Rust derives today, so no second derivation exists to disagree, until one does. The key commitment detects the mismatch only on read. | Persistent wrong key for blobs from one platform. | T1 for every label in Cryptographic Primitives — Key Derivation. A CI check that the labels in code equal the documented set. No platform derives outside core. | Asset and Metadata Encryption — Asset Key Derivation | Partly: no label vectors. |
| R6 | Two plaintext dedup hashes. The Swift import hashes the original with CryptoKit over a whole in-memory buffer (capsule-swift/Modules/ManagedStore/Sources/ImportService.swift, ContentHasher.swift); Rust streams it through hash_reader in capsule-core::crypto::hash (capsule-library/src/utils/mod.rs). A v1 catalog’s hash_sha256 column may still hold BLAKE3 digests, because the column was renamed without a version bump or a re-hash (capsule-library/src/db/migrate.rs). |
Missed duplicates are imported twice. A false duplicate skips a file the library does not hold, for example when a failed read hashes as the empty input. A digest compared against the wrong algorithm reports healthy originals corrupt, or a corrupt one healthy. | Each platform tests only its own hasher, Swift against a mock (MockContentHasher). A BLAKE3 and a SHA-256 digest are both 64 hex characters. |
A shared corpus whose digests disagree across platforms; a catalog digest that never matches a re-hash of its file. | Swift MUST take the dedup digest from core over FFI. Until it does, T1 pins both hashers on one corpus (empty, one byte, 1 MiB exactly and ±1, a multi-GiB sparse file). Stored digests name their algorithm, and a migration re-hashes or quarantines untagged legacy values. A zero-length read of a source whose size is non-zero is an error, never hashed. | Import Pipeline | Open. |
| R7 | Serialization drift. Canonical CBOR differs between encoders; the peering channel’s JSON is serde_json of Rust types with byte strings as integer arrays, so a field rename or serde attribute is a wire change; a value one crate encodes another decodes differently (hex against base64 in the drop passphrase proof). |
Signatures and metadata-blob hashes fail on other implementations, so valid assets are quarantined; peering stops interoperating; an honest guest is refused. | Same-language round trips accept any self-consistent encoding. A derive change reads as a refactor. | Quarantines on one platform only; interop failures. | T1 for every signed record type (RFC 8949 §4.2.1 deterministic encoding, generated by an independent encoder and checked against the RFC’s examples); the peering golden fixtures of Peering — Wire Format; a contract test that sends the wasm-produced drop request to the real server route. | Metadata — Canonical CBOR Encoding | Open: no peering fixtures; the drop proof is broken (Web Upload — Known Gaps). |
| R8 | The protocol date is restated in the web client (capsule-web/src/lib/api.ts) and the Android app (ServerSessions.kt), and the FFI constructor takes it as an argument. |
One binary sends two dates (system invariant 8). A date ahead of what the build implements claims semantics it lacks; one behind is refused against newer album pins. | Each copy is right when typed and drifts on the next bump. | The CI gate of Versioning — Protocol Version Source. | Export the constant over UniFFI and wasm; delete every literal; the gate and per-client header assertions. | Versioning — Protocol Version Source | Open (Versioning — Known Gaps). |
| R9 | Server clock jumps. A restored VM snapshot or a broken time source steps the clock back or forward. | Ahead: trash is purged before its retention window ends, which is irreparable. Behind: sessions, links and counters outlive their bounds. | Retention is judged on the wall clock alone. The boot check sees only a clock behind recorded instants, and the runtime check logs only backward steps (Server Filesystem — Server Clock). | The purge sweeper compares the wall-clock and monotonic time elapsed since its previous run. | A purge pass MUST NOT run when the two disagree by more than one minute: it logs ERROR and waits for an operator or for agreement. T5 with a stepped clock. |
Server Filesystem — Server Clock | Open: no skew detection (Self Hosting — Clock). |
| R10 | fsync semantics. A volatile write cache acknowledges flushes; an EIO is retried and then reports success; a rename is not followed by a directory sync. |
A receipt names bytes that never reached the disk, and the original is released. Irreparable. | A deep verify made right after the write can be served from the page cache, so it proves only that memory holds the bytes. |
The scrub’s rolling re-read; the power-cut drill (Self Hosting — Blob directory). | T5 for every fsync and rename site (Transfer Protocol — Faults and Responses). The deep read for a release MUST drop or bypass the page cache for that blob first. |
Transfer Protocol — Failure Model | Partly: whether dropping the cache works on ZFS and btrfs is open. |
| R11 | GC deletes attested bytes. A sweep that has re-confirmed zero references unlinks a blob as a finalization commits onto it; the reference query misses a table that names an address. | A fresh index row and custody receipt name nothing. Irreparable once the client releases. | Today a commit that finds the address present discards its stage (capsule-server/src/blob/fs.rs), no lock orders it against the sweep, and the reference query counts only asset rows (reference_count in capsule-server/src/index/postgres.rs), not drops, share records or live sessions. |
Scrub row-to-blob check; stored = false after a receipt. |
The per-address lock of Server Filesystem — Deletion and Garbage Collection, tested by T5 interleavings. A schema test fails on any column holding a content address that the reference query does not read and that is not listed as exempt with a reason. | Server Filesystem — Deletion and Garbage Collection | Open. |
| R12 | LWW by self-asserted time. Registers order writes by (ts, device_id) (capsule-core/src/metadata/crdt/lww.rs). |
A device whose clock reads 2099 wins every later edit to the register it touched, with no way to override it. A silent overwrite of user intent. | Merge tests use honest timestamps. | A register whose winner is not the chain head’s write. | Order by provenance-chain position (Metadata — Collaborative Metadata); T4 property: a far-future ts wins nothing. |
Metadata — Collaborative Metadata | Open. |
| R13 | Metadata sealing order. A sidecar references the manifest that seals it, or a bundle becomes visible before its metadata and provenance blobs finalize. | A circular or dangling binding is quarantined on every reader; a visible asset with no metadata. | Writers set provenance_chain_hash (capsule-library/src/lifecycle/provenance.rs) and no reader compares it with the sealing manifest’s prior_provenance_hash. |
Reader-side equality check. | The equality check in every reader (Metadata — Provenance Binding and Sealing Order); the visibility gate of Upload — What Gets Uploaded; T4 over generated edit sequences. | Metadata — Provenance Binding and Sealing Order | Open: no reader check. |
| R14 | The path is never reported. No app calls FfiSession::set_path (capsule-sdk/src/ffi.rs), and a session starts unmetered. |
Phones upload and fetch in bulk over cellular, spending the user’s data. | Desktop and CLI tests have an honest path. | Per-platform smoke test of Network Resilience — Validation. | An unreported path is metered (Network Resilience — Path Snapshot); each shell feeds the OS listeners. | Network Resilience — Path Snapshot | Open. |
| R15 | Decompression bomb and hostile sizes. A small compressed body inflates without bound, or a stated length sizes an allocation. | A client exhausts memory and is killed mid-operation. | Nothing is compressed yet, so no test sends a bomb; no body is capped after decoding. | T4: bombs and oversized lengths at every decoder. | The per-operation decoded-body cap (Network Resilience — HTTP Transport), applied before parsing. | Network Resilience — Compression | Open (Network Resilience — Known Gaps). |
| R16 | Search index corruption. A truncated or corrupt fst file is mapped; FTS5 shadow tables are damaged. |
A mapped truncated file raises SIGBUS and the app crash-loops. Damaged FTS silently omits results and smart-album members. |
Corruption needs a crash or a disk fault at the wrong moment. | Header and checksum validation before mapping; FTS5 integrity-check at open after an unclean shutdown. |
Validate before mapping, rebuild on any failure, never rewrite in place (Search — Suggestions: fst); T4 fuzz over corrupt fst files; incremental index equals a fresh rebuild. |
Search — The Index | Not built. |
| R17 | Export archives a user’s tool cannot read. Data descriptors on stored entries, ZIP64 fields or parts past 65,535 entries that a reader mishandles. | A user who exports and then deletes the library holds an archive they cannot open. | Writing and reading back with the same library passes. | The compatibility matrix of Export — Validation. | The matrix in CI, and every finished part read back through rc-zip and checked against SHA256SUMS before it is reported finished. |
Export — Archive Format | Not built. |
| R18 | Hand-off judged on device clocks. The origin judges a hand-off by its own deadline, and the server has no registration (Peering — Delegation). | A stalled courier is never refused, and the origin cannot tell a working courier from a dead one. No loss: the origin releases only on its own receipt. | Device clocks agree in tests. | Hand-off overdue on the origin. | Server-clock deadlines sent as durations (Peering — Hand-off Registration); T5 with skewed device clocks. | Peering — Hand-off Registration | Open. |
| R19 | verify_asset fails open. One chokepoint decides acceptance on every client (Key Management — Write Authorization). |
A forged or unauthorized manifest is accepted everywhere at once. | Positive fixtures pass a function that accepts too much. | Negative fixtures. | One negative fixture per terminal-reject reason (Signed Manifests and Provenance — Validation); mutation testing on it (T4): a surviving mutant fails the gate. | Key Management — Write Authorization | Partly. |
| R20 | The plaintext library in OS backups. The library root is not excluded from iCloud or Android backup (capsule-android/src/main/AndroidManifest.xml sets allowBackup="true" with no extraction rules). |
Plaintext originals and the decrypted index sit in a provider’s cloud outside Capsule’s encryption. | No test reads the platform’s backup configuration. | A build check on the manifest and the exclusion flag. | The exclusion of Client Filesystem — Mobile Clients, asserted by a build test per platform. | Platform Integrations — The Plaintext Boundary | Open. |
| R21 | Trusted-contact release before the notice period ends. The server compares the claim’s start with a wall clock that stepped forward, or a veto written concurrently with the release is lost. | A contact recovers the master key without the owner having had the full window to block, which is the whole guarantee of the path. | The release is a server-side time comparison no client re-checks, and the veto and the release are separate writes. | The release is logged with the claim’s start, the release time and the vetoes seen; an owner device that syncs a release it did not expect alerts. | Notice periods are measured in database time in the same transaction that checks for a veto and releases, so a veto and a release serialize; T5 clock-step and interleaving tests on that transaction. | Backup and Recovery — Opt-in: Trusted-Contact Recovery | Open: not implemented. |