{"slug":"trust","title":"Trust model","about":"What the signed log proves and what it does not, who is trusted with what, and what is out of scope.","source":"docs/THREAT-MODEL.md","markdown":"# Threat model: censorship resistance (v0, 2026-11-28)\n\nThe claim in `docs/SPEC.md` is \"no silent removal or alteration, and no single point of control\", not \"unreachable\".\nThis file says what the `jit-trust` code supports today, what it does not, and what a client must do to get it.\n\nBuilt and tested in `crates/jit-trust`: keys and ids (`id.rs`), the ref log (`log.rs`), Merkle proofs (`merkle.rs`),\ngit object checks (`objects.rs`), bundles (`bundle.rs`), mirroring (`mirror.rs`), tokens (`token.rs`) and agent\ncertificates (`principal.rs`), and the wiring of the log into `jit-store` ref updates (`host.rs`). Not built: any\nwitness network or gossip, and root key rotation. Statements about those are marked \"(designed)\".\n\n## 1. What is protected, and from whom\n\nAssets:\n- The history of every ref: which commit each ref pointed to, in which order, by whose hand.\n- Git objects reachable from the refs, and non-git records (changes, reviews, issues) anchored by digest.\n- The repository's identity, `RepoId`: the root ed25519 public key, fixed at genesis.\n- The ability to continue the project under that identity on another host.\n\nAdversaries:\n- A hostile or coerced host. It runs the server, holds the log signer key, and may hold the root key (custodial).\n- A network attacker between client and host. TLS is assumed; the log makes a TLS failure detectable, not harmless.\n- A malicious mirror, or anyone handing out a bundle.\n- A contributor or agent holding a valid token, possibly over-scoped or stolen.\n- A thief of any one key (root, signer, principal, instance, witness).\n\n## 2. Trust anchors and keys\n\n| Key | Held by | Can do | If stolen or lost |\n| --- | --- | --- | --- |\n| Root (`RepoId`) | Owner; also the host if custodial | Sign `Genesis` and `SetSigner`: choose who signs the log | Theft: the thief can `SetSigner` to its own key and fork the log at any point. Loss: no future signer change. No rotation or recovery in v0. |\n| Log signer | Host (a self-hoster may use the root key) | Sign every `RefUpdate` and `Record` entry and every checkpoint | The thief can append any ref move or record and sign checkpoints for a fork. Evidence names the key, not the person. Loss: the log stops until a root-signed `SetSigner`. |\n| Principal (person, agent) | That principal | Sign push certificates (`sign_push`); mint tokens (`Token::mint`); issue `AgentCert` | The thief can sign writes as that principal and mint tokens up to the principal's `RepoAcl` rights on every instance that knows it. |\n| Instance key | Host | Mint tokens for any subject, bounded by that subject's `RepoAcl` rights | The thief can act as any principal on that instance within their rights; such writes are host-attested only. |\n| Witness | Independent party | `SignedCheckpoint::cosign` | The thief can cosign a fork. No witness set exists yet. |\n\n## 3. What a hostile or coerced host CAN do\n\n| Action | Detectable? | By whom, with what evidence |\n| --- | --- | --- |\n| Refuse service, stop serving the repository | Yes, trivially | Anyone. Not prevented. The remedy is portability (section 8). |\n| Append entries nobody asked for: move or delete a ref, anchor a `Record` | Visible, not prevented | Anyone who reads the log: the entry is permanent and signed by the signer key. |\n| Attribute a write to a principal who did not make it, when the entry has no `actor_sig` | Not distinguishable from a real write | The `Actor` fields are host-asserted. Only an entry with a valid `actor_sig` binds the principal, on whose behalf it acted and the token id. Stock git clients cannot produce one. |\n| Replay a push certificate when a ref returns to an earlier value | No | Open problem 3. |\n| Set any `time_ms` | No | Entry and checkpoint times are the host's clock. Nothing verifies them. |\n| Split view: show different logs to different clients | Only by comparison | Two checkpoints for one `RepoId`, signed by the same signer, that no consistency proof connects. Needs clients, mirrors or witnesses to compare. No gossip exists. |\n| Freeze: keep serving an old valid checkpoint | Only by a client that saw a newer one | Nothing bounds checkpoint age. |\n| Rewrite history after genesis for a client that holds nothing | No | A fresh client verifies a fully re-signed log as valid (shown at the end of `a_mirror_detects_a_rollback_and_a_fork_and_keeps_the_evidence`). |\n| With the root key (custodial): anything the owner can | As above | Including `SetSigner` to a new key and a new fork from any point. |\n| Stop serving content and say so: a `Withheld` entry (decision 0047) | Yes, by design | Anyone who reads the log: what is withheld, since when, the reason class and reference, under the host's key. Mirrors and bundles then treat that content as optional and report it; copies that already hold it keep it. Nothing checks that the stated reason is true. |\n| Stop serving content without saying so | Yes, as a failure | A mirror or a bundle check fails on the missing objects of a ref that no withholding covers. |\n| Delete objects no current ref reaches; withhold record content | Content no; existence yes | The log still names every old `Oid` and every record digest. Bundles count earlier ref values they do not carry (`history_missing`) and list absent records (`records_missing`); a mirror does not fetch earlier values. |\n| Read everything; see who pushed what and when | Not hidden, by design | Non-goal (section 8). |\n\n## 4. What it CANNOT do without detection\n\nEach row assumes the client verifies (`verify_log`, `verify_bundle` or `mirror`), and where noted that it kept an\nearlier checkpoint. Tests are in `crates/jit-trust/tests/log.rs` (L) and `tests/portability.rs` (P).\n\n| Attack | Mechanism | Test |\n| --- | --- | --- |\n| Drop an entry from the middle | `seq` must equal position (`BadSequence`); `prev` must chain | L `a_dropped_entry_is_detected` |\n| Reorder entries | `BadSequence` | L `reordered_entries_are_detected` |\n| Insert or duplicate an entry | `BadSequence` | L `an_inserted_or_duplicated_entry_is_detected` |\n| Alter any byte of a stored entry | Canonical decoding, strict ed25519 verification, chain | L `any_altered_byte_is_detected` |\n| Alter one entry and re-sign it with the signer key | The next entry's `prev` no longer matches (`BrokenChain`) | L `an_entry_altered_and_resigned_by_the_host_breaks_the_chain` |\n| Rewrite from some point and re-sign everything after (needs an earlier checkpoint) | The old checkpoint does not match; no consistency proof exists; the two checkpoints are evidence | L `a_history_rewritten_from_some_point_on_fails_against_what_was_seen_before`; P `a_mirror_detects_a_rollback_and_a_fork_and_keeps_the_evidence` |\n| Drop the last entries (needs an earlier checkpoint) | `CheckpointMismatch`; `MirrorError::Rollback` | L `dropped_last_entries_are_detected_against_a_checkpoint_seen_before`; P as above |\n| Sign entries with any key but the signer in force | `WrongSigner`, `BadSignature` | L `only_the_signer_in_force_can_extend_the_log` |\n| Hand the log to another key without the root key | `SetSigner` needs the root key | L `the_host_cannot_hand_the_log_to_another_key_but_the_root_can` |\n| Pass off another repository's log, or a genesis the root did not sign | `WrongRepo`; `WrongSigner` at 0 | L `a_log_is_bound_to_its_repository_key` |\n| Move a ref from a value the log never gave it | Replayed compare-and-swap (`RefMismatch`) | L `a_forged_update_from_a_value_the_ref_never_had_is_detected` |\n| Reuse an actor's push certificate on another write, or change for whom it acted | `BadActorSignature` | L `an_actor_signature_binds_the_write_to_the_actor`, `an_actor_signature_also_covers_for_whom_and_under_which_token` |\n| Serve an object whose content differs from its id, or leave out an object a ref needs | Every object is re-hashed (SHA-1 with collision detection); the closure of every ref must be complete | P `a_mirror_refuses_altered_or_withheld_content_and_changes_nothing`, `a_tampered_or_misattributed_bundle_is_refused` |\n| Serve different content for an anchored record | The content must hash to the digest in the log | P `a_mirror_refuses_altered_or_withheld_content_and_changes_nothing` |\n| Edit the log file on disk behind the server | `RepoLog::open` re-verifies everything | L `the_file_store_persists_discards_a_torn_tail_and_exposes_tampering` |\n\n\"Detection\" means the client gets an error and changes nothing. It does not mean the honest data is recovered: that\nneeds a copy elsewhere, which is what mirrors and bundles are for.\n\n## 5. What a client MUST check\n\nState to keep per `RepoId`, outside the host's control: the last verified `SignedCheckpoint` and the log up to it (or\nat least its size, root, head, signer and refs). `FsRepo` keeps exactly this under `<data>/trust/<RepoId>/`. A client\nthat keeps nothing gets only the first rows of section 4.\n\n(a) First clone.\n1. Get the `RepoId` from a source the host does not control (the project's site, a signed release, a person). A\n   `RepoId` read from the same host proves nothing.\n2. `FsRepo::open(data, repo, format)` then `sync_from(&remote)`; or fetch all entries and the latest checkpoint and\n   call `verify_log(repo, entries, Some(&cp))`, then check each object as `objects::walk` does.\n3. Check the refs you use equal `VerifiedLog.refs`. Refs served outside the log are not covered.\n4. If witness keys are configured, require `cp.witnessed_by(&trusted) >= k` (designed; no witnesses exist).\n5. Keep the checkpoint.\n\n(b) Every later fetch. `mirror` does all of this; a client doing it by hand must do the same.\n1. Fetch the new checkpoint. Smaller than what you hold: rollback. Stop and keep both checkpoints.\n2. Equal size: require an equal root. A different root with a valid signature is equivocation evidence.\n3. Fetch the entries since your size and replay them on top of your state (`RepoLog::preview`). A consistency proof\n   alone is not enough: it shows append-only, not that the new entries obey the signer and compare-and-swap rules.\n4. Check `verify_checkpoint(&new, repo, signer)` with the signer in force after the replay, not the key the checkpoint\n   names. A `SetSigner` in the new range changes it. Check the checkpoint's root equals the replayed root.\n5. Fetch and re-hash the objects the new refs need; check each record against its digest.\n6. Only then extend your log and replace the stored checkpoint.\n\nA light client that does not replay entries can check only `verify_consistency(old.root, new.root, proof)` and\n`verify_inclusion` for the entries it cares about. It then trusts the host on the signer in force and on ref values.\n\n(c) A mirror. As (b), and also:\n1. Keep the checkpoint in a separate file from the log. `FileLogStore::open` discards a torn tail, so a log file cut\n   short looks like a shorter valid log; `FsRepo::open` refuses a log shorter than its stored checkpoint.\n2. On `MirrorError::Rollback` or `MirrorError::Fork`, keep the local copy unchanged and publish both checkpoints.\n3. Know the limit: `mirror` fetches what the current refs reach. History that was force-pushed away before the first\n   sync is not fetched, and nothing checks the remote still has it.\n4. Serve your checkpoints to others so that views can be compared.\n\n(d) Importing a bundle.\n1. Call `verify_bundle(input, Some(repo))` with the out-of-band `RepoId`. With `None` the bundle proves itself under\n   whatever key it names: check `BundleSummary.repo` yourself.\n2. `import_bundle` refuses a bundle that is behind the local log or diverges from it, and writes the log last.\n3. Read `BundleSummary.records_missing`: records the log anchors whose content the bundle does not carry.\n4. A bundle says nothing about freshness. Compare its checkpoint with any other view you can reach.\n\n## 6. Mirrors and malicious bundles\n\nA mirror or a bundle maker holds no signer or root key, so it cannot forge entries or checkpoints, and it cannot pass\noff another repository: everything is bound to `RepoId`. It can serve an old prefix (freeze), leave out record\ncontent (reported as missing), refuse service, or serve one side of a host's split view. It can serve a validly\nsigned fork that a stolen or custodial root key created; nothing in v0 says which fork is right. Objects no ref\nreaches and records the log does not anchor are refused, so a bundle cannot smuggle content in. Cost limits: a bundle\nis verified in memory in v0, with each object or record capped at `MAX_BUNDLE_ITEM` (1 GiB) and each entry at\n`MAX_ENTRY_BYTES` (16 MiB); there is no cap on the total, so a client must bound the bytes it is willing to read.\n\n## 7. Tokens and agents\n\nTokens are Biscuit public-key bearer tokens, attenuable offline (`Token::attenuate`). The verifier\n(`Authority::authorize`) caps size (4 KiB) and blocks (8) before parsing, accepts only blocks of one fixed shape,\nintersects the typed scopes itself and never runs Biscuit's Datalog engine, so a holder cannot widen a token or make\nverification expensive by appending a crafted block (tests in `token.rs`). The issuer, the revocation list and the\n`RepoAcl` are consulted on every call, cached tokens included.\n\n- A stolen token works for anyone until `not_after_ms`, within its scope. Nothing binds a token to its holder's key.\n- A token authenticates one principal (`Grant.actor`): its issuer, or for an instance-minted token the subject the\n  instance vouches for. Sub-agent names in a token (`Grant.delegate`, `chain`) are written by whoever held it and\n  prove nothing: anyone holding a token can name any principal. Ownership and permissions must key on `actor`\n  (decision 0045); a delegate is proven only by a push certificate from its own key.\n- Attenuation narrows what a sub-agent gets. It does not protect the parent token, and the parent cannot see or\n  revoke a child it did not record: revoking a parent block's id revokes every child; revoking one child needs its id.\n- A token minted by a principal's own key is bounded by that principal's `RepoAcl` rights on the instance verifying\n  it. A token minted by the instance key is bounded by its subject's rights.\n- An over-scoped token can make writes that are valid and permanent in the log. The log records `token_id`, which\n  identifies the token, not the hand that used it.\n- `AgentCert` has an expiry and no revocation.\n\nMitigations: short expiry, narrow `refs` and `paths`, protected refs that only the merge queue moves, and push\ncertificates from the agent's own key.\n\n`refs/queue/` is the server's own: the landing queue pins its candidates there, and no token writes under it,\nan administrator's and the instance root's included (a token that may write and not read gets the answer for\na repository it cannot see). It is refused twice: at authorization, before a push is\nread (the API's trust adapter, `RESERVED_REFS`), and inside the ref transaction (jit-collab's guard). Reading\nthere is as for any ref.\n\nThe queue's pinning and unpinning of a candidate there (its own cause, `queue-pin`, used for nothing else) are\n**not entries of the signed log**; everything else is, a landing included, whatever ref it moves: a candidate pin is scratch state,\nand what the queue did is recorded by the landing (the target's ref update and the anchored `landing` record\nnaming the rule). What this costs: a host could pin and unpin arbitrary commits there without a trace in the\nlog. It gains nothing by it that it did not have: a host can hold any object it likes without telling anyone,\nthe prefix is not advertised, and nothing under it reaches a clone, a bundle or a mirror. A ref there moved by\nanyone, or by any other cause, is still logged. Under a withholding a candidate is handed out or refused by\nthe rules in `docs/contracts/jit-trust.md` (\"Under a withholding\").\n\n**A refs withholding hides refs, not content.** It covers names: the host refuses those refs and what only they\nreach. Content that another served ref also reaches (a branch built on it, a change's pin, a tag) stays served.\nSomeone who wants a commit kept available after its branch is withheld needs only one other ref that reaches it,\nmade before or after; someone complying with an order about content must cover every ref that reaches it or\nwithhold the whole repository, and should check with a fresh clone. The stronger meaning (a ref built on withheld\ncontent is itself not served) is decision 0070 and is not built.\n\n## 8. Non-goals, concretely\n\nThe spec excludes anonymity, hiding content from the operator, and evading lawful process against a user. So: a host\nthat receives a lawful takedown can remove the repository at that host, and this design does not stop it. Every host\nsees content and metadata. The log is readable by anyone who can read the repository: who pushed what, when, and\nunder which token id. What the design gives instead: a removal or alteration at one host shows up as a refusal or as\na signed entry, not silently; it cannot change what mirrors and bundles already hold; and when the owner holds the\nroot key, one root-signed `SetSigner` on any mirror's copy continues the project under the same `RepoId` with no help\nfrom the old host (P `the_owner_moves_the_repository_to_a_mirror_without_the_old_host`). With a custodial root key\nthat last property does not hold, which is why a host hands the key over on request (`Trust::hand_over_root_key`).\n\nAn account is not needed to leave. Whoever holds the root key can present a `RootRequest` (signed with that key,\naddressed to the host, valid for minutes) and receive the bundle; the host consults no account, token or grant\n(`tests/key_holder.rs`, decision 0049). A suspension therefore governs writing at that host, not access to one's\nown history. It is not a way around a withholding: what the host withholds stays out of that export too. A stolen\nroot key gives the thief the same export.\n\n## 9. Open problems and planned work\n\nOrdered by how much each weakens the headline claim.\n\n1. No comparison of views. Split view and freeze are undetectable unless clients compare checkpoints. Cosigning\n   exists as a type (`Cosignature`, `witnessed_by`), but `cosign` does not itself check consistency, the cosigned\n   message has no witness time, and there is no witness network or gossip. Until then \"no silent alteration\" holds\n   only for clients that kept an earlier checkpoint. And no client keeps one today: there is no route for a\n   consistency proof, and neither `neo verify` nor the log page remembers a checkpoint. What to build, and the\n   options for a reader who holds nothing, are decision 0073.\n2. No fork-choice rule for migration. \"The log with the root-signed `SetSigner` wins\" is not in the code:\n   `verify_log` accepts the old host's fork and the owner's fork alike. If the old host appended entries after the\n   mirror's copy ends, clients that saw them hold checkpoints the moved log cannot extend, and they will reject the\n   legitimate move as a fork. A rule is needed (for example: accept divergence only where the other branch's first\n   entry is a root-signed `SetSigner`), plus tooling that hands clients the evidence.\n3. Push certificates are optional and not bound to a position. `push_message` signs the repository, the full `Actor`\n   and the body. If a ref returns to an earlier value (revert, force-push, delete and recreate), the host can replay\n   an old certificate. Planned: bind a nonce or `prev`, and make client-signed pushes the default for `jit`. Until\n   then every entry made through today's clients is attributed on the host's word.\n4. Root key: no rotation, no recovery, no shared control. Theft lets the thief fork from any point; loss freezes the\n   signer for ever. The root key can also equivocate: two different `SetSigner` entries at one position.\n5. Freshness. Nothing bounds checkpoint age. Planned: witness-signed times and a client maximum age.\n6. Records can be re-anchored. Nothing forbids a second `Record` entry with the same kind and id; bundles and mirrors\n   carry the content matching the newest digest. The earlier digest stays in the log, so the change is visible, but\n   a reader showing \"the latest\" shows the newest. Records need revision rules and actor signatures.\n7. Retention. Objects no current ref reaches are not required by any check. The log keeps every old `Oid`, so a\n   mirror could check availability; no code does. Bundles do not carry them.\n8. The spec sentence \"a host cannot rewrite or drop history without it being provable\" is true only against someone\n   who holds an earlier checkpoint or entries. For a client with no prior state the host can serve any log after\n   genesis, or any log at all with a custodial root.\n9. SHA-1. v0 repositories use `ObjectFormat::Sha1`. Hashing uses `sha1-checked` and treats a detected collision\n   attack as an error; the path is not exercised by a test with a real collision. The log itself is SHA-256.\n10. Startup cost. Opening a log re-verifies every signature: about 43 µs per entry, so tens of seconds per million\n    entries. A host under pressure to restart quickly must not skip it silently; a signed local snapshot is planned.\n11. Wiring. `jit-server` registers `HostLog` with the store when it starts, so every ref update, by git or by the\n    API (the landing queue's own pins under `refs/queue/` excepted, above), is logged inside the transaction that moves the ref: there is no push to a running server that is not\n    logged (the earlier sentence here said otherwise and was stale). A ref update that names no actor is refused.\n    A custodial root key seed sits unencrypted in the metadata store.\n12. Leaving a hosted instance: what you can and cannot take today. **A verified copy: yes.** Anyone who can read\n    a repository can clone it with git and verify its signed log (`neo verify`), pinning the repository's id, and\n    can mirror it; the copy proves what the host said and when. **A signed bundle over HTTP: not yet** (the\n    library writes one, `export_bundle`; the route `GET /v1/repos/{repo}/bundle` is being built). **The signer:\n    not yet.** Moving a repository's log to another host as *the same repository* needs its root key, to sign the\n    hand-over (`SetSigner`). For a repository created on a hosted instance the instance made that key and holds\n    it; the library can hand it to the owner (`Trust::hand_over_root_key`), and **no route does**. So today a\n    hosted user can leave with everything that proves the history, and cannot yet continue that history elsewhere\n    under the same identity; another host would start a new repository from the copy. Whether and how the key is\n    handed over is the operator's decision, not yet taken: once the owner holds it, the host can no longer sign\n    a hand-over on the owner's behalf, and a lost key cannot be replaced.\n","jit":"curl -s https://docs.neoopensource.com/trust?format=md","api":"/trust?format=md","api_url":"https://git.neoopensource.com/trust?format=md"}