Implementation:0sec labs 0 Harness Reproduction
| Knowledge Sources | |
|---|---|
| Domains | Source_Code_Review, domain:Harness_Generation, Fuzzing |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tools for Tier-2 multi-component and Tier-3 QEMU sanitizer harness reproduction of C/C++ vulnerabilities, provided by the 0security CLI package.
Description
The runHarnessTier2 function generates a multi-component linker harness for a suspect function, emitting a C harness file and linker fragment. The runHarnessTier3 function builds on Tier-2 by adding QEMU sanitizer validation (ASan, UBSan, MSan) to confirm the crash reproduces under instrumentation. Both use the core engine's buildTier2Harness, extractCorpus, and runTier3Validation functions. Tier-1 (single-function libFuzzer) is the default harness tier.
Usage
Import these when you need to reproduce a vulnerability found during source code review with a generated harness. They are Step 4 (optional) of the source code security review workflow.
Code Reference
Source Location
- Repository: 0security
- File: packages/cli/src/commands/review-harness-tier2.ts:L27+, packages/cli/src/commands/review-harness-tier3.ts:L38+
Signature
export async function runHarnessTier2(args: RunHarnessTier2Args): Promise<void>;
export async function runHarnessTier3(args: RunHarnessTier3Args): Promise<void>;
interface RunHarnessTier2Args {
repo: string; // repository path
harnessFunction: string; // suspect function to drive
harnessHeader?: string; // header to #include
harnessBuildSystem?: string; // autotools | cmake | meson | auto
outputDir?: string;
}
interface RunHarnessTier3Args extends RunHarnessTier2Args {
harnessSanitizers?: string; // asan,ubsan,msan
harnessQemuKernel?: string; // QEMU kernel path
harnessQemuDisk?: string; // QEMU disk path
}
Import
import { runHarnessTier2 } from "./commands/review-harness-tier2.js";
import { runHarnessTier3 } from "./commands/review-harness-tier3.js";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| args.repo | string | Yes /// Repository path | |
| args.harnessFunction | string | Yes /// Suspect function to drive (Tier-2) | |
| args.harnessBuildSystem | string | No /// Build system: autotools, cmake, meson, auto | |
| args.harnessSanitizers | string | No /// Sanitizers: asan,ubsan,msan (Tier-3) | |
| args.harnessQemuKernel | string | No /// QEMU kernel path (Tier-3) |
Outputs
| Name | Type | Description |
|---|---|---|
| Tier-2 return | Promise<void> /// Side effect: emitted harness C file + linker fragment in output dir | |
| Tier-3 return | Promise<void> /// Side effect: QEMU sanitizer validation result |
Usage Examples
Via CLI
# Tier-2 harness for a specific function
0 review ./c-project --profile c-library --harness-tier 2 \
--harness-function parse_header \
--harness-header parse.h \
--harness-build-system cmake
# Tier-3 with QEMU sanitizer validation
0 review ./c-project --profile c-library --harness-tier 3 \
--harness-function parse_header \
--harness-sanitizers asan,ubsan \
--harness-qemu-kernel ./kernel.img \
--harness-qemu-disk ./disk.img