WebAssembly Linear Memory - 2D Address Map

Follow base + offset through the bounds rule on a map of committed memory, reserved space and guard region, then fuzz it.

Switch to 3D

Presets

Playback

Address and memory

Base, offset and width of one access, and the fuzz window.

Guard region

Which strategy the engine reserved.

Layers

Model checks

The science

Linear memory and the bounds rule

A WebAssembly instance sees one contiguous byte array, its linear memory, made of 64 KiB pages. Every load or store computes an effective address ea = base + offset from two unsigned 32-bit numbers (the pointer and the static offset encoded in the instruction) and is legal only if ea + len ≤ memory.size. The sum is formed in 64-bit arithmetic, so it never wraps round to a small address. Anything else is a trap: the module stops and the host is untouched. For a pointer drawn uniformly from all 232 values the chance of a legal access is (size − offset − len + 1) / 232 - a few parts per million for a few pages - and the page measures it by Monte Carlo as an independent check.

Guard regions or explicit checks

64-bit engines usually reserve 4 GiB of address space per instance plus a guard region. Pages the module has not been granted are simply unmapped, so a stray store faults in hardware and costs zero extra instructions. When a static offset is larger than the guard the compiler cannot rely on the fault and emits an explicit compare-and-branch instead (modelled here as three instructions). Either way the outcome is the same trap; only the price differs.

Capabilities instead of system calls

WebAssembly has no instruction that talks to the operating system. A module can only call imports the host linked when it created the instance. This is capability-based security: console.log and math.sqrt are linked, fs.open and net.connect can be granted or revoked by the host, and process.spawn cannot be linked at all in this model. A call to something not in the import table never reaches the host. The attack surface readout is the share of the five candidate imports that are linked.

Honest simplifications: a real engine also validates the module before running it, may add Spectre mitigations, and shares one process with the host; this page models only memory bounds and the import table. The 3 instructions per explicit check, the 12-page limit and the 2/4 GiB guard sizes are illustrative round numbers, not any single engine's defaults. The page shows defensive mechanisms only; it contains no exploit code.

What to try
  • Leave the sweep on and watch the effective address cross from page to page, then fall off the end of the committed memory into the reserved region and the guard.
  • Choose One byte past the end: a single byte over the bound is already a trap.
  • Choose Offset carries past 4 GiB: the 64-bit sum lands beyond the 4 GiB index space and still traps - it does not wrap to a low address.
  • Press Fuzz burst with a window of 8x memory and compare the legal fraction with the closed form shown in the readouts.
  • Switch the guard to No guard and see every illegal access become an explicit check on the pipeline.
Where the fuzz addresses landed
Bounds-check cost against big-offset share
Memory.grow against bytes allocated