ESSS是一种静态分析工具,可检测C和C ++代码库中缺失和错误的错误检查。该工具会自动推论功能的错误规范,而无需先验知识,然后找到了丢失错误检查或与这些规格不一致的代码位置。
该存储库包含ESSS源代码,以及脚本和数据以在本文中使用的基准上运行工具和EESI。
工件评估VM已经包含ESSS工具和LLVM工具链预先构建的。使用的LLVM版本为14.0.6。我们自己执行构建而不是提供发行版本的原因是为了确保确切结果的可重复性,而无需具有特定于发行版的贴片。
该工具在最近的任何Linux分布上都支持。我们确认它可以肯定在Ubuntu 22.04上有效。尽管我们确实建议至少8个GIB RAM,但不需要特殊的硬件要求。即使该工具可以较少运行,但最大的基准可能会占用多达2 GIB的RAM,而对于其他进程的内存却较少。
如果您想手动构建ESS工具和/或LLVM工具链,请按照以下说明进行操作。
构建ESS工具需要以下依赖项:
$ cd /home/evaluation/ESSS/llvm
$ mkdir llvm-project
$ cd llvm-project
$ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/clang-14.0.6.src.tar.xz
$ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/llvm-14.0.6.src.tar.xz
$ tar xf llvm-14.0.6.src.tar.xz
$ tar xf clang-14.0.6.src.tar.xz
$ mv clang-14.0.6.src clang
$ mv llvm-14.0.6.src llvm
$ cd ..
$ ./build-llvm.sh$ cd /home/evaluation/ESSS/analyzer
$ make这将构建分析仪工具,并将二进制文件放置在/home/evaluation/ESSS/analyzer/build/lib目录中。
将工具应用于自己的基准测试时,您需要先生成比特代码文件。为此,您应该使用WLLVM。按照WLLVM读数页面上的安装说明。
此外,我们还依靠MUSL来推断LIBC的规格。虽然该工具的工作并不是严格必要的,但这将提高推断规格的精度。论文中使用的版本是Musl 1.2.3,但任何版本都应起作用。这些是将MUSL构建到比特码文件中的步骤:
cd musl
mkdir prefix
export CC=wllvm
./configure --prefix= " $( realpath prefix ) "
make -j4
make install
extract-bc prefix/lib/libc.so要编译一个与我们的工具一起使用的程序,您应该遵循所述程序的构建说明,但请使用WLLVM包装器作为编译器。这将导致您的工具可以分析的比特代码文件。理想情况下,您将所有比特代码文件分别传递给我们的工具,因为同时给整个程序(默认情况下,提取物bc发生的情况)的处理要比单独的文件慢。
该工具可以直接通过执行./kanalyzer内部/home/evaluation/ESSS/analyzer/build/lib执行。参数是比特代码文件的途径。输出写入Stdout。该工具还包含一些可选的参数,可以使用--help选项列出。
要运行用于推断程序中的规格和检测错误的工具,您可以使用以下命令:
./kanalyzer /path/to/mysl/libc.so.bc /path/to/bitcode1.bc /path/to/bitcode2.bc ...输出将写入Stdout,其中包括推断的规格和错误。
该工具支持可以使用命令行参数设置的配置选项。
最重要的配置选项是:
--missing-ct :缺少检查的阈值。只有具有至少该值的分数的报告才会报告。默认值为0.725。--incorrect-ct :不正确规格的阈值。只有具有至少该值的分数的报告才会报告。默认值为0.725。其他有用的选项包括:
--refine-vsa :这使得在误差值集与函数的可能常数返回值之间进行交点,以提高误差规格的精度。默认为true。--st :[0,1]之间的关联分析置信度。协会必须越高。默认为0.925。--interval-ct :[0,1]之间的置信度阈值。误差间隔应该越高。-c <number> :将线程数设置为<number> 。未对1以外的其他值进行彻底测试。还有一些调试选项:
--print-random-non-void-function-samples <number> :要打印多少个随机的非流动函数名称,可用于采样函数来计算召回函数。默认为0。--ssc :打印检测到的错误将单独检查。默认为false。我们在example目录中提供了最小示例。 example/example.c中有一些简单的玩具代码。您可以使用example/build_and_run.sh脚本通过分析仪运行。运行后,您应该获得以下输出:
Function error return intervals (3, pre-libc-pruning 3):
Function: func {return index 0}
[0, 0]
Function: generate_error {return index 0}
[-2147483648, -1] U [1, 2147483647]
Function: malloc {return index 0}
[0, 0]
存储库的结构如下。改编自CRIX的文件被标记为这样。
? ESSS
│ ├── ? analyzer [the ESSS tool source code]
│ │ │ ├── ? Makefile [adapted from Crix]
│ │ │ └── ? src
│ │ │ │ ├── ? ...
│ │ │ │ └── ? src
│ │ │ │ │ ├── ? Analyzer.{cc, h} [Entry point of the application, adapted from Crix]
│ │ │ │ │ ├── ? CallGraph.{cc, h} [MLTA component from Crix]
│ │ │ │ │ ├── ? ClOptForward.h [Forward declarations of command line options]
│ │ │ │ │ ├── ? Common.{cc, h} [Common utility functions, adapted from Crix]
│ │ │ │ │ ├── ? DataFlowAnalysis.{cc, h} [Dataflow analysis helpers]
│ │ │ │ │ ├── ? DebugHelpers.{cc, h} [Debugging helpers]
│ │ │ │ │ ├── ? EHBlockDetector.{cc, h} [Specification inference component]
│ │ │ │ │ ├── ? ErrorCheckViolationFinder.{cc, h} [Bug detection component]
│ │ │ │ │ ├── ? FunctionErrorReturnIntervals.{cc, h} [Data structure file]
│ │ │ │ │ ├── ? FunctionVSA.{cc, h} [Value set analysis of return values component]
│ │ │ │ │ ├── ? Helpers.{cc, h} [Common utility functions]
│ │ │ │ │ ├── ? Interval.{cc, h} [Interval data structure]
│ │ │ │ │ ├── ? Lazy.h [Lazy execution utility class]
│ │ │ │ │ ├── ? MLTA.{cc, h} [MLTA component from Crix]
│ │ │ │ │ └── ? PathSpan.h [Data structure to store (parts of) paths]
│ └── ? evaluation [Scripts and data to run the tool on the benchmarks]
│ │ ├── ? benchmark-instructions [Instructions to compile each benchmark into bitcode files]
│ │ ├── ? ...
│ │ ├── ? eesi-<program>-output [Our EESI output for <program>]
│ │ ├── ? eesi-<program>-precision [Random sample from EESI's output for <program> for precision calculation]
│ │ ├── ? run-eesi-<program>.sh [Runs EESI for <program> (e.g. openssl)]
│ │ ├── ? my-<program>-output [Our ESSS output for <program>]
│ │ ├── ? run-my-<program>.sh [Runs ESSS for <program> (e.g. openssl)]
│ │ ├── ? <program>-bugs [Bug categorisations for <program> (e.g. openssl)]
│ │ ├── ? <program>-recall-sample [Random sample from error-returning functions in <program> for recall calculation]
│ │ ├── ? <program>-precision-ground-truth [Ground truth for precision evaluation for ESSS]
│ │ ├── ? <program>-random-functions-for-precision-my-tool [Random sample from ESSS's output for <program> for precision calculation]
│ │ ├── ? compute_my_stats.py [Computes stats for ESSS for a program]
│ │ └── ? compute_eesi_stats.py [Computes stats for EESI for a program]
特别是,在ehblockdetector.cc和errorCheckVioLationFinder.cc中的错误检测中实现了规范推断。
运行每个基准测试的说明在evaluation/benchmark-instructions目录中提供。要运行一个基准之一,请在evaluation目录中执行相应的脚本(如上述存储库结构概述中所述)。
compute_my_stats.py :此脚本计算给定基准测试的ESSS工具的精度,召回和F1分数。compute_eesi_stats.py :此脚本计算给定基准测试的EESI工具的精度,召回和F1分数。run-eesi-<program>.sh :此脚本在给定基准测试上运行EESI工具。run-my-<program>.sh :此脚本在给定的基准测试上运行ESSS工具。 为了简化评估,我们为每个基准标准提供了一个运行脚本来运行工具。这些可以在/home/evaluation/ESSS/evaluation中找到:
run-my-openssl.shrun-my-openssh.shrun-my-php.shrun-my-zlib.shrun-my-libpng.shrun-my-freetype.shrun-my-libwebp.sh评估工件作为Zenodo上的虚拟盒VM图像提供。为了构建VM图像,我们从Ubuntu 22.04 LTS(X86-64)安装开始。然后,我们可以使用vm/build-vm.sh中提供的脚本来安装和设置评估所需的所有内容。
该工具基于明尼苏达大学的CRIX工具。特别是,我们重用CRIX的MLTA组件。 ESS是根据相同许可分配的。
链接到USENIX纸张出版物页面:https://www.usenix.org/conference/usenixsecurity24/presentation/dossche
链接到最终出版物PDF:https://www.usenix.org/system/files/usenixsecurity24-dossche.pdf
链接到最终伪影附录PDF(可用,功能性,再现徽章):https://www.usenix.org/system/files/usenixsecurity24-appendix-dossche.pdf
@inproceedings {dossche2024inferenceoferrorspecifications,
author = {Niels Dossche and Bart Coppens},
title = {Inference of Error Specifications and Bug Detection Using Structural Similarities},
booktitle = {33rd USENIX Security Symposium (USENIX Security 24)},
year = {2024},
isbn = {978-1-939133-44-1},
address = {Philadelphia, PA},
pages = {1885--1902},
url = {https://www.usenix.org/conference/usenixsecurity24/presentation/dossche},
publisher = {USENIX Association},
month = aug
}