text
stringlengths
0
1.99k
::. When Do We Want It By? .::
June 2026
::. When will Phrack 73 be released? .::
Summer 2026
----( Contact )----
< Editors : staff[at]phrack{dot}org >
> Submissions : submissions[at]phrack{dot}org <
< /dev/urandom : loopback[at]phrack{dot}org >
> Arts & Leisure : arts[at]phrack{dot}org <
< Twitter/X : phrack >
> Mastodon : phrack[at]haunted{dot}computer <
< BlueSky : phrack{dot}org >
The rules are simple:
+ 7-bit ASCII wrapped to 76 columns OR Markdown UTF-8
+ ANTISPAM in the subject line or face the Spam God and
walk backwards into hell
|=-----------------------------------------------------------------------=|
|=------=[ Popping an alert from a sandboxed WebAssembly module ]=-------=|
|=-----------------------------------------------------------------------=|
|=--------------------------=[ Thomas Rinsma ]=--------------------------=|
|=----------------------------=[ th0mas.nl ]=----------------------------=|
|=-----------------------------------------------------------------------=|
---[ Table of contents
0 - Introduction
1 - The WebAssembly-JavaScript interface
2 - A "feature" of the specification
3 - Importing from the prototype
4 - Planning our escape
5 - Available gadgets
5.1 - Dynamic function calling
5.2 - First steps in constructing a string
5.3 - Extracting named properties
5.4 - Obtaining individual characters
5.5 - Accumulating into a string
6 - Keeping things JS engine-agnostic
7 - Exploit recap
8 - Mitigation
9 - Retrospective
10 - References
11 - Full PoC
---[ 0 - Introduction
This is a story about breaking a security boundary that may not have been
intended, but that many assume exists. We will use some odd JavaScript
features in unintended ways to help us to escape this "sandbox", eventually
popping an alert from within an isolated WebAssembly module.
Usage of WebAssembly (WASM) is becoming more common lately. Primarily, it's
a fast, easy and secure way to run native programs on the web. However,
it's also become popular as a way to provide plugin support or allow for
modular components. Not just in the browser, but also server-side with
Node.js and in entirely different stacks using stand-alone WebAssembly
runtimes.
A WASM module's only interface with the outside world is its set of
"imports": effectively a set of external function references which the
module can invoke. This is what makes it such a good fit for a plugin
system: the host application can quite easily "sandbox" the WASM module by
only allowing it access to a limited set of APIs. Or at its extreme: not
giving it any imports, constraining the module to be entirely side-effect-
free and relying on return values of the module's exports.
Hence, it should be perfectly safe to load and run untrusted WASM modules
in such a restricted environment, right??
---[ 1 - The WebAssembly-JavaScript interface
Let's first take a step back and explore the basics of WASM modules and how
they're loaded from JavaScript.
Here's a very simple WASM module (given in the WAT text representation).
It defines a single import ("logger"), which it calls with the number 42:
(module
(import "ns" "logger" (func $logger (param i32)))
(func $main
i32.const 42
call $logger
)
(start $main)
)
We can load and instantiate the module (in its binary form) from JavaScript