cargo-fuzz

Fuzz Rust library code with libFuzzer through a Cargo subcommand.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill cargo-fuzz-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cargo-fuzz
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/cargo-fuzz
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill cargo-fuzz-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust developers need a structured way to discover memory bugs, panics, and parser vulnerabilities by feeding randomized inputs to their code, and cargo-fuzz provides the standard libFuzzer-based workflow integrated directly into Cargo projects. ## Core Features & Use Cases - Harness Creation and Execution: Initialize a fuzz directory, write fuzz targets with the fuzz_target! macro, and run campaigns with a single cargo +nightly fuzz run command. - Sanitizer and Coverage Integration: Run targets under AddressSanitizer by default, disable sanitizers for safe Rust to gain speed, and generate HTML coverage reports from the corpus. - Structure-Aware Fuzzing: Combine with the arbitrary crate to derive structured inputs instead of raw byte slices. - Use Case: Fuzz the ogg crate's packet parser by seeding the corpus with a sample Ogg file, running the campaign, and analyzing coverage to find untested code paths. ## Quick Start Ask the agent to initialize cargo-fuzz in your Rust project, write a fuzz target for your parser function, and run the campaign with the nightly toolchain.

Frequently Asked Questions about cargo-fuzz

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fuzz Rust code with cargo-fuzz?

Install the nightly toolchain and cargo-fuzz, run cargo fuzz init, then write a fuzz target using the fuzz_target! macro that calls your library function. Start the campaign with cargo +nightly fuzz run fuzz_target_1.

cargo-fuzz vs AFL++ vs LibAFL for Rust fuzzing?

cargo-fuzz is the primary choice for Cargo-based projects with quick setup and sanitizer integration. AFL++ suits multi-core fuzzing or non-Cargo projects, while LibAFL targets custom fuzzer research and advanced use cases.

Does cargo-fuzz work with the stable Rust toolchain?

No, cargo-fuzz requires the nightly toolchain because it uses features only available in nightly. Install it with rustup install nightly and invoke commands as cargo +nightly fuzz run.

How do I make cargo-fuzz faster for safe Rust code?

Disable sanitizers with the --sanitizer none flag, which removes roughly 2x AddressSanitizer overhead. Verify your code has no unsafe blocks first using cargo-geiger.

Why does cargo-fuzz fail with cannot find binary?

cargo-fuzz requires your code structured as a library crate. Split binary projects by moving the logic from main.rs into lib.rs with public functions the fuzz target can call.

How do I fuzz structured data instead of raw bytes in Rust?

Derive Arbitrary from the arbitrary crate on your structs and change the fuzz target signature to accept your type instead of &[u8]. libFuzzer then generates structured inputs automatically.