Skip to main content
QUICK REVIEW

[Paper Review] Swivel: Hardening WebAssembly against Spectre

Shravan Narayan, Craig Disselkoen|arXiv (Cornell University)|Feb 25, 2021
Security and Verification in ComputingComputer Science57 references15 citations
TL;DR

Swivel is a compiler-based framework that hardens WebAssembly (Wasm) against Spectre attacks by enforcing speculative control and data flow isolation through linear blocks and memory masking. It achieves low performance overhead—under 10.3% on SPEC 2006 benchmarks—while eliminating sandbox breakout, poisoning, and host poisoning attacks without relying on pipeline fences or process isolation.

ABSTRACT

We describe Swivel, a new compiler framework for hardening WebAssembly (Wasm) against Spectre attacks. Outside the browser, Wasm has become a popular lightweight, in-process sandbox and is, for example, used in production to isolate different clients on edge clouds and function-as-a-service platforms. Unfortunately, Spectre attacks can bypass Wasm's isolation guarantees. Swivel hardens Wasm against this class of attacks by ensuring that potentially malicious code can neither use Spectre attacks to break out of the Wasm sandbox nor coerce victim code-another Wasm client or the embedding process-to leak secret data. We describe two Swivel designs, a software-only approach that can be used on existing CPUs, and a hardware-assisted approach that uses extension available in Intel 11th generation CPUs. For both, we evaluate a randomized approach that mitigates Spectre and a deterministic approach that eliminates Spectre altogether. Our randomized implementations impose under 10.3% overhead on the Wasm-compatible subset of SPEC 2006, while our deterministic implementations impose overheads between 3.3% and 240.2%. Though high on some benchmarks, Swivel's overhead is still between 9x and 36.3x smaller than existing defenses that rely on pipeline fences.

Motivation & Objective

  • Address the critical security gap in WebAssembly where Spectre attacks can bypass sandbox isolation on modern superscalar CPUs.
  • Mitigate Spectre-based attacks including sandbox breakout, sandbox poisoning, and host poisoning in in-process Wasm deployments.
  • Enable strong in-memory isolation for Wasm in performance-sensitive environments like serverless computing and edge clouds without sacrificing scalability.
  • Provide a practical, deployable solution compatible with existing hardware and compilers, avoiding reliance on expensive pipeline fences or process isolation.
  • Demonstrate that effective Spectre hardening is possible with minimal performance cost through intelligent static compilation and hardware-assisted features.

Proposed method

  • Compile Wasm code into linear blocks (LBs)—straight-line x86 code sequences that enforce control transfer only at block boundaries, preventing speculative branching into unauthorized regions.
  • Enforce memory access masking within each linear block to restrict speculative data accesses to the sandbox’s memory region only.
  • Eliminate reliance on the return stack buffer (RSB) by omitting ret instructions and using a separate stack pointer for return tracking, preventing RSB underflow attacks.
  • Leverage Intel® CET and MPK for hardware-assisted isolation in Swivel-CET, enabling fine-grained control-flow integrity and memory protection with minimal performance impact.
  • Apply speculative load hardening (SLH) to protect indirect call and switch tables from Spectre-PHT and Spectre-BTB attacks.
  • Use address space layout randomization (ASLR) in the software-only variant (Swivel-SFI) to increase the difficulty of crafting reliable Spectre gadgets.

Experimental results

Research questions

  • RQ1Can a compiler-based approach effectively prevent Spectre attacks in WebAssembly without relying on pipeline fences or process isolation?
  • RQ2To what extent can software-only compilation techniques like linear blocks and memory masking prevent speculative execution attacks in Wasm?
  • RQ3How does the performance overhead of Swivel compare to existing defenses such as fence insertion or process-based isolation in real-world workloads?
  • RQ4Can hardware extensions like Intel® CET and MPK be effectively integrated into a Wasm compiler stack to provide stronger, deterministic Spectre mitigation?
  • RQ5Is it possible to achieve both strong security guarantees and acceptable performance in high-throughput, multi-tenant environments like serverless platforms using a single compilation framework?

Key findings

  • Swivel-SFI, the software-only variant, imposes less than 10.3% overhead on the Wasm-compatible subset of SPEC 2006, demonstrating practical performance for production use.
  • The deterministic Swivel-CET variant achieves complete elimination of Spectre attacks using Intel® CET and MPK, with overheads ranging from 3.3% to 240.2% on SPEC 2006 benchmarks.
  • Swivel’s overhead is 9× to 36.3× lower than existing fence-based defenses, which incur 1.8× to 19.6× performance degradation.
  • By avoiding ret instructions and using a separate stack pointer, Swivel-SFI eliminates RSB underflow vulnerabilities that could otherwise be exploited in Spectre attacks.
  • The use of linear blocks and memory masking ensures that speculative control and data flow are confined within the sandbox boundary, preventing both breakout and poisoning attacks.
  • Swivel effectively defends against all three attack surfaces: sandbox breakout, sandbox poisoning, and host poisoning, making it suitable for multi-tenant environments like FaaS and edge computing.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.