harness-writing

Write fuzzing harnesses for C, C++, Rust, and Go targets across libFuzzer, AFL++, and cargo-fuzz.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/marumo333/atrox --skill harness-writing-marumo333
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: harness-writing
Source: https://github.com/marumo333/atrox/tree/main/.claude/skills/trailofbits/plugins/testing-handbook-skills/skills/harness-writing
Command: npx skills add https://github.com/marumo333/atrox --skill harness-writing-marumo333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly written fuzzing harnesses miss entire code paths, produce non-reproducible crashes, and waste fuzzing compute. This Skill provides proven patterns for building harnesses that correctly route fuzzer-generated bytes into your system under test. ## Core Features & Use Cases - Harness Patterns: Covers minimal harnesses, input size validation, integer casting, FuzzedDataProvider usage, interleaved fuzzing, and structure-aware fuzzing with the arbitrary crate. - Tool-Specific Guidance: Includes signatures, compilation commands, and integration tips for libFuzzer, AFL++ persistent mode, cargo-fuzz, and go-fuzz. - Troubleshooting & Anti-Patterns: Diagnoses low execution speed, non-reproducible crashes, memory leaks, and global state issues. - Use Case: You need to fuzz a C++ string concatenation API that takes multiple typed parameters. Use the FuzzedDataProvider pattern to extract integers and terminated strings from raw fuzzer bytes, then compile with clang and AddressSanitizer. ## Quick Start Write a libFuzzer harness for my C++ parser function that accepts a byte buffer and size, with input validation and FuzzedDataProvider for structured extraction.

Frequently Asked Questions about harness-writing

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

FAQPage Schema
How do I write a fuzzing harness for C++ with libFuzzer?▼

Implement the LLVMFuzzerTestOneInput function that receives a uint8_t data pointer and size, then call your target function. Compile with clang++ using -fsanitize=fuzzer,address to link the fuzzing runtime and detect memory bugs.

How to extract structured data from fuzzer input bytes?▼

Use FuzzedDataProvider to consume typed values like integers and strings from raw bytes via methods such as ConsumeIntegral and ConsumeBytesWithTerminator. In Rust, the arbitrary crate derives deserialization directly into your structs.

libFuzzer vs AFL++ harness: what is the difference?▼

libFuzzer uses an in-process LLVMFuzzerTestOneInput callback and can start with an empty corpus. AFL++ typically reads from stdin or files, requires seed inputs, and achieves best performance with persistent mode using __AFL_LOOP.

Why are my fuzzing crashes not reproducible?▼

Non-reproducible crashes usually come from non-determinism or global state. Replace rand() with a PRNG seeded from fuzzer input, mock time and system calls, and reset all global state at the start of each harness iteration.

When should I use interleaved fuzzing in one harness?▼

Use interleaved fuzzing when multiple related operations share similar input types, such as arithmetic or CRUD operations. A mode byte selects the operation, letting one shared corpus benefit all operations and revealing interaction bugs.

What are the limitations of the arbitrary crate for Rust fuzzing?▼

The arbitrary crate does not offer reverse serialization, so you cannot manually construct byte arrays mapping to specific structs. It works best starting from an empty corpus with libFuzzer, but is problematic for AFL++ which needs seed inputs.