google fuzzer-test-suite

数据集下载地址

https://github.com/google/fuzzer-test-suite

数据集介绍

Google fuzzer-test-suite has applications spanning various domains like image processing, SQL, json parsing, etc. This test suite is inspired by real-life applications that have known bugs, hard-to-find code paths, or other challenges for bug finding tools. Each of the 24 applications in the suite has some version of the application which has memory-leaks, crashes orinput-agnostic errors like assertion failures and lines of code difficult to reach. Some of them have a set of specific inputs, or seeds to help the tools in finding bugs and maximising coverage.

数据集中各个文件夹介绍

github中有28个文件夹,8个文件。以下是对它们的介绍:

  1. custom-build.sh

sh语法中:
$0 就是编写的shell脚本本身的名字
$1 是在运行shell脚本传的第一个参数
$2 是在运行shell脚本传的第二个参数
这个脚本首先把第一个参数赋值给MODE,第二个参数赋值给HOOK_FILE,-n用于判断MODE是否为空,MODE有三种模式:asan,ubsan和hooks。

asan模式下:FUZZING_ENGINE=libfuzzer,然后设置CFLAGS="-O2 -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div",这些参数的意思是:-O2设置效能优化级别,-fno-omit-frame-pointer是便于用addressSanitizer获取完整的函数调用栈帧信息,-gline-tables-only允许获得带有函数名、文件名和行号的函数调用栈,-fsanitize=address检测堆内存越界和内存泄漏,-fsanitize-address-use-after-scope检测use-after-scope,-fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div用于不同级别的插桩。
ubsan模式下,FUZZING_ENGINE=libfuzzer,然后设置 CFLAGS="-O2 -fno-omit-frame-pointer -gline-tables-only -fsanitize=undefined -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div",-fsanitize=undefined检测栈溢出。
hooks模式下:首先检查hook_file是否存在,然后设置FUZZING_ENGINE=hooks,CFLAGS="-O0 -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div",然后export HOOKS_FILE。

  1. common.sh

代码内容:
[-e $(basename &0)]
查看文件是否存在,就是说要在另一个文件夹下执行这个文件。

FUZZING_ENGINE=${FUZZING_ENGINE:-"fsanitize_fuzzer"}
判断FUZZING_ENGINE是否为空,如果为空就把"fsanitize_fuzzer赋值给它"

POSSIBLE_FUZZING_ENGINE="libfuzzer afl honggfuzz coverage fsanitize_fuzzer hooks"
检查FUZZER_ENGINE是否合法
然后定义了一堆变量,根据fuzzing_engine设置CC和CXX,CFLAGS,CXXFLAGS最后定义了一堆函数。

  1. 24个目标程序文件夹:
    数据集中共有26个目标程序(其中openssl有三个,总共24个目标程序的文件夹.openthread这个程序可以编译出两个目标程序ip6_send_fuzzer和radio_receive_done_fuzzer,openssl1.1.0c可以编译出x509和bignum两个程序):

每个测试程序的子文件夹中有readme.md描述AddressSanitizer报错信息,build.sh,crash以及test-libfuzzer.sh文件。一些程序有其他的文件如seed,target.cc等,以boringssl-2016-02-12/build.sh为例:

#!/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

build_lib() {
  rm -rf BUILD
  cp -rf SRC BUILD
  (cd BUILD && cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_COMPILER="$CC" -DCMAKE_C_FLAGS="$CFLAGS -Wno-deprecated-declarations" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-error=main" && make -j $JOBS)
}

get_git_revision https://github.com/google/boringssl.git  894a47df2423f0d2b6be57e6d90f2bea88213382 SRC
build_lib
build_fuzzer

if [[ ! -d seeds ]]; then
  mkdir seeds
  cp BUILD/fuzz/privkey_corpus/* seeds/
fi

if [[ $FUZZING_ENGINE == "hooks" ]]; then
  # Link ASan runtime so we can hook memcmp et al.
  LIB_FUZZING_ENGINE="$LIB_FUZZING_ENGINE -fsanitize=address"
fi
set -x
$CXX $CXXFLAGS -I BUILD/include BUILD/fuzz/privkey.cc ./BUILD/ssl/libssl.a ./BUILD/crypto/libcrypto.a -lpthread $LIB_FUZZING_ENGINE -o $EXECUTABLE_NAME_BASE

这段脚本首先执行custom-build.sh,common.sh,执行完这两个脚本应该已经定义好了FUZZING_ENGINE,CFLAGS,以及fuzzer的路径等,
然后gei_git_revision用于从连接中git clone相关的程序,然后执行build_lib函数,指定cmake的参数中-DBUILD_SHARED_LIBS=OFF设置生成动态库。
然后执行build_fuzzer在common.sh中定义,根据fuzzing_engine调用其中不同的函数。
如果提供了seeds就把seed文件拷贝到seeds文件里。
如果是hooks模式就设置一个lib_fuzzing_engine。
设置-x选项后,之后执行的每一条命令,都会显示的打印出来;
然后就是编译程序了吧。

boringssl-2016-02-12/test-libfuzzer.sh,用于设置libfuzzer的一些参数、语料库文件夹:

#!/bin/bash
# Copyright 2016 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
. $(dirname $0)/../common.sh

# Note: this target contains unbalanced malloc/free (malloc is called
# in one invocation, free is called in another invocation).
# and so libFuzzer's -detect_leaks should be disabled for better speed.
export ASAN_OPTIONS=detect_leaks=0:quarantine_size_mb=50

set -x
rm -rf $CORPUS fuzz-*.log
mkdir $CORPUS
[ -e $EXECUTABLE_NAME_BASE ] && ./$EXECUTABLE_NAME_BASE -artifact_prefix=$CORPUS/ -use_value_profile=1 -jobs=$JOBS -workers=$JOBS $LIBFUZZER_FLAGS $CORPUS seeds
grep "AddressSanitizer: heap-use-after-free" fuzz-0.log || exit 1

每个程序的介绍

  • boringssl-2016-02-12: It is a software library that secures connection over computer networks. It is the OpenSSL equivalent developed for specific use by Google. (含有一个8 byte read-heap-use-after-free bug)
  • c-ares-CVE-2016-5180: It is a C library for asynchronous DNS requests.(含有一个1 byte write heap buffer overflow,对应CVE-2016-5180
  • freetype2-2017: It is a font engine used to efficiently produce glyphs.(这个程序主要用于代码覆盖率的比较,它有一个整数溢出漏洞,但是要发现这个漏洞需要很长的时间)
  • guetzli-2017-3-30: It is a freely licensed JPEG encoder developed at Google. We were unable to compile thebinary for this application.(这个程序提供了两个测试用例以及AFL的字典中的jpeg.dict,含有一个assertion failure.)
  • harfbuzz-1.3.2: It is an engine used to convert unicode to glyphs.(含有一个assertion failure.)
  • json-2017-02-12: Library to process JSON.(提供了一个seed,含有一个assertion failure.)
  • lcms-2017-03-21: It is an open source color management system.(提供了一个seed,含有两个heap buffer overflow,其中一个heap buffer overflow30分钟内可以被发现,另一个存在但是没有被发现)
  • libarchive-2017-01-04: It is an open-source C programming library that provides access to a variety of differentarchive formats like tar, zip etc.(提供一个初始测试用例,含有一个heap-buffer-overflow,一小时内可以找到。)
  • libjpeg-turbo-07-2017: It is an image codec that is used for faster JPEG compression and decompression.(提供了一个seed,这个程序主要是用于代码覆盖率的比较,用libfuzzer的话一小时内可以覆盖全部路径。)
  • libpng-1.2.56: It is a library of C functions to handle PNG images.(提供了一个seed,有一个out-of-memory)
  • libssh-2017-1272: It is C library implementing the SSHv2 protocol on client and server side.(含有一个memory leak bug,2分钟左右可以找到)
  • libxml2-v2.9.2: It is the XML C parser and toolkit.(有4个bug,一个CVE-5-8317一分钟内发现,一个use-after-free ,还有两个heap-buffer-overflow)
  • llvm-libcxxabi-2017-01-27: A C++ demangler.(含有2个bug,一个stack-overflow,一个out-of-range access)
  • openssl: OpenSSL is a Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocol.
    – openssl-1.0.1f 有两个bug,CVE-2014-016010秒内发现,CVE-2014-3513,runtime文件夹确保程序能够到达路径。
    – openssl-1.0.2d 有一个bug,CVE-2015-3193
    – openssl-1.1.0c,bignum有两个bugCVE-2017-3732CVE-2017-3736,X509有一个bugCVE-2017-3735
  • openthread-2018-02-27: It implements all thread networking layers.(可以编译两个程序:ip6_send_fuzzer和radio_receive_done_fuzzer,ip6有6个stack-buffer-overflow,1个null-dereference,radio有1个heap-buffer-overflow,4个stack-buffer-overflow)
  • pcre2-10.00: It is a set of functions that implement regular expression pattern matching using the samesyntax and semantics as Perl 5.(含有1个heap-buffer-overflow,1分钟内找到)
  • proj4-2017-08-14: It is a coordinate transformation library.(有1个内存泄漏,用libfuzzer10分钟内可以完全覆盖)
  • re2-2014-12-09: It is a software library for handling regular expressions.(含有2个bug,1个out-of-memory,1个memory leak)
  • sqlite-2016-11-14: It is a relational database management system contained in a C library.(含有3个bug:两个heap-buffer-overflow和1个memory leak)
  • vorbis-2017-12-11: It is a software library used to produce lossy audio encoding.(提供了1个seed,含有3个bug:2个heap-buffer-overflow,1个null dereference)
  • woff2-2016-05-06: It is a web font compression library.(含有2个bug:1个heap-buffer-overflow,1个out-of-memory)
  • wpantund-2018-02-27: It is a network interface daemon that provides a native IPv6 network interface to alow-power wireless Network Co-Processor.(这个程序主要用于代码覆盖率的比较)
  1. docs文件夹:

A/B testing:

  • 在B个benchmark上比较K个fuzzing engines,在J个核上跑N次独立实验。会有一个报告包含代码覆盖率随时间变化,是否发现bug,跑了几轮,语料库大小,覆盖率之间的差异。
  • 执行:可以在本地也可以在Google computer engine上,生成KBN个虚拟机,每个虚拟机有J个核,加上一个用于调度的虚拟机。运行同一个程序,定期将语料库同步到共享磁盘上,然后定期同步所有语料库和数据,更新报告。
    docs目录下的图片
  1. engine-comparison文件夹:
  2. examples文件夹:包含example-hooks.cc
  3. tutorial文件夹:
  4. build-and-test.sh

执行这个脚本时需要输入参数是程序的名字,然后他会执行common.sh,程序目录下的build.sh,test-libfuzzer.sh。

  1. test-everything.sh
  2. 此外还有AUTHORS,CONTRIBUTING,LICENSE,README.md。

初始测试用例

在数据集中有的程序没有提供测试用例,有的提供了测试用例。issue#170中有人问到初始测试用例,官方给的回答是:fuzzing在没有初始测试用例的情况下也可以跑,有的程序中没有提供seed的程序我们跑的时候不提供初始测试用例。

程序编译

接下来以libjpeg-turbo-07-2017为例介绍下基本的编译与使用方式。
下图展示了libjpeg-turbo-07-2017文件夹下google-test提供的所有文件。用户需要执行目标文件夹下的build.sh文件,进行编译获取目标程序。下面重点介绍build.sh中具体的编译过程。
mulu
在这里插入图片描述
build.sh中进行的主要操作为上图红框命令,依次为静态编译目标库,编译LIB_FUZZING_ENGINE,编译被测程序。

  1. 静态编译目标库
    脚本13行,首先将libjpeg项目下载到SRC文件夹中;
    脚本14行,执行build_lib函数;
    将SRC复制到BUILD文件夹中;
    执行静态编译命令,“autoreconf -fiv”“./configure --disable-shared”
    “make”
    得到目标库文件:libturbojpeg.a
    在这里插入图片描述
  2. 编译LIB_FUZZING_ENGINE
    脚本15行,执行build_fuzzer函数,这是common.sh中的一个函数;

在这里插入图片描述
build_fuzzer会根据指定的FUZZING_ENGINE执行对应的函数。目前 FUZZING_ENGINE支持的参数如下:

在这里插入图片描述
我们可以直接在第10行指定FUZZING_ENGINE的值,这里设置为afl,那么接下来要执行的是build_afl。
在这里插入图片描述
上图72行,首先编译AFL项目的afl-llvm-rt.o.c,这里是为了引入afl的llvm插桩模式,这里会得到一个目标文件afl-llvm-rt.o.o;
上图73行,编译libfuzzer项目的afl_driver.cpp,在afl_driver.cpp中定义了main函数是最终被测试程序的入口。在main函数中,会循环调用LLVMFuzzerTestOneInput这个函数,google-test为我们提供了这个函数的实现,定义了对于libturbojpeg库我们要测试哪些模块,以及要执行哪些函数,这里我们会得到一个目标文件afl_driver.o;
在这里插入图片描述
最后将afl-llvm-rt.o.o和afl_driver.o打包成一个静态库,这里由于FUZZING_ENGINE指定的是AFL,所以就得到了libFuzzingEngine-afl.a。

  1. 编译被测程序
    在build.sh的第22行,编译最终的测试主体libjpeg_turbo_fuzzer.cc,并将在libturbojpeg.a和libFuzzingEngine-afl.a调用的相关函数链接进来。

在这里插入图片描述

在libjpeg_turbo_fuzzer.cc中,实现了LLVMFuzzerTestOneInput这个函数,在这个函数中调用libjpeg一些常用功能和相关函数,如tjDecompressHeader3和tjDecompress2,最终得到了被测程序libjpeg-turbo-07-2017-afl。
在这里插入图片描述
程序静态链接分析
在该例中,主要测试的对象是libjpeg库中tjInitDecompress,tjDecompressHeader3,tjDestroy,tjDecompress2这几个函数。只需要查看编译出的文件中是否包含这几个函数的具体执行过程就可以判断静态链接是否成功。将libjpeg-turbo-07-2017-afl用IDA进行分析。
在这里插入图片描述
如上图在编译出程序的代码节可以找到相关函数的实现。

在这里插入图片描述
可以看到在调用函数与代码块跳转前都需要执行llvm插桩的代码。并且将FUZZ_ENGINE改为“coverage”后生成的被测程序libjpeg-turbo-07-2017-coverage程序中也可以找到这些库函数的具体实现。

每个程序的编译细节

已有的论文中对这个数据集的使用

  1. Reinforcement Learning-based Hierarchical Seed Scheduling for Greybox Fuzzing.

26个程序中去掉了很容易crash的程序以及1个不能跑qemu模式的程序,选择了11个程序运行。分别是:freetype2,guetzli,harfbuzz,lcms,libpng,libjpeg,openssl-1.1.0c-x509,openthread-ip6,openthread-radio,sqlite,vorbis每个跑12个小时,重复10次实验。FTS提供了初始种子时使用提供的种子,没有时使用“123\n456\n789\nabc\ndef\n”。所有的fuzzer在qemu模式下运行。
在这里插入图片描述

  1. Boosting fuzzer efficiency: an information theoretic perspective

去掉了那些超过15%运行崩溃的程序,留下了12个程序:freetype2,guetzli,harfbuzz,lcms,libpng,libjpeg,openssl-1.1.0c-x509,openthread-ip6,openthread-radio,sqlite,vorbis,wpantund。设置8G memory限制,跑1个小时,跑40次。

  1. EnFuzz: Ensemble Fuzzing with Seed Synchronization among Diverse Fuzzers.

24个程序都跑了,(openthread和openssl-c应该各自可以编出来两个程序,但论文没提到只是用一个)。每个程序编译时使用AddressSanitizer。每个程序跑24小时,跑10次。结果:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  1. SAFL:Increasing and accelerating testing coverage with symbolic execution and guided fuzzing.
    选择了10个程序:boringssl,re2,guetzli,libxml2,lcms,pcre2,proj4,libssh,libarchive 和 c-ares. 每个程序编译(ASAN),运行24小时。结果:
    在这里插入图片描述

在这里插入图片描述
5. SYNFUZZ: Efficient Concolic Execution via Branch Condition Synthesis.
SynFuzz和QSYM用3个核跑8小时,其它baseline用1个核每个跑24小时,跑10次。结果如下:
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值