论文标题
MSWAMS:不安全代码的内存安全执行
MSWasm: Soundly Enforcing Memory-Safe Execution of Unsafe Code
论文作者
论文摘要
今天汇编为WebAssembly(WASM)的大多数程序都是用C和C ++等不安全的语言编写的。不幸的是,在汇编为WASM时,内存 - UNSAFE C代码仍然不安全 - 攻击者可以在WASM中利用缓冲区溢出和在WASM中使用后,就像在本机平台上一样容易。内存安全的WebAssembly(MSWAMS)建议将WASM扩展使用语言级内存安全抽象,以精确解决此问题。在本文中,我们建立在原始的MSWAMS位置纸上,以实现这一愿景。我们提供了MSWAMS的精确和正式语义,并证明,通过构建良好的MSWAMS程序可以安全。为此,我们根据彩色记忆位置和指针开发了一种新颖的,独立于语言的内存安全性属性。该属性还使我们可以理解正式的C到MSWAMS编译器的安全保证,并证明它始终会产生内存安全的程序(并保留安全程序的语义)。然后,我们使用这些正式结果来指导几个实现:两个MSWAMS到本机代码的编译器,以及一个C到MSWAMS编译器(扩展了Clang)。我们的MSWASM编译器支持不同的执行机制,使开发人员可以根据他们的需求进行安全性绩效。我们的评估表明,软件中执行记忆安全的开销范围从22%(仅执行空间安全)到Polybenchc Suite上的198%(实施全部存储安全性)。更重要的是,MSWAMS的设计使得很容易在执行机制之间进行交换。随着快速(尤其是基于硬件的)执法技术可用,MSWAMS几乎可以免费利用这些进步。
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.