harness writing

Documentation Community

Skill notes

Overview

The harness is the bridge between the fuzzer's random byte generation and your application's API. It must parse raw bytes into meaningful inputs, call target functions, and handle edge cases gracefully. The most important part of any fuzzing setup is the harness—if written poorly, critical parts of your application may not be covered.

Key Concepts

Concept · Description Harness · Function that receives fuzzer input and calls target code under test SUT · System Under Test—the code being fuzzed Entry point · Function signature required by the fuzzer (e.g., LLVMFuzzerTestOneInput) FuzzedDataProvider · Helper class for structured extraction of typed data from raw bytes

When to Apply

Apply this technique when: Creating a new fuzz target for the first time Fuzz campaign has low code coverage or isn't finding bugs Crashes found during fuzzing are not reproducible Target API requires complex or structured inputs

Quick Reference

Task · Pattern Minimal C++ harness · extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) Minimal Rust harness · fuzz_target!( · data: &[u8] · { ... }) Size validation · if (size < MIN_SIZE) return 0; Cast to integers · uint32_t val = *(uint32_t*)(data);

Step 1: Identify Entry Points

Find functions in your codebase that: Accept external input (parsers, validators, protocol handlers) Parse complex data formats (JSON, XML, binary protocols) Perform security-critical operations (authentication, cryptography) Have high cyclomatic complexity or many branches

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
Documentation
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@trailofbits · no license declared
Token usage
Moderate
Setup complexity
Guided setup
External API key
Not required
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
Python
Detected file/system behavior
  • Read-only
  • Write / modify
  • Shell exec
Network behavior
Local-only
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

01
Step 1: Identify Entry Points

Find functions in your codebase that: Accept external input (parsers, validators, protocol handlers) Parse complex data formats (JSON, XML, binary protocols) Perform security-critical operations (authentication, cryptography) Have high cyclomatic complexity or many branches

02
Step 2: Write Minimal Harness

Start with the simplest possible harness that calls your target function: C/C++: Rust:

03
Step 3: Add Input Validation

Reject inputs that are too small or too large to be meaningful: Rationale: The fuzzer generates random inputs of all sizes. Your harness must handle empty, tiny, huge, or malformed inputs without causing unexpected issues in the harness itself (crashes in the SUT are fine—that's what we're looking for).

04
Step 4: Structure the Input

For APIs that require typed data (integers, strings, etc.), use casting or helpers like `FuzzedDataProvider`: Simple casting: Using FuzzedDataProvider:

05
Step 5: Test and Iterate

Run the fuzzer and monitor: Code coverage (are all interesting paths reached?) Executions per second (is it fast enough?) Crash reproducibility (can you reproduce crashes with saved inputs?) Iterate on the harness to improve these metrics.

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.