Back to rankings

🐇 Fuzzing Rust code with American Fuzzy Lop

rustfuzz-testingaflfuzzing
Star Growth
Stars
1.8k
Forks
118
Weekly Growth
Issues
37
5001k1.5k
Apr 2015Jan 2019Oct 2022Jul 2026
Artifactscrates.iocargo add afl.rs
README

afl.rs logo
afl.rs

Fuzzing Rust code with AFLplusplus

What is it?

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

Documentation can be found in the Rust Fuzz Book.

What does it look like?

Screen recording of afl

Screen recording of AFL running on Rust code.

Hints

Before starting to fuzz, you should reconfigure your system for optimal performance and better crash detection. This can be done with cargo afl system-config. But this subcommand requires root, so it uses sudo internally. Hence, you might need to enter your password.

By default, the AFL++ CMPLOG feature is activated, which helps to achieve good code coverage. However, it is not beneficial to activate CMPLOG on more than two instances. So if you run multiple AFL++ instances on your fuzzing target, you can disable CMPLOG by specifying the command line parameter '-c -'. To omit CMPLOG instrumentation from the built target entirely, set the environment variable AFLRS_NO_CMPLOG to 1 when building.

This document will familiarize you with AFL++ features to help in running a successful fuzzing campaign.

By default, the fuzzing config is set when cargo-afl is used to build. If you want to prevent this, just set the environment variable AFL_NO_CFG_FUZZING to 1 when building.

Resettable State (fuzz_with_reset!)

AFL++ persistent mode runs the fuzz target in a loop. Static initialization (e.g., OnceLock, lazy_static, once_cell::Lazy) only executes on the first iteration — subsequent iterations skip those code paths, causing AFL's stability metric to drop.

Use fuzz_with_reset! to provide a reset closure that clears static state after each iteration.

Note: the example uses Mutex<Option<T>> instead of OnceLock/OnceCell because those types do not support resetting out-of-the-box.

use std::sync::Mutex;

static CACHE: Mutex<Option<Vec<u8>>> = Mutex::new(None);

fn main() {
    afl::fuzz_with_reset!(|data: &[u8]| {
        let mut cache = CACHE.lock().unwrap();
        if cache.is_none() {
            *cache = Some(data.to_vec());
        }
        drop(cache);
        // ... fuzz logic ...
    }, || {
        // Reset closure: called after each successful iteration
        *CACHE.lock().unwrap() = None;
    });
}

A fuzz_with_reset_nohook! variant is also available (like fuzz_nohook!, it does not override the panic hook).

See afl/examples/reset_demo.rs for a complete example.

IJON

If you want to use IJON - helping fuzzer coverage through code annotation - then have a look at the maze example.

Note that the IJON macros have been rustyfied to lowercase - hence IJON_MAX(x) is ijon_max(x) in Rust.

You will need to the following imports from afl, in addition to any macros that you use (e.g., afl::ijon_max):

use afl::ijon_hashint;
use afl::ijon_hashstr;
Related repositories
farion1231/cc-switch

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

Rustcrates.ioMIT Licenseai-toolsclaude-code
ccswitch.io
119.8k8k
rustdesk/rustdesk

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

Rustcrates.ioGNU Affero General Public License v3.0remote-controlremote-desktop
rustdesk.com
118.6k18.1k
rust-lang/rust

Empowering everyone to build reliable and efficient software.

Rustcrates.ioApache License 2.0rustcompiler
rust-lang.org
114.8k15.4k
tauri-apps/tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.

Rustcrates.ioApache License 2.0rustwebview
tauri.app
109.3k3.8k
denoland/deno

A modern runtime for JavaScript and TypeScript.

Rustcrates.ioMIT Licensedenotypescript
deno.com
107.8k6.2k
oven-sh/bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

Rustcrates.ioOtherbunbundler
bun.com
95k4.9k
unionlabs/union

The trust-minimized, zero-knowledge bridging protocol, designed for censorship resistance, extremely high security, and usage in decentralized finance.

Rustcrates.ioApache License 2.0blockchaincosmos
union.build
73.9k3.9k
rtk-ai/rtk

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Rustcrates.ioApache License 2.0agentic-codingai-coding
rtk-ai.app
72.4k4.5k
toeverything/AFFiNE

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

TypeScriptnpmOthereditorcrdt
affine.pro
70.7k5.1k
openinterpreter/openinterpreter

A coding agent for open models like Kimi K3

Rustcrates.ioApache License 2.0coding-agentdeepseek
openinterpreter.com
67.1k5.8k
BurntSushi/ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Rustcrates.ioThe Unlicenseripgreprecursively-search
66.4k2.7k
alacritty/alacritty

A cross-platform, OpenGL terminal emulator.

Rustcrates.ioApache License 2.0terminal-emulatorsopengl
alacritty.org
65k3.5k