Taint Tracking for WebAssembly

Aron Szanto, Timothy Tamm, Artidoro PagnoniarXiv 2018

Abstract

WebAssembly seeks to provide an alternative to running large and untrusted binaries within web browsers by implementing a portable, performant, and secure bytecode format for native web computation. However, WebAssembly is largely unstudied from a security perspective. In this work, we build the first WebAssembly virtual machine that runs in native JavaScript, and implement a novel taint tracking system that allows a user to run untrusted WebAssembly code while monitoring the flow of sensitive data through the application. We also introduce indirect taint, a label that denotes the implicit flow of sensitive information between local variables. Through rigorous testing and validation, we show that our system is correct, secure, and relatively efficient, benefiting from the native performance of WebAssembly while retaining precise security guarantees of more mature software paradigms.

Introduction

As web applications grow more complex, incorporating 3D gaming and video editing, they increasingly rely on WebAssembly (wasm) to execute heavy computational loads at near-native speeds directly in the browser. While wasm is designed with a sandboxed environment, it frequently handles highly sensitive user data. To ensure third-party wasm code does not leak or mishandle this data, security researchers require robust tools like taint tracking—a method of tagging sensitive data and monitoring its propagation through a program's execution.

This paper introduces the first JavaScript-based WebAssembly Virtual Machine (VM) capable of performing byte-level taint tracking. This system is uniquely capable of monitoring both direct and indirect flows of sensitive data through untrusted wasm binaries, filling a critical gap in the current web security ecosystem.

Methodology

The authors developed a custom JavaScript-based WebAssembly VM consisting of two main components: a scaffolding core for parsing and memory allocation, and an execution core for byte-by-byte opcode interpretation.

Taint Tracking Implementation

On top of this VM, the authors implemented a highly granular taint tracking system:

  • Byte-Level Granularity: Unlike variable-level tracking, which can be bypassed by unaligned memory reads, this system assigns a taint label to every allocable byte in memory and every stack variable. This prevents malicious actors from evading detection by reading tainted variables at slight memory offsets.
  • Direct vs. Indirect Taint: The system tracks direct assignments as well as indirect flows, where a tainted variable influences control flow (e.g., branching conditions) or memory access (e.g., array indexing).
  • Eliminating False Positives: By tracking at the byte level, the system avoids common pitfalls like tainting an entire array if only a single element is tainted, maintaining high precision.

Validation was performed using a custom suite of C-compiled programs, ranging from simple variable assignments to complex algorithms like the Euler Totient function.

Results

The implementation demonstrates high correctness, successfully executing complex binaries and accurately tracking taint through recursion, type casting, and non-linear memory access.

Performance and Memory Overhead

Performance analysis shows that while taint tracking introduces overhead, it remains asymptotically linear ($O(n)$). Direct tracking has a minimal impact, whereas indirect tracking—required for complex control flow—incurs a more significant but still bounded penalty.

Performance overhead for the Totient Function with and without taint tracking (TT).

Memory usage also scales linearly with the number of allocated objects, as the system must maintain metadata for every byte of tracked memory to ensure security guarantees.

Memory allocation overhead scaling with input size n.

Discussion and Future Work

A key limitation identified is the "untaken branch" problem: if a tainted variable causes a loop or branch not to execute, the variables inside that unexecuted block avoid being tainted, even though their state was indirectly influenced. Solving this would require symbolic execution to explore all possible execution paths.

Future work aims to:

  1. Incorporate a symbolic execution core to resolve the untaken branch limitation.
  2. Extend the VM to support floating-point operations and the wasm import section.
  3. Package the system into a user-facing browser extension, allowing end-users to actively monitor how untrusted wasm applications handle their private data.

Summary updated

BibTeX
@misc{szanto2018taint,
  author = {Aron Szanto and Timothy Tamm and Artidoro Pagnoni},
  title = {{Taint Tracking for WebAssembly}},
  year = {2018},
  eprint = {1807.08349},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1807.08349},
}
Figure