mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-02-03 18:49:28 -05:00
| .. | ||
| check | ||
| fuzz_dname_from_str.in | ||
| fuzz_dname_to_str.in | ||
| fuzz_packet.in@69e4a98151 | ||
| fuzz_zscanner.in@4cf63e8894 | ||
| knotd_wrap | ||
| .gitignore | ||
| fuzz_dname_from_str.c | ||
| fuzz_dname_to_str.c | ||
| fuzz_packet.c | ||
| fuzz_zscanner.c | ||
| main.c | ||
| Makefile.am | ||
| README.md | ||
Fuzzing stdio-wrapped knotd with AFL
- Ensure Clang
- Ensure AFL 1.83b+ or install a fresh one
curl -O -L http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgztar -xzf afl-latest.tgzcd afl-*/makemake -C llvm_modesudo make install
- Compile Knot DNS with
afl-clangcompilerCC=afl-clang-fast ./configure --disable-shared --disable-utilities --disable-documentation- (Add
--with-sanitizer=addressfor ASAN) make
- Try running
knotd_stdiocd tests-fuzzmake check-compilemkdir -p /tmp/knotd-fuzz/rundir /tmp/knotd-fuzz/storage./knotd_stdio -c ./knotd_wrap/knot_stdio.conf- (Consider adding zones or modules to the configuration)
- Prepare an initial corpus
- Checkout the dns-fuzzing repository
git clone https://github.com/CZ-NIC/dns-fuzzing in - (Add more custom test cases to
in/packet/)
- Checkout the dns-fuzzing repository
- Minimize the tested corpus with
afl-cminand simple packet parser (doesn't work with ASAN!)afl-cmin -i in/packet/ -o min -- ./fuzz_packet
- Run the fuzzer
AFL_PERSISTENT=1 afl-fuzz -m 1000M -i min -o out -- ./knotd_stdio -c knotd_wrap/knot_stdio.conf- (Add
AFL_USE_ASAN=1and use-m noneif compiled with ASAN) - (Consider parallel fuzzing, see
afl-fuzz -h)
NOTE: Sanitizer utilization is a bit problematical with AFL, see [notes_for_asan.txt] (https://github.com/mirrorer/afl/blob/master/docs/notes_for_asan.txt).
Fuzzing with libFuzzer (requires Clang 6.0+)
- Ensure Clang with
-fsanitize=fuzzersupport (e.g. LLVM) - Configure with
- Compile Knot DNS:
make
- Create and check the fuzzing binaries
cd tests-fuzzmake check
- Download the corpora
git submodule initgit submodule update --recursive --remote
- (Optional) add more test cases
./fuzz_packet -merge=1 fuzz_packet.in <DIR_WITH_NEW_PACKET_TEST_CASES>./fuzz_zscanner -merge=1 fuzz_zscanner.in <DIR_WITH_NEW_ZSCANNER_TEST_CASES>
- Run the fuzzer
- (Set proper symbolizer if necessary
export ASAN_SYMBOLIZER_PATH=$(readlink -f `which llvm-symbolizer-6.0`)for ASAN orexport UBSAN_SYMBOLIZER_PATH=$(readlink -f `which llvm-symbolizer-6.0`)for UBSAN) ./fuzz_packet fuzz_packet.inor./fuzz_zscanner fuzz_zscanner.in- (Add parallel fuzzing
-jobs=<CPUS>
- (Set proper symbolizer if necessary