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
}