April 02, 20266 min readBy Lalit Mukesh

SecurityAI AgentsWASMNode.js

Autonomous AI agents are capable of performing complex multi-step tasks. However, giving an LLM-driven agent the ability to execute terminal commands or write files directly onto a host system is a massive security risk. A single prompt injection or agent hallucination can result in accidental data loss or server compromise.

The Agentic Shield Framework

To solve this, we developed Agentic Shield, a security framework that intercepts all system calls made by autonomous agents. The agent runs inside a sandboxed environment compiled to WebAssembly (WASM), isolating file operations and process execution from the host machine.

Interacting via WASI

By using the WebAssembly System Interface (WASI), we can restrict the directories the agent can read and write to, and completely block network requests unless they are explicitly whitelisted. Here is how we initialize the sandboxed Node runner:

typescript
import { WASI } from 'wasi';
import fs from 'fs';

const wasi = new WASI({
  args: [],
  env: {},
  preopens: {
    '/sandbox': './safe_workspace'
  }
});

// Load and run the agent script inside WASM
const wasmBuffer = fs.readFileSync('agent_runner.wasm');
const wasmModule = await WebAssembly.compile(wasmBuffer);
const instance = await WebAssembly.instantiate(wasmModule, {
  wasi_snapshot_preview1: wasi.wasiImport
});

wasi.start(instance);

Deterministic Guardrails

While LLMs are probabilistic, safety must be deterministic. Agentic Shield enforces strict rule-based policies prior to execution:

  • Regex-based command blocklists (e.g., blocking rm -rf outside the target build directory).
  • Access Token and Environment Variable masking to prevent secrets leakage.
  • Strict CPU and Memory limits to prevent infinite loops.

Security should never be an afterthought. By running agents inside strict, WASM-driven sandboxes with deterministic checks, we can leverage the power of automation without risking system integrity.