A lot of "exploitation" exercises compare a string and return a flag. The bug is a story around the comparison. I wanted the bug in the code, reachable by an ordinary program, and a checker that reads memory afterwards. That meant writing an engine.
The layout
| Offset | Field | Meaning |
|---|---|---|
| +0 | mapId | index into a host-side map table |
| +4 | size | bytes, including this header |
| +8 | mark | sweep mark |
| +12 | elem | pointer word to an elements block, or zero |
Slots are four bytes. A value is a 32-bit word: low bit zero means a Smi carrying value << 1, low bit one means a pointer holding a cage offset. Pointers are eight-byte aligned, so the tag costs nothing. Every reference is an offset into one Uint8Array, which means there is no address space to leak — that boundary is the model's whole point.
Why doubles are not in slots
A double needs eight bytes. A slot has four. So a double property does not hold a number; it holds a pointer to an eight-byte HeapNumber elsewhere in the cage.
When an array of Smis starts receiving doubles, the block is reallocated with eight-byte elements, the values are copied, and the map is swapped. Between the load of the old block and the store into the new one there is a window. V8 shipped a bug in that window this year, the second bug in the previous post. The HeapNumber split is why the window exists.
The bug I left in
In the Forge, assigning an array's length writes the length slot and does not resize the elements block. Every later index then trusts the new length and walks forward past the block, through whatever the bump allocator put next.
xs.length = 64; // the slot moves; the block does not
xs[15] = 1; // 15 is past the block, inside a neighbouring object
The index is not secret. The heap panel lists every live block with its offset, so the reader computes where the target's property slot sits and chooses the index that lands on it. One lab asks you to rewrite a seeded canary's property; the next asks you to use the same primitive on something more interesting.
The escape
The host is a table of values outside the cage: the flag, a shell path, a file, a secret. Guest code reaches it only through a view object, whose first slot holds a handle index. open() hands out a view on handle 1. Handle 3 is never handed out by anything.
The last lab aims the length bug at the view's index slot. Allocate the view after the array and the forward walk reaches it. Allocate it before and it does not. Allocation order decides what the bug can reach.
Who judges
The first version ran in the browser. A flag in the bundle is visible, and a client that decides the solve can be edited.
The fix came from the engine itself. Workers ban eval, but nothing here evaluates strings — the parser produces an AST and the interpreter walks it. So the scored run moved into the Worker. The flag lives in the environment, the checkers read the heap and the host log, and the client only sends source and draws the reply.
| Client-side, before | Worker-scored, now |
|---|---|
| flag in the bundle | flag in env, never shipped |
| any solve is a display decision | solve requires the read log |
| devtools defeats it | devtools shows nothing |
The rate limit is 30 runs a minute per visitor, the cage is 64 KiB, and a run stops at 400,000 steps. A program that loops forever gets an error, not a bill.
The escape, spelled out
Run var xs = [1,2,3,4]; var v = open(); once and read the panel. The elements block sits just before the array object; the view sits after it. An element i is at elements + 16 + i*4, and the view's index slot is at view + 20.
With the numbers this engine currently produces, that is index 15:
var xs = [1, 2, 3, 4];
var v = open();
xs.length = 512;
xs[15] = 3;
print(read(v)); // native:0x7f3a2c10The write is four bytes wide and lands exactly on the index slot. Nothing checks that the view still names what it did when open() returned it, because nothing can: the index is ordinary writable memory, and that is precisely the failure real engines spend their sandbox budget preventing.
What it still doesn't have
No JIT, so no compiler bugs. No pointer compression, so the cage is small. No GC pressure worth the name. And the final step of a real chain — turning cage access into native execution — has nowhere to happen, because there is no native code.
The page says so. What is there: bugs in the engine, a score read from the heap, and a boundary you can point at.