This is the artifact of the paper ERASan: Efficient Rust Address Sanitizer, which is accepted at the IEEE Symposium on Security and Privacy 2024.
ERASan is an Efficient Address Sanitizer design customized for Rust. It performs selective instrumentation to memory accesses in both safe and unsafe code areas, where Rust cannot guarantee safety, to significantly reduce ASan's runtime overhead.
Unlike ASan, ERASan only identifies potential unsafe memory access sites where Rust compiler cannot guarantee to maximize performance gain during memory access validation check at runtime, while fully preserving ASan's memory bug detection capabilities.
Below are instructions for building artifacts and instructions for running them on Rust Memory Bug PoC targets.
To run the experiments in the paper, we used a 10-core Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz, 64GB DDR4 RAM, and running Ubuntu 22.04.1 LTS (GNU/Linux 6.2.0). ERASan is implemented with rustc-1.64.0 (llvm 14.0.6) and SVF-2.4 version.
Before we start, git clone source code of ERASan and set environmental variables by using ERASan Environment Script
git clone https://github.com/S2-Lab/ERASan.git
cd ERASan/env
source env.sh
# Build Rust Compiler (1.64.0 v) with raw pointer annotation (MIR level) implementation
cd ERASan/build
./rust-1.64.0-build
# After building Rust Compiler, please build Rust compiler-rt files
./rust-1.64.0-compiler-rt.sh
Note: If you are stuck in proceeding of building the Rust Compiler, please refer to the FAQ.
# Build SVF-2.4 with our pointer analysis implementation (LLVM-IR level)
cd ERASan/build
./SVF-build.sh
# Build ERASan LLVM Pass for supporting ERASan (LLVM-14.0.6 v)
cd ERASan/build
./erasan.sh
Note: If you are stuck in proceeding of building the ERASan mode, please refer to the FAQ.
# To support original ASan mode, you should follow
cd ERASan/build
./asan.sh
# To support ERASan-rawptr (without optimization of pointer analysis) mode, you should follow
cd ERASan/build
./erasan-rawptr.sh
# To support ERASan-unsafe (unsafe Rust code block base) mode, you should follow
cd ERASan/build
./erasan-unsafe.sh
# To support ERASan-threadsafe (without optimization of pointer analysis to multi-thread APIs) mode, you should follow
cd ERASan/build
./erasan-threadsafe.sh
# To support ERASan-debloating (supporting for ASan-- with ERASan) mode, you should follow
cd ERASan/build
./erasan-debloating.sh
Note:
To reproduce Rust's Memory bugs, we offer test sets' scripts accompanied by a reproducible PoC selected in RustSec Advisory Database. For example, if you'd like to reproduce RUSTSEC-2023-0005, you should follow:
cd ERASan/poc/RUSTSEC-2023-0005
./run.sh
Note: Make sure that before reproducing PoC, you should adjust environmental settings to ERASan mode by using ERASan Mode Script
To reproduce the results in each table and figure, you can use the benchmark scripts in the benchmarks directory as follows.
cd ERASan/benchmarks/
Note: Make sure that before conducting benchmark tests, you should build environmental settings by using Mode Change Script according to test modes (e.g., native, asan, erasan, erasan-rawptr, erasan-unsafe, erasan-threadsafe, erasan-debloating)
# If you already built the project under ERASan mode script, you can skip this process
cd ERASan/build/
./erasan.sh
# In the directory of ERASan/benchmarks
source setup.sh
# In the directory of ERASan/benchmarks/itoa/build
cd ERASan/benchmarks/itoa/build
# Adjust configurations and build project
./build-itoa.sh
# In the directory of ERASan/benchmarks/itoa/test/native
cd ../test/native
./native-itoa.sh
# Make sure that you use AddressSanitizer pass (AddressSanitizer.cpp) by using ERASan/build/asan.sh before conducting benchmark test
cd $S2HOME/build
./asan.sh
# In the directory of ERASan/benchmarks/itoa/test/asan
cd $S2HOME/benchmarks/itoa/test/asan
./asan-itoa.sh
# Make sure that you use ERASan pass (ERASan.cpp)
cd $S2HOME/build
./erasan.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan
cd $S2HOME/benchmarks/itoa/test/erasan
./erasan-itoa.sh
# Make sure that you use ERASan-rawptr pass
cd $S2HOME/build
./erasan-rawptr.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-rawptr
cd $S2HOME/benchmarks/itoa/test/erasan-rawptr
./erasan-rawptr-itoa.sh
# Make sure that you use ERASan-unsafe pass (ERASan_Unsafe.cpp)
cd $S2HOME/build
./erasan-unsafe.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-unsafe
cd $S2HOME/benchmarks/itoa/test/erasan-unsafe
./erasan-unsafe-itoa.sh
# Make sure that you use ERASan-threadsafe pass (ERASan_ThreadSafe.cpp)
cd $S2HOME/build
./erasan-threadsafe.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-threadsafe
cd $S2HOME/benchmarks/itoa/test/erasan-threadsafe
./erasan-threadsafe-itoa.sh
# Make sure that you use ERASan-debloating pass (ERASan_Debloating.cpp)
cd $S2HOME/build
./erasan-debloating.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-debloating
cd $S2HOME/benchmarks/itoa/test/erasan-debloating
./erasan-debloating-itoa.sh
./unset.sh
# Quit the build process when it stucks or exits accidentally
ctrl + c
# Execute rust compiler rebuild script until the build process is successfully finished
cd ERASan/build/error_handling
./rust-1.64.0-rebuild.sh
Note: If you are still stuck in building the rust compiler or each mode (ASan, ERASan, ERASan-rawptr, ERASan-unsafe, ERASan-threadsafe, ERASan-debloating), please change the build parallelism options. Or execute Rebuild Script until you succeed in building the Rust Compiler.
# python3 ./x.py build --stage 1 -j 8 -> python3 ./x.py build --stage 1
python3 ./x.py build --stage 1
2 commits
LLVM
72.5%
C
20.4%
Rust
5.0%
C++
1.8%
This is the artifact of the paper ERASan: Efficient Rust Address Sanitizer, which is accepted at the IEEE Symposium on Security and Privacy 2024.
ERASan is an Efficient Address Sanitizer design customized for Rust. It performs selective instrumentation to memory accesses in both safe and unsafe code areas, where Rust cannot guarantee safety, to significantly reduce ASan's runtime overhead.
Unlike ASan, ERASan only identifies potential unsafe memory access sites where Rust compiler cannot guarantee to maximize performance gain during memory access validation check at runtime, while fully preserving ASan's memory bug detection capabilities.
Below are instructions for building artifacts and instructions for running them on Rust Memory Bug PoC targets.
To run the experiments in the paper, we used a 10-core Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz, 64GB DDR4 RAM, and running Ubuntu 22.04.1 LTS (GNU/Linux 6.2.0). ERASan is implemented with rustc-1.64.0 (llvm 14.0.6) and SVF-2.4 version.
Before we start, git clone source code of ERASan and set environmental variables by using ERASan Environment Script
git clone https://github.com/S2-Lab/ERASan.git
cd ERASan/env
source env.sh
# Build Rust Compiler (1.64.0 v) with raw pointer annotation (MIR level) implementation
cd ERASan/build
./rust-1.64.0-build
# After building Rust Compiler, please build Rust compiler-rt files
./rust-1.64.0-compiler-rt.sh
Note: If you are stuck in proceeding of building the Rust Compiler, please refer to the FAQ.
# Build SVF-2.4 with our pointer analysis implementation (LLVM-IR level)
cd ERASan/build
./SVF-build.sh
# Build ERASan LLVM Pass for supporting ERASan (LLVM-14.0.6 v)
cd ERASan/build
./erasan.sh
Note: If you are stuck in proceeding of building the ERASan mode, please refer to the FAQ.
# To support original ASan mode, you should follow
cd ERASan/build
./asan.sh
# To support ERASan-rawptr (without optimization of pointer analysis) mode, you should follow
cd ERASan/build
./erasan-rawptr.sh
# To support ERASan-unsafe (unsafe Rust code block base) mode, you should follow
cd ERASan/build
./erasan-unsafe.sh
# To support ERASan-threadsafe (without optimization of pointer analysis to multi-thread APIs) mode, you should follow
cd ERASan/build
./erasan-threadsafe.sh
# To support ERASan-debloating (supporting for ASan-- with ERASan) mode, you should follow
cd ERASan/build
./erasan-debloating.sh
Note:
To reproduce Rust's Memory bugs, we offer test sets' scripts accompanied by a reproducible PoC selected in RustSec Advisory Database. For example, if you'd like to reproduce RUSTSEC-2023-0005, you should follow:
cd ERASan/poc/RUSTSEC-2023-0005
./run.sh
Note: Make sure that before reproducing PoC, you should adjust environmental settings to ERASan mode by using ERASan Mode Script
To reproduce the results in each table and figure, you can use the benchmark scripts in the benchmarks directory as follows.
cd ERASan/benchmarks/
Note: Make sure that before conducting benchmark tests, you should build environmental settings by using Mode Change Script according to test modes (e.g., native, asan, erasan, erasan-rawptr, erasan-unsafe, erasan-threadsafe, erasan-debloating)
# If you already built the project under ERASan mode script, you can skip this process
cd ERASan/build/
./erasan.sh
# In the directory of ERASan/benchmarks
source setup.sh
# In the directory of ERASan/benchmarks/itoa/build
cd ERASan/benchmarks/itoa/build
# Adjust configurations and build project
./build-itoa.sh
# In the directory of ERASan/benchmarks/itoa/test/native
cd ../test/native
./native-itoa.sh
# Make sure that you use AddressSanitizer pass (AddressSanitizer.cpp) by using ERASan/build/asan.sh before conducting benchmark test
cd $S2HOME/build
./asan.sh
# In the directory of ERASan/benchmarks/itoa/test/asan
cd $S2HOME/benchmarks/itoa/test/asan
./asan-itoa.sh
# Make sure that you use ERASan pass (ERASan.cpp)
cd $S2HOME/build
./erasan.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan
cd $S2HOME/benchmarks/itoa/test/erasan
./erasan-itoa.sh
# Make sure that you use ERASan-rawptr pass
cd $S2HOME/build
./erasan-rawptr.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-rawptr
cd $S2HOME/benchmarks/itoa/test/erasan-rawptr
./erasan-rawptr-itoa.sh
# Make sure that you use ERASan-unsafe pass (ERASan_Unsafe.cpp)
cd $S2HOME/build
./erasan-unsafe.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-unsafe
cd $S2HOME/benchmarks/itoa/test/erasan-unsafe
./erasan-unsafe-itoa.sh
# Make sure that you use ERASan-threadsafe pass (ERASan_ThreadSafe.cpp)
cd $S2HOME/build
./erasan-threadsafe.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-threadsafe
cd $S2HOME/benchmarks/itoa/test/erasan-threadsafe
./erasan-threadsafe-itoa.sh
# Make sure that you use ERASan-debloating pass (ERASan_Debloating.cpp)
cd $S2HOME/build
./erasan-debloating.sh
# In the directory of ERASan/benchmarks/itoa/test/erasan-debloating
cd $S2HOME/benchmarks/itoa/test/erasan-debloating
./erasan-debloating-itoa.sh
./unset.sh
# Quit the build process when it stucks or exits accidentally
ctrl + c
# Execute rust compiler rebuild script until the build process is successfully finished
cd ERASan/build/error_handling
./rust-1.64.0-rebuild.sh
Note: If you are still stuck in building the rust compiler or each mode (ASan, ERASan, ERASan-rawptr, ERASan-unsafe, ERASan-threadsafe, ERASan-debloating), please change the build parallelism options. Or execute Rebuild Script until you succeed in building the Rust Compiler.
# python3 ./x.py build --stage 1 -j 8 -> python3 ./x.py build --stage 1
python3 ./x.py build --stage 1
2 commits
LLVM
72.5%
C
20.4%
Rust
5.0%
C++
1.8%