Skip to main content
QUICK REVIEW

[Paper Review] Memory-Safety Challenge Considered Solved? An In-Depth Study with All Rust CVEs

Hui Xu, Zhuangbin Chen|arXiv (Cornell University)|Mar 6, 2020
Security and Verification in ComputingComputer Science36 references11 citations
TL;DR

This paper investigates Rust's effectiveness in preventing memory-safety bugs by analyzing 186 real-world CVEs involving memory safety. It finds that all such bugs require unsafe code, confirming Rust's core promise; however, subtle soundness issues in safe APIs—particularly around ownership, functions, and generics—pose ongoing challenges, leading to recommendations for safer coding practices and tooling extensions.

ABSTRACT

Rust is an emerging programing language that aims at preventing memory-safety bugs without sacrificing much efficiency. The claimed property is very attractive to developers, and many projects start using the language. However, can Rust achieve the memory-safety promise? This paper studies the question by surveying 186 real-world bug reports collected from several origins which contain all existing Rust CVEs (common vulnerability and exposures) of memory-safety issues by 2020-12-31. We manually analyze each bug and extract their culprit patterns. Our analysis result shows that Rust can keep its promise that all memory-safety bugs require unsafe code, and many memory-safety bugs in our dataset are mild soundness issues that only leave a possibility to write memory-safety bugs without unsafe code. Furthermore, we summarize three typical categories of memory-safety bugs, including automatic memory reclaim, unsound function, and unsound generic or trait. While automatic memory claim bugs are related to the side effect of Rust newly-adopted ownership-based resource management scheme, unsound function reveals the essential challenge of Rust development for avoiding unsound code, and unsound generic or trait intensifies the risk of introducing unsoundness. Based on these findings, we propose two promising directions towards improving the security of Rust development, including several best practices of using specific APIs and methods to detect particular bugs involving unsafe code. Our work intends to raise more discussions regarding the memory-safety issues of Rust and facilitate the maturity of the language.

Motivation & Objective

  • To evaluate whether Rust truly prevents memory-safety bugs in real-world systems, as claimed by its designers.
  • To identify and categorize the root causes of memory-safety vulnerabilities in Rust programs beyond just unsafe code.
  • To understand the role of safe APIs in introducing subtle soundness issues that can lead to memory safety violations.
  • To provide actionable recommendations for developers and tool builders to improve Rust's security posture.
  • To extend prior work by analyzing a comprehensive dataset of all known Rust CVEs with memory-safety issues by end-2020.

Proposed method

  • Collected a dataset of 186 memory-safety CVEs from multiple sources, including Advisory-DB, Trophy Case, and GitHub projects, covering all known Rust CVEs with memory-safety issues by December 2020.
  • Manually analyzed each bug to classify its consequence (e.g., use-after-free, buffer overflow) and identify the underlying culprit pattern.
  • Employed a hybrid approach: top-down labeling of bug consequences using standard memory-safety categories, and bottom-up grouping of similar culprit patterns.
  • Categorized bugs into three main types: automatic memory reclaim, unsound functions, and unsound generic or trait usage.
  • Proposed best practices for safe API usage and suggested extending static analysis to detect unsafe patterns in unsafe code, especially related to ownership and drop semantics.
  • Compared findings with prior work (e.g., Qin et al., 2020) to highlight novel contributions, particularly in the analysis of generic and trait-based unsoundness.

Experimental results

Research questions

  • RQ1To what extent do real-world memory-safety bugs in Rust require unsafe code, confirming Rust’s memory-safety promise?
  • RQ2What are the dominant patterns and root causes of memory-safety vulnerabilities in Rust, especially when they do not involve explicit unsafe blocks?
  • RQ3How do Rust’s ownership and borrowing system, particularly automatic drop and stack unwinding, contribute to unintended memory safety issues?
  • RQ4What are the key challenges developers face in writing sound generic or trait-based code in Rust, and how do these lead to unsoundness?
  • RQ5What practical recommendations can be derived for developers and tool builders to improve the security of Rust programs?

Key findings

  • All 186 memory-safety bugs in the dataset require unsafe code, confirming that Rust successfully enforces its memory-safety promise when safe code is used.
  • Many memory-safety issues are not critical exploits but mild soundness problems in safe APIs, such as incorrect drop implementations or unsound trait bounds.
  • Automatic memory reclaim—triggered by Rust’s ownership system and drop semantics—leads to use-after-free, double-free, and invalid pointer issues, especially under stack unwinding.
  • Unsound functions represent a core challenge in Rust development, as they can introduce undefined behavior even without unsafe blocks, often due to incorrect type-level reasoning.
  • Unsound generic or trait usage is a growing concern, particularly when generic bounds or trait implementations violate memory safety, and is a more complex and subtle source of bugs.
  • The study identifies specific API patterns and coding practices that increase the risk of unsoundness, leading to concrete recommendations for safer Rust development.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.