Visitar URL original
[2026-10-07] Local Sandboxes in Copilot CLI, App, and VSCode [GA] (#6… · github/docs@03b432e · GitHub
Skip to content

Commit 03b432e

Browse files
hubwriterCopilotCopilotCopilot
authored
[2026-10-07] Local Sandboxes in Copilot CLI, App, and VSCode [GA] (#63554)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Copilot-Session: 780b4f08-fb48-49b0-9c02-580adc1b160b
1 parent 2c5e31e commit 03b432e

20 files changed

Lines changed: 469 additions & 278 deletions

File tree

‎content/billing/concepts/product-billing/cloud-and-local-sandboxes.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ category:
1111
---
1212

1313
> [!NOTE]
14-
> {% data reusables.cli.public-preview-sandbox %}
14+
> {% data reusables.cli.public-preview-cloud-sandbox %}
1515
1616
## How sandbox usage is measured
1717

‎content/copilot/concepts/agents/copilot-cli/understanding-local-sandboxing.md‎

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,23 @@ docsTeamMetrics:
1313
- copilot-cli
1414
---
1515

16-
> [!NOTE]
17-
> {% data reusables.cli.public-preview-local-sandbox %}
18-
19-
{% data reusables.cli.sandbox-on-windows %}
20-
2116
## Introduction
2217

2318
When you enable local sandboxing, {% data variables.copilot.copilot_cli_short %} runs the commands it invokes on your behalf inside an operating-system sandbox. The sandbox enforces a **filesystem policy**: a set of rules that decide which paths a sandboxed process or operation can read, which it can write, and which it cannot touch at all.
2419

2520
Most of this policy is assembled automatically, so that everyday commands keep working without setup. This article explains how {% data variables.product.prodname_copilot_short %} arrives at the policy, and how to check the access it grants in a particular directory.
2621

27-
For an overview of local sandboxing, including how to turn it on and off, see [AUTOTITLE](/copilot/concepts/about-cloud-and-local-sandboxes) and [AUTOTITLE](/copilot/how-tos/cloud-and-local-sandboxes/using-local-sandboxing).
22+
For an overview of local sandboxing, including how to turn it on and off, see [AUTOTITLE](/copilot/concepts/about-cloud-and-local-sandboxes) and [AUTOTITLE](/copilot/how-tos/cloud-and-local-sandboxes/using-local-sandboxing). For details of how to configure local sandboxing, see [AUTOTITLE](/copilot/how-tos/cloud-and-local-sandboxes/configuring-local-sandbox-settings).
2823

2924
## What the policy applies to
3025

3126
The filesystem policy covers the work {% data variables.product.prodname_copilot_short %} does on your behalf, but it is enforced in different ways depending on the kind of work:
3227

3328
* **Shell commands and built-in searches** run as sandboxed child processes, so the operating system enforces the policy directly. The `grep` and `glob` tools, for example, run ripgrep as a sandboxed child process.
34-
* **Local MCP and language server processes (LSP)** can also run inside the sandbox, so the operating system enforces the policy on them too.
29+
* **Local MCP and language server processes (LSP)** run inside the sandbox by default, so the operating system enforces the policy on them too. You can change this in the sandbox settings unless a managed policy requires it.
3530
* **Built-in file-reading and file-editing tools** run as part of {% data variables.copilot.copilot_cli_short %} itself rather than as a sandboxed child process. They check the same filesystem policy before reading or writing a file, but because the operating-system sandbox never sees these operations, the check is a software-only safeguard rather than one the operating system enforces.
36-
* **Remote MCP servers** run outside your machine, so there is no local child process to sandbox and the filesystem policy does not constrain them.
37-
* **Subagents** do not act directly; they orchestrate other tools. Whether the policy applies, and how, depends on the tool a subagent invokes.
31+
* **Remote MCP servers** run outside your machine, so there is no local child process to sandbox and the filesystem policy does not constrain them. Their connections from the CLI can still be restricted by the network policy when **Sandbox MCP servers** is enabled.
32+
* **Subagents** use other tools to do their work. Whether the policy applies, and how, depends on the tool a subagent invokes.
3833

3934
A sandboxed **process** is therefore constrained by the operating system, while an in-process **operation** enforces the same policy in software—which is why this article refers to a sandboxed process or operation rather than only to commands.
4035

@@ -53,7 +48,7 @@ Because access is denied unless granted, {% data variables.product.prodname_copi
5348
5449
## How the policy is built
5550

56-
Before each sandboxed process starts, {% data variables.copilot.copilot_cli_short %} resolves the effective policy for that process using the current working directory, environment, settings, and automatic grants. This restricts the process to only the access that it needs, and means you don't have to manage these common locations yourself.
51+
Before each sandboxed process starts, {% data variables.copilot.copilot_cli_short %} resolves the effective policy for that process using the current working directory, environment, settings, and automatic grants. This includes common locations needed by tools, so you don't have to grant each one yourself. Tools can also receive access to selected session files and installed skills they need to use.
5752

5853
### Your working directory
5954

@@ -72,7 +67,11 @@ On macOS, standard system locations are granted read-only permission so that com
7267

7368
### Package-manager caches
7469

75-
To let installs and builds work inside the sandbox, {% data variables.product.prodname_copilot_short %} also grants access to the caches and registries used by common package managers and toolchains—read-only for most locations, and read/write for selected writable locations, such as build caches and package-manager dependency stores. In the `/sandbox policy` report, this appears as **dev-tool access**.
70+
When **Allow dev tool access** is enabled, {% data variables.product.prodname_copilot_short %} grants access to the caches and registries used by common package managers and toolchains. Most locations are read-only. Selected locations, such as npm's cache, build caches, and some dependency stores, are writable so installs and builds can work.
71+
72+
These grants depend on the command and the tools detected in your project. They can follow cache locations you have configured outside the usual directories. Some granted configuration files contain registry credentials, and writable caches can be shared with commands you run outside the sandbox. Turn off **Allow dev tool access** if you prefer to grant these locations yourself.
73+
74+
In the `/sandbox policy` report, the **Dev tools** section lists the detected tools and their paths. Selected writable caches are created when a command needs them, so they may not appear in the report before the first use.
7675

7776
### Git repositories
7877

@@ -82,11 +81,11 @@ Because read access spans the whole repository, a sandboxed command can read fil
8281

8382
## When access rules overlap
8483

85-
Because {% data variables.product.prodname_copilot_short %} grants several locations, and you can add your own, the rules can overlap. When they do, the **more specific path wins**. For example, if `/project` is writable but you mark `/project/secrets` read-only, everything in `/project` stays writable except `/project/secrets`. This is a useful way to protect a sensitive subfolder.
84+
Because {% data variables.product.prodname_copilot_short %} grants several locations, and you can add your own, the rules can overlap. When read-only and read/write grants overlap, the **more specific path wins**. For example, if `/project` is writable but you mark `/project/secrets` read-only, everything in `/project` stays writable except `/project/secrets`. Denied paths take precedence over both kinds of grant.
8685

87-
Overlaps are also resolved in your favor when a convenience grant would otherwise get in the way. Consider a Python project with a local virtual environment (`.venv`) that appears on your `PATH`. Treating that directory as an ordinary read-only tool location would make it read-only—even though it sits inside your writable project—and a command such as `pip install` could then fail when it tried to update the environment. {% data variables.product.prodname_copilot_short %} resolves this for you: a grant it added automatically (such as a tool directory on `PATH`) gives way to a broader read/write grant that already covers it. So a project-local `.venv`, `node_modules/.bin`, or similar directory stays writable as part of your workspace.
86+
Discovered tool-directory grants give way to read/write access that already covers them. Consider a Python project with a local virtual environment (`.venv`) that appears on your `PATH`. Treating that directory as an ordinary read-only tool location would make it read-only—even though it sits inside your writable project—and a command such as `pip install` could then fail when it tried to update the environment. {% data variables.product.prodname_copilot_short %} leaves it writable as part of your workspace. Other read-only rules, including ones you configure yourself, are not discarded this way.
8887

89-
Rules that **you** configure are always kept. If you mark a path read-only, or you deny it, that decision stands even when the same path would otherwise be discovered and granted automatically. This gives you a reliable way to protect a sensitive location—for example, denying a `.env` file so that no sandboxed command can read your secrets.
88+
Rules that **you** configure are not removed just because the same path was discovered automatically. You can use them to restrict access to a sensitive location, such as an existing `.env` file. Missing paths and symbolic links need additional care, as described in [Troubleshooting filesystem access](#troubleshooting-filesystem-access).
9089

9190
## Checking what the current policy allows
9291

@@ -96,16 +95,38 @@ Because the policy is assembled for each directory and command, the simplest way
9695
/sandbox policy
9796
```
9897

99-
{% data variables.product.prodname_copilot_short %} prints the **effective** policy for your current directory: the read/write, read-only, and denied paths that a command launched from here would actually receive, together with the network access and dev-tool access in force. This is the resolved result after the automatic grants and your own settings have been combined and any overlaps resolved—not just a copy of your saved settings.
98+
{% data variables.product.prodname_copilot_short %} prints the **effective** policy for your current directory. Paths are grouped by source, such as **User-configured paths** and **Dev tools**, and by access level. The report also includes network settings and a **Capabilities** section covering settings such as bypass, MCP/LSP sandboxing, and authentication. This is the result after automatic grants, your settings, and managed restrictions have been combined—not just a copy of your saved settings.
99+
100+
To inspect the developer-tool access for a particular command, add the command after `policy`. For example:
101+
102+
```shell copy
103+
/sandbox policy npm install
104+
```
105+
106+
This does not run `npm install`. It shows the tool access the command would receive. The preview creates no directories, including missing denied paths and tool caches.
100107

101108
A few things to keep in mind when you read the report:
102109

103110
* It reflects your **current directory**. Because grants are discovered per directory, the same settings can resolve to different paths depending on where you run.
104-
* If a path you configured does not exist on disk, it is left out of the policy and noted in a **Notes** section. This explains why a rule you added might appear to have no effect.
111+
* Check **Notes** for configured paths that could not be included. Missing read/write or read-only grants are omitted. On Linux, missing denied paths are omitted from this preview, but launch preparation creates them before applying the policy. The preview retains them on macOS and on Windows hosts that support denied paths.
105112
* If sandboxing is turned off, `/sandbox policy` tells you so instead of printing a policy, because no restrictions are in force.
106113

107114
To check only whether sandboxing is currently on, use `/sandbox status`. For more about these commands, see [AUTOTITLE](/copilot/how-tos/cloud-and-local-sandboxes/using-local-sandboxing).
108115

116+
## Troubleshooting filesystem access
117+
118+
If a configured read/write or read-only path does not exist, create it outside the sandbox before starting the command again. A running child process keeps the policy it received at launch. Creating a path later does not add a missing grant to that process. Restart a long-running server if it needs the updated access.
119+
120+
Before a sandboxed process starts, {% data variables.copilot.copilot_cli_short %} creates missing denied paths and their parent directories on your machine. This includes paths intended for files, so a missing `.env` becomes a directory. The directories remain after the process exits.
121+
122+
If a denied path cannot be prepared, the process does not start. The read-only `/sandbox policy` preview does not perform this preparation, which is why missing denied paths are omitted there on Linux. For troubleshooting, see [AUTOTITLE](/copilot/how-tos/cloud-and-local-sandboxes/using-local-sandboxing#troubleshooting-blocked-paths-that-do-not-exist).
123+
124+
A symbolic link inside an allowed directory does not guarantee access to a target outside that directory. If a denial message names such a target, inspect it and grant access only if intended. Adding a resolvable symbolic link itself through `/sandbox config` also adds its current target for read/write or read-only access. Handwritten path rules and automatically discovered developer-tool grants do not automatically add that target.
125+
126+
Denied paths are handled differently from grants: the CLI resolves their written path and current target. On Linux, a denied symbolic link protects its target, but does not reliably prevent the link itself from being replaced. Prefer denying the actual sensitive directory rather than relying on a symbolic-link rule alone.
127+
128+
For network failures, managed restrictions, and bypass choices, see [Troubleshooting blocked commands](/copilot/how-tos/cloud-and-local-sandboxes/using-local-sandboxing#troubleshooting-blocked-commands).
129+
109130
## Customizing the policy
110131

111132
You can grant extra read/write or read-only paths, deny paths, and change other filesystem behavior, either from the `/sandbox config` dialog or in your settings file. After you make a change, run `/sandbox policy` to confirm the result. For step-by-step instructions, see [AUTOTITLE](/copilot/how-tos/cloud-and-local-sandboxes/configuring-local-sandbox-settings).

‎content/copilot/concepts/copilot-surfaces/copilot-cli.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ To use the CLI programmatically, include the `-p` or `--prompt` command-line opt
6767
6868
## Running {% data variables.copilot.copilot_cli_short %} commands in a sandbox
6969

70-
> [!NOTE]
71-
> {% data reusables.cli.public-preview-sandbox %}
72-
7370
To prevent {% data variables.product.prodname_copilot_short %} from modifying files you don't want it to touch, you can force agents to run commands within a local sandboxed environment. Alternatively, you can run an entire CLI session in an isolated environment in the cloud. For more information, see [AUTOTITLE](/copilot/concepts/about-cloud-and-local-sandboxes).
7471

7572
### Local sandboxing
@@ -78,6 +75,9 @@ You can enable local sandboxing inside a {% data variables.copilot.copilot_cli_s
7875

7976
### Cloud sandboxing
8077

78+
> [!NOTE]
79+
> {% data reusables.cli.public-preview-cloud-sandbox %}
80+
8181
You can start a {% data variables.copilot.copilot_cli_short %} session inside an isolated, cloud-hosted environment with cloud sandboxes. This is useful when you want to run code without affecting your local machine, keep a session's state between uses, continue a session from a different machine, or run multiple tasks in parallel. Cloud sandbox policies inherit from {% data variables.copilot.copilot_cloud_agent %} policies, so existing security controls like firewall rules extend to cloud sandboxes without additional setup.
8282

8383
To start a cloud-backed session, run:

0 commit comments

Comments
 (0)