arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.03271cs.CRcs.PL
收藏

TYPEPULSE:检测 Rust 程序中的类型混淆缺陷

TYPEPULSE: Detecting Type Confusion Bugs in Rust Programs

Hung-Mao Chen, Xu He, Shu Wang, Xiaokuan Zhang, Kun Sun

AI总结:

本文提出静态分析工具 TYPEPULSE,结合类型转换分析、指针别名分析和属性图,检测 Rust 程序中的未对齐、不一致布局和不匹配作用域三类类型混淆缺陷,在 3000 个 Rust 软件包中发现 71 个新缺陷,超过 RUSTSEC 过去五年报告总数。

摘要:

Rust 支持类型转换,并通过健壮的静态类型检查和严格的所有权准则来保证这些转换的安全性。然而,在某些情况下,程序员需要使用不安全的 Rust 进行特定的类型转换,尤其是涉及指针的转换。因此,这些转换可能导致严重的内存损坏问题。尽管针对 C/C++ 中类型混淆缺陷的研究已经相当广泛,但针对 Rust 中类型混淆缺陷的研究仍然缺乏。此外,由于 Rust 在类型系统中引入了新的特性,C/C++ 中现有的解决方案无法直接应用于 Rust。在本文中,我们开发了一个名为 TYPEPULSE 的静态分析工具,用于检测 Rust 中三大类类型混淆缺陷,包括未对齐(misalignment)、不一致布局(inconsistent layout)和不匹配作用域(mismatched scope)。TYPEPULSE 首先执行类型转换分析,以收集并确定类型对的 trait 约束。此外,它还执行指针别名分析,以解析指针的别名关系。在将信息整合到属性图中之后,它构建类型模式,并在各种转换场景中检测每种类型的缺陷。我们在排名前 3,000 的 Rust 软件包上运行了 TYPEPULSE,发现了 71 个新的类型混淆缺陷,超过了 RUSTSEC 过去五年报告的类型混淆缺陷总数。我们已收到来自开发者的 32 次确认,以及一个 CVE 编号和六个 RUSTSEC 编号。

英文摘要:

Rust supports type conversions and safe Rust guarantees the security of these conversions through robust static type checking and strict ownership guidelines. However, there are instances where programmers need to use unsafe Rust for certain type conversions, especially those involving pointers. Consequently, these conversions may cause severe memory corruption problems. Despite extensive research on type confusion bugs in C/C++, studies on type confusion bugs in Rust are still lacking. Also, due to Rust's new features in the type system, existing solutions in C/C++ cannot be directly applied to Rust. In this paper, we develop a static analysis tool called TYPEPULSE to detect three main categories of type confusion bugs in Rust including misalignment, inconsistent layout, and mismatched scope. TYPEPULSE first performs a type conversion analysis to collect and determine trait bounds for type pairs. Moreover, it performs a pointer alias analysis to resolve the alias relationship of pointers. Following the integration of information into the property graph, it constructs type patterns and detects each type of bug in various conversion scenarios. We run TYPEPULSE on the top 3,000 Rust packages and uncover 71 new type confusion bugs, exceeding the total number of type confusion bugs reported in RUSTSEC over the past five years. We have received 32 confirmations from developers, along with one CVE ID and six RUSTSEC IDs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑