Fuzzing in the Large

In the past chapters, we have always looked at fuzzing taking place on one machine for a few seconds only. In the real world, however, fuzzers are run on dozens or even thousands of machines; for hours, days and weeks; for one program or dozens of programs. In such contexts, one needs an infrastructure to collect failure data from the individual fuzzer runs, and to aggregate such data in a central repository. In this chapter, we will examine such an infrastructure, the FuzzManager framework from Mozilla.


import bookutils
import Fuzzer


To use the code provided in this chapter, write

>>> from fuzzingbook.FuzzingInTheLarge import <identifier>

and then make use of the following features.

The Python FuzzManager package allows for programmatic submission of failures from a large number of (fuzzed) programs. One can query crashes and their details, collect them into buckets to ensure thay will be treated the same, and also retrieve coverage information for debugging both programs and their tests.

Collecting Crashes from Multiple Fuzzers

So far, all our fuzzing scenarios have been one fuzzer on one machine testing one program. Failures would be shown immediately, and diagnosed quickly by the same person who started the fuzzer. Alas, testing in the real world is different. Fuzzing is still fully automated; but now, we are talking about multiple fuzzers running on multiple machines testing multiple programs (and versions thereof), producing multiple failures that have to be handled by multiple people. This raises the question of how to manage all these activities and their interplay.

A common means to coordinate several fuzzers is to have a central repository that collects all crashes as well as their crash information. Whenever a fuzzer detects a failure, it connects via the network to a crash server, which then stores the crash information in a database.

Crash Database Crash Database Fuzzer 1 Fuzzer 1 Crash Server Crash Server Fuzzer 1->Crash Server Crash Server->Crash Database Fuzzer 2 Fuzzer 2 Fuzzer 2->Crash Server Fuzzer 3 Fuzzer 3 Fuzzer 3->Crash Server Fuzzer 4 Fuzzer 4 Fuzzer 4->Crash Server Fuzzer 5 Fuzzer 5 Fuzzer 5->Crash Server Fuzzer 6 Fuzzer 6 Fuzzer 6->Crash Server

The resulting crash database can be queried to find out which failures have occurred – typically, using a Web interface. It can also be integrated with other process activities. Most importantly, entries in the crash database can be linked to the bug database, and vice versa, such that bugs (= crashes) can be assigned to individual developers.

In such an infrastructure, collecting crashes is not limited to fuzzers. Crashes and failures occurring in the wild can also be automatically reported to the crash server. In industry, it is not uncommon to have crash databases collecting thousands of crashes from production runs – especially if the software in question is used by millions of people every day.

What information is stored in such a database?

  • Most important is the identifier of the product – that is, the product name, version information as well as the platform and the operating system. Without this information, there is no way developers can tell whether the bug is still around in the latest version, or whether it already has been fixed.

  • For debugging, the most helpful information for developers are the steps to reproduce – in a fuzzing scenario, this would be the input to the program in question. (In a production scenario, the user's input is not collected for obvious privacy reasons.)

  • Second most helpful for debugging is a stack trace such that developers can inspect which internal functionality was active in the moment of the failure. A coverage map also comes in handy, since developers can query which functions were executed and which were not.

  • If general failures are collected, developers also need to know what the expected behavior was; for crashes, this is simple, as users do not expect their software to crash.

All of this information can be collected automatically if the fuzzer (or the program in question) is set up accordingly.

In this chapter, we will explore a platform that automates all these steps. The FuzzManager platform allows to

  1. collect failure data from failing runs,
  2. enter this data into a centralized server, and
  3. query the server via a Web interface.

In this chapter, we will show how to conduct basic steps with FuzzManager, including crash submission and triage as well as coverage measurement tasks.

Running a Crash Server

FuzzManager is a tool chain for managing large-scale fuzzing processes. It is modular in the sense that you can make use of those parts you need; it is versatile in the sense that it does not impose a particular process. It consists of a server whose task is to collect crash data, as well as of various collector utilities that collect crash data to send it to the server.

Setting up the Server

To run the examples in this notebook, we need to run a crash server – that is, the FuzzManager server. You can either

  1. Run your own server. To do so, you need to follow the installation steps listed under "Server Setup" on the FuzzManager page. The FuzzManager folder should be created in the same folder as this notebook.

  2. Have the notebook start (and stop) a server. The following commands following commands do this automatically. They are meant for the purposes of this notebook only, though; if you want to experiment with your own server, run it manually, as described above.

import os
import sys
import shutil

We start with getting the fresh server code from the repository.

if os.path.exists('FuzzManager'):
!git clone https://github.com/MozillaSecurity/FuzzManager
Cloning into 'FuzzManager'...
remote: Enumerating objects: 12309, done.
remote: Counting objects: 100% (2228/2228), done.
remote: Compressing objects: 100% (1090/1090), done.
remote: Total 12309 (delta 1472), reused 1717 (delta 1099), pack-reused 10081
Receiving objects: 100% (12309/12309), 5.60 MiB | 8.35 MiB/s, done.
Resolving deltas: 100% (8229/8229), done.
Note: switching to '0.4.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 81d591d chmod +x TaskStatusReporter
!cd FuzzManager; python server/manage.py migrate > /dev/null

We create a user named demo with a password demo, using this handy trick.

!(cd FuzzManager; echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('demo', 'demo@fuzzingbook.org', 'demo')" | python server/manage.py shell)

We create a token for this user. This token will later be used by automatic commands for authentication.

import subprocess
import sys
result = subprocess.run(['python', 

err = result.stderr.decode('ascii')
if len(err) > 0:
    print(err, file=sys.stderr, end="")
token = result.stdout
token = token.decode('ascii').strip()

The token is stored in ~/.fuzzmanagerconf in our home folder. This is the full configuration:

sigdir = /home/example/fuzzingbook
serverhost =
serverport = 8000
serverproto = http
serverauthtoken = 5e96a8c9503247c139f744d9fb112b676a34a796
tool = fuzzingbook
Starting the Server

Once the server is set up, we can start it. On the command line, we use

$ cd FuzzManager; python server/manage.py runserver

In our notebook, we can do this programmatically, using the Process framework introduced for fuzzing Web servers. We let the FuzzManager server run in its own process, which we start in the background.

For multiprocessing, we use the multiprocess module - a variant of the standard Python multiprocessing module that also works in notebooks. If you are running this code outside of a notebook, you can also use multiprocessing instead.

from multiprocess import Process
import subprocess
def run_fuzzmanager():
    def run_fuzzmanager_forever():
        proc = subprocess.Popen(['python', 'server/manage.py',

        while True:
            line = proc.stdout.readline()
            print(line, end='')

    fuzzmanager_process = Process(target=run_fuzzmanager_forever)

    return fuzzmanager_process

While the server is running, you will be able to see its output below.

fuzzmanager_process = run_fuzzmanager()
import time

Logging In

Now that the server is up and running, FuzzManager can be reached on the local host using this URL.

fuzzmanager_url = ""

To log in, use the username demo and the password demo. In this notebook, we do this programmatically, using the Selenium interface introduced in the chapter on GUI fuzzing.

from IPython.display import display, Image
from bookutils import HTML, rich_output
from GUIFuzzer import start_webdriver  # minor dependency

For an interactive session, set headless to False; then you can interact with FuzzManager at the same time you are interacting with this notebook.

gui_driver = start_webdriver(headless=True, zoom=1.2)
gui_driver.set_window_size(1400, 600)

This is the starting screen of FuzzManager:

We now log in by sending demo both as username and password, and then click on the Login button.

After login, we find an empty database. This is where crashes will appear, once we have collected them.

Collecting Crashes

To fill our database, we need some crashes. Let us take a look at simply-buggy, an example repository containing trivial C++ programs for illustration purposes.

!git clone https://github.com/choller/simply-buggy
Cloning into 'simply-buggy'...
remote: Enumerating objects: 22, done.
remote: Total 22 (delta 0), reused 0 (delta 0), pack-reused 22
Receiving objects: 100% (22/22), 4.90 KiB | 4.90 MiB/s, done.
Resolving deltas: 100% (9/9), done.

The make command compiles our target program, including our first target, the simple-crash example. Alongside the program, there is also a configuration file generated.

!(cd simply-buggy && make)
clang++ -fsanitize=address -g -o maze maze.cpp
clang++ -fsanitize=address -g -o out-of-bounds out-of-bounds.cpp
clang++ -fsanitize=address -g -o simple-crash simple-crash.cpp

Let's take a look at the simple-crash source code in simple-crash.cpp. As you can see, the source code is fairly simple: A forced crash by writing to a (near)-NULL pointer. This should immediately crash on most machines.

 * simple-crash - A simple NULL crash.
 * WARNING: This program neither makes sense nor should you code like it is
 *          done in this program. It is purely for demo purposes and uses
 *          bad and meaningless coding habits on purpose.

int crash() {
  int* p = (int*)0x1;
  *p = 0xDEADBEEF;
  return *p;

int main(int argc, char** argv) {
  return crash();

The configuration file simple-crash.fuzzmanagerconf generated for the the binary also contains some straightforward information, like the version of the program and other metadata that is required or at least useful later on when submitting crashes.

platform = x86-64
product = simple-crash-simple-crash
product_version = 83038f74e812529d0fc172a718946fbec385403e
os = linux

pathPrefix = /Users/zeller/Projects/fuzzingbook/notebooks/simply-buggy/
buildFlags = -fsanitize=address -g

Let us run the program! We immediately get a crash trace as expected:

simple-crash(13650,0x110a6c600) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
==13650==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000001 (pc 0x000107b26eb8 bp 0x7ff7b83dbca0 sp 0x7ff7b83dbc70 T0)
==13650==The signal is caused by a WRITE memory access.
==13650==Hint: address points to the zero page.
    #0 0x107b26eb8 in crash() simple-crash.cpp:11
    #1 0x107b26f3a in main simple-crash.cpp:16
    #2 0x1109f14fd in start+0x1cd (dyld:x86_64+0x54fd)

==13650==Register values:
rax = 0x0000000000000001  rbx = 0x0000000107b33060  rcx = 0x0000100000000000  rdx = 0x0000100000000000  
rdi = 0x0000000000000001  rsi = 0x00007ff7b83dbd00  rbp = 0x00007ff7b83dbca0  rsp = 0x00007ff7b83dbc70  
 r8 = 0x000000000066c317   r9 = 0xffffffff00000000  r10 = 0x0000000000000000  r11 = 0x0000000000000246  
r12 = 0x0000000110a6c3a0  r13 = 0x00007ff7b83dbd78  r14 = 0x0000000107b26f20  r15 = 0x0000000110a58010  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV simple-crash.cpp:11 in crash()

Now, what we would actually like to do is to run this binary from Python instead, detect that it crashed, collect the trace and submit it to the server. Let's start with a simple script that would just run the program we give it and detect the presence of the ASan trace:

import subprocess
cmd = ["simply-buggy/simple-crash"]
result = subprocess.run(cmd, stderr=subprocess.PIPE)
stderr = result.stderr.decode().splitlines()
crashed = False

for line in stderr:
    if "ERROR: AddressSanitizer" in line:
        crashed = True

if crashed:
    print("Yay, we crashed!")
    print("Move along, nothing to see...")
Yay, we crashed!

With this script, we can now run the binary and indeed detect that it crashed. But how do we send this information to the crash server now? Let's add a few features from the FuzzManager toolbox.

Program Configurations

A ProgramConfiguration is largely a container class storing various properties of the program, e.g. product name, the platform, version and runtime options. By default, it reads the information from the .fuzzmanagerconf file created for the program under test.

from FTB.ProgramConfiguration import ProgramConfiguration
configuration = ProgramConfiguration.fromBinary('simply-buggy/simple-crash')
(configuration.product, configuration.platform)
('simple-crash-simple-crash', 'x86-64')

Crash Info

A CrashInfo object stores all the necessary data about a crash, including

  • the stdout output of your program
  • the stderr output of your program
  • crash information as produced by GDB or AddressSanitizer
  • a ProgramConfiguration instance
from FTB.Signatures.CrashInfo import CrashInfo

Let's collect the information for the run of simply-crash:

cmd = ["simply-buggy/simple-crash"]
result = subprocess.run(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stderr = result.stderr.decode().splitlines()
 '==13663==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000001 (pc 0x00010b80aeb8 bp 0x7ff7b46f7d30 sp 0x7ff7b46f7d00 T0)']
stdout = result.stdout.decode().splitlines()

This reads and parses our ASan trace into a more generic format, returning us a generic CrashInfo object that we can inspect and/or submit to the server:

crashInfo = CrashInfo.fromRawCrashData(stdout, stderr, configuration)
Crash trace:

# 00    crash
# 01    main
# 02    start+0x1cd

Crash address: 0x1

Last 5 lines on stderr:
 r8 = 0x000000000066c3cb   r9 = 0xffffffff00000000  r10 = 0x0000000000000000  r11 = 0x0000000000000246  
r12 = 0x000000010f96d3a0  r13 = 0x00007ff7b46f7e08  r14 = 0x000000010b80af20  r15 = 0x000000010f959010  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV simple-crash.cpp:11 in crash()


The last step is to send the crash info to our crash manager. A Collector is a feature to communicate with a CrashManager server. Collector provides an easy client interface that allows your clients to submit crashes as well as download and match existing signatures to avoid reporting frequent issues repeatedly.

from Collector.Collector import Collector

We instantiate the collector instance; this will be our entry point for talking to the server.

collector = Collector()

To submit the crash info, we use the collector's submit() method:

{'rawStdout': '',
 'rawStderr': 'AddressSanitizer:DEADLYSIGNAL\n=================================================================\n==13663==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000001 (pc 0x00010b80aeb8 bp 0x7ff7b46f7d30 sp 0x7ff7b46f7d00 T0)\n==13663==The signal is caused by a WRITE memory access.\n==13663==Hint: address points to the zero page.\n    #0 0x10b80aeb8 in crash() simple-crash.cpp:11\n    #1 0x10b80af3a in main simple-crash.cpp:16\n    #2 0x10f8f24fd in start+0x1cd (dyld:x86_64+0x54fd)\n\n==13663==Register values:\nrax = 0x0000000000000001  rbx = 0x000000010b817060  rcx = 0x0000100000000000  rdx = 0x0000100000000000  \nrdi = 0x0000000000000001  rsi = 0x00007ff7b46f7e00  rbp = 0x00007ff7b46f7d30  rsp = 0x00007ff7b46f7d00  \n r8 = 0x000000000066c3cb   r9 = 0xffffffff00000000  r10 = 0x0000000000000000  r11 = 0x0000000000000246  \nr12 = 0x000000010f96d3a0  r13 = 0x00007ff7b46f7e08  r14 = 0x000000010b80af20  r15 = 0x000000010f959010  \nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV simple-crash.cpp:11 in crash()\n==13663==ABORTING',
 'rawCrashData': '',
 'metadata': '{"pathPrefix": "/Users/zeller/Projects/fuzzingbook/notebooks/simply-buggy/", "buildFlags": "-fsanitize=address -g"}',
 'testcase_size': 0,
 'testcase_quality': 0,
 'testcase_isbinary': False,
 'platform': 'x86-64',
 'product': 'simple-crash-simple-crash',
 'product_version': '83038f74e812529d0fc172a718946fbec385403e',
 'os': 'linux',
 'client': 'Braeburn.fritz.box',
 'tool': 'fuzzingbook',
 'env': '',
 'args': '',
 'bucket': None,
 'id': 1,
 'shortSignature': '[@ crash]',
 'crashAddress': '0x1'}

Inspecting Crashes

We now submitted something to our local FuzzManager demo instance. If you run the crash server on your local machine, you can go to you should see the crash info just submitted. You can inquire the product, version, operating system, and further crash details.

If you click on the crash ID, you can further inspect the submitted data.

Since Collectors can be called from any program (provided they are configured to talk to the correct server), you can now collect crashes from anywhere – fuzzers on remote machines, crashes occurring during beta testing, or even crashes during production.

Crash Buckets

One challenge with collecting crashes is that the same crashes occur multiple times. If a product is in the hands of millions of users, chances are that thousands of them will encounter the same bug, and thus the same crash. Therefore, the database will have thousands of entries that are all caused by the same one bug. Therefore, it is necessary to identify those failures that are similar and to group them together in a set called a crash bucket or bucket for short.

In FuzzManager, a bucket is defined through a crash signature, a list of predicates matching a set of bugs. Such a predicate can refer to a number of features, the most important being

  • the current program counter, reporting the instruction excuted at the moment of the crash;
  • elements from the stack trace, showing which functions were active at the moment of the crash.

We can create such a signature right away when viewing a single crash:

Clicking the red Create button creates a bucket for this crash. A crash signature will be proposed to you for matching this and future crashes of the same type:

Accept it by clicking Save.

You will be redirected to the newly created bucket, which shows you the size (how many crashes it holds), its bug report status (buckets can be linked to bugs in an external bug tracker like Bugzilla) and many other useful information.

Crash Signatures

If you click on the Signatures entry in the top menu, you should also see your newly created entry.

You see that this signature refers to a crash occurring in the function crash() (duh!) when called from main() when called from start() (an internal OS function). We also see the current crash address.

Buckets and their signatures are a central concept in FuzzManager. If you receive a lot of crash reports from various sources, bucketing allows you to easily group crashes and filter duplicates.

Coarse-Grained Signatures

The flexible signature system starts out with an initially proposed fine-grained signature, but it can be adjusted as needed to capture variations of the same bug and make tracking easier.

In the next example, we will look at a more complex example that reads data from a file and creates multiple crash signatures - a file out-of-bounds.cpp:

 * out-of-bounds - A simple multi-signature out-of-bounds demo.
 * WARNING: This program neither makes sense nor should you code like it is
 *          done in this program. It is purely for demo purposes and uses
 *          bad and meaningless coding habits on purpose.
#include <cstring>
#include <fstream>
#include <iostream>

void printFirst(char* data, size_t count) {
  std::string first(data, count);
  std::cout << first << std::endl;

void printLast(char* data, size_t count) {
  std::string last(data + strlen(data) - count, count);
  std::cout << last << std::endl;

int validateAndPerformAction(char* buffer, size_t size) {
  if (size < 2) {
    std::cerr << "Buffer is too short." << std::endl;
    return 1;

  uint8_t action = buffer[0];
  uint8_t count = buffer[1];
  char* data = buffer + 2;

  if (!count) {
    std::cerr << "count must be non-zero." << std::endl;
    return 1;

  // Forgot to check count vs. the length of data here, doh!

  if (!action) {
    std::cerr << "Action can't be zero." << std::endl;
    return 1;
  } else if (action >= 128) {
    printLast(data, count);
    return 0;
  } else {
    printFirst(data, count);
    return 0;

int main(int argc, char** argv) {
  if (argc < 2) {
    std::cerr << "Usage is: " << argv[0] << " <file>" << std::endl;

  std::ifstream input(argv[1], std::ifstream::binary);
  if (!input) {
    std::cerr << "Error opening file." << std::endl;

  input.seekg(0, input.end);
  int size = input.tellg();
  input.seekg(0, input.beg);

  if (size < 0) {
    std::cerr << "Error seeking in file." << std::endl;

  char* buffer = new char[size];
  input.read(buffer, size);

  if (!input) {
    std::cerr << "Error while reading file." << std::endl;

  int ret = validateAndPerformAction(buffer, size);

  delete[] buffer;
  return ret;

This program looks way more elaborate compared to the last one, but don't worry, it is not really doing a whole lot:

  • The code in the main() function simply reads a file provided on the command line and puts its contents into a buffer that is passed to validateAndPerformAction().

  • That validateAndPerformAction() function pulls out two bytes of the buffer (action and count) and considers the rest data. Depending on the value of action, it then calls either printFirst() or printLast(), which prints either the first or the last count bytes of data.

If this sounds pointless, that is because it is. The whole idea of this program is that the security check (that count is not larger than the length of data) is missing in validateAndPerformAction() but that the illegal access happens later in either of the two print functions. Hence, we would expect this program to generate at least two (slightly) different crash signatures - one with printFirst() and one with printLast().

Let's try it out with very simple fuzzing based on the last Python script.

Since FuzzManager can have trouble with 8-bit characters in the input, we introduce an escapelines() function that converts text to printable ASCII characters.

escapelines() implementatipn
def isascii(s):
    return all([0 <= ord(c) <= 127 for c in s])
def escapelines(bytes):
    def ascii_chr(byte):
        if 0 <= byte <= 127:
            return chr(byte)
        return r"\x%02x" % byte

    def unicode_escape(line):
        ret = "".join(map(ascii_chr, line))
        assert isascii(ret)
        return ret

    return [unicode_escape(line) for line in bytes.splitlines()]
['Hello,', 'world!']

Now to the actual script. As above, we set up a collector that collects and sends crash info whenever a crash occurs.

cmd = ["simply-buggy/out-of-bounds"]

# Connect to crash server
collector = Collector()


crash_count = 0

for itnum in range(0, TRIALS):
    rand_len = random.randint(1, 1024)
    rand_data = bytes([random.randrange(0, 256) for i in range(rand_len)])

    (fd, current_file) = tempfile.mkstemp(prefix="fuzztest", text=True)
    os.write(fd, rand_data)

    current_cmd = []

    result = subprocess.run(current_cmd,
    stdout = []   # escapelines(result.stdout)
    stderr = escapelines(result.stderr)
    crashed = False

    for line in stderr:
        if "ERROR: AddressSanitizer" in line:
            crashed = True

    print(itnum, end=" ")

    if crashed:
        sys.stdout.write("(Crash) ")

        # This reads the simple-crash.fuzzmanagerconf file
        configuration = ProgramConfiguration.fromBinary(cmd[0])

        # This reads and parses our ASan trace into a more generic format,
        # returning us a generic "CrashInfo" object that we can inspect
        # and/or submit to the server.
        crashInfo = CrashInfo.fromRawCrashData(stdout, stderr, configuration)

        # Submit the crash
        collector.submit(crashInfo, testCase = current_file)

        crash_count += 1


print("Done, submitted %d crashes after %d runs." % (crash_count, TRIALS))
0 (Crash) 1 2 (Crash) 3 4 5 6 7 8 (Crash) 9 10 11 12 (Crash) 13 14 (Crash) 15 16 17 18 19 
Done, submitted 5 crashes after 20 runs.

If you run this script, you will see its progress and notice that it produces quite a few crashes. And indeed, if you visit the FuzzManager crashes page, you will notice a variety of crashes that have accumulated: