PRINCIPLES.md defines Anneal's central promise to its users:
One of Anneal‘s outputs is a TCB audit log, a list of code and assumptions Anneal trusts (including itself) to compile your code and prove it correct. Anneal’s promise is this:
If the code in your TCB audit log is correct, its assumptions are valid, and Anneal emits no errors, then your code is sound and satisfies any stated specifications.
This document defines what Anneal does and does not aim to defend against—and why—so that promise holds even when Rust code, specifications, and Lean proofs are written by untrusted humans or reward-hacking AI coding agents. For the invariant goals that govern this threat model, see META_PRINCIPLES.md; for how Anneal's architecture implements these defenses, see docs/trust-model.md.
Unlike testing, which checks that a program behaves as expected on specific inputs, formal verification claims that a mathematical proof establishes a property for all valid inputs. Because writing specifications and machine-checked proofs requires significant effort, projects increasingly rely on external contributors and AI coding agents to write Rust code, specifications, proof automation, and Lean 4 proofs.
An honest developer uses cargo anneal to find genuine bugs in their code or proofs. By contrast, a malicious contributor—or a reward-hacking AI coding agent optimizing to make cargo anneal exit 0—has an incentive to make verification succeed without proving the property the maintainer expects:
sorry, a custom axiom, unverified native evaluation (native_decide), or a compiler override (@[implemented_by], @[extern]) into a Lean proof.ensures(true)), restrict the precondition to a trivial or empty case (requires(x == 0) or requires(false)), modify a helper definition that the specification depends on, or bypass verification with an explicit trust waiver (such as #[anneal::trusted]).cargo-anneal binary or its toolchain dependencies so the command exits 0 unconditionally.Anneal's threat model therefore assumes that repository changes may be authored by adversarial humans or reward-hacking AI coding agents rather than assuming good-faith inputs.
No automated tool can defend against a compromised host operating system or know what specifications and assumptions exist only in a maintainer's head. Turning PRINCIPLES.md's promise into an end-to-end guarantee that code behaves as the maintainer expects therefore requires an explicit division of labor:
Here, an uncompromised execution environment ensures that cargo-anneal's “no errors” result and TCB audit log are genuine, while the two human-reviewed surfaces are “trusted” in fundamentally different ways that must not be conflated:
unsafe functions), the stated specifications—together with any helper functions, trait implementations, constants, types, or mathematical models that define their meaning, and the request bindings (request.json, including compilation flags, environment, and source lists, scope, and proof specification and theorem bindings) that select which Rust code and theorem obligations are verified—express what the user is asking Anneal to verify.rustc, the Lean 4 kernel, and their semantic models) together with any unproved assumptions or trust waivers in the verified crate or its dependencies.Bounded human-review corollary: Because Anneal makes these two surfaces explicit and enforces total defenses (Section 3) over everything outside them, a human reviewer knows which code and artifacts can define or affect the meaning of stated specifications and which code and assumptions are trusted without proof via the TCB audit log—and can safely ignore everything outside those two categories, including all proofs, all proof-automation libraries, and all verified Rust implementation bodies that do not define specifications or TCB assumptions, no matter how large, complex, or adversarial they are.
To uphold this division of labor without security theater, Anneal classifies every threat by whether an automated verification tool can prevent it totally without rejecting legitimate code: threats that cannot in principle be prevented totally by an automated tool are stated as explicit assumptions (Section 2), whereas threats from untrusted repository contents outside the human-reviewed surfaces are met with mathematically or structurally total defenses (Section 3).
The overarching operational threat that Anneal does not aim to defend against is a compromised execution environment: an environment in which an untrusted human, agent, or process can modify or interpose on cargo-anneal, its binary dependencies (cargo, rustc, lean, or pre-compiled toolchain files), its environment variables (PATH, LD_PRELOAD), its working files during verification, or the channel reporting the verification result and TCB audit log.
This includes host OS tampering executed during compilation by Rust build-time code inside the repository—such as Cargo build.rs build scripts, procedural macros, or compiler plugins. (By contrast, non-malicious Rust code generated by a build.rs script or procedural macro is compiled by rustc and verified by Anneal under the same soundness, specification, and TCB rules as hand-written code in the crate.)
Build-time Lean 4 elaboration (#eval, run_cmd, by_elab, initialize) is bounded separately: on Linux, Anneal aims to contain untrusted Lean elaborator host file reads and writes, network access, and host IPC during verification, and restricts specification modules to declarative syntax before elaboration. Four residual boundaries remain outside automated elaborator containment: host path-metadata and existence visibility when unprivileged user namespaces are unavailable on the runner, non-Linux hosts or runs where the operator explicitly opts into unsandboxed elaboration (which taints the verification outcome), local resource exhaustion or denial of service, and external interactive editor or Lean language-server sessions outside Anneal.
There is no in-principle way for an un-sandboxed user-space tool to defend against a compromised execution environment. If an agent running under the same OS user account as cargo-anneal—or a build.rs script, procedural macro, or compiler process invoked during the build—has write access to the host's binaries, working directory, or environment, it does not need to find a soundness bug in Anneal or the Lean 4 kernel: it can replace cargo-anneal (or lean) or overwrite build outputs on disk so verification reports a clean TCB audit log and exits 0. In-process checks inside cargo-anneal cannot defend against an actor or child process that can modify the host environment in which those checks run; preventing build-time code from tampering with the host requires OS-level sandboxing of the build.
Anneal's threat model therefore assumes an uncompromised execution environment: the operating system, filesystem, environment, and installed Anneal toolchain binaries are intact and outside the untrusted actor's write or process-control access when verification runs.
The .olean disk cache that cargo anneal verify reuses (the per-user default, or a root named by --olean-cache-dir or ANNEAL_OLEAN_CACHE_DIR) is part of that environment. A cache hit is trusted on the strength of digests the entry itself records, so anything that can write the cache root can substitute compiled artifacts, including the auditor‘s. cargo anneal verify refuses an explicit root inside or containing the working directory or any input directory (manifest, proof, request, or rustc source directories), except that a root under the per-user cache base that holds the default cache may lie inside a working directory, such as HOME, that strictly contains that base; keeping the root write-isolated from less trusted runs (for example, runs on untrusted Rust inputs or with unsandboxed elaboration) is the operator’s responsibility.
The read-only prebuilt .olean bundle (the installed bundle‘s or the Lean prefix’s share/anneal/prebuilt, or a directory named by --prebuilt-dir) is part of that environment for the same reason: its manifest records the digests that its artifacts are checked against. cargo anneal verify applies the same checkout-overlap refusal (without the per-user cache-base exception) to an explicit --prebuilt-dir, and fails closed when that directory or its manifest is missing, uses another cache format, or lists a module built from different inputs.
This assumption naturally aligns with the standard split between local development environments and Continuous Integration (CI):
cargo anneal locally remains useful as a fast feedback loop for catching ordinary mistakes and naive agent shortcuts, but a local pass is not a security guarantee. (A local run satisfies the threat model only when the agent is confined inside a separate OS sandbox, container, or VM while cargo-anneal runs outside that sandbox.)build.rs or procedural-macro execution is a concern) and human code review to gate merges to main, running cargo anneal in CI with protected workflow configurations and a pinned Anneal toolchain satisfies the uncompromised execution environment assumption.Even in an uncompromised CI environment, Anneal does not aim to judge automatically whether a stated specification or an assumption in the TCB audit log matches the maintainers' intent. No automated tool can distinguish in principle between “the maintainers decided to narrow this function's specification” and “a reward-hacking agent weakened the specification to make proofs pass.”
In particular, automated vacuity checks cannot defend against adversarial specification weakening. Suppose a reward-hacking agent cannot prove a specification across all valid inputs of a function parse(buf: &[u8]). Even if Anneal rejected contradictory preconditions such as requires(false) by checking that at least one valid input satisfies the precondition, the agent could trivially satisfy that check by restricting the precondition to a single narrow case—such as requires(buf.is_empty()) or requires(x == 0)—or by weakening the postcondition to ensures(true), leaving almost all executions or behaviors unverified. Conversely, heuristically rejecting narrow preconditions or weak postconditions would reject legitimate domain-specific contracts.
Anneal therefore does not treat heuristic or satisfiability-based vacuity checks as a security defense. Because any weakening of a stated specification or addition of a TCB waiver appears on the two human-reviewed surfaces, judging that stated specifications are strong enough and that logged TCB assumptions are acceptable is a human-review responsibility.
Within an uncompromised execution environment, Anneal treats the repository's proofs, specifications, and Rust source files as untrusted and aims to provide total, un-bypassable defenses against the two ways untrusted repository contents could subvert verification—without rejecting legitimate Rust crates, Cargo workspaces, or Lean 4 specifications and proofs:
An adversarial proof in the crate or in a proof-automation library can attempt to make Lean accept a false claim without proving the theorem derived from Anneal‘s soundness definition and the crate’s stated specifications—for example, by introducing sorry or a custom axiom, invoking unverified native evaluation (native_decide), defining partial or unsafe constants, attaching compiler overrides (@[implemented_by], @[extern], @[csimp]), or proving a weakened, shadowed, or renamed theorem statement instead of the generated verification obligation.
Anneal aims to prevent any untrusted proof or tactic library from altering the theorem statement or causing a false claim to pass—without restricting legitimate Lean 4 proofs, tactics, or macros—so that proofs never need to be trusted or reviewed by humans.
Even when every proof is mathematically sound in the Lean kernel, an adversarial change outside a function's inline contract could attempt to alter what is proved or assumed without appearing on the two surfaces a human reviewer audits:
is_sorted(result) so it always returns true—or silently altering a build or request binding (compilation.cfg, compilation.env, crate_root, source_files, scope, or proof.specification) outside the reviewed request and specification diff. Anneal aims to ensure that every definition and compilation or scope binding capable of affecting the meaning or target of a stated specification is explicitly demarcated on (or surfaced in) the human-reviewed specification surface, and that no code outside that surface can shadow, redefine, or silently alter what a specification means.#[anneal::trusted])—even an uncalled entry point—or calling any waived, unverified, or external (extern) function must be recorded in the TCB audit log (surfacing the waived code or assumption so edits to waived code cannot pass silently). Likewise, every verified caller must prove a callee‘s stated preconditions—including unsafe function preconditions (which are part of the human-reviewed specification surface)—at the call site, and every trait implementation must prove the trait’s stated specifications (and, for unsafe traits, its safety contract).Because Anneal ensures that nothing outside the human-reviewed specification and TCB audit log surfaces can silently alter a specification's meaning or introduce an unproved assumption—without noise from ordinary implementation or proof edits—verified Rust implementation bodies that do not define specifications or TCB assumptions never need to be reviewed by humans.