Skip to main content

Local sandboxing in the GitHub Copilot CLI

There's a moment in every agentic workflow where you pause and think: wait, what exactly is Copilot allowed to touch right now?

For a long time the answer was: pretty much everything under your working directory and whatever shell commands it decides to run to get the job done. That was fine when Copilot was mostly suggesting code. It's a different story when it's running tools, executing scripts, and modifying files on your behalf.

As of June 2026, GitHub has an answer: local sandboxing, now in public preview. It doesn't replace good judgment about what you ask Copilot to do, but it does put a real isolation boundary between the agent's tool execution and the rest of your machine.

Let’s explore this feature…

Why do we need this?

The Copilot CLI has evolved significantly since GA. What started as a smart terminal assistant now has Autopilot mode, /plan, fleet parallelism, rubber duck, and a full agentic harness underneath. When you run Copilot in Autopilot mode on a refactoring task, it will read files, write files, and execute shell commands — potentially dozens of them — without stopping to ask each time.

That's the whole point. But it means the trust surface is no longer "can it read my README." It's "can it reach my ~/.ssh directory, hit external APIs, or run rm -rf on something it misunderstood."

Local sandboxing addresses this by isolating the shell command execution that Copilot initiates on your behalf. The agent still runs on your machine, still has access to the files you give it permission to use, but the sandbox enforces boundaries around what its spawned processes can actually reach.

The underlying technology is Microsoft MXC, the same isolation layer that runs across macOS, Linux, and Windows. This gives you a consistent experience regardless of platform. No Docker required, no VM overhead.

Enabling the sandbox

Inside any active Copilot CLI session, it's a single command:

/sandbox enable

That's it. From that point forward, shell commands that Copilot executes run inside the isolated environment. The setting persists across sessions via settings.json, so you don't have to re-enable it every time.

To disable it again:

/sandbox disable

If you want to check the current state or fine-tune the configuration, just run /sandbox on its own. This opens the interactive configuration interface.

The /sandbox configuration interface

Running /sandbox drops you into a three-tab TUI. Use Tab to switch between tabs, Esc to save and close.

General tab

This is the top-level on/off switch and the place to configure general sandbox behaviour. The Sandboxing enabled toggle here is exactly what /sandbox enable and /sandbox disable control. You can flip it from the config interface too.

Notice that you can decide if the MCP servers and LSP servers should also run in the same sandbox.

Use the arrow keys to navigate between settings and hit enter to change a setting.

Filesystem tab

By default, the sandbox restricts filesystem access: processes spawned by Copilot can't freely read or write outside your project directory. The Filesystem tab lets you add explicit path rules to extend that boundary where needed.

Key bindings in this tab:

Key Action
A Add a new path rule
Enter Edit an existing path rule
D Delete a path rule

When adding a rule, you specify the file or directory path and the permission level — read-only or read/write. This is useful for giving Copilot access to shared tooling or config outside the repo, without opening up your entire home directory.

Network tab

By default, the sandbox restricts outbound network connections. The Network tab lets you define per-host allow/block rules.

Same key bindings as Filesystem:

Key Action
A Add a new host rule
Enter Edit an existing host rule
D Delete a host rule

For each host you add, you set whether to allow or block access. This gives you a whitelist-style model: block everything by default, explicitly allow the registries or APIs your workflow actually needs.


Remark: At the moment, the Windows sandbox cannot block or allow specific hosts.

Where settings live

All sandbox configuration is stored in settings.json under the sandbox key in your Copilot CLI configuration directory. On most systems that's ~/.copilot/settings.json. You can set a different location via the COPILOT_HOME environment variable.

The structure looks roughly like this:

{
  "sandbox": {
    "enabled": true,
    "addCurrentWorkingDirectory": true,
    "sandboxMcpServers": true,
    "sandboxLspServers": true,
    "userPolicy": {
      "filesystem": {
        "readwritePaths": [],
        "readonlyPaths": [
          "C:\\Users\\user\\.nuget\\packages"
        ],
        "deniedPaths": [],
        "clearPolicyOnExit": true
      },
      "network": {
        "allowOutbound": true,
        "allowLocalNetwork": false,
        "allowedHosts": [
          "api.nuget.org",
          "registry.npmjs.org"
        ],
        "blockedHosts": []
      }
    }
  }
}

You can edit this file directly if you prefer, rather than going through the TUI each time. Useful for scripting a baseline config across machines or committing a team-level starting point.

 

Remark: If you're running Copilot in an org context, there's an enterprise-grade layer on top of this: local sandbox policies can be centrally configured and enforced via Microsoft Intune and other MDM platforms. This means administrators can lock down what Copilot's processes can touch on managed devices, without relying on individual developers to configure it themselves.

Each session inherits the org's sandbox policy, so the security controls you've already defined in your Intune baseline apply to Copilot execution on day one.

Conclusion

If you're using Autopilot mode or letting Copilot run multi-step tasks with shell access, enabling the local sandbox should be your default posture. It's one command, it persists, and it gives you configurable control over what the agent's processes can actually reach on your system.

The fact that it's built on MXC — rather than requiring Docker or WSL or any container runtime — means there's genuinely no excuse not to have it on. It costs you nothing and it draws a real line around what Copilot can touch.

/sandbox enable

Run that now, then tune the filesystem and network rules to match what your workflow actually needs. Future you will thank present you the first time Autopilot goes rogue on a find | xargs rm command.

More information

About cloud and local sandboxes for GitHub Copilot - GitHub Docs

Popular posts from this blog

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Cache stampede: when our cache turned against us

While investigating some performance issues, we ran into an ASP.NET Core API that cached a fairly expensive aggregation query for 60 seconds. Under normal load, that was fine: one request rebuilds the cache, everyone else reads from it. Under peak load, dozens of requests would arrive in that same expiry window, all see a cache miss, and all fire the same expensive query in parallel. The database didn't like that. That was the moment when our caching layer stopped helping and started hurting. A burst of requests comes in at the same time, all miss the cache, and all go hammer the database or the downstream API at once. That's a cache stampede . The cache was supposed to protect our backend, and for a few hundred milliseconds it did the opposite. Why this happens IMemoryCache.GetOrCreate (and its async sibling) looks like it protects you, but it doesn't add any locking on its own. Look at the naive version: public async Task<Report> GetReportAsync(string key) ...

A complex system designed from scratch never works

A few years ago, I worked as an architect on a big mainframe rewrite. I still count it as one of my failures. Not because the technology was wrong, but because I couldn't convince the management team to simplify the approach. Years later, the organization is still struggling to get the new system up and running. I left the project at the time, because I couldn't put my name behind an approach that would take very long and cost a lot of money without a working system to show for it along the way. Gall’s Law That memory keeps coming back to me, because it's a textbook case of Gall's Law playing out in real life. Gall's Law , from John Gall's Systemantics , states it plainly: A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works, and it cannot be patched to make it work. You have to start over with a simple system that works. What does that mean in practice,...