Fuzzing Rust code with AFLplusplus
Fuzz testing is a software testing technique used to find security and stability issues by providing pseudo-random data as input to the software. AFLplusplus is a popular, effective, and modern fuzz testing tool based on AFL. This library, afl.rs, allows one to run AFLplusplus on code written in the Rust programming language.
Documentation can be found in the Rust Fuzz Book.
Screen recording of AFL running on Rust code.
lazy_static
variables present problems for AFL's persistent mode, which afl.rs uses. Such variables can cause AFL to give incorrectly low stability reports, or fail to report timeouts, for example.
To address such problems, rust-fuzz provides a "resettable" version of lazy_static
. To use it, make the following two changes to your target's Cargo.toml
file.
- Add a
[patch.crates-io]
section and overide thelazy_static
dependency with the rust-fuzz version:[patch.crates-io] lazy_static = { git = "https://github.com/rust-fuzz/resettable-lazy-static.rs" }
- Enable the
reset_lazy_static
feature on afl.rs:[dependencies] afl = { version = "*", features = ["reset_lazy_static"] }