Add fuzzing quickstart guide to make it trivial to start fuzzing Bitcoin Core.
Fuzzing is fun and having more people contributing coverage-increasing inputs to https://github.com/bitcoin-core/qa-assets would be awesome :)
Add fuzzing quickstart guide to make it trivial to start fuzzing Bitcoin Core.
Fuzzing is fun and having more people contributing coverage-increasing inputs to https://github.com/bitcoin-core/qa-assets would be awesome :)
@practicalswift This is very informative. 👍
After reading https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md, I was still a bit unclear what that AFL really is. Maybe add http://lcamtuf.coredump.cx/afl/ URL to make it super clear that it's just another fuzzer ("american fuzzy lop")?
0 | @@ -1,9 +1,98 @@ 1 | Fuzz-testing Bitcoin Core 2 | ========================== 3 | 4 | -A special test harness in `src/test/fuzz/` is provided for each fuzz target to 5 | -provide an easy entry point for fuzzers and the like. In this document we'll 6 | -describe how to use it with AFL and libFuzzer. 7 | +## Quickstart guide 8 | + 9 | +To quickly get started with fuzzing Bitcoin Core:
should mention that this only works on linux
I have only tested this under Linux. What part is Linux specific? I would assume these instructions should work for all users with a working and not too ancient Clang/LLVM installation?
Are you referring to the "macOS hints for libFuzzer" instructions later on in the document?
Yes, I meant to say that this doesn't work on mac, even with the latest clang installed
Added:
# macOS X users: If you have problem with this step then make sure to read "macOS hints for
# libFuzzer" on https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer
See below :)
68 | +# abort using ^C after fuzzing a few seconds 69 | +$ ls process_message-seeded-from-thin-air/ 70 | +349ac589fc66a09abc0b72bb4ae445a7a19e2cd8 4df479f1f421f2ea64b383cd4919a272604087a7 71 | +a640312c98dcc55d6744730c33e41c5168c55f09 b135de16e4709558c0797c15f86046d31c5d86d7 72 | +c000f7b41b05139de8b63f4cbf7d1ad4c6e2aa7f fc52cc00ec1eb1c08470e69f809ae4993fa70082 73 | +$ cat -v process_message-seeded-from-thin-air/349ac589fc66a09abc0b72bb4ae445a7a19e2cd8
Pretty sure that throwing arbitrary bytes at bash will lead to random code execution; E.g. sends all your bitcoins to whoever created the seed
I'm not sure I follow at all TBH. Who would throw arbitrary bytes at bash and why? :)
Ah, sorry. I missed the -v. Maybe make it more clear that --show-nonprinting must be passed when looking at fuzz seeds?
Good idea! Replaced -v with --show-nonprinting to make it super clear :)
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
@kiminuo Very good point! I've now also added a quickstart guide for afl-fuzz. Let me know what you think about the current version :)
@practicalswift I find it very good. Thank you for the update!
Updated by adding a link to a nice libFuzzer tutorial provided by Google :)
218 | +$ make 219 | +# For macOS you may need to ignore x86 compilation checks when running "make". If so, 220 | +# try compiling using: AFL_NO_X86=1 make 221 | +$ mkdir -p inputs/ outputs/ 222 | +$ echo A > inputs/thin-air-input 223 | +$ afl-fuzz -i inputs/ -o outputs/ -- src/test/fuzz/bech32
$ afl/afl-fuzz -i inputs/ -o outputs/ -- src/test/fuzz/bech32
I needed to add afl/ to run the fuzzer. same on line 140.
@Thoragh Oh, good catch! Now added afl/.
Thanks a lot for testing the instructions. That's great!
Rebased! :)
210 | +## macOS hints for libFuzzer 211 | + 212 | +The default Clang/LLVM version supplied by Apple on macOS does not include 213 | fuzzing libraries, so macOS users will need to install a full version, for 214 | example using `brew install llvm`. 215 | +>>>>>>> doc: Add fuzzing quickstart guides for libFuzzer and afl-fuzz. Simplify instructions.
:eyes:
Ouch! Fixed :)
Thanks friend!
Ready for merge? :)
ACK 33dd764984def9371f324d3add19ee894a0260bf
121 | +```sh 122 | +$ git clone https://github.com/bitcoin/bitcoin 123 | +$ cd bitcoin/ 124 | +$ git clone https://github.com/google/afl 125 | +$ make -C afl/ 126 | +$ make -C afl/llvm_mode/
macOS users will likely get stuck here (even using brew installed llvm). This will fail to link given afls usage of -znodelete. Dropping that flag leads to issues with undefined symbols.
ACK 33dd764984def9371f324d3add19ee894a0260bf - ran through the quick start and process message instructions. macOS users might see issues with afl-fuzz.