Skip to content
Branch: master
Find file Copy path
Find file Copy path
9 contributors

Users who have contributed to this file

@mikea @kcc @inferno-chromium @oliverchang @Dor1s @steadmon @korrawitp @collinw @alex
96 lines (72 sloc) 4.46 KB

Reproducing OSS-Fuzz issues

You've been CC'ed on an OSS-Fuzz issue (examples), now what? Before attempting to fix the bug, you should be able to reliably reproduce it.

Fuzz target bugs

Every issue has a reproducer (aka "testcase") file attached. Download it. If the issue is not public, you will need to login using your Google account (why?) that the bug report CCs. This file contains the bytes that were fed to the Fuzz Target.

If you have already integrated the fuzz target with your build and test system, all you do is run:

$ ./fuzz_target_binary <testcase_path>

If this is a timeout bug, add the -timeout=25 argument.
If this is an OOM bug, add the -rss_limit_mb=2048 argument.
Read more on how timeouts and OOMs are handed here.

Depending on the nature of the bug, the fuzz target binary needs to be built with the appropriate sanitizer (e.g. if this is a buffer overflow, with AddressSanitizer).

If you are not sure how to build the fuzzer using the project's build system, you may also use Docker (how?, why?) commands to replicate the exact build steps used by OSS-Fuzz and then feed the reproducer input to the fuzz target.

Building using Docker

Pull the latest Docker images

$ python infra/ pull_images

Docker images get regularly updated with a newer version of build tools, build configurations, scripts, and other changes. In some cases, a particular issue can be reproduced only with a fresh image being used.

Build the image and the fuzzers

$ python infra/ build_image $PROJECT_NAME
$ python infra/ build_fuzzers --sanitizer <address/memory/undefined> $PROJECT_NAME

Reproducing bugs

$ python infra/ reproduce $PROJECT_NAME <fuzz_target_name> <testcase_path>

Find the type of sanitizer used in the report using the value in the Sanitizer column. It is one of the following:

  • address for AddressSanitizer
  • memory for MemorySanitizer
  • undefined for UndefinedBehaviorSanitizer

E.g. for building libxml2 project with UndefinedBehaviorSanitizer (undefined) instrumentation and reproduce a crash testcase for a fuzzer named libxml2_xml_read_memory_fuzzer, it will be:

$ python infra/ build_image libxml2
$ python infra/ build_fuzzers --sanitizer undefined libxml2
$ python infra/ reproduce libxml2 libxml2_xml_read_memory_fuzzer ~/Downloads/testcase

Reproduce using local source checkout

$ python infra/ build_fuzzers --sanitizer <address/memory/undefined> $PROJECT_NAME <source_path>
$ python infra/ reproduce $PROJECT_NAME <fuzz_target_name> <testcase_path>

This is essentially the previous command that additionally mounts local sources into the running container.

  • Fix issue. Write a patch to fix the issue in your local checkout and then use the previous command to verify the fix (i.e. no crash occurred). Use gdb if needed.
  • Submit fix. Submit the fix in the project's repository. ClusterFuzz will automatically pick up the changes, recheck the testcase and will close the issue (in < 1 day).
  • Improve fuzzing support. Consider improving fuzzing support in your project's build and test system.

Reproducing build failures

Our infrastructure runs some sanity tests to make sure that your build was correctly configured, even if it succeeded. To reproduce these locally, run:

$ python infra/ build_image $PROJECT_NAME
$ python infra/ build_fuzzers --sanitizer <address/memory/undefined> --engine <libfuzzer/afl/honggfuzz> $PROJECT_NAME
$ python infra/ check_build  --sanitizer <address/memory/undefined> --engine <libfuzzer/afl/honggfuzz> $PROJECT_NAME <fuzz_target_name>

For reproducing a coverage build failure, follow Code Coverage page to build your project and generate a code coverage report.

You can’t perform that action at this time.