Sandbox a Coding Agent Before Giving It More Access

A coding agent can follow your instructions and still run a command that reads the wrong file, reaches the wrong service or exposes a credential. Reviewing its answer afterwards cannot undo every action it took.

Sandboxing addresses a different part of the problem. Rather than relying only on instructions about what the agent should do, it restricts what its tools and commands are allowed to reach while the work is happening.

Decide the boundary before you start the agent

For each task, identify what the agent actually needs to use. A request to change a page in one repository does not automatically require access to your whole home directory, unrelated projects, private credentials or unrestricted network connections.

  • Files: which project directories may the agent read, and which may it modify? Consider whether it needs access outside the checked-out repository.
  • Network: does the task require internet access, access to internal services or neither? A package download and a request to an internal database are not the same permission.
  • Credentials: does the task need Git or GitHub authentication? If not, do not expose those credentials merely because the agent is running locally.
  • Tools: consider local services and integrations, including MCP tools, that could provide another route to sensitive data.

A useful rule is to start from the narrowest access that allows the accepted task to complete, then expand it deliberately when a specific step genuinely requires more. Keep the task's expected output and acceptance checks separate from the permissions you give it.

What the GitHub release establishes

In its October 2026 release announcement, GitHub says local sandboxing is generally available for GitHub Copilot CLI, the Copilot app and VS Code sessions using Agent Host. It describes restrictions on filesystem, network, credentials and other capabilities for agent-initiated tool execution, based on developer or organisation policies.

GitHub says the feature uses Microsoft eXecution Container (MXC) to translate a common policy into operating-system controls on Windows, macOS and Linux. It also describes enterprise-managed settings that can require sandboxing and prevent developers from weakening those policies. The announcement says local sandboxing is included with Copilot at no additional cost.

Those are GitHub's claims about the named Copilot environments, not proof that every agent, extension, integration or command on your machine is isolated in the same way. GitHub explicitly qualifies coverage of some local MCP tools and language servers as dependent on support. Check the coverage and policy settings for the environment you actually use.

Sandboxing is not the same as approval

A permission prompt asks whether an action should proceed. A sandbox defines what an action can reach when it proceeds. You can use both, but neither substitutes for the other. An approved command can still be too broad; a sandboxed command can still write incorrect code inside its allowed workspace.

Model selection and execution restrictions are also separate. GitHub says Copilot's sandbox policies apply to tool execution regardless of which model is selected. A more capable model does not remove the need to define what its commands may access.

Claude Code's October 2026 release notes separately list fixes involving sandbox read restrictions and permission bypasses. That supports the broader point that execution boundaries need maintenance and should not be treated as infallible. It does not establish feature equivalence between Claude Code and Copilot.

When a model decides whether to ask permission

In its 26 October 2026 announcement, GitHub says Assisted permissions are generally available in Copilot CLI, the Copilot app and Visual Studio Code. When Copilot asks to run a command, access a file path or open a URL, a large language model evaluates the request. Requests it classifies as clearly safe proceed without manual approval; other requests are not automatically approved. What happens next depends on the session mode.

This is a change to how approval is decided, not evidence that a request is confined to the files and services intended for the task. A model's classification should not be treated as an independent safety test. The announcement's feed summary does not specify the criteria used to classify requests or establish how often those judgements are correct. It also does not establish that the model making the permission decision is the same model generating the code.

Keep the controls distinct. A sandbox should impose limits on what commands can reach, whether approval was manual or automatic. Confirm which restrictions actually apply in your environment rather than assuming Assisted permissions provides the same protection as sandboxing.

When a denied action does not stop Autopilot

GitHub's Copilot CLI 1.0.108-0 release notes say that, since version 1.0.106, Autopilot with Assisted Permissions no longer stops for permission prompts: the agent tries another approach and later reports actions it could not take. This is a behaviour reported for that named combination of mode and permissions, not evidence that all Copilot sessions behave the same way.

A refused request therefore does not necessarily mean the task has stopped. It also does not establish that the agent can get around an enforced sandbox: trying a different approach and crossing a file, network or credential boundary are different things. Before an unattended run, decide whether alternative approaches within the allowed boundary are acceptable. Afterwards, inspect the reported refused actions alongside the actual changes and test results. If the task genuinely needs broader access, make that a deliberate decision rather than assuming a permission refusal protected the rest of the system.

Decide where automatic approval is appropriate

  • Routine work in an isolated workspace: Assisted permissions may reduce approval interruptions, provided the files, tools and network destinations available to commands are already appropriately restricted.
  • Sensitive or hard-to-reverse operations: prefer manual approval for tasks that could affect credentials, live data, production services or unrelated projects. Even a manual prompt does not replace keeping those resources outside the execution boundary.
  • Unexpected requests: if the agent needs access beyond the agreed boundary, decide whether the task really requires it. Do not turn off restrictions simply to make the request succeed.

GitHub gives the following ways to select the mode:

  • Copilot CLI: run /permissions and select assisted.
  • Copilot app: open the mode picker, choose Tool permissions, then Assisted.
  • Visual Studio Code: open the permissions picker and select Assisted permissions.

For organisations, GitHub says managed settings can disable Assisted separately, or block Allow All while still permitting Assisted. Administrators can set a default for new sessions; developers can choose other modes that policy permits. If the chosen default is unavailable or prohibited, the session starts with manual approval. These settings govern which approval modes can be used; they do not remove the need to enforce and test the agent's execution boundary.

Ignore files are not access controls

An October 2026 research summary by Gias Uddin describes a reported case in which Copilot read and tried to alter a secrets file despite entries in both .gitignore and .copilotignore. The associated study reviewed 446 relevant Reddit posts, selected through automated filtering and manual verification. These are reported incidents, not a representative measurement of how often any particular product fails.

The practical distinction is simple: an ignore rule that changes what is indexed, suggested or committed is not proof that an agent-run command cannot open the file. Do not store sensitive credentials within a command's reachable filesystem and assume the ignore rule will protect them. Test the effective access boundary using a harmless stand-in file outside the approved workspace; it should be inaccessible even if an agent or its tools try to read it.

Failures to design for, not just prompt against

The same research summary groups reports into categories including unauthorised file operations, destructive deletion, violations of user constraints, prompt injection through malicious pull requests and risks from third-party MCP integrations. It also describes privacy concerns around unauthorised access and data transmission. The categories overlap; their reported percentages should not be treated as failure probabilities for a coding session.

  • Deletion and modification: keep live data, production services and unrelated directories outside the execution boundary. Use recoverable backups and verify the diff before applying changes.
  • Untrusted repository content: treat pull requests, comments and tool responses as task data, not instructions that can expand agent permissions.
  • Integrations: inspect which external systems an MCP server can reach, and limit credentials and write operations separately from ordinary repository access.
  • Secret exposure: remove unnecessary secrets from the agent's runtime rather than relying on prompt wording or ignore patterns.

The study identifies failure patterns worth testing against; it does not establish that all coding agents ignore exclusion rules or that one sandbox configuration works across all products. Inspect and verify the controls available in your own environment.

A practical check before an unattended run

  1. Write down the required change and which files should be affected.
  2. Identify the directories, network destinations, tools and credentials the task genuinely needs.
  3. Inspect the sandbox settings and confirm that unrelated files and services are outside the allowed boundary.
  4. Choose a permission mode suited to the task. Keep automatic approval decisions separate from enforceable access restrictions.
  5. If you work in a managed organisation, check whether its mandatory policies are enforced rather than relying solely on a local preference.
  6. Run the task, check any reported refused actions, inspect the changed files and independently test the accepted behaviour before merging or deploying it.

If the agent cannot do the task within that boundary, decide whether the extra access is justified. Do not silently turn off isolation to make the error go away. For sensitive systems, a separate disposable environment and independent review may still be necessary.

Keep the controls separate

Sandboxing limits the effects of tools the agent runs. Clear instructions reduce ambiguous decisions. Testing establishes whether the result works. Review checks whether the change is acceptable for the risk. Each catches a different class of failure.

For the instruction and starting-project side of the problem, see preventing insecure defaults. For deciding how much checking is enough, see how to test code you didn't write. Giving an agent more independence should mean designing stronger boundaries and clearer evidence, not simply trusting its report.

All articles