Workspace Trust is a critical security feature that controls whether code in a project folder can be executed by VS Code and extensions. Configure it properly to prevent malicious code execution.
Enable Workspace Trust in your global settings:
{
"security.workspace.trust.enabled": true,
"security.workspace.trust.startupPrompt": "always",
"security.workspace.trust.emptyWindow": false,
"security.workspace.trust.banner": "always",
"security.workspace.trust.untrustedFiles": "prompt"
}
Create a workspace trust policy file workspace-trust-policy.json:
{
"trustedFolders": [
"/home/user/trusted-projects",
"/Users/user/work/company-repos"
],
"untrustedFileExtensions": [
".exe",
".bat",
".cmd",
".ps1"
],
"allowedExtensionsInUntrustedWorkspaces": [
"ms-vscode.vscode-json",
"ms-python.python",
"ms-vscode.cpptools"
]
}
For enterprise environments, configure extension allowlists via Group Policy or configuration management:
{
"extensions.autoCheckUpdates": false,
"extensions.autoUpdate": false,
"extensions.ignoreRecommendations": true,
"extensions.supportUntrustedWorkspaces": {
"ms-vscode.vscode-json": {
"supported": true,
"restrictedConfigurations": []
}
}
}
Verification: Open an untrusted folder - VS Code should prompt you about workspace trust and restrict extension functionality until you explicitly trust the workspace.
Warning: Trusting a workspace allows all extensions to execute code within that folder. Only trust workspaces containing code you've personally reviewed or from verified sources.