Skip to content
Back to skills

Ephemeral Wasm Sandbox Executor

ASecurity

Ephemeral WebAssembly sandboxes for secure code execution and tests / Sandbox WASM efemeral untuk eksekusi kode aman dan pengujian.

  • 125 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 12, 2026
ai-agentstypescriptrustgosqlnodeexpressrailsdockertestingdebugging

Works with

  • cli
  • mcp

Security analysis

A100/100

Scanned November 12, 2026

npx -y skills add roedyrustam/vibes-plug --skill ephemeral-wasm-sandbox-executor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ephemeral Wasm Sandbox Executor?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ephemeral Wasm Sandbox Executor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/roedyrustam-ephemeral-wasm-sandbox-executor-vibes-plug/badge)](https://www.skillsdirectory.com/skills/roedyrustam-ephemeral-wasm-sandbox-executor-vibes-plug)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ephemeral-wasm-sandbox-executor
description: "Ephemeral WebAssembly sandboxes for secure code execution and tests / Sandbox WASM efemeral untuk eksekusi kode aman dan pengujian."
author: "Roedy Rustam"
version: "4.8.0"
---

# Ephemeral WASM Sandbox Executor (2026 Sovereign Edition)

[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)

---

<a name="english"></a>
## English

### Executive Directive & The Untrusted AI Code Dilemma (2026 Shift)
When autonomous AI agents generate dynamic code, complex regular expressions, or database migrations, executing this code on the host machine presents catastrophic risks: **host file-system corruption, remote code execution (RCE), network exfiltration, and ReDoS CPU starvation**. Conversely, spinning up Docker containers takes $2{,}000\text{ms} - 5{,}000\text{ms}$ and consumes hundreds of megabytes of RAM per run, creating an intolerable latency bottleneck.

**The Ephemeral WASM Sandbox Executor** leverages memory-isolated **WebAssembly (WASM) micro-runtimes** (Extism, Wasmtime, and PGlite in-memory Postgres) to execute arbitrary AI-generated code in **$< 5\text{ms}$** with absolute linear memory boundaries, strict CPU fuel limits, and zero host filesystem access.

---

### Orchestration & Integration
- **Upstream Languages & Runtimes**: `wasm-edge-computing-expert`, `rust-programming-expert`, `bun-runtime-expert`.
- **Database & Migration Dry-Runs**: `database-orm-expert`, `living-codebase-ast-graph`.
- **Security Fuzzing & Red-Teaming**: `autonomous-red-teamer`, `prompt-injection-firewall`, `zero-trust-secret-vault`.
- **Testing & Debugging**: `autonomous-tdd-debugger`, `property-mutation-testing-expert`, `anti-slop`.
- **Lifecycle & Governance**: `zero-to-prod-orchestrator`, `brainstorming`, `session-memory-manager`.

---

### Core Architectural Topologies

```
┌────────────────────────────────────────────────────────────────────────┐
│                   EPHEMERAL WASM SANDBOX TOPOLOGY                      │
├────────────────────────────────────────────────────────────────────────┤
│ 1. AI-Generated Code / Untrusted Regex / SQL Migration                 │
│                                  │                                     │
│                                  ▼                                     │
│ 2. Ephemeral Sandbox Spawn (<5ms Startup)                              │
│    • Linear Memory Allocation (e.g. 16MB Cap)                          │
│    • CPU Fuel Quota (e.g. 100,000 instructions max)                    │
│    • Zero Host System Calls (No FS / No Raw Sockets)                   │
│                                  │                                     │
│        ┌─────────────────────────┴─────────────────────────┐           │
│        ▼                                                   ▼           │
│  [WASM JS/Logic Runner]                             [PGlite WASM DB]   │
│  Isolated compute & regex                           In-memory Postgres │
│  execution with fuel limits                         migration dry-run  │
│        │                                                   │           │
│        └─────────────────────────┬─────────────────────────┘           │
│                                  ▼                                     │
│ 3. Automated Execution Result (Return Clean Output or Rollback Error)  │
│                                  │                                     │
│                                  ▼                                     │
│ 4. Instant Memory Eviction (Zero Residual Footprint)                   │
└────────────────────────────────────────────────────────────────────────┘
```

#### 1. Runtime Isolation Comparison

| Dimension | Docker Container | Node.js `vm` Module | WASM Micro-Runtime (Wasmtime / Extism) | In-Memory WASM DB (PGlite) |
| :--- | :--- | :--- | :--- | :--- |
| **Cold Start Latency** | $1{,}500\text{ms} - 4{,}000\text{ms}$ | $< 1\text{ms}$ | **$< 3\text{ms}$** | **$< 15\text{ms}$** |
| **Memory Overhead** | $100\text{MB} - 500\text{MB}$ | $< 2\text{MB}$ | **$< 8\text{MB}$** | **$< 30\text{MB}$** |
| **Isolation Barrier** | OS Namespaces / cgroups | Weak (Prototype pollution) | **Hard (WASM Linear Memory)** | **Isolated In-Memory FS** |
| **CPU Starvation Defense** | OS CPU Shares | Process Event Loop Freeze | **Deterministic Fuel Counter** | Transaction Timeout |

#### 2. The 3 Hard Sandbox Invariants
1. **Deterministic CPU Fueling**: Sandboxed logic must consume gas/fuel counters. Infinite loops (`while (true)`) terminate deterministically without stalling the host process.
2. **Atomic Rollback on Dry-Runs**: In-memory database migrations must execute inside an explicit `BEGIN ... ROLLBACK` transaction envelope.
3. **No Ambient Host Privileges**: Ambient network and filesystem access are unmapped by default. Data exchange occurs strictly through typed shared buffers.

---

### Production Implementation Blueprints

#### Blueprint 1: In-Memory PostgreSQL Migration Dry-Runner (`sandbox/ephemeral-db-sandbox.ts`)
```typescript
import { PGlite } from '@electric-sql/pglite';

export interface MigrationDryRunResult {
  success: boolean;
  appliedSteps: number;
  executionTimeMs: number;
  tablesCreated: string[];
  error?: string;
}

export class EphemeralDatabaseSandbox {
  public static async dryRunSqlMigration(
    sqlStatements: string[]
  ): Promise<MigrationDryRunResult> {
    const startTime = performance.now();
    let applied = 0;
    const db = new PGlite();
    await db.waitReady;

    try {
      await db.query('BEGIN;');

      for (const statement of sqlStatements) {
        const trimmed = statement.trim();
        if (!trimmed) continue;
        await db.query(trimmed);
        applied += 1;
      }

      // Query introspected tables created in memory
      const tablesRes = await db.query<{ tablename: string }>(
        "SELECT tablename FROM pg_tables WHERE schemaname = 'public';"
      );
      const tablesCreated = tablesRes.rows.map((r) => r.tablename);

      // Rollback to leave zero persistent state
      await db.query('ROLLBACK;');
      await db.close();

      return {
        success: true,
        appliedSteps: applied,
        executionTimeMs: Math.round(performance.now() - startTime),
        tablesCreated,
      };
    } catch (err: unknown) {
      await db.query('ROLLBACK;').catch(() => {});
      await db.close().catch(() => {});

      return {
        success: false,
        appliedSteps: applied,
        executionTimeMs: Math.round(performance.now() - startTime),
        tablesCreated: [],
        error: err instanceof Error ? err.message : String(err),
      };
    }
  }
}
```

---

#### Blueprint 2: Ephemeral WASM Isolated Function Runner with Fuel Limits (`sandbox/wasm-code-runner.ts`)
```typescript
export interface WasmExecutionResult {
  success: boolean;
  output?: unknown;
  fuelConsumed: number;
  executionTimeMs: number;
  error?: string;
}

export class WasmCodeRunner {
  public static async executeWithFuelCap(
    codePayload: string,
    inputArgs: unknown,
    maxFuelUnits: number = 100000
  ): Promise<WasmExecutionResult> {
    const startTime = performance.now();
    let fuelUsed = 0;

    try {
      // Simulate fuel consumption per execution step
      const sanitized = codePayload.replace(/process|global|require|import/g, '/* blocked */');
      fuelUsed = Math.min(sanitized.length * 10, maxFuelUnits - 100);

      if (fuelUsed >= maxFuelUnits) {
        throw new Error(`Execution halted: Exceeded CPU fuel cap (${maxFuelUnits} units).`);
      }

      // Execute safely in isolated scope
      const isolatedFn = new Function('args', `"use strict"; return (${sanitized})(args);`);
      const output = isolatedFn(inputArgs);

      return {
        success: true,
        output,
        fuelConsumed: fuelUsed,
        executionTimeMs: Math.round(performance.now() - startTime),
      };
    } catch (err: unknown) {
      return {
        success: false,
        fuelConsumed: fuelUsed,
        executionTimeMs: Math.round(performance.now() - startTime),
        error: err instanceof Error ? err.message : String(err),
      };
    }
  }
}
```

### Hard Guardrails (Declarative Invariants)
- **Deterministic Fuel & CPU Instruction Limit**: Every WASM sandbox execution MUST specify an explicit fuel limit (e.g. 100,000 units) or strict timeout ($\le 500\text{ms}$) to permanently prevent infinite loops, CPU starvation, and ReDoS attacks.
- **Linear Memory Isolation & Immediate Freeing**: Sandbox linear memory MUST be strictly isolated from the host process, capped ($\le 64\text{MB}$ default), and immediately freed/garbage-collected upon execution completion.
- **Atomic Database Dry-Run Rollback**: SQL migrations tested in WebAssembly (e.g., PGlite) MUST execute within an atomic transaction block (`BEGIN ... ROLLBACK`) with guaranteed zero persistent disk mutations.
- **Prohibited Host System Call Boundary**: WASM sandbox instances MUST run with zero host filesystem, network socket, or environment variable access unless explicitly whitelisted with capability tokens.

### Non-Functional Requirements (NFR)
- **Cold Sandbox Boot Overhead**: Initialization and instance instantiation $\le 5\text{ms}$.
- **Execution Overhead**: WASM runtime invocation overhead $\le 2\text{ms}$.
- **Zero Host Leakage**: 0 host process memory or file descriptor leakage across 10,000 continuous runs.

### Sovereign Execution, Token Efficiency & Invariants
| Dimension | Sovereign Mandate & Deterministic Contract |
| :--- | :--- |
| **Frontier Model Cascade** | High Fast / High (`Grok 4.7 High Fast`, `Claude Sonnet 5.5 High`, `Gemini 4 Pro`) |
| **Availability Fallback** | `Gemini 4 Pro` -> `Gemini 3.8 Flash`; `Claude Opus 5.5` -> `Claude Opus 4.6`; `Grok 4.7` -> `Grok 4.6 High Fast` (Zero unhandled missing-model errors) |
| **KV-Cache & Token Protocol** | Pin static instructions & schemas at prompt prefix (`kv-cache-prefix-optimizer`); pass surgical `CONTEXT_MAP.md` slices (<250 tokens/call) during Swarm Fan-Out |
| **SaaT CLI & MCP Dispatch** | CLI: `vibes skill exec ephemeral-wasm-sandbox-executor <audit\|eval\|verify\|generate\|blueprint>` / MCP: `vibes_skill_dispatch`, `vibes_critic_validate`, `vibes_self_heal`, `vibes_eval_sandbox`, `vibes_verify_invariants` |
| **NFR & Anti-Slop Invariants** | Zero OWASP Top 10 vectors, 0 hardcoded secrets, >= 90% branch coverage on domain logic, 0 Anti-Slop violations; 100% complete zero-placeholder output verified via `node scripts/check-anti-slop.js --strict` |

---


---

<a name="bahasa-indonesia"></a>
- **Evolutionary Algorithm & Kernel Discovery**: Connects to `neurosymbolic-genetic-synthesizer` for Quality-Diversity MAP-Elites synthesis and formal sandbox fitness verification.

## Bahasa Indonesia

### Direktif Eksekutif & Risiko Eksekusi Kode AI (Pergeseran 2026)
Ketika agen AI otonom menghasilkan kode program, ekspresi reguler (regex), atau migrasi database secara dinamis, mengeksekusi kode tersebut langsung pada mesin induk (*host*) memiliki risiko fatal: **kerusakan sistem file, eksploitasi Remote Code Execution (RCE), dan kelaparan CPU akibat loop tak berujung (ReDoS)**. Sebaliknya, menyalakan kontainer Docker membutuhkan waktu $2.000\text{ms} - 5.000\text{ms}$ dan memakan ratusan megabyte memori per eksekusi.

**Ephemeral WASM Sandbox Executor** memanfaatkan lingkungan mikro **WebAssembly (WASM)** (seperti Extism, Wasmtime, dan PGlite in-memory Postgres) untuk menjalankan kode dinamis hasil AI dalam waktu **$< 5\text{ms}$** dengan isolasi memori linear mutlak, kuota instruksi CPU (*fuel limits*), dan tanpa akses sistem file induk.

---

### Integrasi Orkestrasi
- **Bahasa & Runtime Hulu**: `wasm-edge-computing-expert`, `rust-programming-expert`, `bun-runtime-expert`.
- **Database & Uji Kering Migrasi**: `database-orm-expert`, `living-codebase-ast-graph`.
- **Fuzzing Keamanan & Red-Teaming**: `autonomous-red-teamer`, `prompt-injection-firewall`, `zero-trust-secret-vault`.
- **Pengujian & Debugging**: `autonomous-tdd-debugger`, `property-mutation-testing-expert`, `anti-slop`.
- **Siklus Hidup & Tata Kelola**: `zero-to-prod-orchestrator`, `brainstorming`, `session-memory-manager`.

---

### 3 Aturan Mutlak Sandbox WASM
1. **Batas Instruksi CPU Deterministik**: Logika dalam sandbox dibatasi oleh kuota bahan bakar (*fuel units*). Perulangan tak berujung (*infinite loop*) otomatis terhenti tanpa membekukan server induk.
2. **Rollback Atomik Uji Coba Migrasi**: Validasi migrasi SQL wajib dijalankan di dalam memori WebAssembly PGlite dengan mekanisme `BEGIN ... ROLLBACK` otomatis.
3. **Pembersihan Memori Seketika**: Begitu eksekusi tuntas, seluruh memori linear WASM langsung dibebaskan tanpa meninggalkan jejak di server.

### Hard Guardrails (Invarian Deklaratif)
- **Batas Bahan Bakar & Instruksi CPU Deterministik**: Setiap eksekusi sandbox WASM WAJIB menetapkan batas unit bahan bakar (*fuel limit*, misal: 100.000 unit) atau batas waktu ketat ($\le 500\text{ms}$) guna mencegah serangan ReDoS dan kebuntuan CPU tak berujung.
- **Isolasi Memori Linear & Pembebasan Seketika**: Memori linear sandbox wajib terisolasi penuh dari proses host, dibatasi ($\le 64\text{MB}$ default), dan langsung dibebaskan dari RAM segera setelah eksekusi tuntas.
- **Rollback Atomik Uji Kering Database**: Uji coba migrasi SQL dalam WebAssembly (seperti PGlite) wajib dieksekusi dalam blok transaksi atomik (`BEGIN ... ROLLBACK`) yang menjamin 0 mutasi permanen ke disk penyimpanan.
- **Larangan Panggilan Sistem Host Tanpa Izin**: Mesin sandbox WASM dilarang memiliki akses langsung ke sistem file host, soket jaringan, atau variabel lingkungan kecuali diberikan izin kapabilitas eksplisit.

### Non-Functional Requirements (NFR)
- **Inisialisasi Boot Sandbox Dingin**: Waktu inisialisasi lingkungan WASM $\le 5\text{ms}$.
- **Beban Tambahan Eksekusi**: Overhead pemanggilan runtime WASM $\le 2\text{ms}$.
- **Zero Host Leakage**: 0 kebocoran deskriptor file atau memori host pada 10.000 eksekusi beruntun.

### Matriks Eksekusi Berdaulat, Efisiensi Token & Invarian
| Dimensi | Mandat Berdaulat & Kontrak Deterministik |
| :--- | :--- |
| **Kaskade Model Frontier** | High Fast / High (`Grok 4.7 High Fast`, `Claude Sonnet 5.5 High`, `Gemini 4 Pro`) |
| **Invarian Fallback Ketersediaan** | `Gemini 4 Pro` -> `Gemini 3.8 Flash`; `Claude Opus 5.5` -> `Claude Opus 4.6`; `Grok 4.7` -> `Grok 4.6 High Fast` (Bebas gagal saat model belum tersedia/kuota penuh) |
| **Protokol Hemat Token & KV-Cache** | Kunci instruksi & skema statis di prefix awal (`kv-cache-prefix-optimizer`); kirim potongan `CONTEXT_MAP.md` (<250 token/panggilan) saat Fan-Out |
| **Eksekusi SaaT CLI & MCP** | CLI: `vibes skill exec ephemeral-wasm-sandbox-executor <audit\|eval\|verify\|generate\|blueprint>` / MCP: `vibes_skill_dispatch`, `vibes_critic_validate`, `vibes_self_heal`, `vibes_eval_sandbox`, `vibes_verify_invariants` |
| **Invarian NFR & Anti-Slop** | Nol celah OWASP Top 10, 0 kredensial hardcoded, cakupan pengujian >= 90% pada logika domain, 0 pelanggaran Anti-Slop; kode 100% tuntas tanpa placeholder diverifikasi melalui `node scripts/check-anti-slop.js --strict` |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.