1 Fuzzing nbdkit using the American Fuzzy Lop (afl) fuzzer
2 --------------------------------------------------------
4 We can fuzz nbdkit using the -s (read from stdin) option, and feeding
5 in a file of "network" input. The stdout from nbdkit (ie. data that
6 would normally be sent back to the client) is ignored.
8 You will need to recompile nbdkit with afl instrumentation:
10 ./configure CC=/usr/bin/afl-gcc CXX=/usr/bin/afl-g++
14 The fuzzing/testcase_dir directory contains some initial testcases
17 Run multiple copies of afl-fuzz. Usually you should run 1 master (-M)
18 and as many slaves (-S) as you can.
22 mkdir -p fuzzing/sync_dir
23 afl-fuzz -i fuzzing/testcase_dir -o fuzzing/sync_dir -M fuzz01 \
24 ./server/nbdkit -s ./plugins/memory/.libs/nbdkit-memory-plugin.so 1M
28 # replace fuzzNN with fuzz02, fuzz03, etc.
29 afl-fuzz -i fuzzing/testcase_dir -o fuzzing/sync_dir -S fuzzNN \
30 ./server/nbdkit -s ./plugins/memory/.libs/nbdkit-memory-plugin.so 1M
35 To find out if the fuzzing is covering all of the code, I used afl-cov
36 (https://github.com/mrash/afl-cov). Usage is rather complex, so
37 consult the README of that project, but in brief:
39 (1) Create a second copy of the nbdkit source, and compile it with
42 ./configure CFLAGS="-O2 -g -pg -fprofile-arcs -ftest-coverage"
46 (2) Assuming ../nbdkit-afl is the nbdkit source compiled with afl, and
47 the current directory is nbdkit compiled with profiling, then run the
48 command below. You can run this even while afl-fuzz is running.
50 afl-cov -d ../nbdkit-afl/fuzzing/sync_dir \
52 --coverage-cmd "cat AFL_FILE | ./server/nbdkit -s ./plugins/memory/.libs/nbdkit-memory-plugin.so 1M"
54 This will create an HTML test coverage report in
55 ../nbdkit-afl/fuzzing/sync_dir/cov/web/
60 To report security bugs, see ‘SECURITY’ in the top source directory.
62 We only have testcases for the newstyle fixed protocol so far, but if
63 people report that they are exposing the oldstyle protocol to the
64 internet / untrusted clients then we could extend the testing for
67 We have only fuzzed the memory plugin, which is convenient because it
68 stores everything in memory and throws it away when nbdkit exits.
69 Since plugins can have bugs as well as the core server, it may be
70 productive to test other plugins and filters.