<p>In the <a href="https://arxiv.org/pdf/1812.00140.pdf" rel="nofollow noreferrer">paper</a> The Art, Science and Engineering of Fuzzing the authors define fuzzing as “a process of repeatedly running a program with generated inputs that may be syntactically or semantically malformed”.</p>
<p>Fuzz testing is not a new concept. It was introduced in the early 1990s but at the present time its potential for finding bugs has not been fully explored in the Bitcoin Core codebase.</p>
<p>Of course fuzzing is a technique not only used by those seeking to prevent bugs in a software project (defenders) but also those seeking to exploit a bug (attackers). There is a danger that if projects like Bitcoin Core fall behind the state of the art in defense techniques that attackers could take advantage.</p>
<p>Matt Corallo discussed fuzz testing at <a href="https://www.youtube.com/watch?v=0lGO5I74qJM" rel="nofollow noreferrer">London Bitcoin Devs</a> in February 2019.</p>
<blockquote>
<p>Fuzz testing is a general testing approach of black boxing a test case that takes as input some random set of bytes, running a program on it and trying to make it crash. This is primarily used for decoders, things like that. They have proven to be very, very, very effective at taking an image decompression library or something that processes untrusted data off a network and making it crash, finding vulnerabilities in it, finding stack overflow, buffer overflow kind of vulnerabilities. They are not just completely dumb, like shove in random bytes. They actually instrument the binary. Usually what they do is they instrument the binary, and you can do this in hardware or in software, and detect when a given input has found new paths in the program. So you map out all the if statements and all the branches in the program and if it finds an input that hits a new branch then it considers that input interesting and it will mutate that input a little bit more than other inputs.</p>
</blockquote>
<p>Matt Corallo added at <a href="https://diyhpl.us/wiki/transcripts/advancing-bitcoin/2019/2019-02-07-matt-corallo-rust-lightning/" rel="nofollow noreferrer">Advancing Bitcoin</a> in February 2019:</p>
<blockquote>
<p>Fuzzing has been incredibly useful across the software world but mostly for finding vulnerabilities in things like image decompressors, image decoders, message deserializers, that sort of thing. And what it does is you write a program that takes as input some arbitrary string of bytes and you do something with those bytes and the fuzzer tries to make you crash. So if you have some image decoder or decompressor often times it will find a bug where you used too much memory, you have an out of memory condition and you have a DoS vulnerability there. Or maybe it will find a bug where you have some buffer overflow, something like that. Or whatever depending on the language you’re writing in. Fuzzers have been amazing. You can go look up all of the various CVEs and vulnerabilities they’ve found. We’ve been playing a lot with them in rust-lightning and we have the standard ones of just make sure all of our message deserializers don’t crash or don’t use infinite memory. But we also have some allow nodes to do completely arbitrary things. So we have one fuzz target that runs a full node and can receive bytes on the wire. This allows you to literally do anything that another node could do to you possibly in a fuzzing environment where the fuzzer is trying to creatively crash your program and comes up with different inputs that might exercise different code paths</p>
</blockquote>

CC BY-SA 4.0
2020-11-11T12:55:27.187Z
2020-11-11T12:55:27.187Z
Michael Folkson
<p>I've been looking at the Bitcoin Core PR review club sessions on fuzz testing <a href="https://bitcoincore.reviews/17860" rel="nofollow noreferrer">here</a> and <a href="https://bitcoincore.reviews/18521" rel="nofollow noreferrer">here</a>.</p>
<p>Can you explain at a high level what is fuzz testing?</p>

<bitcoin-core-development><testing><bitcoincore-review><fuzz-test>
What is fuzz testing?
Michael Folkson
# What is fuzz testing?

(Asked by: username_0 on 2020-11-11)

I've been looking at the Bitcoin Core PR review club sessions on fuzz testing [here](https://bitcoincore.reviews/17860) and [here](https://bitcoincore.reviews/18521).

Can you explain at a high level what is fuzz testing?

**Tags:** bitcoin-core-development, testing, bitcoincore-review, fuzz-test


---

## 1 answers

### Answer by username_0 on 2020-11-11. Score: 3 | Accepted answer

In the [paper](https://arxiv.org/pdf/1812.00140.pdf) The Art, Science and Engineering of Fuzzing the authors define fuzzing as “a process of repeatedly running a program with generated inputs that may be syntactically or semantically malformed”.

Fuzz testing is not a new concept. It was introduced in the early 1990s but at the present time its potential for finding bugs has not been fully explored in the Bitcoin Core codebase.

Of course fuzzing is a technique not only used by those seeking to prevent bugs in a software project (defenders) but also those seeking to exploit a bug (attackers). There is a danger that if projects like Bitcoin Core fall behind the state of the art in defense techniques that attackers could take advantage.

Matt Corallo discussed fuzz testing at [London Bitcoin Devs](https://www.youtube.com/watch?v=0lGO5I74qJM) in February 2019.

> Fuzz testing is a general testing approach of black boxing a test case that takes as input some random set of bytes, running a program on it and trying to make it crash. This is primarily used for decoders, things like that. They have proven to be very, very, very effective at taking an image decompression library or something that processes untrusted data off a network and making it crash, finding vulnerabilities in it, finding stack overflow, buffer overflow kind of vulnerabilities. They are not just completely dumb, like shove in random bytes. They actually instrument the binary. Usually what they do is they instrument the binary, and you can do this in hardware or in software, and detect when a given input has found new paths in the program. So you map out all the if statements and all the branches in the program and if it finds an input that hits a new branch then it considers that input interesting and it will mutate that input a little bit more than other inputs.

Matt Corallo added at [Advancing Bitcoin](https://diyhpl.us/wiki/transcripts/advancing-bitcoin/2019/2019-02-07-matt-corallo-rust-lightning/) in February 2019:

> Fuzzing has been incredibly useful across the software world but mostly for finding vulnerabilities in things like image decompressors, image decoders, message deserializers, that sort of thing. And what it does is you write a program that takes as input some arbitrary string of bytes and you do something with those bytes and the fuzzer tries to make you crash. So if you have some image decoder or decompressor often times it will find a bug where you used too much memory, you have an out of memory condition and you have a DoS vulnerability there. Or maybe it will find a bug where you have some buffer overflow, something like that. Or whatever depending on the language you’re writing in. Fuzzers have been amazing. You can go look up all of the various CVEs and vulnerabilities they’ve found. We’ve been playing a lot with them in rust-lightning and we have the standard ones of just make sure all of our message deserializers don’t crash or don’t use infinite memory. But we also have some allow nodes to do completely arbitrary things. So we have one fuzz target that runs a full node and can receive bytes on the wire. This allows you to literally do anything that another node could do to you possibly in a fuzzing environment where the fuzzer is trying to creatively crash your program and comes up with different inputs that might exercise different code paths


---

