Blast-radius control 02 of 05
Agents that execute code run in ephemeral, network-restricted, filesystem-restricted containers. No ambient credentials. No egress except what you explicitly allowlist. This applies especially to MCP servers: every server you install gets the same trust surface as the calling agent. Run them in a jail so the worst-case outcome is a corrupted scratchpad, not a compromised host.
// MCP server running with host-level trust. Don't do this.
const mcp = spawnMCPServer('npx @acme/filesystem-mcp')
// That package now has your ~/.aws, your ~/.ssh, your env vars.
// Sandbox it instead.
const server = await Sandbox.create('acme/filesystem-mcp', {
network: 'none', // no egress
readonlyRootfs: true, // no writes outside mounts
user: 'nobody', // no ambient uid privileges
mounts: [
// Only the workspace. Nothing else is visible.
{ host: workspaceDir, container: '/workspace', readonly: false },
],
// Scoped credentials only. No inherited host environment.
env: { WORKSPACE_TOKEN: scopedToken },
})
const mcp = connectMCP(server.socketPath())
If the worst it can do is corrupt its own scratchpad, you've won.