wget/fuzz
Tim Rühsen 103aaf7740 Add NTLM fuzzer
* configure.ac: Create WITH_NTLM conditional.
* fuzz/Makefile.am: Add wget_ntlm_fuzzer.
* fuzz/wget_ntlm_fuzzer.c: New file.
* fuzz/wget_ntlm_fuzzer.in/*: Initial fuzz corpora.
2020-03-06 18:52:37 +01:00
..
wget_cookie_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_css_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_css_fuzzer.repro Fix buffer overflow in CSS parser 2018-04-26 22:40:28 +02:00
wget_ftpls_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_html_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_netrc_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_ntlm_fuzzer.in Add NTLM fuzzer 2020-03-06 18:52:37 +01:00
wget_options_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_progress_fuzzer.in * fuzz/wget_progress_fuzzer.in/*: Add fuzzer corpora 2020-01-10 13:56:39 +01:00
wget_read_hunk_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_robots_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
wget_url_fuzzer.in * fuzz/*.in/*: Update corpora from OSS-fuzz 2019-04-26 14:47:17 +02:00
fuzzer.h Update copyright year to 2020 2020-01-10 12:56:08 +01:00
get_all_corpora Add OSS-Fuzz infrastruture 2018-04-16 09:58:51 +02:00
get_ossfuzz_corpora * fuzz/get_ossfuzz_corpora: Remove -f from unzip, mkdir *.in/ 2019-04-26 14:14:12 +02:00
glob_crash.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
main.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
Makefile.am Add NTLM fuzzer 2020-03-06 18:52:37 +01:00
README.md * fuzz/README.md: Add --enable-assert to fuzzing build 2019-12-27 13:41:20 +01:00
run-afl.sh Update copyright year to 2020 2020-01-10 12:56:08 +01:00
run-clang.sh Update copyright year to 2020 2020-01-10 12:56:08 +01:00
view-coverage.sh Add OSS-Fuzz infrastruture 2018-04-16 09:58:51 +02:00
wget_cookie_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_cookie_fuzzer.dict Add new fuzzer for the Set-Cookie parser 2018-04-27 12:56:25 +02:00
wget_css_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_ftpls_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_ftpls_fuzzer.dict Add new fuzzer for the FTP listing parsers 2018-04-21 19:24:25 +02:00
wget_html_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_html_fuzzer.dict Add new HTML parser fuzzer 2018-04-20 22:33:58 +02:00
wget_netrc_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_netrc_fuzzer.dict Add new fuzzer for the .netrc parser 2018-04-28 20:49:57 +02:00
wget_ntlm_fuzzer.c Add NTLM fuzzer 2020-03-06 18:52:37 +01:00
wget_options_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_options_fuzzer.dict Revert " Hi, Thank you again Darshit for your response. The RejectHeaderField rule rejects ANY header" 2019-05-30 11:19:46 +02:00
wget_progress_fuzzer.c Add new fuzzer for the progress bar code 2020-01-10 13:56:39 +01:00
wget_read_hunk_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_robots_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00
wget_url_fuzzer.c Update copyright year to 2020 2020-01-10 12:56:08 +01:00

Fuzzers

These are fuzzers designed for use with libFuzzer or afl. They can be used to run on Google's OSS-Fuzz (https://github.com/google/oss-fuzz/).

The convention used here is that the initial values for each parser fuzzer are taken from the $NAME.in directory.

Crash reproducers from OSS-Fuzz are put into $NAME.repro directory for regression testing with top dir 'make check' or 'make check-valgrind'.

Running a fuzzer using clang

Use the following commands on top dir:

export CC=clang
export CXX=clang++
# address sanitizer:
#export CFLAGS="-O1 -g -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined,integer,nullability -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp"
export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link"
# undefined sanitizer;
export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=bool,array-bounds,float-divide-by-zero,function,integer-divide-by-zero,return,shift,signed-integer-overflow,vla-bound,vptr -fno-sanitize-recover=bool,array-bounds,float-divide-by-zero,function,integer-divide-by-zero,return,shift,signed-integer-overflow,vla-bound,vptr -fsanitize=fuzzer-no-link"
export CXXFLAGS="$CFLAGS -stdlib=libc++"
export LIB_FUZZING_ENGINE="-lFuzzer -lstdc++"
./configure --enable-fuzzing --without-metalink --without-zlib --disable-pcre --without-libuuid --enable-assert
make clean
make -j$(nproc)
cd fuzz

# run wget_options_fuzzer
UBSAN_OPTIONS=print_stacktrace=1 ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer \
  ./run-clang.sh wget_options_fuzzer

If you see a crash, then a crash corpora is written that can be used for further investigation. E.g.

==2410==ERROR: AddressSanitizer: heap-use-after-free on address 0x602000004e90 at pc 0x00000049cf9c bp 0x7fffb5543f70 sp 0x7fffb5543720
...
Test unit written to ./crash-adc83b19e793491b1c6ea0fd8b46cd9f32e592fc

To reproduce the crash:

./wget_options_fuzzer < ./crash-adc83b19e793491b1c6ea0fd8b46cd9f32e592fc

You can also copy/move that file into wget_options_fuzzer.repro/ and re-build the project without fuzzing for a valgrind run, if you like that better. Just a ./configure and a make check-valgrind should reproduce it.

Running a fuzzer using AFL

Use the following commands on top dir:

$ export LIB_FUZZING_ENGINE=""
$ CC=afl-clang-fast ./configure --enable-fuzzing
$ make -j$(nproc) clean all
$ cd fuzz
$ ./run-afl.sh wget_options_fuzzer

Fuzz code coverage using the corpus directories *.in/

Code coverage reports currently work best with gcc+lcov+genhtml.

In the top directory:

CC=gcc CFLAGS="-O0 -g" ./configure
make fuzz-coverage
xdg-open lcov/index.html

To work on corpora for better coverage, cd fuzz and use e.g. ./view-coverage.sh wget_options_fuzzer.

Creating wget_options_fuzzer.dict

for i in `../src/wget --help|tr ' ' '\n'|grep ^--|cut -c 3-|sort`;do echo \"$i\"; done >wget_options_fuzzer.dict