Agent documentation index: llms.txt. Markdown versions are available for docs pages.
Download

Sandboxing

You can restrict what operations the Zed Agent can run in multiple ways. One way to restrict them is Tool Permissions, but these are of limited use when the agent wants to do things like run a complicated script in a terminal.

Sandboxing instead uses OS features to forcibly restrict which resources a tool call has access to. This does not rely on an agent following a particular set of instructions. If the agent attempts to access a resource that is restricted by the sandbox, the OS will block it. See How much can I trust the sandbox? for more details.

Tool Permissions can be used in addition to sandboxing:

  • Tool permissions restrict the agent’s ability to run certain tool actions in the first place
  • Once a tool action is actually running, sandboxing restricts what it can do

Sandboxing applies only to Zed Agent. It does not sandbox Zed itself, language servers, extensions, tasks, your normal terminal tabs, External Agents, or Terminal Threads.

Sandboxed Tools

Zed Agent sandboxing currently applies to the terminal and fetch tools.

ToolWhat sandboxing limits
terminalFilesystem writes and outbound network access for commands the agent runs; Git metadata is protected.
fetchHosts which can be accessed.

Tools are still governed by Tool Permissions, Agent Profiles, and project trust, but they are not currently run inside this OS sandbox.

Requirements

Sandboxing is supported, in some form, on all platforms. In order to sandbox a terminal tool call, the following is required:

  • On Linux, a runnable, non-setuid bwrap binary must be on the $PATH. See Installing Bubblewrap.
  • On Windows, Windows 11 with Process Security Environment support: version 24H2, 25H2, or 26H1 with the August 2026 update or later, or 26H2 with the September 2026 update or later. See Windows.

There are no extra requirements on MacOS.

The fetch tool has no extra requirements on any platform.

Default Access

By default, sandboxed Zed Agent tool actions have these restrictions:

Access typeDefault behavior
Filesystem readsTerminal commands can read most of the filesystem, including protected Git metadata.
Project writesTerminal commands can write inside open project directories, except for protected Git metadata.
Git metadata.git directories and linked worktree Git metadata remain readable but are not writable while sandboxed.
Temporary filesTerminal commands receive a writable temporary location. The exact behavior differs by platform.
Other writesWrites outside the default writable locations are blocked unless you approve a broader sandbox request.
Outbound networkingNetwork access is blocked unless you approve a host-specific or unrestricted network sandbox request.
Local IPC socketsSandboxed commands cannot open Unix-domain sockets (for example, to the desktop session bus or a container daemon), which could otherwise be used to run commands outside the sandbox.

How much can I trust the sandbox?

Enabling sandboxing dramatically reduces the risk of various kinds of attacks. However, it does not fully eliminate them.

Firstly, sandboxing relies on OS-level features, which may contain bugs. Operating systems have historically had bugs in security features. And while we have tested thoroughly, there may also be bugs in Zed’s implementation. These could allow privilege escalation - for example, allow an agent to write to a file that it should only have read access to.

Sandboxing also only applies the restrictions that the user requested. If an agent requests write access to your home directory, sandboxing will not (and should not!) do anything to prevent an agent adding a malicious key to $HOME/.ssh.

Be careful with what you grant the agent. At any point in time, you can view the state of the sandbox by hovering the padlock icon in the top right of the thread. If an agent is requesting an overly broad permission, deny it, and ask it to use a smaller grant. When requesting elevated privileges, agents must provide a reason, which is displayed in the prompt. Read it, and decide whether it makes sense before approving.

Also, sandboxing restricts only what the terminal and fetch tools in the Zed agent can do. It has no effect on other parts of Zed, including:

  • Language servers
  • The built-in git client
  • The regular terminal
  • And more…

Even when sandboxing is enabled, you should remain vigilant. A malicious or unaligned agent may use these side channels to escalate privileges. For example:

  • An agent may add a malicious Rust procedural macro to your codebase, which will be automatically executed by rust-analyzer outside the sandbox.
  • An agent may modify a Makefile to inject a malicious script, which is executed outside the sandbox when you next run make in the built-in terminal.
  • The agent cannot write to your repository’s protected .git directory, but it can create a submodule under your project whose Git metadata (including config such as core.fsmonitor) it fully controls. That metadata may then be executed outside the sandbox when you subsequently run Git commands in a regular terminal. Your shell prompt may even execute Git commands every time it renders!

There are steps you can take to mitigate these issues. For example:

  • disable language servers that execute user-defined code from the project (such as Rust procedural macros).
  • use a shell prompt that reports Git status without executing repository-defined programs.
  • review the diff before running git commit

But none of this changes the fundamental principle: a sandbox is not a substitute for good security practices. It is one layer in a defense-in-depth strategy.

Zed’s default profile aims to strike a balance between security and convenience, but we encourage you to tune your settings based on your own security requirements and risk profile. A disabled sandbox is not a very effective sandbox.

Approval Prompts

When the agent needs access outside the default sandbox, Zed shows a sandbox approval prompt before the tool action runs. Depending on what the tool requested, the prompt can ask you to allow:

  • network access to specific hosts, such as github.com or *.npmjs.org
  • network access to any host
  • write access to specific filesystem paths
  • unrestricted filesystem writes, except protected Git metadata
  • running a terminal command without the sandbox

You can grant a sandbox request for:

  • one tool action
  • the rest of the current thread
  • always

Approvals for the rest of the thread are remembered only for that thread. Approvals granted with “always” are saved in settings.json under agent.sandbox_permissions.

Persistent Sandbox Permissions

If you want to pre-approve common sandbox requests, add persistent permissions to your settings file:

{
  "agent": {
    "sandbox_permissions": {
      "network_hosts": ["github.com", "*.npmjs.org"],
      "write_paths": ["/Users/you/.cache/my-tool"]
    }
  }
}

The available options are:

SettingDescription
network_hostsHosts that sandboxed tools may reach without prompting. Entries can be exact hostnames or leading-*. wildcards.
allow_all_hostsAllow sandboxed tools to reach any host without prompting.
write_pathsDirectory subtrees that sandboxed terminal commands may write to without prompting. Paths are absolute.
allow_fs_write_allAllow sandboxed terminal commands to write anywhere except protected Git metadata without prompting.
allow_unsandboxedTurn sandboxing off entirely for Zed Agent terminal commands. The fetch tool will have no restrictions.

Prefer narrow grants, such as a specific host or write path, over allow_all_hosts, allow_fs_write_all, or allow_unsandboxed.

Git Metadata

Git metadata writes are not grantable while a terminal command is sandboxed. This includes writes to .git directories, linked worktree metadata, refs, the index, hooks, local Git config, and other Git-controlled metadata files. Approving a specific writable path or allow_fs_write_all does not make Git metadata writable.

Platform Support

Sandboxing uses different operating system mechanisms on each platform. The user-facing prompts are similar, but the enforcement details vary.

macOS

On macOS, Zed uses Apple’s Seatbelt sandbox through sandbox-exec.

Sandboxed terminal commands:

  • can read the filesystem
  • can write inside open project directories, except protected Git metadata
  • can write to a per-thread temporary directory exposed through $TMPDIR, $TMP, and $TEMP
  • can read protected Git metadata
  • cannot write protected Git metadata, even if you approve broader write access
  • cannot write elsewhere unless you approve additional paths or broader write access
  • cannot reach the network unless you approve network access
  • can reach only an allowlist of macOS system (Mach) services that developer tooling needs; services that could be abused to escape the sandbox (LaunchServices and launchd, which can launch processes outside it), read the clipboard (the pasteboard), or capture audio are not reachable

When network access is approved on macOS, Zed uses an HTTP/HTTPS proxy so access can be limited to approved hosts. Tools that do not honor proxy environment variables, such as SSH, FTP, and raw socket clients, may not work even after host-specific network access is approved. For networked terminal commands, prefer HTTPS URLs over SSH URLs when possible.

Linux

On Linux, Zed uses Bubblewrap (bwrap) for sandboxing.

Zed only uses a non-setuid bwrap binary. Its sandbox is built entirely on unprivileged user namespaces, so a setuid-root bwrap provides no extra functionality, and running one would mean executing root-privileged setup with arguments partly derived from model-influenced input. If the only bwrap found on your PATH is setuid-root, Zed refuses to run it; install a non-setuid Bubblewrap to enable sandboxing.

Sandboxed terminal commands:

  • can read the filesystem, including protected Git metadata contents
  • can write inside open project directories, except protected Git metadata
  • can write to /tmp, which is backed by a fresh temporary filesystem and is cleared between terminal tool calls (when you approve unrestricted filesystem writes, /tmp is instead your real host /tmp rather than a fresh temporary filesystem)
  • cannot write protected Git metadata
  • cannot write elsewhere unless you approve additional paths or broader write access
  • cannot reach the network unless you approve network access

When host-specific network access is approved on Linux, Zed uses an HTTP/HTTPS proxy so access can be limited to approved hosts. Tools that do not honor proxy environment variables, such as SSH, FTP, and raw socket clients, may not work even after host-specific network access is approved.

If Bubblewrap is unavailable or cannot create a sandbox in the current environment, Zed may run the command without the OS sandbox and show a warning in the tool output.

Warning: On Linux and Windows, restrictions on filesystem objects are determined at sandbox creation time. Among other things, this means that an agent given access to a non-Git-repo directory /foo could create /foo/.git. See How much can I trust the sandbox? for more information on the implications of this.

Installing Bubblewrap

Zed needs a runnable, non-setuid bwrap binary on your $PATH. Installing bubblewrap from your distribution’s package manager is usually all you need.

You can test whether it’s working with:

bwrap --ro-bind / / -- echo "working"

“Non-setuid” here refers to the setuid bit. Historically, bubblewrap has shipped both a setuid and non-setuid binary. The setuid binary is being phased out for security concerns, and so Zed’s sandbox explicitly rejects setuid bwrap binaries.

Ubuntu-specific requirements

Bubblewrap relies on a Linux kernel feature known as “namespaces”. Unprivileged users on many systems can create namespaces, but historically, this feature has been used for a variety of attacks.

In response to this, in Ubuntu 23.10, Canonical added a security measure that restricts unprivileged user namespaces. These restrictions are enforced by AppArmor.

Because of this, you may also need to install an AppArmor profile for bubblewrap after you install it. This is a configuration file that gives bubblewrap the ability to create namespaces without needing sudo.

sudo apt install bubblewrap

# On Ubuntu 25.04 and later, `apparmor` ships with a profile for bubblewrap by default.
# Make sure you're up-to-date
sudo apt install --only-upgrade apparmor

# On older versions, manually install the profile
sudo apt update
sudo apt install apparmor-profiles apparmor-utils
sudo install -m 0644 \
  /usr/share/apparmor/extra-profiles/bwrap-userns-restrict \
  /etc/apparmor.d/bwrap-userns-restrict
sudo apparmor_parser -r /etc/apparmor.d/bwrap-userns-restrict

Windows

On Windows, Zed runs sandboxed terminal commands in a Windows AppContainer. Windows 10 isn’t supported; see Requirements. If the sandbox can’t be created, Zed asks whether to run the command without it.

Sandboxed terminal commands:

  • run in PowerShell rather than Git Bash, and so do commands you approve to run unsandboxed
  • can read the filesystem on local drives
  • can write inside open project directories, except protected Git metadata
  • can write to a per-command temporary directory exposed through %TEMP% and %TMP%, which is removed when the command finishes
  • can read protected Git metadata
  • cannot write protected Git metadata, even if you approve broader write access
  • cannot write elsewhere unless you approve additional paths or broader write access
  • cannot reach the network unless you approve network access

When host-specific network access is approved on Windows, Zed uses an HTTP/HTTPS proxy so access can be limited to approved hosts. The proxy is set through the proxy environment variables and as the command’s WinHTTP proxy. Tools that honor neither may need the proxy configured explicitly.

Some programs aren’t yet compatible with AppContainer and have to run without the sandbox.

Choosing What to Approve

When reviewing a sandbox prompt, prefer the narrowest permission that lets the task proceed:

  • approve a specific host instead of all hosts when the destination is known
  • approve a specific write path instead of unrestricted filesystem writes
  • approve unsandboxed execution only when the command cannot work inside the sandbox
  • use one-time approvals for unfamiliar commands
  • use thread or always approvals only for access you expect to reuse

If a command fails because the sandbox blocked access, ask the agent why it needs that access before approving a broader request.