A Framework for Fuzz Target Generation and Evaluation
Department of Informatics & Telecommunications, University of Athens
April 11, 2025
from_scratch
branchFuzzing is the execution of a Program Under Test (PUT) using input(s) sampled from an input space (the “fuzz input space”) that protrudes the expected input space of the PUT [1].
These inputs are often generated or mutated automatically.
Goal: trigger unexpected behavior (e.g., crashes, hangs, memory errors).
The purpose of fuzzing relies on the assumption that there are bugs within every program, which are waiting to be discovered. Therefore, a systematic approach should find them sooner or later.
Fuzz testing is valuable for:
- Software that receives inputs from untrusted sources (security);
- Sanity checking the equivalence of two complex algorithms (correctness);
- Verifying the stability of a high-volume API that takes complex inputs (stability), e.g. a decompressor, even if all the inputs are trusted.
LibFuzzer is an in-process, coverage-guided, evolutionary fuzzing engine. LibFuzzer is linked with the library under test, and feeds fuzzed inputs to the library via a specific fuzzing entrypoint (fuzz target).
Used to fuzz library functions. The programmer writes a fuzz target to test their implementation.
Fuzz target
A function that accepts an array of bytes and does something interesting with these bytes using the API under test [4].
AKA fuzz driver, fuzzer entry point, harness.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { DoSomethingWithData(Data, Size); return 0; }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { DoSomethingWithData(Data, Size); return 0; }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { DoSomethingWithData(Data, Size); return 0; }
AFL fuzzes programs/binaries. The inputs are taken from the seeds_dir
and their mutations.
Scalable, distributed, CI fuzzing solution for open-source projects [7].
The vulnerability had the potential to affect almost every internet user, yet was caused by a relatively simple memory buffer overflow bug that could have been detected by fuzzing [9].
This framework generates fuzz targets for real-world C/C++, Java, Python projects with various Large Language Models (LLM) and benchmarks them via the OSS-Fuzz platform [10].
Warning
The project must come with preexisting fuzz targets. Fuzz-Introspector gives the LLM info about the harnesses, not the main program/functions.
json
code reports.One of our sample projects,
tinyxml2
, went from 38% line coverage to 69% without any interventions from our team.
from_scratch
Branchfrom_scratch
BranchFuture plans for OSS-Fuzz-Gen include bootstrapping a project fuzz-wise, meaning generating harnesses for a codebase without harnesses.
The work for this feature is located in https://github.com/google/oss-fuzz-gen/blob/main/experimental/from_scratch. The latest commits do not work. Known working commit: 171aac2
.
$ git checkout 171aac2
.// out/01.rawoutput
<code>
#include <stdint.h>
#include <stddef.h>
typedef struct {
int sec; /* seconds after the minute - [ 0 to 59 ] */
int min; /* minutes after the hour - [ 0 to 59 ] */
int hour; /* hours since midnight - [ 0 to 23] */
int mday; /* day of the month - [ 1 to 31 ] */
int mon; /* months since January - [ 0 to 11 ] */
int year; /* years */
int wday; /* days since Sunday - [ 0 to 6 ] */
int yday; /* days since January 1 - [ 0 to 365 ] */
} date_t;
extern int dateparse(const char* datestr, date_t* t, int *offset, int stringlen);
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Ignore input if it is less than 1
if (size < 1) {
return 0;
}
// Convert data to string
char *datestr = (char *)data;
// Initialize a date_t struct and an offset integer
date_t t;
int offset = 0;
// Call the function-under-test
dateparse(datestr, &t, &offset, (int)size);
return 0;
}
</code>
<code>
tags.A GitHub action that when integrated to a C/C++ project will:
These slides can be found at: https://kchousos.github.io/ofg-presentation/
Konstantinos Chousos - OSS-Fuzz-Gen