If your team uses Claude Code, Codex or Cursor, a lot of the JavaScript that runs on your machines was just written by an agent: a script to migrate some JSON, a quick reproduction of a bug, a test file, a postinstall hook in a package it just added. The agent writes it and then runs it with node, usually on the developer’s laptop, with the developer’s files and credentials in reach.
This post covers where that code should run. In short: not inside your own Node process, not behind a flag that was never meant to stop hostile code, and not on the laptop. It should run on a machine that belongs to that agent.
What Node itself says about running untrusted code
Two features look like sandboxes and are often used as one. Node’s documentation is direct about both.
node:vm. The vm module docs open with a warning: “The node:vm module is not a security mechanism. Do not use it to run untrusted code.” A vm context separates globals. It is not a boundary between the code and your process, your files or your network.
The permission model. Node’s permission model is enabled with --permission. You then grant access with flags such as --allow-fs-read=/some/folder, --allow-fs-write, --allow-net, --allow-child-process and --allow-worker. The docs describe it as a “seat belt” that “prevents trusted code from unintentionally changing files or using resources”. They also say: “It does not provide security guarantees in the presence of malicious code.”
Both are useful for what they are. Neither one is the place to run code that nobody on the team has read.
Why the laptop is the wrong default
An agent on a laptop runs node script.js as the developer. That script can read ~/.ssh, cloud CLI credentials, .env files from other projects and anything else that user can read. If it opens a network connection, it does so from inside your network. A postinstall script in a package the agent added runs with the same rights, before anyone has looked at it. The agents’ own permission prompts help, but they ask about the command, node script.js, not about what the script does.
A container narrows this, but it shares the host’s kernel. A microVM boots its own kernel, so the code your agent wrote runs on a different kernel from the machine that started it.
Send it to the agent’s own machine, from its MCP settings
Sandscale sandboxes are Firecracker microVMs, one per run, each booting its own kernel, with the network access your plan allows. Your agent can start and use them through MCP, so nobody on the team has to write a harness.
Connect the agent once. These forms are from the Sandscale Quickstart and each tool’s own MCP docs:
Cursor, in ~/.cursor/mcp.json (Cursor MCP docs):
{ "mcpServers": { "sandscale": { "url": "https://mcp.sandscale.dev/mcp" } } }
Codex, in ~/.codex/config.toml, then codex mcp login sandscale (Codex MCP docs):
[mcp_servers.sandscale]
url = "https://mcp.sandscale.dev/mcp"
Claude Code uses the local server that comes with the Sandscale CLI (macOS and Linux):
sandscale login
claude mcp add sandscale -- sandscale mcp
Then tell the agent where its JavaScript goes. One line in the project’s instructions is enough: CLAUDE.md for Claude Code, AGENTS.md for Codex, or a project rule for Cursor. For example:
Run any JavaScript you write in a Sandscale sandbox using the
builtin:nodetemplate, not on this machine. Terminate the sandbox when you are done.
We wrote up a Cursor project rule along these lines for tests.
With the remote server, the agent starts a box with sandbox_create, writes the script in with sandbox_upload_file, runs it with sandbox_run, which returns the exit code, standard output and standard error, and ends it with sandbox_stop. The full list is in the remote tool reference. The local server that Claude Code uses, sandscale mcp, offers the API commands as tools, among them sandbox_create, sandbox_file_write, sandbox_exec and sandbox_terminate. A new sandbox’s network is none unless your plan and policy allow another mode and you ask for it.
Tools that change something can go through your coding tool’s approval prompt. That prompt is now asking a better question: whether to run this code in a throwaway microVM, not whether to run it on your laptop.
If you want to do the same thing yourself from a terminal, these are the forms in the Quickstart and in the --help of the Sandscale CLI (version 1.4.1):
sandscale sandbox create --template-id builtin:node --network none
sandscale sandbox file-write --id SANDBOX_ID --path /workspace/script.js --content @script.js
sandscale sandbox run SANDBOX_ID -- node script.js
sandscale sandbox terminate --id SANDBOX_ID
create answers with the sandbox’s id. run prints standard output and standard error, then the exit code, and works in /workspace unless you pass --workdir. Each command that changes something asks first; --yes skips the question in scripts.
Layering Node’s own controls inside the box
The microVM is the boundary. Inside it, Node’s permission model still has a use: it catches honest mistakes before they waste a run. If the script should only read its input folder, say so:
node --permission --allow-fs-read=/workspace script.js
Check that the Node version in your template supports the flags you use, against the Node docs for that version. And keep the order of trust straight: the flag is a seat belt for code you expect to behave. The microVM is for code you have not read.
What this does not cover
- Network. Network access follows your plan and your organization’s policy. A script that needs to install packages needs a network setting that allows it. A script that should not talk to anything should run in a sandbox with network
none, which is the default. - Secrets you hand over. Any process in the box can read a secret you give it. Give runs narrow, short-lived credentials from Vault, never your own tokens.
- Review. Running the code somewhere safe does not make it correct. The agent’s diff still needs a person.
E2B and similar companies sell sandboxes to developers building AI products. Sandscale is for teams using coding agents: every agent gets its own machine, so the team gets more done. The Quickstart connects your agent on the Free plan.