arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2507.03344cs.CRcs.SE
收藏

利用硬件能力保障混合 Rust 代码安全

Securing Mixed Rust with Hardware Capabilities

Jason Zhijingcheng Yu, Fangqi Han, Kaustab Choudhury, Trevor E. Carlson, Prateek Saxena

AI总结:

本文提出 CapsLock 机制,在基于能力的硬件抽象上通过“使用时撤销”实现跨语言运行时检测,保障混合 Rust 代码中的所有权、借用和 AXM 原则,并在实验中验证了其高兼容性与漏洞发现能力。

摘要:

Rust 编程语言强制执行三项基本 Rust 原则,即所有权、借用和 AXM(别名异或可变性,Aliasing Xor Mutability),以防止内存安全违规和数据竞争等安全漏洞。然而,Rust 项目通常包含混合代码,即同时使用不安全 Rust、FFI(外部函数接口,Foreign Function Interfaces)和内联汇编以实现底层控制的代码。Rust 编译器无法在混合 Rust 代码中静态强制执行 Rust 原则,这可能导致许多安全漏洞。在本文中,我们提出了 CapsLock,一种能够在机器代码层面运行并在运行时检测混合代码中 Rust 原则违规的安全执行机制。CapsLock 保持足够简单,可以实现在近期基于能力的硬件抽象中,这些抽象提供了低成本的空间内存安全。CapsLock 为基于能力的设计引入了一种新颖的“使用时撤销”(revoke-on-use)抽象,其中通过某个能力访问内存对象会隐式地使指向该对象的某些其他能力失效,从而自动提供时间内存安全,而无需软件显式指定此类失效。因此,CapsLock 是首个能够提供跨语言 Rust 原则执行能力的机制。我们在 QEMU 上实现了 CapsLock 的原型。评估结果表明,CapsLock 与现有 Rust 代码高度兼容(通过了 100 个最流行 crate 的内置测试用例中的 99.7%),并能在使用 FFI 或内联汇编的真实世界 Rust 项目中标记 Rust 原则违规。在实验中,我们在这些 crate 中发现了 8 个此前未知的漏洞。

英文摘要:

The Rust programming language enforces three basic Rust principles, namely ownership, borrowing, and AXM (Aliasing Xor Mutability) to prevent security bugs such as memory safety violations and data races. However, Rust projects often have mixed code, i.e., code that also uses unsafe Rust, FFI (Foreign Function Interfaces), and inline assembly for low-level control. The Rust compiler is unable to statically enforce Rust principles in mixed Rust code which can lead to many security vulnerabilities. In this paper, we propose CapsLock, a security enforcement mechanism that can run at the level of machine code and detect Rust principle violations at run-time in mixed code. CapsLock is kept simple enough to be implemented into recent capability-based hardware abstractions that provide low-cost spatial memory safety. CapsLock introduces a novel revoke-on-use abstraction for capability-based designs, wherein accessing a memory object via a capability implicitly invalidates certain other capabilities pointing to it, thereby also providing temporal memory safety automatically, without requiring software to explicitly specify such invalidation. Thus, CapsLock is the first mechanism capable of providing cross-language enforcement of Rust principles. We implemented a prototype of CapsLock on QEMU. Evaluation results show that CapsLock is highly compatible with existing Rust code (passing 99.7% of the built-in test cases of the 100 most popular crates) and flags Rust principle violations in real-world Rust projects that use FFI or inline assembly. We discovered 8 previously unknown bugs in such crates in our experiments.

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

↑