Recipes · Chapter 47 of 69
Turn On the Command Sandbox
Run Kiro's agent shell commands inside an operating-system sandbox: sandbox.json, the three network modes, allowing hosts with sandbox_network rules, and setup on macOS, Linux, and Windows.
Advanced 4 min read last reviewed 2026-10-21
◎ Learning objective
Turn on Kiro's local command sandbox in the IDE or CLI, choose a network mode, allow the hosts your builds need, and confirm it is active.
Permission rules decide whether Kiro may run a command. The command sandbox limits what that command can reach once it is running. Kiro added it to the IDE (1.3) and the CLI (2.31.0) on 13 October 2026.
When to use this
Turn it on before you let an agent run shell commands without watching each one: Autopilot, the CLI’s /autonomous on, a headless CI job, or any repository you did not write. On a personal project where you approve every command it adds little.
Know what it covers before you rely on it:
| Inside the sandbox | Outside the sandbox |
|---|---|
| Terminal commands the agent runs, and every child process | The agent harness and its conversation with the model |
Local stdio MCP servers, if you turn on mcpSandboxing | Built-in file tools (permission rules still govern them) |
| Remote HTTP and SSE MCP servers |
It applies only to sessions on your machine. Cloud sessions already run in a managed cloud sandbox.
Steps
-
Check your platform. macOS needs nothing; Kiro uses the built-in Seatbelt sandbox. Linux needs Bubblewrap (
bwrap) on yourPATH, plussocatif you will useCOMMON_DEPENDENCIESor allow specific hosts; Kiro does not install them. Windows needs a one-time administrator setup: the IDE prompts for it, and in the CLI you run/sandbox setup(use CLI 2.31.1 or later if policy blocks programs in%TEMP%). -
Open the configuration. IDE: select Command sandbox in the status bar; Kiro opens the project file if one exists, otherwise your global file, creating
{"enabled": false}if neither does. CLI: run/sandboxin a local V3 session. -
Turn it on and pick a network mode.
Example:
~/.kiro/settings/sandbox.json{ "enabled": true, "networkAccess": "COMMON_DEPENDENCIES" }networkAccessOutbound network from sandboxed commands DEFAULT_BLOCKEDBlocked, except hosts you allow. The default COMMON_DEPENDENCIESCommon package, source, build, and container services; everything else blocked DEFAULT_ALLOWEDOpen. sandbox_networkdeny rules are not reliable hereThe values are case-sensitive and unknown keys are ignored.
-
Allow the extra hosts your build needs with
sandbox_networkrules in permissions.yaml. Unlike other capabilities, the first matching rule wins, so list specific hosts before broader*.suffixwildcards.capability: alldoes not includesandbox_network.# ~/.kiro/settings/permissions.yaml rules: - capability: sandbox_network match: ['packages.internal.example.com'] effect: allow -
Decide on MCP. Set
"mcpSandboxing": trueto start local stdio MCP servers inside the same sandbox. Changing it restarts local MCP servers, which can take about a minute. -
Decide the scope. A global policy applies everywhere. A project file can turn the sandbox on for one repository, or tighten an active global policy, but cannot disable it, open the network further, or turn off global MCP wrapping. A cloned repository therefore cannot loosen your settings.
-
For unattended CLI work, use
/autonomous onin a local V3 session. Kiro switches to the Default agent, turns the sandbox on, and stops asking you to approve each shell command. For V3 headless runs (2.31.0 and later), a savedsandbox.jsonwithenabled: trueapplies automatically; add--sandboxwhen the run must stop rather than continue without protection.
Check it worked
In the IDE the status bar reads Active (it shows Applying while a change loads, Error if the change failed and the old settings stayed, and Unavailable if the platform backend is missing). Then ask the agent to fetch a URL with curl from a host you have not allowed. Under DEFAULT_BLOCKED the command should fail to connect; add an allow rule and it should succeed.
Common problems
- Status says Unavailable. The backend is missing:
bwrapon Linux, or the Windows administrator setup. Until you fix it, commands run without operating-system isolation. Reload the IDE window or start a new CLI session afterwards. - A build cannot download dependencies. Switch to
COMMON_DEPENDENCIES, or add asandbox_networkallow rule for the host. - Windows refuses
COMMON_DEPENDENCIESorDEFAULT_ALLOWED. Complete the one-time setup.DEFAULT_BLOCKEDworks before it. - The agent still edited a file you wanted protected. Built-in file tools are outside the sandbox. Use deny rules in permissions.yaml and .kiroignore for files.
- An MCP server is not covered. Wrapping failed for that server; command sandboxing is still active. Check the server’s command and MCP logs.
Related
- Set up permissions.yaml decides what the agent may do at all.
- Run Kiro CLI headless in CI is where an unattended sandbox matters most.
- Keep secrets out with .kiroignore covers files, which the sandbox does not.
Frequently asked questions
What does the Kiro command sandbox do?
It runs the shell commands Kiro's agent starts, and every child process they start, inside an operating-system sandbox that limits what they can reach, including outbound network access. You can also run local stdio MCP servers inside it. The agent harness, built-in file tools, and remote HTTP or SSE MCP servers stay outside. It arrived in Kiro IDE 1.3 and Kiro CLI 2.31.0 on 13 October 2026.
Where is the Kiro sandbox.json file?
The global file is ~/.kiro/settings/sandbox.json (in Kiro CLI it moves under KIRO_HOME when that is set). A project file at <workspace-root>/.kiro/settings/sandbox.json can turn the sandbox on for one repository or tighten an active global policy, but it can never loosen one.
Does the Kiro sandbox block network access?
By default, yes. networkAccess defaults to DEFAULT_BLOCKED, which blocks outbound traffic except hosts you allow with a sandbox_network permission rule. COMMON_DEPENDENCIES opens common package, source, build, and container services. DEFAULT_ALLOWED opens everything.
Is Kiro's sandbox enough to make autonomous runs safe?
No. Kiro's documentation says the sandbox reduces what a command can do but is not a guarantee of isolation. Keep reviewing proposed commands, keep deny rules for operations that must never run, and keep secrets out of reach with .kiroignore.
☰ Chapter summary
- The local command sandbox (IDE 1.3, CLI 2.31.0, October 2026) runs agent shell commands and their child processes inside an operating-system sandbox.
- The agent itself, built-in file tools, and remote MCP servers stay outside it; permission rules still apply, and it is not complete isolation.
- Configure it in sandbox.json: ~/.kiro/settings/sandbox.json globally, .kiro/settings/sandbox.json per project. A project can only tighten an active global policy.
- networkAccess is DEFAULT_BLOCKED (the default), COMMON_DEPENDENCIES, or DEFAULT_ALLOWED; sandbox_network permission rules allow or deny specific hosts.
- macOS needs nothing; Linux needs bwrap (and socat for filtered network); Windows needs a one-time administrator setup.
- CLI /autonomous on turns the sandbox on and stops asking you to approve each shell command in a local V3 session.
All chapter summaries are collected on the revision page.
Related chapters
- RecipesSet Up permissions.yamlControl what Kiro's agent may do with permissions.yaml: the capability list, the deny over ask over allow order, match and exclude globs, and the six scopes.
- RecipesRun Kiro CLI Headless in CIRun kiro-cli chat --no-interactive in a pipeline: authenticate with KIRO_API_KEY, trust the smallest tool set, and fail fast when MCP servers are missing.
- RecipesKeep Secrets Out With .kiroignoreWrite a .kiroignore file so Kiro's agent never reads .env, keys, or customer data, and know which surfaces honour it today.
- ConceptsAgentic DevelopmentAgentic development means the AI plans and performs multi-step work. How Kiro's agent loop, autonomy modes, permissions, and checkpoints work.
- Hands-onKiro CLI GuideInstall kiro-cli, drive sessions with slash commands, manage agents and context, and take the agent into scripts and CI.