Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

What Verus guarantees

When Verus successfully runs on your program without reporting an error, what does that tell you? First, note that Verus only examines Rust code that the developer explicitly indicates should be verified, either by wrapping it in the verus! macro, or by adding the #[verus_spec] or #[verus_verify] attributes. Verus does not inspect and hence cannot provide any guarantees for code that hasn’t opted into verification.

For code that has opted into verification, a successful Verus verification promises:

  1. The code is memory safe and free of undefined behavior (UB).
  2. The code is panic free, modulo resource exhaustion (see below).
  3. The code is correct, in the sense that it meets its specification.

Note that the last guarantee is only as strong as the specification itself. A weak spec may not provide the guarantees you expect. For example, given a function that returns an Option<T>, if the specification only ensures interesting properties when the function returns Some, then the implementation might always return None, satisfying the spec, but likely not satisfying the caller.

Equally important are the properties that Verus does not guarantee, even when it successfully verifies code:

  1. Verus does not verify the performance of the code, so it can still be horribly slow.

  2. Verus does not verify the absence of resource exhaustion, so your program might still run out of memory or stack space, but even then, Verus ensures exception safety: Verus verifies code defensively against unwinding panics that might result from out-of-memory conditions or from unverified code.

  3. While Verus enforces termination of specification and proof code (since this is crucial for soundness), Verus does not verify that your executable code will terminate. While Verus verifies decreases clauses, this only provides lightweight termination checking, not a guarantee of program termination.

    Proving termination of Rust programs is quite challenging. Even single-threaded programs may not terminate if they happen to a call into a Rust standard library function that never returns. Single-threaded programs can also encode recursion (e.g., via Rc and interior mutability), without explicit recursive calls. Proving termination for concurrent programs is even more complex and still requires significant research and development.

  4. Verus is not (and cannot be) defensive against UB in unverified code.

The guarantees Verus does provide are contingent on the following:

  1. The invocation of Verus is trusted. Verus supports flags like --verify-function and --no-verify that disable some or all verification checks during development. Verification results should only be trusted when flags like these are not included in the invocation of Verus. The --no-cheating flag will report an error if these specific flags are provided, but even then, the invocation of Verus is still a trusted action.
  2. Verus supports various ways to introduce assumptions, since assumptions are often necessary in realistic verification projects. If these assumptions are wrong or violated, then that undermines the verification guarantees. To control for this, please see the --no-cheating command-line flag.
  3. As discussed later in this chapter, verified code that expects to be called from unverified code needs to take additional precautions. Verus provides the (experimental) -V check-api-safety flag to help with this.
  4. Rust proc-macros can make arbitrary changes to Rust source code before Verus sees the code, or they can change what code Verus sees during verification compared to what a normal Rust compile sees. Verus does not prevent such shenanigans.
  5. Verus does not typically support unstable Rust features. It attempts to reject uses of such features, but we cannot guarantee that we will catch them all.
  6. The correctness of Verus, the solvers it depends on, and on Rust itself (including rustc, cargo, etc.).