terminal: Disable read all by default#311850
Merged
dileepyavan merged 18 commits intomainfrom Apr 24, 2026
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for a filesystem read allow-list to the terminal sandbox configuration (Linux/macOS), aiming to default-deny reads from the user home while re-allowing common developer/tooling paths and configured exceptions.
Changes:
- Introduces
allowReadto the Linux/macOS filesystem sandbox settings schema and runtime config type. - Generates sandbox config with default
denyRead(home) plus derivedallowReadfrom configured allow-list, workspace folders, write-allowed paths, VS Code runtime/data paths, and a shared tooling allow-list. - Adds a shared terminal sandbox read allow-list module and updates tests for the new deny/read-allow behavior.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/terminalSandboxService.test.ts | Updates/extends tests to validate new deny-home + allowRead derivation behavior (currently Linux-only). |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts | Implements allowRead generation, home-deny defaults, allow-list integration, and path expansion logic. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxReadAllowList.ts | Adds shared read allow-list groups for Git/Node/common dev tooling paths. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandbox.ts | Extends local runtime config type with filesystem.allowRead. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts | Adds allowRead to Linux/macOS configuration schema defaults and docs. |
| extensions/copilot/.vscode/settings.json | Enables chat.agent.sandbox.enabled in the Copilot extension workspace settings. |
Copilot's findings
Comments suppressed due to low confidence (2)
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts:532
- On macOS, the generated filesystem paths are not normalized/expanded (eg
~is left intact):macAllowWrite,macDenyRead,macAllowRead, anddenyWriteare passed through without_expandHomePath, but the allow-list (getTerminalSandboxReadAllowList) and default write paths contain many~/*entries. Unless the sandbox runtime expands~itself, this will make the macOS allow/deny lists ineffective. Consider applying the same home expansion for macOS (and for all filesystem arrays), and add coverage to ensure the written config contains absolute paths.
const linuxAllowWrite = this._resolveLinuxFileSystemPaths(this._updateAllowWritePathsWithWorkspaceFolders(linuxFileSystemSetting.allowWrite));
const macAllowWrite = this._updateAllowWritePathsWithWorkspaceFolders(macFileSystemSetting.allowWrite);
const linuxDenyRead = this._resolveLinuxFileSystemPaths(this._updateDenyReadPathsWithHome(linuxFileSystemSetting.denyRead));
const macDenyRead = this._updateDenyReadPathsWithHome(macFileSystemSetting.denyRead);
const linuxAllowRead = this._resolveLinuxFileSystemPaths(this._updateAllowReadPathsWithAllowWrite(linuxFileSystemSetting.allowRead, linuxAllowWrite));
const macAllowRead = this._updateAllowReadPathsWithAllowWrite(macFileSystemSetting.allowRead, macAllowWrite);
const linuxDenyWrite = this._resolveLinuxFileSystemPaths(linuxFileSystemSetting.denyWrite);
const sandboxSettings = {
network: {
allowedDomains: allowedDomainsSetting,
deniedDomains: deniedDomainsSetting
},
filesystem: {
denyRead: this._os === OperatingSystem.Macintosh ? macDenyRead : linuxDenyRead,
allowRead: this._os === OperatingSystem.Macintosh ? macAllowRead : linuxAllowRead,
allowWrite: this._os === OperatingSystem.Macintosh ? macAllowWrite : linuxAllowWrite,
denyWrite: this._os === OperatingSystem.Macintosh ? macFileSystemSetting.denyWrite : linuxDenyWrite,
},
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts:664
_getVSCodeDataReadPathshardcodes~/vscode-server-insidersand~/.vscode-server-insiders. This seems build-variant specific and will miss stable (vscode-server) or other product variants. Consider deriving these names fromthis._productService.serverApplicationName(and including both dotted and non-dotted forms if needed) rather than hardcoding the insiders folder name.
private _getVSCodeDataReadPaths(): string[] {
const paths = ['~/vscode-server-insiders', '~/.vscode-server-insiders'];
const userHome = this._getUserHomePath();
if (userHome) {
paths.push(this._pathJoin(userHome, this._productService.dataFolderName));
if (this._productService.serverDataFolderName) {
paths.push(this._pathJoin(userHome, this._productService.serverDataFolderName));
}
}
return paths;
- Files reviewed: 6/6 changed files
- Comments generated: 3
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/ec5cf3c2-6c7b-4577-bdbb-8ac3d42bdfb0 Co-authored-by: dileepyavan <52841896+dileepyavan@users.noreply.github.com>
vijayupadya
approved these changes
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
allowReadfilesystem sandbox settings for Linux and macOS so specific paths can be re-allowed inside denied read regions.allowRead, common developer tool paths, VS Code data/runtime paths, and write-allowed paths.For testing: https://builds.code.visualstudio.com/builds/insider?commit=bd9e94a3d725475dce55f422e21913dc212ceed8&dev=true
fixes [Terminal_ Sandbox]: Do not allow reading arbitrary paths inside the $HOME folder #312191