← Back to blog
Tutorials#github-copilot

GitHub Copilot's Local Sandbox: What It Blocks and What Developers Should Check

Learn how GitHub Copilot's local sandbox restricts filesystem, network, and credential access for agent-run commands, and how to test those limits yourself before you trust them.

9 min readby the editors
GitHub Copilot's Local Sandbox: What It Blocks and What Developers Should Check cover illustration

GitHub Copilot's local sandbox limits what agent-run commands can touch on your machine. With it on, a command Copilot runs can write to your project folder but not your home directory, cannot reach your local network by default, and sees placeholder Git and GitHub CLI tokens instead of the real ones. That cuts the damage a bad command can do. It does not make every agent action safe, and the limits depend on your operating system and your settings. This guide covers what the sandbox restricts, how to turn it on in Copilot CLI, and four tests to run in a throwaway project before you rely on it.

Before you start

System requirements

Copilot access

A GitHub Copilot plan, signed in to Copilot CLI or the app

The sandbox is a local feature of the client. Check GitHub's docs for current plan and policy requirements; enterprise owners can require or restrict it.

Copilot surface

Copilot CLI or the GitHub Copilot app

Both support local sandboxing. VS Code has its own sandbox settings, documented separately by VS Code. The app cannot sandbox cloud sessions or sessions on a remote host.

Windows

Windows 11 25H2 (KB5124010+) or 26H1 (KB5124006+)

The OS must support the BaseContainer tier of the ProcessContainer backend. Some features, such as denied paths and localhost access, need a supported version or the command fails.

Linux

Bubblewrap (bwrap) 0.5.0+ and slirp4netns

Both must be on your PATH. Install them from your distribution's package manager.

macOS

No extra packages listed

GitHub does not list prerequisites for macOS. Keychain access is off by default inside the sandbox.

Test project

A disposable folder with dummy credentials

Our recommendation, not a GitHub rule. Run every test below away from real repositories and real secrets.

01

What does GitHub Copilot's local sandbox do?

It puts a boundary around the commands and tools Copilot runs: files, network, and credentials.

AI coding agents write code, run terminal commands, edit files, and call external services. That is useful right up until the agent runs a command you did not intend, or reads something it had no reason to read. The local sandbox restricts the resources those agent-run operations can reach.

It works in four areas. Filesystem: which folders a command can read or write. Network: whether a command can reach the internet, your local network, or specific hosts. Credentials: Git and GitHub CLI tokens, plus any environment variables you choose to mask. Permission requests: what happens when a command needs more access than the policy allows.

The defaults below come from GitHub's documentation for Copilot CLI. Your effective policy can differ by operating system, enterprise policy, and your own settings, so check it with /sandbox policy rather than trusting the defaults table further down.

Tip
Most commands and tools Copilot invokes run inside the sandbox, including local MCP servers and language servers by default. Remote MCP servers are a different story; see the limitations section.

02

How do you turn on the sandbox in Copilot CLI?

Install the OS prerequisites, then enable it with /sandbox enable or the --sandbox flag.

On Linux, install Bubblewrap and slirp4netns first. Windows and macOS need no extra packages, but Windows must be on a supported build (see the requirements above).

Inside Copilot CLI, run /sandbox enable. The choice is saved as sandbox.enabled in ~/.copilot/settings.json, and the status line shows sandbox enabled. To try it for one session without saving anything, start Copilot with --sandbox. Already-open sessions need a restart (copilot --continue) or their own /sandbox enable.

Sandbox settings live in your personal settings file only. GitHub does not support them in repository-level settings files, so a repo cannot quietly loosen your sandbox. In the Copilot app, the switch is the Sandbox new sessions toggle under Settings > Projects > your project > Sandbox. App and CLI settings are separate.

Linux: install prerequisites (Debian / Ubuntu)
sudo apt install bubblewrap slirp4netns
bwrap --version
Linux: install prerequisites (Fedora)
sudo dnf install bubblewrap slirp4netns
bwrap --version
macOS / Linux / Windows: start a sandboxed session
copilot --sandbox
Inside Copilot CLI: enable, inspect, configure
/sandbox enable
/sandbox status
/sandbox policy
/sandbox config
03

Test 1: does the filesystem restriction hold?

Put a harmless file outside the workspace, ask Copilot to read and change it, and confirm it is untouched.

By default a sandboxed command can write to the current working directory and temp folders. In a Git repository it can also write .git, while the rest of the repo above the working directory is read-only. Your home directory is not granted. Note that /add-dir adds a folder to Copilot's context but does not grant sandbox access to it.

Create a test project and a canary file in your home directory. Start Copilot with --sandbox from inside the test project, then ask it to run: cat ~/sandbox-canary.txt, and then: echo changed > ~/sandbox-canary.txt (on Windows, Get-Content and Set-Content on the same path).

Expected result: both are blocked. Copilot may offer to retry outside the sandbox. Decline for this test. Then, in a normal terminal outside Copilot, check that the file still says original.

Test 1, filesystem. Inside the sandbox boundary, Copilot runs in ~/sandbox-test, and the working directory, .git and temp folders are read/write. Outside it, ~/sandbox-canary.txt in the home directory holds the word original. Copilot's attempts to read and overwrite it are both blocked and the retry is declined. Checked in a normal terminal afterwards, the file still says original.
Pass: both attempts are blocked and the canary still says original.Open full size →
macOS / Linux: create the test project and canary
mkdir ~/sandbox-test && cd ~/sandbox-test && git init
echo "original" > ~/sandbox-canary.txt
Windows PowerShell: create the test project and canary
New-Item -ItemType Directory $HOME\sandbox-test; Set-Location $HOME\sandbox-test; git init
Set-Content $HOME\sandbox-canary.txt "original"
macOS / Linux: verify afterwards (outside Copilot)
cat ~/sandbox-canary.txt
Windows PowerShell: verify afterwards (outside Copilot)
Get-Content $HOME\sandbox-canary.txt

Tip
Allow dev tool access is on by default. It gives read access to package-manager and developer-tool configs, which can include stored tokens. If your test needs a strict filesystem, turn it off on the Filesystem tab and see what breaks.

04

Test 2: does the network policy match what you configured?

Test outbound internet and local network separately, against endpoints you control.

In Copilot CLI, outbound internet is allowed by default and local network access is off. Test them as two separate questions.

For local network, start a small web server in a normal terminal, then ask the sandboxed Copilot session to curl it. With the default settings on macOS, the request should fail. Behaviour differs by OS: on Linux, commands can reach servers they start themselves but not your host's localhost, and on Windows the local-network switch also opens private-network access.

For outbound internet, add a host rule on the Network tab of /sandbox config. Once any Allow rule exists, every unmatched host is blocked. Deny beats Allow, and denying example.com also blocks its subdomains. Add an Allow rule for one host, then curl that host and a second one. Only the first should succeed.

Test 2, network. With the default policy, a curl from inside the sandbox to a local test server on 127.0.0.1:8765 is blocked, while example.com and httpbin.org return 200. With one Allow rule for example.com, the local server is still blocked, example.com returns 200, and httpbin.org is blocked because unmatched hosts are now denied. Notes cover how host rules resolve and how local-network behaviour differs on macOS, Linux and Windows.
One Allow rule flips the default: every host it does not match is blocked.Open full size →
macOS / Linux: local test server (normal terminal)
python3 -m http.server 8765
Windows PowerShell: local test server (normal terminal)
py -m http.server 8765
macOS / Linux: ask Copilot to run these inside the sandbox
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:8765
curl -s -o /dev/null -w "%{http_code}\n" https://example.com
Windows: ask Copilot to run these inside the sandbox
curl.exe -s -o NUL -w "%{http_code}\n" http://127.0.0.1:8765
curl.exe -s -o NUL -w "%{http_code}\n" https://example.com

Tip
Host rules accept hostnames, *.example.com wildcards, and single IP addresses. CIDR ranges are not supported, and *.example.com does not match example.com itself.

05

Test 3: are credentials masked the way you expect?

Use a dummy token and watch where the real value is, and is not, delivered.

Git and gh authentication are on by default. Commands get placeholder credentials, and a local proxy swaps in the real ones only for approved HTTPS destinations. The gh token is delivered only to github.com, api.github.com, and uploads.github.com. Git credentials keep their original host, port, and repository path.

You can mask other variables too. Set a dummy variable before you start Copilot, add it to the sandbox credentials config with the one host allowed to receive it, and restart the session. Inside the sandbox, ask Copilot to echo the variable: it should print a placeholder, not your value.

Then send it in an Authorization header to a header-echo service. The real value should arrive only at the host you listed. Masking works only for HTTPS headers such as Authorization or X-Api-Key, or an HTTP Basic password. Plain HTTP, request bodies, URLs, and signed requests never get the real value.

Test 3, credentials. A dummy token set in your shell shows up as a placeholder inside the sandbox. A local proxy swaps in the real value only for HTTPS headers sent to hosts in injectHosts, here httpbin.org. Any other host, plain HTTP, request bodies, URLs and signed requests only get the placeholder. The gh token is delivered only to github.com, api.github.com and uploads.github.com, and an approved bypass skips the proxy entirely.
The real value reaches only the hosts you list in injectHosts, and only in an HTTPS header.Open full size →
~/.copilot/settings.json (mask the dummy token)
{
  "sandbox": {
    "enabled": true,
    "credentials": {
      "envVars": {
        "DUMMY_API_TOKEN": {
          "injectHosts": ["httpbin.org"]
        }
      }
    }
  }
}
macOS / Linux: set a dummy token, then start Copilot
export DUMMY_API_TOKEN="not-a-real-secret-123"
copilot --sandbox
Windows PowerShell: set a dummy token, then start Copilot
$env:DUMMY_API_TOKEN = "not-a-real-secret-123"
copilot --sandbox

Tip
Never use a production secret for this test. On Windows, masking needs Allow local network turned on, which also permits private-network access. If curl fails with a certificate error on macOS or Windows, look at /sandbox ca trust.

06

Test 4: what happens when a command asks to bypass the sandbox?

Trigger a block on purpose, read the prompt, and understand what approving it gives away.

When a command fails and the failure looks like the sandbox's doing, Copilot can offer to retry it with broader access. You can approve one retry, keep the blocked result, or turn the sandbox off for the rest of the session if policy allows. In the Copilot app, the prompt reads Run outside the sandbox?

Rerun the canary write from Test 1 and look closely at the prompt before answering. The important detail: an approved bypass skips credential masking and the proxy. The command runs with your normal environment, real secrets included. It does not gain admin or root rights, but it gets everything your user account can reach.

On supported Windows hosts the retry is staged. It first relaxes file and process limits while keeping network limits (sandbox relaxed), and only offers a full bypass (sandbox bypassed) if that still fails.

If you would rather blocked commands stay blocked, turn off Allow sandbox bypass on the General tab. Organizations can enforce this with managed sandbox.allowBypass set to false.

Test 4, bypass requests. A blocked command triggers the prompt Run outside the sandbox? Keeping the blocked result changes nothing. Approving one retry runs that command with your normal environment and real secrets, without masking or the proxy, and without admin rights. Turning the sandbox off for the session, if policy allows, exposes every later command. On supported Windows hosts the retry is staged from sandbox relaxed to sandbox bypassed. Allow sandbox bypass off, or managed sandbox.allowBypass false, keeps blocked commands blocked.
An approved bypass is one command with your real environment. Read it before you say yes.Open full size →

Tip
Write down the configuration, commands, logs, and outcome of each test. Make claims about what the sandbox blocks only from what you observed.

What does the sandbox allow by default?

ResourceDefault in Copilot CLI
Current working directory and temp foldersRead / write
Rest of the Git repo above the working directoryRead only (.git is read / write)
Home directory and other pathsBlocked
Dev-tool configs and package cachesRead (caches read / write), on by default
Outbound internetAllowed
Local networkOff
Git and gh credentialsPlaceholders, real token only at approved hosts
Sandbox bypass requestsOn, each one needs your approval

These are Copilot CLI defaults from GitHub's documentation, checked on 12 October 2026. Run /sandbox policy to see your effective policy, which also folds in automatic grants and any managed enterprise settings.

What are the limitations?

Sandboxing reduces risk. It does not remove it.

  • Configuration matters. Broad filesystem rules or unrestricted outbound network access weaken the protection, and outbound internet is on by default.
  • Approved operations can still do damage. A command can delete or rewrite anything inside the permissions it has, including your project folder, even when the sandbox works exactly as designed.
  • Not every tool has the same boundary. Shell commands, built-in file operations, local MCP servers, and remote MCP servers run under different models. Remote MCP authentication is not protected by credential masking.
  • Bypass changes everything about one command. An approved bypass runs with your real environment and real secrets. Read what the command is before you approve it.
  • Some tools will not work through the proxy. Tools that ignore the supplied certificate bundle, need HTTP/2, pin certificates, use client certificates, or sign requests may fail.
  • Platform behaviour differs. Local network access, denied paths, and masking all behave differently on Windows, macOS, and Linux.

A quick security checklist

  • Confirm sandboxing is enabled and supported: /sandbox status, and the status line shows sandbox enabled.
  • Review the effective filesystem permissions with /sandbox policy.
  • Restrict network access to what the task needs, using Allow host rules.
  • Minimize credential exposure: mask API tokens and set injectHosts to the one host that needs each.
  • Read every bypass request before approving, or turn bypass off.
  • Check which tools and MCP servers are covered. Remote MCP servers are not masked.
  • Run your tests in an isolated project before pointing Copilot at a sensitive repository.
Personal verdict

Turn the local sandbox on, run the four tests above once on your own machine, and treat it as one layer of defense next to code review, dependency scanning, secret detection, and least-privilege access. We would also restrict outbound hosts and read every bypass prompt, because those are where the defaults leave the most room.

Frequently asked questions

Is GitHub Copilot's local sandbox on by default?+

No. In Copilot CLI you turn it on with /sandbox enable or the --sandbox flag. In the Copilot app, the Sandbox new sessions toggle is off by default unless enterprise settings require it.

Does the sandbox block internet access?+

Not by default. Copilot CLI allows outbound connections and blocks local network access. To limit the internet, add Allow host rules on the Network tab of /sandbox config. Once one Allow rule exists, unmatched hosts are blocked.

Can a sandboxed command read my GitHub token?+

It sees a placeholder GH_TOKEN. A local proxy substitutes the real token only for requests to github.com, api.github.com, and uploads.github.com. An approved sandbox bypass skips this and runs with your real environment.

Does the sandbox cover MCP servers?+

Local MCP servers run in the sandbox by default (the Sandbox MCP servers setting is on) and receive masked variables as placeholders. Remote MCP authentication is not protected by masking.

Can a repository change my sandbox settings?+

No. GitHub does not support sandbox settings in repository-level settings files. They live in your personal Copilot settings, and enterprise managed policy can only narrow them.

Which operating systems are supported?+

Windows 11 25H2 with KB5124010 or later, or 26H1 with KB5124006 or later. Linux with Bubblewrap 0.5.0+ and slirp4netns on your PATH. macOS is supported with no extra packages listed.

Sources & further reading

Sources and further reading

More practical field notes from Agent Builders HQ are on the way.

Stay tuned →