#!/bin/bash # Copyright 2016 Google Inc. All Rights Reserved. # Licensed under the Apache License, Version 2.0 (the "License"); . $(dirname $0)/../custom-build.sh $1 $2 . $(dirname $0)/../common.sh
if [[$FUZZING_ENGINE == "hooks"]]; then # Link ASan runtime so we can hook memcmp et al. LIB_FUZZING_ENGINE="$LIB_FUZZING_ENGINE -fsanitize=address" fi $CXX $CXXFLAGS$SCRIPT_DIR/target.cc -I BUILD BUILD/.libs/libcares.a $LIB_FUZZING_ENGINE -o $EXECUTABLE_NAME_BASE
root@server:~/fuzz/cares$ ls c-ares cares-fuzzer target.cc root@server:~/fuzz/cares$ ./cares-fuzzer INFO: Seed: 3031255060 INFO: Loaded 1 modules (10 inline 8-bit counters): 10 [0x5a90e0, 0x5a90ea), INFO: Loaded 1 PC tables (10 PCs): 10 [0x56c278,0x56c318), INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes INFO: A corpus is not provided, starting from an empty corpus #2 INITED cov: 3 ft: 3 corp: 1/1b exec/s: 0 rss: 27Mb #4 NEW cov: 4 ft: 4 corp: 2/3b lim: 4 exec/s: 0 rss: 27Mb L: 2/2 MS: 2 ChangeBit-InsertByte- #1331 NEW cov: 6 ft: 6 corp: 3/20b lim: 17 exec/s: 0 rss: 27Mb L: 17/17 MS: 2 InsertByte-CrossOver- #1368 REDUCE cov: 6 ft: 6 corp: 3/19b lim: 17 exec/s: 0 rss: 27Mb L: 16/16 MS: 2 CrossOver-EraseBytes- #1048576 pulse cov: 6 ft: 6 corp: 3/19b lim: 4096 exec/s: 524288 rss: 773Mb #2097152 pulse cov: 6 ft: 6 corp: 3/19b lim: 4096 exec/s: 419430 rss: 773Mb ================================================================= ==664326==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000d2c052 at pc 0x000000550e1c bp 0x7ffd914ddd30 sp 0x7ffd914ddd28 WRITE of size 1 at 0x603000d2c052 thread T0 #0 0x550e1b in ares_create_query (/home/rootfuzz/cares/cares-fuzzer+0x550e1b) #1 0x55053c in LLVMFuzzerTestOneInput /home/rootfuzz/cares/target.cc:14:3 #2 0x4586a1 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/rootfuzz/cares/cares-fuzzer+0x4586a1) #3 0x457de5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) (/home/rootfuzz/cares/cares-fuzzer+0x457de5) #4 0x45a087 in fuzzer::Fuzzer::MutateAndTestOne() (/home/rootfuzz/cares/cares-fuzzer+0x45a087) #5 0x45ad85 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) (/home/rootfuzz/cares/cares-fuzzer+0x45ad85) #6 0x44973e in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/rootfuzz/cares/cares-fuzzer+0x44973e) #7 0x472582 in main (/home/rootfuzz/cares/cares-fuzzer+0x472582) #8 0x7f4b400f8082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) #9 0x41e4dd in _start (/home/rootfuzz/cares/cares-fuzzer+0x41e4dd)
0x603000d2c052 is located 0 bytes to the right of 18-byte region [0x603000d2c040,0x603000d2c052) allocated by thread T0 here: #0 0x51e20d in malloc (/home/rootfuzz/cares/cares-fuzzer+0x51e20d) #1 0x5508f6 in ares_create_query (/home/rootfuzz/cares/cares-fuzzer+0x5508f6) #2 0x55053c in LLVMFuzzerTestOneInput /home/rootfuzz/cares/target.cc:14:3 #3 0x4586a1 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/rootfuzz/cares/cares-fuzzer+0x4586a1) #4 0x457de5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) (/home/rootfuzz/cares/cares-fuzzer+0x457de5) #5 0x45a087 in fuzzer::Fuzzer::MutateAndTestOne() (/home/rootfuzz/cares/cares-fuzzer+0x45a087) #6 0x45ad85 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) (/home/rootfuzz/cares/cares-fuzzer+0x45ad85) #7 0x44973e in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/rootfuzz/cares/cares-fuzzer+0x44973e) #8 0x472582 in main (/home/rootfuzz/cares/cares-fuzzer+0x472582) #9 0x7f4b400f8082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)
SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/rootfuzz/cares/cares-fuzzer+0x550e1b) in ares_create_query Shadow bytes around the buggy address: 0x0c068019d7b0: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa 0x0c068019d7c0: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa 0x0c068019d7d0: fa fa fa fa fa fa fa fa fd fd fd fa fa fa fd fd 0x0c068019d7e0: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa 0x0c068019d7f0: fa fa fa fa fa fa fa fa fa fa fa fa fd fd fd fa =>0x0c068019d800: fa fa fa fa fa fa fa fa 00 00[02]fa fa fa fa fa 0x0c068019d810: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c068019d820: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c068019d830: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c068019d840: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c068019d850: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb Shadow gap: cc ==664326==ABORTING MS: 4 ChangeBit-InsertByte-EraseBytes-ChangeByte-; base unit: 7c9981f8ba526a6e0b8c1bbb846c08e2d6026e3a 0x5c,0x2e, \\. artifact_prefix='./'; Test unit written to ./crash-c9257f8fd31ea852baf734ef06d37348bf6e8cb2 Base64: XC4=