49 breaking releases

0.50.0 Apr 18, 2024
0.48.0 Mar 14, 2024
0.43.0 Dec 14, 2023
0.42.0 Nov 28, 2023
0.0.0 Jan 19, 2022

#89 in Development tools

Download history 810/week @ 2024-01-05 468/week @ 2024-01-12 757/week @ 2024-01-19 632/week @ 2024-01-26 1267/week @ 2024-02-02 807/week @ 2024-02-09 1060/week @ 2024-02-16 1149/week @ 2024-02-23 1166/week @ 2024-03-01 1120/week @ 2024-03-08 924/week @ 2024-03-15 934/week @ 2024-03-22 902/week @ 2024-03-29 957/week @ 2024-04-05 882/week @ 2024-04-12 603/week @ 2024-04-19

3,465 downloads per month

MIT/Apache

36KB
532 lines

Kani regression Nightly: CBMC Latest

The Kani Rust Verifier is a bit-precise model checker for Rust.

Kani is particularly useful for verifying unsafe code blocks in Rust, where the "unsafe superpowers" are unchecked by the compiler.


Kani verifies:

  • Memory safety (e.g., null pointer dereferences)
  • User-specified assertions (i.e., assert!(...))
  • The absence of panics (e.g., unwrap() on None values)
  • The absence of some types of unexpected behavior (e.g., arithmetic overflows)

Installation

To install the latest version of Kani (Rust 1.58+; Linux or Mac), run:

cargo install --locked kani-verifier
cargo kani setup

See the installation guide for more details.

How to use Kani

Similar to testing, you write a harness, but with Kani you can check all possible values using kani::any():

use my_crate::{function_under_test, meets_specification, precondition};

#[kani::proof]
fn check_my_property() {
   // Create a nondeterministic input
   let input = kani::any();

   // Constrain it according to the function's precondition
   kani::assume(precondition(input));

   // Call the function under verification
   let output = function_under_test(input);

   // Check that it meets the specification
   assert!(meets_specification(input, output));
}

Kani will then try to prove that all valid inputs produce acceptable outputs, without panicking or executing unexpected behavior. Otherwise Kani will generate a trace that points to the failure. We recommend following the tutorial to learn more about how to use Kani.

GitHub Action

Use Kani in your CI with model-checking/kani-github-action@VERSION. See the GitHub Action section in the Kani book for details.

Security

See SECURITY for more information.

Contributing

If you are interested in contributing to Kani, please take a look at the developer documentation.

License

Kani

Kani is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Rust

Kani contains code from the Rust project. Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See the Rust repository for details.

Dependencies

~0.3–8MB
~48K SLoC