Is unsafe an Achilles' Heel? A Comprehensive Study of Safety Requirements in Unsafe Rust Programming
Mohan Cui, Shuran Sun, Hui Xu, Yangfan Zhou
摘要
Rust is an emerging, strongly-typed programming language focusing on efficiency and memory safety. With increasing projects adopting Rust, knowing how to use Unsafe Rust is crucial for Rust security. We observed that the description of safety requirements needs to be unified in Unsafe Rust programming. Current unsafe API documents in the standard library exhibited variations, including inconsistency and insufficiency. To enhance Rust security, we suggest unsafe API documents to list systematic descriptions of safety requirements for users to follow. In this paper, we conducted the first comprehensive empirical study on safety requirements across unsafe boundaries. We studied unsafe API documents in the standard library and defined 19 safety properties (SP). We then completed the data labeling on 416 unsafe APIs while analyzing their correlation to find interpretable results. To validate the practical usability and SP coverage, we categorized existing Rust CVEs until 2023-07-08 and performed a statistical analysis of std unsafe API usage toward the crates.io ecosystem. In addition, we conducted a user survey to gain insights into four aspects from experienced Rust programmers. We finally received 50 valid responses and confirmed our classification with statistical significance.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 5 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- An Empirical Study of Bugs in the rustc Compiler 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
- An Empirical Study of Bugs in the rustc Compiler 引用了 Verus: Verifying Rust Programs using Linear Ghost Types
- Understanding memory and thread safety practices and issues in real-world Rust programs 引用了 Stacked borrows: an aliasing model for Rust
- Verus: Verifying Rust Programs using Linear Ghost Types 引用了 RustBelt meets relaxed memory
- Verus: Verifying Rust Programs using Linear Ghost Types 引用了 Stacked borrows: an aliasing model for Rust
- A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
- A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries 引用了 Stacked borrows: an aliasing model for Rust
- Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMs 引用了 Understanding memory and thread safety practices and issues in real-world Rust programs
- Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMs 引用了 Verus: Verifying Rust Programs using Linear Ghost Types
- CULPA: Universal Detection of Memory-Safety Bugs in Unsafe Rust Through the Lens of Safety Requirements 引用了 Verus: Verifying Rust Programs using Linear Ghost Types
- CULPA: Universal Detection of Memory-Safety Bugs in Unsafe Rust Through the Lens of Safety Requirements 引用了 Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMs
- Cpp2Rust: Automatic Translation of C++ to Safe Rust 引用了 Stacked borrows: an aliasing model for Rust
引用它的顶会 Paper5
- An Empirical Study of Bugs in the rustc CompilerZixi Liu, Yang Feng, Yunbo Ni, Shaohua Li 等OOPSLA 2025 · 5 次引用
- A Study of Undefined Behavior Across Foreign Function Boundaries in Rust LibrariesIan McCormack, Joshua Sunshine, Jonathan AldrichICSE 2025 · 5 次引用
- Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMsHuan Li, Bei Wang, Xing Hu, Xin XiaISSTA 2025 · 1 次引用
- Cpp2Rust: Automatic Translation of C++ to Safe RustLucian Popescu, Francisco Gouveia, Henrique Preto, João Silveira 等PLDI 2026 · 1 次引用
- CULPA: Universal Detection of Memory-Safety Bugs in Unsafe Rust Through the Lens of Safety RequirementsHung-Mao Chen, Bo Lu, Xu He, Xiaokuan Zhang 等USENIX Security 2026
它引用的 Paper12
- Occlum: Secure and Efficient Multitasking Inside a Single Enclave of Intel SGXYouren Shen, Hongliang Tian, Yu Chen, Kang Chen 等ASPLOS 2020 · 144 次引用
- Understanding memory and thread safety practices and issues in real-world Rust programsBoqin Qin, Yilun Chen, Zeming Yu, Linhai Song 等PLDI 2020 · 112 次引用
- Verus: Verifying Rust Programs using Linear Ghost TypesAndrea Lattuada, Travis Hance, Chanhee Cho, Matthias Brun 等OOPSLA 2023 · 86 次引用
- RustBelt meets relaxed memoryHoang-Hai Dang, Jacques-Henri Jourdan, Jan-Oliver Kaiser, Derek DreyerPOPL 2020 · 68 次引用
- Stacked borrows: an aliasing model for RustRalf Jung, Hoang-Hai Dang, Jeehoon Kang, Derek DreyerPOPL 2020 · 67 次引用
相关 Paper
- Is rust used safely by software developers?Ana Nora Evans, Bradford Campbell, Mary Lou SoffaICSE 2020 · 57 次引用
- "I wouldn't want my unsafe code to run my pacemaker": An Interview Study on the Use, Comprehension, and Perceived Risks of Unsafe RustSandra Höltervennhoff, Philip Klostermeyer, Noah Wöhler, Yasemin Acar 等USENIX Security 2023
- Learning and Programming Challenges of Rust: A Mixed-Methods StudyShuofei Zhu, Ziyi Zhang, Boqin Qin, Aiping Xiong 等ICSE 2022 · 27 次引用
- Rust for Embedded Systems: Current State and Open ProblemsAyushi Sharma, Shashank Sharma, Sai Ritvik Tanksalkar, Santiago Torres-Arias 等CCS 2024 · 12 次引用
- How do programmers use unsafe rust?Vytautas Astrauskas, Christoph Matheja, Federico Poli, Peter Müller 等OOPSLA 2020 · 78 次引用
