Text of code.visualstudio.com › docs › agents › run › security as Styx crawled it on Oct 9, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Secure AI-assisted development in VS Code

AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. 🎬 Watch The Story of VS Code! VS Code is now on Instagram, follow @vscode.ig for updates, tips, and more. Rewatch GitHub Copilot Day. Secure AI-assisted development in VS Code View as Markdown Ask in VS Code Ask in VS Code Insiders AI-powered development capabilities can autonomously perform different development tasks, which might have significant security implications.

This article covers VS Code's built-in security protections, the risks to be aware of, and how to configure your environment for safe AI-assisted development. For the concepts behind these controls, see Trust and safety . Note This article covers security controls in the VS Code editor for AI-powered development features. For information about how GitHub Copilot handles your data, privacy, and compliance, see the GitHub Copilot Trust Center .

For organization-wide AI policies and controls, see AI settings for your organization and enterprise policies . Recommended security baseline Use the following checklist to set up a secure starting point for AI-assisted development. Each step links to detailed information later in this article. Open untrusted projects in restricted mode. Until you've reviewed a project for malicious content, rely on the Workspace Trust boundary.

Restricted mode disables agents in that workspace. Use agent sandboxing and configure network access. On a supported platform, turn on agent sandboxing to restrict file system access for agent-executed shell commands and child processes. Outbound network access remains enabled by default because chat.agent.sandbox.network.allowNetwork Open in VS Code Open in VS Code Insiders defaults to true . Configure network access separately when you need to restrict it.

Learn more about configuring agent sandboxing . Review all file edits before integrating them. Use the diff editor to inspect changes before you commit, merge, or create a pull request. Protect sensitive files. Configure chat.tools.edits.autoApprove Open in VS Code Open in VS Code Insiders with glob patterns (for example, "**/.env": false ) to require manual approval for edits to sensitive files. Learn more about protecting sensitive files .

Keep auto-approval scoped to the session. Grant tool and terminal permissions at the session level rather than workspace or user level. This limits the duration of elevated trust. Review MCP servers before trusting them. Review repository MCP configuration before you trust a workspace. For servers from other sources, verify that they come from a trustworthy source before starting them. Trust boundaries VS Code's security model uses trust boundaries to limit the potential impact of untrusted code.

Trust decisions cover the workspace, extension publishers, MCP servers, and network domains, and you can revoke trust at any time. Related boundaries can share a decision. For example, MCP servers in .vscode/mcp.json and workspace-root .mcp.json inherit Workspace Trust. For a description of each boundary, see trust boundaries . How VS Code protects your environment VS Code includes several built-in security protections to provide visibility into sensitive operations, limit the scope of actions, and help prevent unintended consequences.

Scope and isolation VS Code limits the potential impact of agent actions by controlling their scope of operation. Workspace-limited file access : Built-in agent tools can only read and write files within the current workspace folder. You can optionally grant read-only access to additional folders with the chat.additionalReadAccessFolders Open in VS Code Open in VS Code Insiders setting. Tools picker : You can selectively enable or disable specific tools using the tools picker, giving you precise control over what capabilities are available to the AI agent.

Session isolation : You can grant permissions that are temporary and don't persist beyond the current session. This enables you to experiment with AI capabilities while maintaining long-term security boundaries. Request limits : Built-in safeguards prevent runaway operations that consume excessive resources or perform unintended bulk actions on your codebase. Agent isolation : Copilot, Claude, and Codex sessions can work in a separate Git worktree, preventing conflicts with your active workspace.

Cloud sessions run on remote infrastructure, which provides inherent isolation from your local machine and local resources. Secure secrets store : Sensitive input parameters for MCP servers are stored using VS Code's secure credentials store to protect authentication tokens and other sensitive data. MCP authentication : VS Code implements the MCP authorization specification to enable OAuth authentication between VS Code and external tools and services.

Approvals and review VS Code uses a permission-based security model where you maintain control over potentially risky operations. Permission levels : The permissions picker in the Chat view lets you choose a permission level for the current session. Manual permissions uses your configured approval settings. For supported sessions that run on the Agent Host, Assisted permissions Assisted permissions is experimental and might change or be removed. uses an LLM judge to evaluate each tool call and asks for your approval when the judge does not approve it.

Allow all auto-approves all tool calls. On the Agent Host, Autopilot is available as an agent mode that auto-approves all tools and drives the agent to continue working until the task is complete. Terminal approval : Before executing terminal commands, the agent requests explicit user approval. When terminal auto-approval is enabled, configurable per-command rules (including regex patterns) auto-approve safe commands while prompting for potentially dangerous ones.

All subcommands in a compound command must match an approved rule. Tool approval : MCP tool invocations require explicit user approval, which you can grant at different scopes: session-level for temporary access, workspace-level for project-specific trust, or user-level for broader permissions. URL and domain approval : When the agent fetches content from a URL, VS Code uses a two-step approval flow. First, it asks you to trust the domain (integrated with the Trusted Domains list).

Then, after the content is fetched, it presents the content for review before it is passed to the model. Review flow for file changes : You can review all suggested changes in a diff editor before you commit, merge, or create a pull request. Extension-host sessions also provide controls for keeping or undoing pending edits. Auto-approval notifications : When a tool or terminal command is automatically approved , VS Code shows an information message and a link to the configuration setting that enabled it.

Warning banners : When advanced modes bypass normal safety checks, VS Code displays clear warning banners and requires explicit consent. Learn more about tool and command approval . Agent sandboxing Agent sandboxing uses OS-level isolation to confine shell execution and child processes. For Agent Host sessions, it can also sandbox MCP servers and language servers that the Agent Host launches when the corresponding settings are active.

Both settings are active by default. Built-in and other non-process tools remain governed by separate permission checks. Agent Host sandboxing is available on supported Windows, macOS, and Linux hosts and is independent of the selected permission level. Sandboxing is an added layer. It is not a virtual machine or user-account boundary, a standalone security boundary, or a replacement for endpoint security. Credentials you explicitly inject, developer-tool configuration and caches, allowed paths, unrestricted or local network access, unsandboxed fallback, and bypass all weaken its isolation.

Learn how to configure agent sandboxing . For th

The rest of this page is on the live site.