Lune

ICSE2024Top-tier venue

Is unsafe an Achilles' Heel? A Comprehensive Study of Safety Requirements in Unsafe Rust Programming

Mohan Cui, Shuran Sun, Hui Xu, Yangfan Zhou

Abstract

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

5 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • An Empirical Study of Bugs in the rustc Compiler cites Understanding memory and thread safety practices and issues in real-world Rust programs
  • An Empirical Study of Bugs in the rustc Compiler cites Verus: Verifying Rust Programs using Linear Ghost Types
  • Understanding memory and thread safety practices and issues in real-world Rust programs cites Stacked borrows: an aliasing model for Rust
  • Verus: Verifying Rust Programs using Linear Ghost Types cites RustBelt meets relaxed memory
  • Verus: Verifying Rust Programs using Linear Ghost Types cites Stacked borrows: an aliasing model for Rust
  • A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries cites 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 cites Stacked borrows: an aliasing model for Rust
  • Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMs cites 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 cites Verus: Verifying Rust Programs using Linear Ghost Types
  • CULPA: Universal Detection of Memory-Safety Bugs in Unsafe Rust Through the Lens of Safety Requirements cites Verus: Verifying Rust Programs using Linear Ghost Types
  • CULPA: Universal Detection of Memory-Safety Bugs in Unsafe Rust Through the Lens of Safety Requirements cites Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMs
  • Cpp2Rust: Automatic Translation of C++ to Safe Rust cites Stacked borrows: an aliasing model for Rust
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers5

  1. An Empirical Study of Bugs in the rustc CompilerZixi Liu, Yang Feng, Yunbo Ni, Shaohua Li et al.OOPSLA 2025 · 5 citations
  2. A Study of Undefined Behavior Across Foreign Function Boundaries in Rust LibrariesIan McCormack, Joshua Sunshine, Jonathan AldrichICSE 2025 · 5 citations
  3. Safe4U: Identifying Unsound Safe Encapsulations of Unsafe Calls in Rust using LLMsHuan Li, Bei Wang, Xing Hu, Xin XiaISSTA 2025 · 1 citation
  4. Cpp2Rust: Automatic Translation of C++ to Safe RustLucian Popescu, Francisco Gouveia, Henrique Preto, João Silveira et al.PLDI 2026 · 1 citation
  5. CULPA: Universal Detection of Memory-Safety Bugs in Unsafe Rust Through the Lens of Safety RequirementsHung-Mao Chen, Bo Lu, Xu He, Xiaokuan Zhang et al.USENIX Security 2026

Builds on12

  1. Occlum: Secure and Efficient Multitasking Inside a Single Enclave of Intel SGXYouren Shen, Hongliang Tian, Yu Chen, Kang Chen et al.ASPLOS 2020 · 144 citations
  2. Understanding memory and thread safety practices and issues in real-world Rust programsBoqin Qin, Yilun Chen, Zeming Yu, Linhai Song et al.PLDI 2020 · 112 citations
  3. Verus: Verifying Rust Programs using Linear Ghost TypesAndrea Lattuada, Travis Hance, Chanhee Cho, Matthias Brun et al.OOPSLA 2023 · 86 citations
  4. RustBelt meets relaxed memoryHoang-Hai Dang, Jacques-Henri Jourdan, Jan-Oliver Kaiser, Derek DreyerPOPL 2020 · 68 citations
  5. Stacked borrows: an aliasing model for RustRalf Jung, Hoang-Hai Dang, Jeehoon Kang, Derek DreyerPOPL 2020 · 67 citations

Related papers

  1. Is rust used safely by software developers?Ana Nora Evans, Bradford Campbell, Mary Lou SoffaICSE 2020 · 57 citations
  2. "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 et al.USENIX Security 2023
  3. Learning and Programming Challenges of Rust: A Mixed-Methods StudyShuofei Zhu, Ziyi Zhang, Boqin Qin, Aiping Xiong et al.ICSE 2022 · 27 citations
  4. Rust for Embedded Systems: Current State and Open ProblemsAyushi Sharma, Shashank Sharma, Sai Ritvik Tanksalkar, Santiago Torres-Arias et al.CCS 2024 · 12 citations
  5. How do programmers use unsafe rust?Vytautas Astrauskas, Christoph Matheja, Federico Poli, Peter Müller et al.OOPSLA 2020 · 78 citations
Dusk over the sea between two cliffs drawn in fine vertical lines