1 Fuzz-testing Bitcoin Core
2 ==========================
4 A special test harness `test_bitcoin_fuzzy` is provided to provide an easy
5 entry point for fuzzers and the like. In this document we'll describe how to
11 It is recommended to always use the latest version of afl:
13 wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
14 tar -zxvf afl-latest.tgz
23 To build Bitcoin Core using AFL instrumentation (this assumes that the
24 `AFLPATH` was set as above):
26 ./configure --disable-ccache --disable-shared --enable-tests CC=${AFLPATH}/afl-gcc CXX=${AFLPATH}/afl-g++
29 make test/test_bitcoin_fuzzy
31 We disable ccache because we don't want to pollute the ccache with instrumented
32 objects, and similarly don't want to use non-instrumented cached objects linked
38 AFL needs an input directory with examples, and an output directory where it
39 will place examples that it found. These can be anywhere in the file system,
40 we'll define environment variables to make it easy to reference them.
49 Example inputs are available from:
51 - https://download.visucore.com/bitcoin/bitcoin_fuzzy_in.tar.xz
52 - http://strateman.ninja/fuzzing.tar.xz
54 Extract these (or other starting inputs) into the `inputs` directory before starting fuzzing.
59 To start the actual fuzzing use:
61 $AFLPATH/afl-fuzz -i ${AFLIN} -o ${AFLOUT} -m52 -- test/test_bitcoin_fuzzy
64 You may have to change a few kernel parameters to test optimally - `afl-fuzz`
65 will print an error and suggestion if so.