MSWasm: Soundly Enforcing Memory-Safe Execution of Unsafe Code
Pith reviewed 2026-05-24 11:27 UTC · model grok-4.3
The pith
Well-typed MSWasm programs are robustly memory safe by construction.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
The central claim is that a well-typed MSWasm program cannot violate memory safety even when the source program contains buffer overflows or use-after-frees; the colored-memory property ensures that every pointer dereference respects the color boundaries established at allocation time, and the C-to-MSWasm compiler is proven to produce only such well-typed programs while preserving semantics for safe inputs.
What carries the argument
The colored-memory property, which labels each memory location and pointer with a color so that accesses are permitted only when colors match and bounds are respected.
If this is right
- The C-to-MSWasm compiler always emits memory-safe code.
- MSWasm programs can be executed under interchangeable enforcement mechanisms ranging from software checks to hardware support.
- Spatial safety alone incurs 22 percent overhead while full memory safety incurs 198 percent overhead on PolyBenchC.
- New enforcement techniques can be adopted by swapping the runtime without changing the typed source programs.
Where Pith is reading between the lines
- The same colored-memory discipline could be applied to other low-level languages that target WebAssembly.
- Hardware memory-safety features could be integrated by mapping colors directly to hardware tags.
- The formal results supply a reusable template for proving memory safety of compilers from other unsafe languages.
Load-bearing premise
The colored-memory property exactly matches the intended robustness notion of memory safety without either missing attacks or ruling out valid programs.
What would settle it
A concrete well-typed MSWasm program together with an input that produces a memory-safety violation such as an out-of-bounds write or a use-after-free.
Figures
read the original 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. 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.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper introduces Memory-Safe WebAssembly (MSWasm) as an extension to WebAssembly with language-level memory-safety abstractions. It defines a precise formal semantics for MSWasm, introduces a novel colored-memory property as the basis for a language-independent notion of robust memory safety, proves that well-typed MSWasm programs satisfy this property by construction, and proves that a formal C-to-MSWasm compiler always produces memory-safe programs while preserving the semantics of safe programs. The paper further describes two MSWasm-to-native compilers supporting different enforcement mechanisms and a Clang-based C-to-MSWasm compiler, with an evaluation on PolyBenchC reporting overheads ranging from 22% (spatial safety) to 198% (full memory safety).
Significance. If the colored-memory property accurately models the intended robustness guarantees, the work supplies a sound formal foundation for memory-safe execution of unsafe code targeting WebAssembly, together with practical compiler implementations that allow security-performance trade-offs. Explicit strengths include the machine-checked-style formal semantics and proofs of type safety and compiler preservation, the design that supports swapping enforcement mechanisms, and the reproducible evaluation on PolyBenchC.
major comments (1)
- [§4] §4 (colored-memory property definition): The property is load-bearing for both the claim that well-typed MSWasm programs are robustly memory safe and the compiler correctness theorem. The manuscript defines the property via colored locations and pointers and proves internal theorems within this model, but provides no reduction, lemma, or explicit argument showing that the property blocks all standard memory-safety violations (buffer overflows, use-after-free, etc.) while permitting legitimate programs. This modeling assumption therefore requires additional justification to support the security claims in the abstract.
minor comments (2)
- [Evaluation] The evaluation reports overhead ranges but does not clearly map each percentage to a specific enforcement mechanism or include per-benchmark breakdowns; adding a table with these details would improve clarity.
- [§3] Notation for colored pointers and memory in the operational semantics could be introduced with a small example to aid readability for readers unfamiliar with the position paper.
Simulated Author's Rebuttal
We thank the referee for the careful review and for highlighting the importance of the colored-memory property. We address the single major comment below.
read point-by-point responses
-
Referee: [§4] §4 (colored-memory property definition): The property is load-bearing for both the claim that well-typed MSWasm programs are robustly memory safe and the compiler correctness theorem. The manuscript defines the property via colored locations and pointers and proves internal theorems within this model, but provides no reduction, lemma, or explicit argument showing that the property blocks all standard memory-safety violations (buffer overflows, use-after-free, etc.) while permitting legitimate programs. This modeling assumption therefore requires additional justification to support the security claims in the abstract.
Authors: We agree that an explicit argument linking the colored-memory property to standard violations strengthens the presentation. The property is defined so that every allocation receives a fresh color, every pointer carries its target color, and well-typed programs may only dereference a pointer whose color matches the accessed location. Consequently, a buffer overflow necessarily targets either an out-of-bounds address (different color) or an invalid location; a use-after-free necessarily targets a location whose color has been updated on deallocation/reuse. Legitimate intra-object accesses remain possible because they stay within the same colored region. We will add a short subsection (or lemma) in §4 that states this correspondence formally, supplies one-line arguments for each classic violation, and notes that the same reasoning applies to the compiler theorem. This addition will be included in the revised manuscript. revision: yes
Circularity Check
Minor self-citation to prior position paper by overlapping authors; core colored-memory property, semantics, and proofs are newly defined
specific steps
-
self citation load bearing
[Abstract]
"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."
The MSWasm vision and approach is introduced via reference to a prior paper whose authors overlap with the present work, though the subsequent formal development (colored memory, semantics, and proofs) does not reduce to that citation.
full rationale
The paper cites an earlier MSWasm position paper by overlapping authors when introducing the vision, but the colored-memory property is presented as novel, the operational semantics and type system are defined in this work, and the robust memory safety theorems for well-typed programs and the C-to-MSWasm compiler are proved here without reducing to prior fitted quantities or self-citations by construction. No self-definitional, fitted-prediction, uniqueness-import, ansatz-smuggling, or renaming patterns appear. This is a normal minor self-citation that does not affect the independence of the central formal results.
Axiom & Free-Parameter Ledger
axioms (1)
- standard math Standard properties of operational semantics and type systems hold for the defined language.
invented entities (1)
-
colored memory locations and pointers
no independent evidence
Reference graph
Works this paper leans on
-
[1]
In 2019 IEEE 32th Computer Security Foundations Symposium (CSF
Journey Beyond Full Abstraction: Exploring Robust Property Preservation for Secure Compilation. In 2019 IEEE 32th Computer Security Foundations Symposium (CSF
work page 2019
-
[2]
Armv8.5-A Memory Tagging Extension. White Paper (2019). Todd M. Austin, Scott E. Breach, and Gurindar S. Sohi
work page 2019
-
[3]
Efficient Detection of All Pointer and Array Access Errors. In Proceedings of the ACM SIGPLAN 1994 Conference on Programming Language Design and Implementation (Orlando, Florida, USA) (PLDI ’94). Association for Computing Machinery, New York, NY, USA, 290–301. https://doi.org/10.1145/ 178243.178446 Arthur Azevedo de Amorim, Cătălin Hriţcu, and Benjamin C. Pierce
-
[4]
Supporting the UK in becoming a leading global player in cybersecurity. https://community. arm.com/blog/company/b/blog/posts/supporting-the-uk-in-becoming-a-leading-global-player-in-cybersecurity. Andreas Haas, Andreas Rossberg, Derek L. Schuff, Ben L. Titzer, Michael Holman, Dan Gohman, Luke Wagner, Alon Zakai, and JF Bastien. 2017a. Bringing the Web up ...
-
[5]
Aaron Hilbig, Daniel Lehmann, and Michael Pradel
What is memory safety? http://www.pl-enthusiast.net/2014/07/21/memory-safety/. Aaron Hilbig, Daniel Lehmann, and Michael Pradel
work page 2014
-
[6]
Not So Fast: Analyzing the Performance of WebAssembly vs. Native Code. In 2019 USENIX Annual Technical Conference (USENIX ATC
work page 2019
-
[7]
In 2002 USENIX Annual Technical Conference (USENIX ATC
Cyclone: A Safe Dialect of C. In 2002 USENIX Annual Technical Conference (USENIX ATC
work page 2002
-
[8]
In Proceedings of the 2013 ACM SIGSAC Conference on Computer and Communications Security
Low-Fat Pointers: Compact Encoding and Efficient Gate-Level Implementation of Fat Pointers for Spatial Safety and Capability-Based Security. In Proceedings of the 2013 ACM SIGSAC Conference on Computer and Communications Security . ACM. Byoungyoung Lee, Chengyu Song, Yeongjin Jang, Tielei Wang, Taesoo Kim, Long Lu, and Wenke Lee
work page 2013
-
[9]
Journal of Automated Reasoning 43, 4 (2009), 363–446
A Formally Verified Compiler Back-end. Journal of Automated Reasoning 43, 4 (2009), 363–446. http://dx.doi.org/10.1007/s10817-009-9155-4 Hans Liljestrand, Thomas Nyman, Kui Wang, Carlos Chinea Perez, Jan-Erik Ekberg, and N. Asokan
-
[10]
Principles of Secure Compilation (PriSC)
Lucet: A Compiler and Runtime for High-Concurrency Low-Latency Sandboxing. Principles of Secure Compilation (PriSC). Kayvan Memarian, Victor B. F. Gomes, Brooks Davis, Stephen Kell, Alexander Richardson, Robert N. M. Watson, and Peter Sewell. 2019a. Exploring C Semantics and Pointer Provenance. Proc. ACM Program. Lang. 3, POPL, Article 67 (Jan. 2019), 32 ...
-
[11]
Into the Depths of C: Elaborating the de Facto Standards. SIGPLAN Not. 51, 6 (June 2016), 1–15. Santosh Nagarakatte, Jianzhou Zhao, Milo M.K. Martin, and Steve Zdancewic
work page 2016
-
[12]
SoftBound: Highly Compatible and Complete Spatial Memory Safety for C.SIGPLAN Not. 44, 6 (June 2009), 245–258. https://doi.org/10.1145/1543135.1542504 Santosh Nagarakatte, Jianzhou Zhao, Milo M.K. Martin, and Steve Zdancewic
-
[13]
CETS: Compiler Enforced Temporal Safety for C. SIGPLAN Not. 45, 8 (June 2010), 31–40. https://doi.org/10.1145/1837855.1806657 Shravan Narayan, Craig Disselkoen, Tal Garfinkel, Nathan Froyd, Eric Rahm, Sorin Lerner, Hovav Shacham, and Deian Stefan
-
[14]
CCured: Type-safe Retrofitting of Legacy Software. ACM Trans. Program. Lang. Syst. 27, 3 (May 2005), 477–526. https://doi.org/10.1145/1065887.1065892 Oleksii Oleksenko, Dmitrii Kuvaiskii, Pramod Bhatotia, Pascal Felber, and Christof Fetzer
-
[15]
Intel MPX Explained: A Cross-Layer Analysis of the Intel MPX System Stack. Proc. ACM Meas. Anal. Comput. Syst. 2, 2, Article 28 (jun 2018), 30 pages. https://doi.org/10.1145/3224423 Aleph One
-
[16]
Phrack magazine 7, 49 (1996), 14–16
Smashing the stack for fun and profit. Phrack magazine 7, 49 (1996), 14–16. Oracle. 2021a. GraalVM. https://www.graalvm.org/. Oracle. 2021b. Truffle Language Implementation Framework. https://www.graalvm.org/22.0/graalvm-as-a-platform/ language-implementation-framework/. Matthew Parkinson, Kapil Vaswani, Dimitrios Vytiniotis, Manuel Costa, Pantazis Deligi...
work page 1996
-
[17]
Tech- nical Report MSR-TR-2017-32
Project Snowflake: Non-blocking safe manual memory management in .NET . Tech- nical Report MSR-TR-2017-32. Microsoft. https://www.microsoft.com/en-us/research/publication/project-snowflake- non-blocking-safe-manual-memory-management-net/ Harish Patil and Charles Fischer
work page 2017
-
[18]
Low-Cost, Concurrent Checking of Pointer and Array Accesses in C Programs. Softw. Pract. Exper. 27, 1 (jan 1997), 87–110. Marco Patrignani
work page 1997
-
[19]
Why Should Anyone use Colours? or, Syntax Highlighting Beyond Code Snippets. CoRR abs/2001.11334 (2020). arXiv:2001.11334 https://arxiv.org/abs/2001.11334 Gregor Peach, Runyu Pan, Zhuoyi Wu, Gabriel Parmer, Christopher Haster, and Ludmila Cherkasova
-
[20]
eWASM: Practical Software Fault Isolation for Reliable Embedded Devices. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 39, 11 (2020), 3492–3505. https://doi.org/10.1109/TCAD.2020.3012647 Louis-Noel Pouchet
- [21]
-
[22]
InProceedings of the 2013 IEEE Symposium on Security and Privacy (SP ’13)
SoK: Eternal War in Memory. InProceedings of the 2013 IEEE Symposium on Security and Privacy (SP ’13) . IEEE Computer Society. Gang Tan
work page 2013
-
[23]
In 2015 IEEE Symposium on Security and Privacy
CHERI: A Hybrid Capability-System Architecture for Scalable Software Compartmentalization. In 2015 IEEE Symposium on Security and Privacy . 20–37. https://doi.org/10.1109/SP.2015.9 WebAssembly. [n.d.]. WebAssembly System Interface. https://github.com/WebAssembly/wasi. Wei Xu, Daniel C. DuVarney, and R. Sekar
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.