# Local sandbox

URL: https://codepanel.ai/docs/local-sandbox

How CodePanel isolates local coding agent commands with macOS sandbox-exec and Linux bwrap, offline autopilot installs, and git ref protection.

Every shell command, repository check, stdio MCP server, and external coding CLI that CodePanel's local runner starts runs inside the operating system sandbox (`sandbox-exec` on macOS, `bwrap` on Linux). The sandbox confines writes to the run's git worktree, blocks credential reads, and closes the network by default for rule-started autopilot runs.

## What the sandbox allows and denies

| Path or capability | Inside a run | Why |
| --- | --- | --- |
| Run's git worktree, isolated `HOME`, and temp dir | Read and write | The agent edits files and runs tests in its own branch without touching your checkout. |
| Shared `.git/worktrees/<run>/`, `.git/objects/`, and the run's own branch ref | Read and write | Lets `git commit` succeed while blocking `git update-ref refs/heads/main` and sibling branches. |
| `~/.ssh`, cloud and `gh` credentials, `~/.codepanel`, keychains, sibling worktrees | Denied | Prevents credential exfiltration and cross-run tampering. |
| Network on owner-started runs | Allowed by default | Lets package installs and toolchains fetch what a manual task needs. |
| Network on autopilot rule-started runs | Denied by default | Untrusted trigger text (such as an issue title) cannot exfiltrate data; installs run offline from your local package cache. |

## Startup proof and fail-closed default

When the local runner starts, it runs a sandbox proof (23 to 32 ms on macOS) confirming that a sandboxed command can run and is refused a read outside the worktree. If no working sandbox is available (Windows, or Linux without bubblewrap), the runner refuses every command, and the refusal names the fix, unless you explicitly opt out: **Settings → Runners & worktrees → Sandbox → Run without a sandbox** in the desktop app, or `"sandbox": { "unsandboxed": true }` in `~/.codepanel/runner/config.json` for a runner you started yourself.

## Network policy and offline installs

Rule-started runs have no network at all, including during dependency installation, unless you allow it for that repository under **Settings → Runners → Network for rule-started runs** (`"ruleNetwork": true` on the checkout in `config.json`).

- For Bun repositories, dependencies install offline from your global store in read-only mode.
- If an offline install cannot finish (for example, a package is missing from the local cache or pnpm needs to write its store), the run pauses in your Inbox as **Needs network**, explaining how to allow network access or start the task manually.
- You can close network access for specific run modes in `config.json` with `"sandbox": { "denyNetwork": ["rule"] }`.

## Credential warnings in `.git/config`

Git needs to read your checkout's `.git/config`, so sandboxed commands can read it too. If `.git/config` contains a token in a remote URL, a `url.<base>.insteadOf` rule, an inline credential helper secret, or an `http.extraheader`, Settings and the run log warn you where it sits without printing the value.

See [Desktop app](/docs/desktop-app) for setup, [Autopilot rules](/docs/autopilot) for rule-started runs, and [Security](/security) for the full defense-in-depth model.
