pull down to refresh

In just 3 weeks we're hosting BTC++ Exploits edition in Florianopolis, Brazil, so we thought it would be fun to offer up some bounties for the best technical explanations of exploits-related concepts.

This week's bounty is for Fuzzing. We've got 10,000 sats for the best explanation of what fuzzing is and how it is used in Bitcoin development.

Go!

10,000 sats bounty
btcpp's bounties
80 sats \ 0 replies \ @fiksn 1h

Mining aims to find new blocks, fuzzing tries to find new vulnerabilities. Both require wast amounts of computing power to explore the search space.

For a cryptographic hash function we believe there is no shortcut and you just have to bruteforce to find the desired prefix, in fuzzing you can have heuristics to guide you - like is the program crashing, was this function visited or did something else unexpected happen with this random input.

reply
0 sats \ 1 reply \ @marcelo39 5h

Fuzzing is an automated software testing technique designed to discover bugs, crashes, memory issues, assertion failures, and potential security vulnerabilities by feeding a program a massive number of semi-random, mutated, or invalid inputs (often called "fuzz" inputs) and observing how the code behaves under those extreme conditions.

The core idea is simple but powerful: instead of writing hand-crafted test cases for every possible scenario (which is impossible for complex systems), a fuzzer generates or mutates inputs intelligently, runs the target code repeatedly, and uses feedback (especially code coverage — which branches/paths were executed) to guide the generation of new, more interesting inputs that explore previously untested areas of the codebase. When the program crashes, hangs, leaks memory, or triggers undefined behavior on some input, that's a signal of a potential bug worth investigating.

There are different styles of fuzzing:

  • Dumb/black-box fuzzing — purely random inputs (early and simple form).
  • Mutation-based fuzzing — start with valid "seed" inputs (e.g., real Bitcoin messages or serialized transactions) and mutate them slightly (flip bits, change lengths, insert garbage, etc.).
  • Generation-based fuzzing — create structured inputs from scratch based on a format/model (more advanced but harder to set up).
  • Coverage-guided fuzzing (the modern gold standard) — tools track which code paths are hit and evolve the input corpus toward deeper coverage.

Popular coverage-guided fuzzers used in open-source projects include libFuzzer (from LLVM/Clang, in-process and very fast), AFL++ (American Fuzzy Lop successor, great for binary-only targets), and Honggfuzz.

How Fuzzing Is Used in Bitcoin DevelopmentHow Fuzzing Is Used in Bitcoin Development

Bitcoin Core (the reference implementation) has integrated coverage-guided fuzzing deeply into its development process since around 2016–2018, evolving from early experiments to a mature infrastructure. This helps catch subtle bugs — especially in parsing, deserialization, validation, and consensus-critical code — before they become exploitable vulnerabilities on mainnet.

Key aspects in Bitcoin Core:

  • Fuzz targets/harnesses — Small, specialized entry points (functions) in src/test/fuzz/ that take a byte array from the fuzzer, interpret it as structured Bitcoin data (e.g., a transaction, block, compact block relay message, script, address, banman entry, etc.), and feed it through the real parsing/validation/consensus logic. Examples include fuzz targets for transaction deserialization, signature checking, block header validation, mempool loading, P2P message handling, and more.
  • Tools integration — Bitcoin Core officially supports:
    • libFuzzer (recommended for speed and in-process execution; build with cmake --preset=libfuzzer and run targets like ./build_fuzz/bin/fuzz -max_total_time=...).
    • AFL++ and Honggfuzz for different coverage strategies or when libFuzzer isn't suitable.
  • Continuous fuzzing — Many targets run on infrastructure like OSS-Fuzz (Google's free fuzzing service for open-source), ClusterFuzz, or private setups. This provides ongoing, always-on fuzzing that has run for millions/billions of executions.
  • Historical impact — Fuzzing has caught numerous issues over the years, including edge cases in deserialization that could have led to crashes, denial-of-service, or (in rare cases) more severe bugs. It helped retroactively test fixes for older CVEs and continuously prevents regressions. Projects like bitcoinfuzz extend this to differential fuzzing across implementations (Bitcoin Core vs. btcd, rust-bitcoin, etc.) to find consensus divergences.
  • Why it's especially valuable for Bitcoin — Bitcoin handles untrusted network data constantly (P2P messages, transactions, blocks from anywhere). Parsing bugs can lead to crashes, network splits, or — worst case — consensus failures or inflation bugs. Fuzzing stress-tests these attack surfaces at scale, far beyond what unit tests or manual review can achieve.

In short: fuzzing acts as an automated "adversary" that tries to break Bitcoin Core's code with weird inputs 24/7, making the network more robust against real-world exploits. It's one of the most cost-effective ways the project invests in security.

reply
159 sats \ 0 replies \ @Fabs 5h

Thanks ChatGPT.

reply

From my understanding it’s a way for a programmer to test their code with different input and scenarios to see if the code is secure

reply

Fuzzing is a form of program-driven quality testing. It is used to purposefully input bad or erroneous data into Bitcoin Core node software to find bugs, errors and glitches. The results can the be used to build in protections going forward, making the blockchain network stronger and more resilient.

reply
reply

deleted by author