2016-11-16 17:56:10 +00:00
|
|
|
# Reproducing OSS-Fuzz issues
|
2016-10-26 16:40:37 +00:00
|
|
|
|
2016-11-19 01:18:02 +00:00
|
|
|
You've been CC'ed on an OSS-Fuzz issue ([examples](https://bugs.chromium.org/p/oss-fuzz/issues/list)),
|
|
|
|
now what?
|
|
|
|
Before attempting a fix the bug you should be able to reliably reproduce it.
|
2016-10-27 03:48:30 +00:00
|
|
|
|
2016-11-19 01:18:02 +00:00
|
|
|
Every issue has a reproducer file attached.
|
|
|
|
This file contains the bytes that were fed to the [Fuzz Target](http://libfuzzer.info/#fuzz-target).
|
|
|
|
|
|
|
|
If you have [properly integrated](ideal_integration.md) the fuzz target with your build and test system
|
|
|
|
all you need is to download the reproducer file and run
|
|
|
|
```
|
|
|
|
./fuzz_target_binary REPRODUCER_FILE
|
|
|
|
```
|
|
|
|
Depending on the nature of the bug, the fuzz target binary needs to be build with the appropriate sanitizer
|
|
|
|
(e.g. if this is a buffer overflow, with [AddressSanitizer](http://clang.llvm.org/docs/AddressSanitizer.html)).
|
|
|
|
|
|
|
|
**TODO**
|
|
|
|
|
|
|
|
Another option is to use the Docker commands (**TODO: link**) to replicate the exact build steps
|
|
|
|
used by OSS-Fuzz and then feed the reproducer input to the target.
|
|
|
|
|
|
|
|
([how?](installing_docker.md), [why?](faq.md#why-do-you-use-docker)), but
|
2016-10-26 16:40:37 +00:00
|
|
|
is entirely possible to do without.
|
|
|
|
|
2016-11-19 01:18:02 +00:00
|
|
|
## **TODO Move into a separate file with docker commands**
|
|
|
|
|
2016-11-05 16:11:54 +00:00
|
|
|
## Bug tracker reports
|
2016-11-04 23:01:33 +00:00
|
|
|
|
|
|
|
Bug reports in our bug tracker have the format:
|
|
|
|
|
|
|
|
```
|
2016-11-07 19:04:28 +00:00
|
|
|
Detailed report: <link to ClusterFuzz report>
|
2016-11-04 23:01:33 +00:00
|
|
|
|
|
|
|
Target: target
|
|
|
|
Fuzzer: libFuzzer_target_fuzzer
|
|
|
|
Fuzzer binary: fuzzer
|
|
|
|
Job Type: libFuzzer_asan_libchewing
|
|
|
|
|
|
|
|
Crash Type: Heap-use-after-free
|
|
|
|
Crash Address: 0x1337
|
|
|
|
Crash State
|
|
|
|
Frame1
|
|
|
|
Frame2
|
|
|
|
Frame3
|
|
|
|
|
|
|
|
Regressed: <Regression range link>
|
|
|
|
|
|
|
|
Minimized Testcase (size): <Testcase download link>
|
|
|
|
```
|
|
|
|
|
|
|
|
Click the testcase download link to download the testcase (you may need to
|
|
|
|
login, using the same Google account that you've been CC'ed with). The "Detailed
|
|
|
|
report" link provides the full stack trace, as well as some additional details
|
|
|
|
that may be useful.
|
|
|
|
|
|
|
|
For the following instructions, `$target` is the text after `Target: ` in the
|
|
|
|
report, and `$fuzzer` is the text after `Fuzzer binary: `. `$testcase_file` is
|
|
|
|
the path to the testcase you just downloaded.
|
|
|
|
|
|
|
|
Note that for older reports, `Fuzzer binary:` and `Target:` may not exist. In
|
|
|
|
this case, please extract this information from the `Fuzzer:` field. This is
|
|
|
|
usually in the format `libFuzzer_$target_$fuzzer`.
|
|
|
|
|
2016-10-26 22:11:18 +00:00
|
|
|
## Docker
|
2016-10-26 16:40:37 +00:00
|
|
|
|
2016-10-26 22:11:50 +00:00
|
|
|
If you have docker installed, follow these steps:
|
2016-10-26 16:40:37 +00:00
|
|
|
|
2016-10-27 03:46:20 +00:00
|
|
|
- *Reproduce from nightly sources:*
|
2016-10-26 18:04:46 +00:00
|
|
|
|
2016-10-26 21:59:27 +00:00
|
|
|
<pre>
|
2016-10-27 03:41:40 +00:00
|
|
|
docker run --rm -v <b><i>$testcase_file</i></b>:/testcase -t ossfuzz/<b><i>$target</i></b> reproduce <b><i>$fuzzer</i></b>
|
2016-10-26 21:59:27 +00:00
|
|
|
</pre>
|
2016-10-26 18:04:46 +00:00
|
|
|
|
2016-10-26 18:51:01 +00:00
|
|
|
It builds the fuzzer from nightly sources (in the image) and runs it with testcase input.
|
2016-10-26 21:13:17 +00:00
|
|
|
E.g. for libxml2 it will be:
|
|
|
|
|
2016-10-26 22:10:58 +00:00
|
|
|
<pre>
|
2016-10-27 03:40:55 +00:00
|
|
|
docker run --rm -ti -v <b><i>~/Downloads/testcase</i></b>:/testcase ossfuzz/<b><i>libxml2</i></b> reproduce <b><i>libxml2_xml_read_memory_fuzzer</i></b>
|
2016-10-26 22:10:58 +00:00
|
|
|
</pre>
|
2016-10-27 03:46:20 +00:00
|
|
|
- *Reproduce from local sources:*
|
2016-10-26 18:04:46 +00:00
|
|
|
|
2016-10-27 03:40:55 +00:00
|
|
|
<pre>
|
2016-10-27 03:44:11 +00:00
|
|
|
docker run --rm -v <b><i>$target_checkout_dir</i></b>:/src/<b><i>$target</i></b> \
|
|
|
|
-v <b><i>$reproducer_file</i></b>:/testcase -t ossfuzz/<b><i>$target</i></b> reproduce <b><i>$fuzzer</i></b>
|
2016-10-27 03:40:55 +00:00
|
|
|
</pre>
|
2016-10-26 18:04:46 +00:00
|
|
|
|
2016-10-27 03:48:12 +00:00
|
|
|
This is essentially the previous command that additonally mounts local sources into the running container.
|
2016-11-02 19:43:54 +00:00
|
|
|
- *Fix the issue.* Use the previous command to verify you fixed the issue locally.
|
|
|
|
[Use gdb](debugging.md#debugging-fuzzers-with-gdb) if needed.
|
2016-10-27 03:45:52 +00:00
|
|
|
- *Submit the fix.* ClusterFuzz will automatically pick up the changes, recheck the testcase
|
2016-10-26 18:04:46 +00:00
|
|
|
and will close the issue.
|