radare2/test/fuzz
2026-08-14 16:34:11 +02:00
..
scripts Use clang18 in test/fuzz, add C-types fuzzer and make orchestrator ##test 2025-11-18 02:42:25 +01:00
config.mk Fix the test/fuzz for the latest clang 2026-03-11 16:27:48 +01:00
fix.sh Zig toolchain for debian/i386 crosscompilations ##build 2026-03-12 12:51:54 +01:00
fuzz.sh Zig toolchain for debian/i386 crosscompilations ##build 2026-03-12 12:51:54 +01:00
fuzz_anal.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_asn1_parse.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_axml_decode.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_bin.c Migrate RBinSection store from RList to RVec ##bin 2026-05-14 10:44:42 +02:00
fuzz_bin2.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_bin_demangle.c Clarify scalar and packed binary language types ##bin 2026-08-14 16:34:11 +02:00
fuzz_bplist_parse.c Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00
fuzz_cmd.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_common.h Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00
fuzz_dwarf.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_fs.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_ia.c Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00
fuzz_json_parse.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_pdb_parse.c Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00
fuzz_pkcs7_parse.c Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00
fuzz_protobuf_decode.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_punycode_decode.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_run_parseline.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_types_parser.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_types_parser_custom.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
fuzz_x509_parse.c Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
Makefile Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00
meson.build Cover axml, json and asn1 parsers for the fuzzing testsuite 2026-03-11 20:26:19 +01:00
README.md Fix null/len checks to please the fuzz suite ##test 2026-03-18 19:21:33 +01:00

libFuzzer radare2 tests

Setup

Get libFuzzer-capable clang

eval $(make env)
make setup

Running with the provided Makefile

cd test/fuzz
make setup
make build
make run-fuzzer T=fuzz_types_parser

Help

make usage
make help T=fuzz_r_run_parseline

Corpus

Corpus files are taken from ./test/fuzz/corpus/${T}.

  • Copy the files you like in there before the run-fuzzer

Note: The make build command builds radare2 normally first, then builds the fuzzing targets with proper sanitizers and fuzzer support. This approach avoids the sanitizer linking issues that can occur when building the entire project with sanitizers enabled.

Refer to https://llvm.org/docs/LibFuzzer.html

Run fuzzer

make run-fuzzer T=fuzz_r_run_parseline

Run with custom options

Note that -detect_leaks=0 is always necessary in FUZZER_OPTS

make run-fuzzer T=fuzz_r_run_parseline FUZZER_OPTS="-workers=1 -runs=50000 -timeout=3"

Replay crashes

make replay T=fuzz_r_run_parseline CRASH_FILES="crash-*"

Manual execution

Show help

./build/test/fuzz/fuzz_r_run_parseline -help=1

Run fuzzer

mkdir corpus_parseline
./build/test/fuzz/fuzz_r_run_parseline \
  -workers=1 -runs=50000 -timeout=3    \
  corpus_parseline

Replay crashes

./build/test/fuzz/fuzz_r_run_parseline crash-*

Adding a new target

  • add your test to /test/fuzz/meson.build
  • add /test/fuzz/fuzz_<name>.c file
    • add system setup to LLVMFuzzerInitialize (disable logging, enable sandbox, etc)
    • add fuzz target to LLVMFuzzerTestOneInput
    • make sure input is short (ideally no longer than 256 bytes)
    • make sure no memory leaks are present
  • -close_fd_mask=2 (mute stderr) if your target is spammy
  • -ignore_ooms -fork=16 if you're likely to OOM