Proving that your Rust code has no undefined behavior
Memory safety and absence of runtime errors: no out-of-bounds access, use-after-free, overflow traps, panics or undefined behavior on any input allowed by the precondition.
Change the question
Ranked by: support for this property, stage, coverage of the features you pick, and trust. Tools that work on compiled code rank lower. Ranking as JSON.
-
Write specifications and proofs next to your Rust code; Verus turns them into questions for the Z3 solver and checks them for every possible run.
Supported.For code that opted into verification, Verus promises memory safety, no undefined behavior and no panics (except running out of memory or stack). This is conditional on the trusted assumptions in the code.
Source Supported — For code that opted into verification, Verus promises memory safety, no undefined behavior and no panics (except running out of memory or stack). This is conditional on the trusted assumptions in the code.- Effort
- Auto-active
- Covers
- 8 of 19 Rust features
- Relies on
- The Z3 SMT solver decides each proof obligation; no proof certificate is kept. Rust's meaning is built into Verus's encoding; no published validation against rustc.
Stage 1 · Usable 0/5 strong -
Translate safe Rust into pure functions in Lean 4 (or F*, Rocq, HOL4) and prove properties there; the Lean kernel checks every proof.
Supported.For the safe Rust it supports. Panics and integer overflow become failures in the generated model, so proving a function returns a result shows it does not panic or overflow. Unsafe code is not supported.
Source Supported — For the safe Rust it supports. Panics and integer overflow become failures in the generated model, so proving a function returns a result shows it does not panic or overflow. Unsafe code is not supported.- Effort
- Interactive
- Covers
- 5 of 19 Rust features
- Relies on
- Aeneas's own model of Rust (LLBC); proved sound on paper, no published validation. Charon, a separate unverified translator from rustc's MIR to LLBC.
Stage 1 · Usable 1/5 strong -
Annotate Rust functions with contracts; Creusot translates the code to Why3, whose SMT solvers prove absence of panics and that the contracts hold.
Partial.Proves code free of panics, overflows and assertion failures. A known gap stated in the guide is that Vec methods that grow the vector can panic on capacity overflow, which the current contracts do not rule out.
Source Partial — Proves code free of panics, overflows and assertion failures. A known gap stated in the guide is that Vec methods that grow the vector can panic on capacity overflow, which the current contracts do not rule out.- Effort
- Auto-active
- Covers
- 11 of 19 Rust features
- Relies on
- SMT solvers (Alt-Ergo, Z3, cvc5) run through Why3 decide; no proof certificates. Rust model built into Creusot's translation; no published validation against rustc.
Stage 1 · Usable 0/5 strong -
Write test-like proof harnesses for Rust code; Kani checks every input the harness allows, up to loop bounds, and gives a counterexample when a check fails.
Partial.Checks by default: arithmetic overflow, division by zero, invalid pointer dereference, out-of-bounds indexing, panics, bad shifts and memory leaks. Not checked: data races, Rust's aliasing rules (Stacked or Tree Borrows), mutation of immutable data, inline assembly. Invalid values and uninitialized memory are checked only with unstable flags.
Source Partial — Checks by default: arithmetic overflow, division by zero, invalid pointer dereference, out-of-bounds indexing, panics, bad shifts and memory leaks. Not checked: data races, Rust's aliasing rules (Stacked or Tree Borrows), mutation of immutable data, inline assembly. Invalid values and uninitialized memory are checked only with unstable flags.- Effort
- Push-button
- Covers
- 9 of 19 Rust features
- Relies on
- CBMC and a SAT solver decide; no proof certificate. A proof only if unwinding checks pass. Rust model built into Kani's code generator; tested by its own regression suite.
Stage 1 · Usable 0/5 strong - s2n-bignum on compiled code: x86-64
Prove hand-written x86-64 or Arm64 assembly correct in HOL Light, on the exact bytes of the built object file; used for AWS's cryptography code.
Partial.Memory-safety proofs (all accesses inside the declared buffers) exist for the functions AWS-LC uses, not yet for the whole library. They do not check accesses below the stack pointer, and the memory model has no unmapped pages, so the caller must pass mapped memory.
Source Partial — Memory-safety proofs (all accesses inside the declared buffers) exist for the functions AWS-LC uses, not yet for the whole library. They do not check accesses below the stack pointer, and the memory model has no unmapped pages, so the caller must pass mapped memory.- Effort
- Interactive
- Covers
- 0 of 0 common features
- Relies on
- Hand-written instruction models; random co-simulation against real CPUs in CI.
Stage 1 · Usable 4/5 strong - Islaris on compiled code: AArch64
Prove Arm or RISC-V machine code correct in Rocq, against the full official Sail ISA models, using Isla symbolic execution and an Iris separation logic.
Supported.Proofs show execution never reaches a failure state and only touches memory the specification owns or allows (MMIO).
Source Supported — Proofs show execution never reaches a failure state and only touches memory the specification owns or allows (MMIO).- Effort
- Interactive
- Covers
- 0 of 0 common features
- Relies on
- Isla and its SMT solver are trusted; Rocq checks the separation-logic proofs. Opcodes come from objdump output that the user trims and annotates by hand.
Stage 0 · Research 2/5 strong - LNSym on compiled code: AArch64
Prove Armv8 (AArch64) machine code correct in Lean 4 by symbolic simulation over a hand-written model; aimed at AWS-LC cryptographic routines.
Unknown.Proofs show no decoding error or unmodeled instruction is reached. The memory-safety part of the GCM init specification is commented out; we found no finished memory-safety proofs.
Source Unknown — Proofs show no decoding error or unmodeled instruction is reached. The memory-safety part of the GCM init specification is commented out; we found no finished memory-safety proofs.- Effort
- Interactive
- Covers
- 0 of 0 common features
- Relies on
- Hand-written AArch64 subset; random co-simulation against real Arm CPUs in CI. Opcodes are pasted from objdump into Lean; not linked to the binary by a proof.
Stage 0 · Research 2/5 strong
No option matches this effort level.
Verify Rust, but not this property
- Alive2 — Alive2 does not prove that a program is free of undefined behavior. Its refinement check only guarantees that the optimized version has no undefined behavior the original lacked.
Ask something else about Rust
New to this? Start with the glossary: auto-activeAuto-active verification. You write specifications and hints in the code; an automatic solver does the proving., interactiveInteractive theorem prover. A proof assistant where you write proofs step by step and the system checks each step., trusted computing baseTrusted computing base (TCB). Everything that must be correct for a proof to mean what it says..