Compilers & Sandboxes · Zero Background Needed · Visual Guide + 8 Fieldbook Chapters · Free
WebAssembly & Bytecode Verification: What It Is & How It Works
How does your browser, Cloudflare Workers, or a desktop app's plugin system run untrusted compiled C++ and Rust code at near-native speed without letting a rogue plugin crash the machine or steal passwords? WebAssembly (Wasm) replaces raw CPU machine code with a compact, portable instruction stream—and before allowing the CPU to execute a single instruction, its bytecode verifier scans every stack push, jump target, and 64 KB memory wall in one fast linear pass.
Start from zero (interactive lab) 5-step interactive studio- Zero background needed
- Starts with an interactive Stack Machine Tray walkthrough (pushing numbers, adding them, and isolating 64 KB memory walls) so zero prior compiler or Wasm knowledge is required.
- Real teaching before every quiz
- Every chapter defines every opcode in plain English, traces a worked tiny example with diagrams, and lets you step the live bytecode machine before predicting.
- Verified against native Wasm
- Works completely offline in your browser, or run all 26 Node tests (230 assertions) comparing your verifier directly against real V8
WebAssembly.validate.
Three Ways In · Layer 3 of 3 · Node.js 22+ · Zero Dependencies
Build With Your Coding Agent — 5 Rungs + Planted Traps
Build a single-pass WebAssembly type verifier and sandboxed linear-memory runtime with your coding agent across five rungs: frame-floored operand stacks, block vs. loop branch arity, polymorphic unreachable stack floors, overflow-proof 64 KB linear-memory bounds, and structural `call_indirect` signature checks. Each rung gives you an architect prompt for Claude Code, Codex, or Cursor, a planted bug that unguided agents write, and a deterministic test suite that catches it.
- Frame-floored type stack: Single-pass operand type stack isolated per structured control frame — Planted trap: Checking only
stack.length > 0on pop so instructions inside ablocksteal outer stack values. - Structured branch targets: Forward
block/ifjumps carrying result types vs. backwardloopjumps carrying loop inputs — Planted trap: Validatingbr 0inside aloop () -> (i32)against the loop's exit result instead of empty loop-header arity. - Polymorphic unreachable code: Unconditional
return/br/unreachablepolymorphic stack mode confined to the current frame — Planted trap: Ignoring type mismatches afterbror letting polymorphicunknowntypes leak pastend. - Overflow-free memory wall: Exact mathematical bounds check
addr + offset + width <= byteLengthon 64 KB pages — Planted trap: Wrappingaddr + offsetin 32-bit signed/unsigned arithmetic so0xFFFFFFFC + 8slips past the wall. - Sealed
call_indirecttable: Runtime table bounds, initialized-slot check, and structural(params, results)signature match — Planted trap: Checking table index bounds without structural signature equality, allowing type-confused indirect calls.
unzip agent-track.zip && cd wasm-verifier-lab/agent-track
node --test test/*.test.mjs
mkdir -p src/mine
WASM_IMPL=src/mine node --test test/rung-01.test.mjs
Download 5-Rung Agent Track (agent-track.zip) Read AGENT-TRACK.md on GitHub Open agent-track/README.md on GitHub
Inside the course
- Start Here — What & Why: How a browser safely runs compiled C++ and Rust in a sandbox, how a stack machine replaces CPU registers with a push/pop tray, and why one upfront verification pass beats slow runtime checks.
- Chapters 1–4 — Stack Types & Safe Jumps: See why Wasm accepts skipped dead code behind a jump while still rejecting type mismatches, check integer vs. float stack types, trace nested block/loop targets, and understand unreachable stack floors.
- Chapters 5–6 — Memory Walls & Safe Plugin Calls: Catch integer-wrap bugs before writing past a 64 KB page boundary, and verify host function signatures at indirect call tables.
- Chapters 7–8 — Verifier Design & Audit Exam: Compare single-pass streaming verification against two-pass control-flow graphs, then audit and patch a real plugin before sign-off.
Local test & source checkout
git clone https://github.com/itsHabib/free-to-learn.git
cd free-to-learn
git switch --detach 7dba0d743224c10a707307769782b0db3f9a2a1a
cd courses/wasm-verifier-lab
node --test tests/wasm-verifier.test.mjsUntrusted C++/Rust plugin arrives.
1. Verifier scans types & jumps BEFORE run.
2. Memory trapped inside 64 KB sandbox wall.
Near-native speed with zero memory escapes.
Step bytecode live across 8 chapters.
Verified against native WebAssembly (230 checks).