tottenjordan/me-skittles/cargo-fuzz
Claude Code and agent skill by tottenjordan/me-skittles
- community
Checking that the SKILL.md file is still in the repository.
cargo-fuzz is the de facto fuzzing tool for Rust projects using Cargo. Use for fuzzing Rust code with libFuzzer backend.
Install
npx vskill@latest install tottenjordan/me-skittles/cargo-fuzzSKILL.md
The same SKILL.md was published earlier as majiayu000/claude-skill-registry/cargo-fuzz.
cargo-fuzz
cargo-fuzz is the de facto choice for fuzzing Rust projects when using Cargo. It uses libFuzzer as the backend and provides a convenient Cargo subcommand that automatically enables relevant compilation flags for your Rust project, including support for sanitizers like AddressSanitizer.
When to Use
cargo-fuzz is currently the primary and most mature fuzzing solution for Rust projects using Cargo.
| Fuzzer | Best For | Complexity | |
|---|---|---|---|
| cargo-fuzz | Cargo-based Rust projects, quick setup | Low | |
| AFL++ | Multi-core fuzzing, non-Cargo projects | Medium | |
| LibAFL | Custom fuzzers, research, advanced use cases | High |
Choose cargo-fuzz when:
- Your project uses Cargo (required)
- You want simple, quick setup with minimal configuration
- You need integrated sanitizer support
- You're fuzzing Rust code with or without unsafe blocks
Quick Start
Initialize and run:
Installation
cargo-fuzz requires the nightly Rust toolchain because it uses features only available in nightly.
Prerequisites
- Rust and Cargo installed via rustup
- Nightly toolchain
Linux/macOS
Verification
Writing a Harness
Project Structure
cargo-fuzz works best when your code is structured as a library crate. If you have a binary project, split your main.rs into:
Initialize fuzzing:
This creates:
Harness Structure
Harness Rules
| Do | Don't | |
|---|---|---|
| Structure code as library crate | Keep everything in main.rs | |
Use fuzz_target! macro | Write custom main function | |
Handle Result::Err gracefully | Panic on expected errors | |
| Keep harness deterministic | Use random number generators |
See Also: For detailed harness writing techniques and structure-aware fuzzing with thearbitrarycrate, see the fuzz-harness-writing technique skill.
Structure-Aware Fuzzing
cargo-fuzz integrates with the arbitrary crate for structure-aware fuzzing:
Add to your library's Cargo.toml:
Running Campaigns
Basic Run
Without Sanitizers (Safe Rust)
If your project doesn't use unsafe Rust, disable sanitizers for 2x performance boost:
Check if your project uses unsafe code:
Re-executing Test Cases
Using Dictionaries
Interpreting Output
| Output | Meaning | |
|---|---|---|
NEW | New coverage-increasing input discovered | |
pulse | Periodic status update | |
INITED | Fuzzer initialized successfully | |
| Crash with stack trace | Bug found, saved to fuzz/artifacts/ |
Corpus location: fuzz/corpus/fuzz_target_1/ Crashes location: fuzz/artifacts/fuzz_target_1/
Sanitizer Integration
AddressSanitizer (ASan)
ASan is enabled by default and detects memory errors:
Disabling Sanitizers
For pure safe Rust (no unsafe blocks in your code or dependencies):
Performance impact: ASan adds ~2x overhead. Disable for safe Rust to improve fuzzing speed.
Checking for Unsafe Code
See Also: For detailed sanitizer configuration, flags, and troubleshooting,see the address-sanitizer technique skill.
Coverage Analysis
cargo-fuzz integrates with Rust's coverage tools to analyze fuzzing effectiveness.
Prerequisites
Generating Coverage Reports
Create coverage generation script:
Generate HTML report:
HTML report saved to: fuzz_html/
See Also: For detailed coverage analysis techniques and systematic coverage improvement,see the coverage-analysis technique skill.
Advanced Usage
Tips and Tricks
| Tip | Why It Helps | |
|---|---|---|
| Start with a seed corpus | Dramatically speeds up initial coverage discovery | |
Use --sanitizer none for safe Rust | 2x performance improvement | |
| Check coverage regularly | Identifies gaps in harness or seed corpus | |
| Use dictionaries for parsers | Helps overcome magic value checks | |
| Structure code as library | Required for cargo-fuzz integration |
libFuzzer Options
Pass options to libFuzzer after --:
Multi-Core Fuzzing
Note: The multi-core fuzzing feature is experimental and not recommended. For parallel fuzzing, consider running multiple instances manually or using AFL++.
Real-World Examples
Example: ogg Crate
The ogg crate parses Ogg media container files. Parsers are excellent fuzzing targets because they handle untrusted data.
Harness at fuzz/fuzz_targets/fuzz_target_1.rs:
Seed the corpus:
Run:
Analyze coverage:
Troubleshooting
| Problem | Cause | Solution | |
|---|---|---|---|
| "requires nightly" error | Using stable toolchain | Use cargo +nightly fuzz | |
| Slow fuzzing performance | ASan enabled for safe Rust | Add --sanitizer none flag | |
| "cannot find binary" | No library crate | Move code from main.rs to lib.rs | |
| Sanitizer compilation issues | Wrong nightly version | Try different nightly: rustup install nightly-2024-01-01 | |
| Low coverage | Missing seed corpus | Add sample inputs to fuzz/corpus/fuzz_target_1/ | |
| Magic value not found | No dictionary | Create dictionary file with magic values |
Related Skills
Technique Skills
| Skill | Use Case | |
|---|---|---|
| fuzz-harness-writing | Structure-aware fuzzing with arbitrary crate | |
| address-sanitizer | Understanding ASan output and configuration | |
| coverage-analysis | Measuring and improving fuzzing effectiveness | |
| fuzzing-corpus | Building and managing seed corpora | |
| fuzzing-dictionaries | Creating dictionaries for format-aware fuzzing |
Related Fuzzers
| Skill | When to Consider | |
|---|---|---|
| libfuzzer | Fuzzing C/C++ code with similar workflow | |
| aflpp | Multi-core fuzzing or non-Cargo Rust projects | |
| libafl | Advanced fuzzing research or custom fuzzer development |
Resources
[Rust Fuzz Book - cargo-fuzz](https://rust-fuzz.github.io/book/cargo-fuzz.html) Official documentation for cargo-fuzz covering installation, usage, and advanced features.
[arbitrary crate documentation](https://docs.rs/arbitrary/latest/arbitrary/) Guide to structure-aware fuzzing with automatic derivation for Rust types.
[cargo-fuzz GitHub Repository](https://github.com/rust-fuzz/cargo-fuzz) Source code, issue tracker, and examples for cargo-fuzz.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingclaude/testing-handbook-skills/skills/cargo-fuzz/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tottenjordan/me-skittles/cargo-fuzz)