Skip to main content
QUICK REVIEW

[论文解读] Auditing Rust Crates Effectively

Lydia Zoghbi, David Thien|arXiv (Cornell University)|Feb 6, 2026
Software Testing and Debugging TechniquesComputer Science被引用 0
一句话总结

论文介绍了 Cargo Scan,这是一种交互式静态分析工具,能够识别 Rust crate 中潜在的危险效果,支持情境感知审计并减少人工审查工作量。它在审计第三方 Rust 代码方面显示出显著的效率提升和可扩展的生态覆盖。

ABSTRACT

We introduce Cargo Scan, the first interactive program analysis tool designed to help developers audit third-party Rust code. Real systems written in Rust rely on thousands of transitive dependencies. These dependencies are as dangerous in Rust as they are in other languages (e.g., C or JavaScript) -- and auditing these dependencies today means manually inspecting every line of code. Unlike for most industrial languages, though, we can take advantage of Rust's type and module system to minimize the amount of code that developers need to inspect to the code that is potentially dangerous. Cargo Scan models such potentially dangerous code as effects and performs a side-effects analysis, tailored to Rust, to identify effects and track them across crate and module boundaries. In most cases (69.2%) developers can inspect flagged effects and decide whether the code is potentially dangerous locally. In some cases, however, the safety of an effect depends on the calling context -- how a function is called, potentially by a crate the developer imports later. Hence, Cargo Scan tracks context-dependent information using a call-graph, and collects audit results into composable and reusable audit files. In this paper, we describe our experience auditing Rust crates with Cargo Scan. In particular, we audit the popular client and server HTTP crate, hyper, and all of its dependencies; our experience shows that Cargo Scan can reduce the auditing burden of potentially dangerous code to a median of 0.2% of lines of code when compared to auditing whole crates. Looking at the Rust ecosystem more broadly, we find that Cargo Scan can automatically classify ~3.5K of the top 10K crates on crates.io as safe; of the crates that do require manual inspection, we find that most of the potentially dangerous side-effects are concentrated in roughly 3% of these crates.

研究动机与目标

  • 在真实系统中由于传递依赖而需审计第三方 Rust crate 的必要性成为动机。
  • 提出一种面向 Rust 的、基于效果的静态分析,用于识别潜在危险代码。
  • 提供一个交互式审计工作流,能够在调用图中传播上下文。
  • 在热门 crates 上评估 Cargo Scan,量化审计效率和覆盖范围。
  • 证明 Cargo Scan 是否能够自动将 crates 分类为安全并识别情境敏感的安全性。

提出的方法

  • 将潜在危险操作建模为效果,并进行面向 Rust 的定制静态分析,将效果映射到函数调用。
  • 构建调用图并使用类污点分析为效果标注局部或情境相关的安全性。
  • 提供三种安全性注释(安全、不安全、需调用者检查)并在依赖关系中传播需调用者检查的效果。
  • 实现一个作为 VSCode 扩展的交互式审计界面,用于浏览效果和调用点。
  • 生成默认的、保守的审计,将所有效果标记为需调用者检查,以界定跨包的审计范围。
  • 在顶级 crates 的分析上评估性能,并以一个针对 hyper 及其依赖的案例研究进行审计。

实验结果

研究问题

  • RQ1前列 Rust crates 中有副作用的比例是多少?
  • RQ2情境敏感(需调用者检查)效果对审计准确性有多大价值?
  • RQ3与全面人工审计相比,Cargo Scan 能否减少审计人员需要审查的代码量?
  • RQ4效果如何跨 crate 边界传播,哪些公共 API 受影响?
  • RQ5默认审计是否足以界定跨依赖的审计工作量?

主要发现

  • 约 34.34% 的顶级 crate 是纯净的(没有危险副作用)。
  • 大约 85% 的所有效果集中在约 3% 的 crates 中。
  • 对于 hyper,约 30.8% 的函数的安全性具有情境敏感性,跨包边界的情境敏感性占比为 5.2%。
  • 使用 Cargo Scan 进行审计时,与不使用 Cargo Scan 的代码审计相比,已审阅代码的中位数下降到 0.2% 的行数。
  • 在对 hyper crate 及其依赖进行审计时,默认审计下跨包审阅的代码行占比的平均值为 13.1%、中位数为 0.4%,跨包审计能进一步降低工作量。
  • Cargo Scan 能自动将约 3,500 个前 10,000 个 crate 分类为安全。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。