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. MemorySafe 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 memorysafety 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 on the PolyBenchC suite, the overhead of enforcing memory safety in software ranges from 22% (enforcing spatial safety alone) to 198% (enforcing full memory safety), and 51.7% when using hardware memory capabilities for spatial safety and pointer integrity.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.

MSWasm: Soundly Enforcing Memory-Safe Execution of Unsafe Code / Michael, Ae; Gollamudi, A; Bosamiya, J; Johnson, E; Denlinger, A; Disselkoen, C; Watt, C; Parno, B; Patrignani, M; Vassena, M; Stefan, D. - In: PROCEEDINGS OF ACM ON PROGRAMMING LANGUAGES. - ISSN 2475-1421. - STAMPA. - 7:POPL(2023), pp. 425-454. [10.1145/3571208]

MSWasm: Soundly Enforcing Memory-Safe Execution of Unsafe Code

Patrignani, M;
2023-01-01

Abstract

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. MemorySafe 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 memorysafety 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 on the PolyBenchC suite, the overhead of enforcing memory safety in software ranges from 22% (enforcing spatial safety alone) to 198% (enforcing full memory safety), and 51.7% when using hardware memory capabilities for spatial safety and pointer integrity.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.
2023
POPL
Michael, Ae; Gollamudi, A; Bosamiya, J; Johnson, E; Denlinger, A; Disselkoen, C; Watt, C; Parno, B; Patrignani, M; Vassena, M; Stefan, D
MSWasm: Soundly Enforcing Memory-Safe Execution of Unsafe Code / Michael, Ae; Gollamudi, A; Bosamiya, J; Johnson, E; Denlinger, A; Disselkoen, C; Watt, C; Parno, B; Patrignani, M; Vassena, M; Stefan, D. - In: PROCEEDINGS OF ACM ON PROGRAMMING LANGUAGES. - ISSN 2475-1421. - STAMPA. - 7:POPL(2023), pp. 425-454. [10.1145/3571208]
File in questo prodotto:
File Dimensione Formato  
ms-main.pdf

Solo gestori archivio

Tipologia: Post-print referato (Refereed author’s manuscript)
Licenza: Tutti i diritti riservati (All rights reserved)
Dimensione 854.34 kB
Formato Adobe PDF
854.34 kB Adobe PDF   Visualizza/Apri
3571208.pdf

accesso aperto

Tipologia: Versione editoriale (Publisher’s layout)
Licenza: Creative commons
Dimensione 460.25 kB
Formato Adobe PDF
460.25 kB Adobe PDF Visualizza/Apri

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/11572/400875
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 3
  • ???jsp.display-item.citation.isi??? 2
social impact