harness-writing

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Poorly written fuzzing harnesses miss code paths, produce non-reproducible crashes, or slow campaigns to a crawl. This Skill provides proven patterns and rules for building harnesses that reliably route fuzzer input into the system under test. ## Core Features & Use Cases - Harness Patterns: Covers minimal harnesses, integer casting, FuzzedDataProvider for structured inputs, interleaved fuzzing across multiple operations, and structure-aware fuzzing with the Rust 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 exhaustion, and global state issues with concrete fixes. - 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 Ask the AI to write a libFuzzer harness for your target function using FuzzedDataProvider to structure the input.

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?

Define the entry point extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size), validate the input size, then call your target function. Compile with clang++ -fsanitize=fuzzer,address and run against a corpus directory.

How do I extract structured data from fuzzer input bytes?

Use FuzzedDataProvider in C++ to consume typed values like integers and terminated strings from the raw byte stream. In Rust, the arbitrary crate derives deserialization of raw bytes directly into your structs.

What is the difference between libFuzzer and AFL++ harnesses?

libFuzzer uses the LLVMFuzzerTestOneInput callback and can start with an empty corpus. AFL++ works best with persistent mode using __AFL_LOOP for 10-100x speedup and requires at least one seed input.

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 discover bugs across all operations and their interactions.

Why is my fuzzer running slowly with few executions per second?

Slow campaigns usually come from logging, blocking I/O, or heavy per-iteration work in the harness. Remove logging, mock I/O with in-memory buffers, free all allocations, and keep each iteration fast and focused.