# Where JavaScript your coding agent writes should run: not node:vm, not your laptop, but the agent's own machine

> Claude Code, Codex and Cursor write and run JavaScript all day. What node:vm and Node's permission model do and do not protect, according to Node's own docs, and how to send that code to a microVM per agent from the agent's MCP settings.

Claude Code, Codex and Cursor write and run JavaScript all day. What node:vm and Node's permission model do and do not protect, according to Node's own docs, and how to send that code to a microVM per agent from the agent's MCP settings.

November 30, 2026 · 5 min read · The Sandscale team

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](https://nodejs.org/api/vm.html) 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](https://nodejs.org/api/permissions.html) 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](https://sandscale.dev/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](https://sandscale.dev/docs/quickstart) and each tool’s own MCP docs:

**Cursor**, in `~/.cursor/mcp.json` ([Cursor MCP docs](https://cursor.com/docs/mcp)):

```json
{ "mcpServers": { "sandscale": { "url": "https://mcp.sandscale.dev/mcp" } } }
```

**Codex**, in `~/.codex/config.toml`, then `codex mcp login sandscale` ([Codex MCP docs](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)):

```toml
[mcp_servers.sandscale]
url = "https://mcp.sandscale.dev/mcp"
```

**Claude Code** uses the local server that comes with the Sandscale CLI (macOS and Linux):

```sh
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:node` template, not on this machine. Terminate the sandbox when you are done.

We wrote up a [Cursor project rule along these lines](https://sandscale.dev/blog/cursor-rule-run-tests-in-a-sandbox) 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](https://sandscale.dev/docs/guides/connect-claude-chatgpt). 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](https://sandscale.dev/docs/quickstart) and in the `--help` of the Sandscale CLI (version 1.4.1):

```sh
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:

```sh
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](https://sandscale.dev/docs/concepts/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](https://sandscale.dev/docs/quickstart) connects your agent on the Free plan.

**On this page**

1. What Node itself says about running untrusted code
2. Why the laptop is the wrong default
3. Send it to the agent’s own machine, from its MCP settings
4. Layering Node’s own controls inside the box
5. What this does not cover

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 30, 2026 · **MCP servers your team's agents install: run them on the agent's own machine, not the laptop with everyone's keys** · A local MCP server runs with the same rights as the client that starts it. What the MCP spec's security guidance says about that, and how to put the coding agent and its MCP servers on a microVM of their own, with no code to write.](https://sandscale.dev/blog/running-untrusted-mcp-servers-in-a-microvm)
- [November 30, 2026 · **MCP tool annotations explained: what readOnlyHint and destructiveHint mean for teams approving agent tool calls** · What each MCP tool annotation means according to the spec, what Claude Code, Codex and Cursor do with them according to their docs, and how a team using coding agents can decide what to auto-approve and what a person must see.](https://sandscale.dev/blog/mcp-tool-annotations-explained)

---
Source: https://sandscale.dev/blog/sandboxing-agent-generated-javascript
