UnsafeCop: Towards Memory Safety for Real-World Unsafe Rust Code with Practical Bounded Model Checking
Open Access
- 13 September 2024
- book chapter
- Published by Springer Nature
- p. 307-324
Abstract
Rust has gained popularity as a safer alternative to C/C++ for low-level programming due to its memory-safety features and minimal runtime overhead. However, the use of the “unsafe” keyword allows developers to bypass safety guarantees, posing memory-safety risks. Bounded Model Checking (BMC) is commonly used to detect memory-safety problems, but it has limitations for large-scale programs, as it can only detect bugs within a bounded number of executions.In this paper, we introduce UnsafeCop that utilizes and enhances BMC for analyzing memory safety in real-world unsafe Rust code. Our methodology incorporates harness design, loop bound inference, and both loop and function stubbing for comprehensive analysis. We optimize verification efficiency through a strategic function verification order, leveraging both types of stubbing. We conducted a case study on TECC (Trusted-Environment-based Cryptographic Computing), a proprietary framework consisting of 30,174 lines of Rust code, including 3,019 lines of unsafe Rust code, developed by Ant Group. Experimental results demonstrate that UnsafeCop effectively detects and verifies dozens of memory safety issues, reducing verification time by 73.71% compared to the traditional non-stubbing approach, highlighting its practical effectiveness.Keywords
This publication has 20 references indexed in Scilit:
- Creusot: A Foundry for the Deductive Verification of Rust Programs2022
- Detecting Cross-language Memory Management Issues in Rust2022
- The Prusti Project: Formal Verification for Rust2022
- rust-code-analysis: A Rust library to analyze and extract maintainability information from source codesSoftwareX, 2020
- No Panic! Verification of Rust Programs by Symbolic Execution2018
- RustBelt: securing the foundations of the Rust programming languageProceedings of the ACM on Programming Languages, 2017
- Cyclomatic ComplexityIEEE Software, 2016
- The SeaHorn Verification Framework2015
- SMACK: Decoupling Source Language Details from Verifier Implementations2014
- CBMC – C Bounded Model Checker2014