[Paper Review] Modular Abstract Definitional Interpreters for WebAssembly
This paper investigates security divergences between C programs compiled to x86 and WebAssembly, finding that 24% of 4,469 vulnerable C programs exhibit different execution outcomes due to the absence of stack canaries in WebAssembly. The study demonstrates that compiler protections like stack smashing protection are not consistently applied to WebAssembly, risking exploitation of buffer overflows that would otherwise be caught in native code.
Even though static analyses can improve performance and secure programs against vulnerabilities, no static whole-program analyses exist for WebAssembly (Wasm) to date. Part of the reason is that Wasm has many complex language concerns, and it is not obvious how to adopt existing analysis frameworks for these features. This paper explores how abstract definitional interpretation can be used to develop sophisticated analyses for Wasm and other complex languages efficiently. In particular, we show that the semantics of Wasm can be decomposed into 19 language-independent components that abstract different aspects of Wasm. We have written a highly configurable definitional interpreter for full Wasm 1.0 in 1628 LOC against these components. Analysis developers can instantiate this interpreter with different value and effect abstractions to obtain abstract definitional interpreters that compute inter-procedural control and data-flow information. This way, we develop the first whole-program dead code, constant propagation, and taint analyses for Wasm, each in less than 210 LOC. We evaluate our analyses on 1458 Wasm binaries collected by others in the wild. Our implementation is based on a novel framework for definitional abstract interpretation in Scala that eliminates scalability issues of prior work.
Motivation & Objective
- To assess whether security properties of C programs, particularly buffer overflow protections, are preserved when compiled to WebAssembly.
- To investigate whether existing compiler protections such as stack canaries are absent in WebAssembly binaries compared to native x86 code.
- To identify and analyze execution divergences between WebAssembly and native code that could lead to security risks in deployed applications.
- To provide a dataset of 1,088 divergent programs for future research on cross-compilation security.
- To encourage research into broader security divergences beyond buffer overflows in WebAssembly compilation.
Proposed method
- Compiled 4,469 C programs with known buffer overflows to both x86 and WebAssembly using Clang and the Emscripten toolchain.
- Executed both x86 and WebAssembly binaries under identical conditions using the Wasmer runtime on Linux.
- Identified execution divergences by comparing program behavior—specifically, whether crashes occurred upon buffer overflow.
- Conducted manual reverse engineering of divergent binaries to analyze differences in generated code, focusing on the absence of stack canaries.
- Evaluated the impact of compiler optimization levels (e.g., -O1) on divergence presence, noting that optimization can influence whether protections are emitted.
- Shared a public dataset of 1,088 divergent programs with their corresponding x86 and WebAssembly binaries for reproducibility and further analysis.
Experimental results
Research questions
- RQ1Do C programs with known buffer overflows exhibit different execution outcomes when compiled to WebAssembly versus x86?
- RQ2What are the root causes of execution divergences between WebAssembly and native code in vulnerable C programs?
- RQ3To what extent do compiler security mechanisms like stack canaries differ between WebAssembly and native code backends?
- RQ4How do compiler optimizations and code variations affect the presence or absence of security protections in WebAssembly binaries?
- RQ5Are there broader security divergences beyond buffer overflows that arise during compilation to WebAssembly?
Key findings
- 24% of the 4,469 vulnerable C programs exhibited divergent execution outcomes between x86 and WebAssembly binaries.
- The root cause of divergence was consistently the absence of stack canaries in WebAssembly binaries, which are present in x86 binaries.
- While x86 binaries crashed upon stack-based buffer overflow, WebAssembly binaries continued execution, indicating a lack of runtime protection.
- The lack of stack canaries in WebAssembly is not due to a flaw in the WebAssembly specification but due to compiler backend choices.
- Compiler optimization levels such as -O1 can influence whether security protections are emitted, affecting the presence of divergences.
- The dataset of 1,088 divergent programs, including both x86 and WebAssembly binaries, is publicly available for further research.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.