MSWasm: 通过语言级内存安全性抽象确保内存安全的代码执行
MSWasm: Soundly Enforcing Memory-Safe Execution of Unsafe Code
AI总结:
MSWasm通过语言级内存安全性抽象,确保内存不安全代码的内存安全执行,通过形式化语义和证明,展示其内存安全性和编译器的正确性。
摘要:
目前大多数编译到WebAssembly(Wasm)的程序是用不安全语言如C和C++编写的。不幸的是,内存不安全的C代码在编译到Wasm时仍然不安全,攻击者可以像在原生平台一样轻易利用缓冲区溢出和使用后释放漏洞。内存安全WebAssembly(MSWasm)提出通过语言级内存安全性抽象扩展Wasm,以精确解决此问题。本文在原始MSWasm位置论文的基础上,实现了这一愿景。我们给出了MSWasm的精确且形式化的语义,并证明了正确类型化的MSWasm程序在构造上是稳健的内存安全。为此,我们开发了一种基于着色内存位置和指针的新型、语言无关的内存安全性属性。该属性还让我们可以推导形式化C到MSWasm编译器的安全保证,并证明其总是产生内存安全的程序(并保持安全程序的语义)。我们使用这些形式化结果来指导几个实现:两个将MSWasm编译到原生代码的编译器,以及一个C到MSWasm的编译器(扩展Clang)。我们的MSWasm编译器支持不同的强制机制,允许开发人员根据需求进行安全性和性能的权衡。我们的评估显示,在PolyBenchC套件上,强制内存安全的软件开销从22%(仅强制空间安全)到198%(强制完全内存安全)。更重要的是,MSWasm的设计使其能够轻松切换强制机制;随着更快(尤其是硬件基于的)强制技术的可用,MSWasm几乎可以免费利用这些进步。
英文摘要:
Most programs compiled to WebAssembly (Wasm) today are written in unsafe languages like C and C++. Unfortunately, memory-unsafe C code remains unsafe when compiled to Wasm -- and attackers can exploit buffer overflows and use-after-frees in Wasm almost as easily as they can on native platforms. Memory-Safe WebAssembly (MSWasm) proposes to extend Wasm with language-level memory-safety abstractions to precisely address this problem. In this paper, we build on the original MSWasm position paper to realize this vision. We give a precise and formal semantics of MSWasm, and prove that well-typed MSWasm programs are, by construction, robustly memory safe. To this end, we develop a novel, language-independent memory-safety property based on colored memory locations and pointers. This property also lets us reason about the security guarantees of a formal C-to-MSWasm compiler -- and prove that it always produces memory-safe programs (and preserves the semantics of safe programs). We use these formal results to then guide several implementations: Two compilers of MSWasm to native code, and a C-to-MSWasm compiler (that extends Clang). Our MSWasm compilers support different enforcement mechanisms, allowing developers to make security-performance trade-offs according to their needs. Our evaluation shows that the overhead of enforcing memory safety in software ranges from 22% (enforcing spatial safety alone) to 198% (enforcing full memory safety) on the PolyBenchC suite. More importantly, MSWasm's design makes it easy to swap between enforcement mechanisms; as fast (especially hardware-based) enforcement techniques become available, MSWasm will be able to take advantage of these advances almost for free.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。