Workspace Trust in Visual Studio Code (2024)

July 6, 2021 by Chris Dias, @chrisdias

Can I trust myself? This is the existential question facing many Visual Studio Code users since the 1.57 update.

Workspace Trust in Visual Studio Code (1)

While we can't answer that question for you, we can tell you more about why we've introduced the concept of Workspace Trust.

But first, a little background.

Cats and keyboards, and bad apples

The internet is full of happy things, like videos of cats typing on keyboards.

For developers, it's also full of tools, packages, and open source built by good people, who want to help you solve that problem you've been working on for hours. Development tools like VS Code integrate package managers, code linters, task runners, bundlers, etc. to provide enjoyable experiences that harness the power of the latest and greatest advancements from the ever-evolving community.

However, the productivity afforded by this rich ecosystem is often a result of the broad access we provide to our development machines. Combine that with the rapid evolution and viral sharing and consumption, developer tools are an appealing target for exploitation, especially considering attackers can use our machines to further spread attacks (for example, via auth tokens stored on developer machines or even through the software authored by the developer).

Being a developer is rewarding, but it's also a risky business. To contribute to a project, you inherently need to trust its authors because activities such as running npm install or make, building a Java or C# project, automated testing, or debugging, all mean that code from the project is executing on your computer.

Our goal with the Workspace Trust feature is to find the right balance, to be safe from the few "bad apples" who want to ruin it for everyone, while continuing to ensure we can have all the nice things that make development so much fun.

Hey, it's just an editor, right?

Workspace Trust in Visual Studio Code (2)

Yes, VS Code is an editor. However, like most modern editors, it is capable of running code from the workspace on your behalf to provide a richer development experience.

Running and debugging code is an obvious example. Code execution that may not be so obvious could be the preLaunchTask that runs before starting the app and can run a build that has an extra task executing arbitrary code unrelated to the build. What about the npm module that steals your crypto wallet private keys? Make a simple edit and a malicious linter is loaded from the node_modules folder, instead of the one that is installed globally. Even reading the code can be deceptive, attackers can use Unicode hacks to hide malicious code in plain sight. Heck, you don't even have to open any source code to be owned.

The intent here isn't to scare you away from all the great tools out there (including VS Code) or to make you change careers. It is to raise awareness that there are many attack opportunities when you download code from the internet written by a person or an organization that you don't have any type of trust relationship with.

Whack-a-Mole

In all the scenarios above, the tools are working as they were designed, and in non-nefarious code bases, they are extremely productive. Setting up a preLaunchTask to build the app before debugging is a great time saver as you don't have to manually build it from the terminal after every change. Linters are highly customizable to support every team's preferred coding guideline and style (yes, tabs vs. spaces). Pre-commit hooks let you check if you've forgotten something or to make sure tests run before committing.

Now, it is unlikely you would be subject to all these attacks at the same time. In fact, there has not (yet) been an exploit through VS Code because there is a great community of experts who have made us aware when new opportunities arise. Our approach, before Workspace Trust, was to address each scenario at the point of vulnerability with a localized permission prompt.

For example, the Jupyter extension warned users that embedded JavaScript can run when you open the visualizers in a Notebook:

Workspace Trust in Visual Studio Code (3)

The ESLint vulnerability was a doozy because it runs when the workspace loads (this was our first modal dialog).

Workspace Trust in Visual Studio Code (4)

This, it turns out, is a losing battle. Users are interrupted with multiple (and slightly different) permission prompts that don't apply to the entire workspace. I trust you, you, you, you, not you, and you, but only on Tuesdays. For us, it's a constant game of Whack-a-Mole, plugging each vulnerability as it is exposed with yet another prompt.

So, one of the patterns we follow when building VS Code is to look at what experiences are being implemented similarly but inconsistently across the tool and extensions, and see if we can bring it into the core. Trust prompting followed this pattern, so we decided to look at building an experience and API that both the tool and extensions could take advantage of, with a (hopefully) clearer user experience.

Trust

Now that you understand some of the various ways code can be run without you knowing, hopefully you have a better idea why we are asking this question up front.

Workspace Trust in Visual Studio Code (5)

We specifically ask if you trust the authors of this workspace because VS Code can't tell if the code is malicious or not (hey, we just know 1's and 0's), where it came from, if you intend to contribute to the project, etc.

You, on the other hand, are smart and you know where the code came from: you (ok), your company (probably ok), your buddy Kai (depends), or some random person on the internet (definitely not).

That knowledge helps make the tool smarter. If you trust the author, great! The tools and extensions have the green light to do their thing and provide a magical experience, and we're not going to bug you again.

If you don't, you are telling us be careful VS Code, don't execute any code. This is what we call Restricted Mode, where potentially harmful functionality is disabled so you can more safely browse the code and eventually make an informed decision.

But that dialog!

We hear you, the modal dialog is pretty big and it keeps coming up for every new folder you open, unless you take action to configure it.

We didn't start with this design. We looked at the ESLint modal dialog saga and asked ourselves if we could provide a non-blocking experience using visual clues and a single notification prompt that was delayed for as long as possible. We wanted to be unobtrusive, start in Restricted Mode (without you really noticing) and prompt for trust at the last moment.

We introduced a "passive" trust notification where you could tell us if you trusted the workspace. We cycled through various UI treatments to signal that the workspace was not trusted, including augmenting the Settings gear icon and introducing a new security icon.

Workspace Trust in Visual Studio Code (6)

If you use the Insiders builds, you will get the latest iterations on new experiences in VS Code like we're talking about with Workspace Trust. Insiders ships daily and we use it to build VS Code.

The idea being a user (you!) could decide, on your terms, when to grant or deny trust of the workspace. When the tool or an extension really needed access, only then would we then put up a notification asking if you trusted the workspace:

Workspace Trust in Visual Studio Code (7)

Now, I'm sure many of you will agree, VS Code suffers from a bit of what we call "Notification Fatigue" (I promise we are working on it 😊). In our testing, we saw that people simply ignored the notification. Users did not see the notification on the gear or even the new security icons. Usage data showed a very low rate of granting trust through the passive notification. In user studies, we watched people spend all their time thinking they had broken something, and then spend time troubleshooting, trying to get back to their expected state.

We intended to be unobtrusive and delay as long as possible, but the reality was that, while in Restricted Mode, the product felt broken, and people thought it was their fault. Not a great place to be for either of us.

Putting you in control

The decision to trust a folder has a fundamental impact on the capabilities of VS Code, so after all the research we decided the right thing was to ask the trust question right away when you try to open a folder. Because the modal dialog is disruptive, we try to balance things out by making the dialog powerful so that you could answer a couple of questions and in the end, see the prompt much less often in your day-to-day work.

From our own dogfooding as well as through interviews with other developers, we found that people generally have a primary folder where they put all their sources and consider it trustworthy. We therefore added the ability to trust the parent folder directly from the dialog. You can trust it and all the sub folders with one click and then you won't see the trust prompt again.

Workspace Trust in Visual Studio Code (8)

Workspace Trust editor

The Workspace Trust editor gives you additional control over what you trust and will be updated in the 1.58 release to make it easier to configure the feature to suit your needs.

And because you can customize the behavior, there are many ways to get to the Trust Editor 😊. Click the Restricted Mode Status bar message, the Manage link in the Restricted Mode banner, the Gear menu, or open the Command Palette (F1) and use the Workspaces: Manage Workspace Trust command.

From the Workspace Trust editor, you can trust the current folder, the parent folder (and all sub folders), as well as any folder on the machine.

Workspace Trust in Visual Studio Code (9)

You can also quickly jump to all the Workspace Trust settings to fine-tune the experience.

Workspace Trust in Visual Studio Code (10)

How we use Workspace Trust

Nobody likes flossing their teeth, but we do it anyway because we know it's the right thing to do. Nobody wants to think about security, but we also know it's the right thing to do. By customizing the experience, you can keep your development experience enjoyable while also protecting yourself against the threats inherent with development (fun flossing?!?).

Most people on the VS Code team start out with a top-level folder, where they work on sources they trust. For example, on my Mac, I put all the sources that I pull from the Microsoft organization on GitHub into my ~/src folder. I designate ~/src as a trusted folder and everything beneath it is inherently trusted. When I open ~/src/vscode or ~src/vscode-docker, etc., they are opened with full trust because I trust the code that my organization writes and consumes.

I've got a separate folder called ~/scratch (short for "scratchpad", you can make it whatever you want obviously), where I put everything else and assume it is untrusted by default. Then, I make trust decisions on a folder-by-folder basis.

To smooth my workflow, I have the "security.workspace.trust.startupPrompt" setting set to "never".

Workspace Trust in Visual Studio Code (11)

With this setting, I am not prompted by the modal dialog and the workspace opens directly in Restricted Mode. I've already decided that the ~src/scratch folder is untrusted, so there is no need to prompt me every time I open a subfolder. If I decide that I do trust the code I'm reading or writing, I can enable it on the folder with two quick clicks (the Restricted Mode notification across the top of VS Code, then the Trust button).

On my Windows machine, things are a little more interesting. I generally work in Ubuntu images running on the Windows Subsystem for Linux (WSL), using the Remote WSL extension. I trust the ~/src folders on Linux and I trust the d:\src folder on the Windows side.

Workspace Trust in Visual Studio Code (12)

A few people on the team go one step further and turn off the Restricted Mode banner across the top as well ("security.workspace.trust.banner": "never"), leaving just the Status bar notification. For me this goes too far, the banner across the top keeps me honest and helps remind me to be vigilant when I am pulling from the internet.

Open source is awesome

We know that VS Code is a tool you use for getting your "real" job done, and any speed bumps or roadblocks we introduce only slow you down building and launching the next unicorn. Many of you took the time to reach out on Twitter, Reddit, and in issues, and we thank you for the candid feedback. We made a number of fixes and improvements coming in the 1.58 release based on your input and look forward to continuing the conversation.

Looking ahead, we want to help extension authors avoid arbitrary code execution and provide more functionality when running in Restricted Mode. Our Roadmap notes the work we are doing with the Visual Studio Marketplace team to bring additional security to the extension ecosystem (we call this "Trusted Extensions"), including validated publishers, signing, and platform-specific extensions. In short, you can think of Workspace Trust as helping good extensions make good decisions. Trusted Extensions will help protect you from bad extensions.

One of the benefits of building VS Code in the open is that the community can help us create the best possible experiences. So, please let us know how we can improve the flow, helping to keep you safe while being as unobtrusive as possible. Comment (politely!) on existing issues, submit a new one, or tweet us @code, we're listening!

Thanks,

Chris and the VS Code Team

Happy Coding (Safely)!

Workspace Trust in Visual Studio Code (2024)

FAQs

Where is workspace settings in VS Code? ›

Depending on whether you have a folder opened as workspace or a . code-workspace file, the location of workspace task and launch configurations will either be inside the . vscode folder or inside the . code-workspace file.

How do you add a workspace in VS Code? ›

Opening workspace files#
  1. Double-click the . code-workspace file in your platform's Explorer.
  2. Use the File > Open Workspace command and select the Workspace file.
  3. Select the Workspace from the File > Open Recent (Ctrl+R) list. Workspaces have a (Workspace) suffix to differentiate them from folders.

Do you trust the author in Visual Studio Code? ›

If you select Yes, I trust the authors , Visual Studio Code will trust the current workspace and enable all of the editor feature you are used to in it.

How do I change my restricted mode in VS Code? ›

Button up here or i could actually go to the command palette with ctrl shift p or command shift p.

How do I manage my workspace in VS Code? ›

vscode folder in the relevant folder. However if you want multiple folders in a workspace, and settings that apply to all, then you have to use a workspace. You don't create a new workspace until you need one. You simply use Open Folder on your project folder and start working on a file.

What is user and workspace in VS Code? ›

VS Code provides two different scopes for settings: User these settings apply globally to any instance of VS Code you open Workspace these settings are stored inside your workspace in a . vscode folder and only apply when the workspace is opened. Settings defined on this scope overwrite the user scope.

What is workspace in Visual Studio Code? ›

A workspace is how Visual Studio represents any collection of files in Open Folder, and it's represented by the IWorkspace type. By itself, the workspace doesn't understand the contents or features related to files within the folder.

What is a workspace in Visual Studio? ›

What is a Visual Studio Code Workspace - YouTube

Can I have multiple workspaces in VS Code? ›

VS Code tips — Multi-root workspaces - YouTube

Can VS Code extensions be malicious? ›

They can contain malware, yes. When you download and run an extension, you are trusting it to do pretty much anything it wants with the permissions of your user. VS Code does not implement sandboxing (like browsers do), and the code is not much restricted.

How do I reset VS Code settings? ›

EDIT
  1. Go to Menu Bar . Click on File -> Preferences -> Settings.
  2. On the top right corner of the Settings tab, click on the 3 dots button ... -> Show Modified Settings.
  3. You can now reset all the modified settings individually.

How do I find the author in Visual Studio? ›

To show this option you can press (Alt + 5) key, by opening the changes window you can see the detail of changes with change set ID, Change set Description, Author Name and Date of Changes.

Where is settings JSON in VS Code? ›

json and How to Open Settings. js in vscode.
...
Open Folder Settings vs code
  1. First, open your desired Workspace.
  2. Then Right-click on File > Preference > Settings.
  3. Navigate to your Project Folder tab.
  4. Then make changes on these settings that will apply to your current project only.
18 Feb 2022

Why are some files greyed out in VS Code? ›

That means the file is excluded from the build. The greyed/striked out file means the file is excluded from the build.

How do I disable all extensions in VS Code? ›

You will be prompted to reload VS Code after you disable an extension. If you want to quickly disable all installed extensions, there is a Disable All Installed Extensions command in the Command Palette and More Actions ( ... ) dropdown menu. Extensions remain disabled for all VS Code sessions until you re-enable them.

What is a workspace in computer? ›

A workspace is (often) a file or directory that allows a user to gather various source code files and resources and work with them as a cohesive unit. Often these files and resources represent the complete state of an integrated development environment (IDE) at a given time, a snapshot.

How do you remove untitled workspace in Visual Studio Code? ›

right click in the workspace you'd like to remove and select the "Remove Folder from Workspace" item; the name of the workspace will become: "NO FOLDER OPENED" that is the one you'll get when you installed the very first time Visual Studio Code.

How do I sync VS Code settings? ›

You can turn on Settings Sync using the Turn On Settings Sync... entry in the Manage gear menu at the bottom of the Activity Bar. You will be asked to sign in and what preferences you would like to sync; currently Settings, Keyboard Shortcuts, Extensions, User Snippets, and UI State are supported.

What is special about the default workspace? ›

The default workspace is a special workspace (available in the non-pro version) which stores the default preferred draft list display and sorting options. The default workspace is applied when using any of the “Clear Filters” options in the app.

How do I create a workspace in Visual Studio 2022? ›

Show activity on this post.
  1. Close all open files in VS Code.
  2. Select File menu >> Open Folder... and open the folder containing your source files.
  3. Select File Menu >> Save Workspace as... it should default to the folder you previously opened. If not browse to it and save the workspace file.
14 Nov 2018

How do I create a workspace in Visual Studio? ›

Creating a New Workspace in VS Code
  1. Select the folders you would like in your Workspace.
  2. Add them to the Workspace by navigating to “File” then “Add Folder to Workspace.”
  3. With your workplace set up, save the new forum by going to “File” then “Save Workspace As.”
5 Apr 2022

What's the difference between Visual Studio and Visual Studio Code? ›

Visual Studio vs Visual Studio Code - Differences

Visual Studio is an Integrated Development Environment, also known as an IDE. Visual Studio Code is a code editor. A developer can easily edit their code. VS is slower when it comes to performing across different platforms.

What is a workspace mapping? ›

In essence, a workspace is a folder, or multiple folders, mapped to areas in TFS. When code is checked out of TFS, the code is stored locally based off your workspace mappings. When you make changes to your code files, you are making those changes locally, to the files contained in your workspace.

How do I open two projects in VS Code? ›

You can simply do File>New Window and open the other project in the new window. Because after you close VSCODE and launch it again it opens only one of these two windows. But with workspace you keep both.

How do you manage multiple projects in VS Code? ›

Working with Multiple Projects in VS Code - YouTube

How do I open a second VS Code? ›

If you are using Windows, just hit Ctrl + Shift + N. If you are on a Mac, just press Command + Shift + N.

Is Visual Studio code a virus? ›

Visual Studio is a programming environment that is used to create software on Windows, rest assured, it is not a virus, it is genuine legitimate software.

How do I turn off VS Code restricted mode? ›

To disable the Restricted mode status bar entry: Right click in the status bar. Uncheck the workspace trust entry.

Are all VS Code extensions free? ›

Yes, VS Code is free for private or commercial use.

What is the default setting for VS Code? ›

How to reset VS Code to the default settings
  1. Go to View > Command Palette or press Cmd + Shift + P (macOS) or Ctrl + Shift + P (Windows).
  2. Search for open settings json and select Preferences: Open Settings (JSON) which show ups from the result list.
8 Feb 2022

How do you change environment in VS Code? ›

To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

What is the shortcut to reset VS Code? ›

Here are the steps to reset the keybindings in VS code. From keybindings.
...
13 Answers
  1. Click File > Preferences > Keyboard Shortcuts.
  2. There is a triple-dot (...) at the top-right hand corner. Click on that and select "Show User Keybindings"
  3. Delete your listed keybindings.

How do you set the author in VS code? ›

To set author and/or ms. author
  1. In VS Code, go to File > Preferences > Settings or select Ctrl+, .
  2. Select User settings to change the settings for all VS Code workspaces, or Workspace settings to change them for just the current workspace.
8 Sept 2022

How do I change the author in Visual Studio? ›

Change your display info through Team Explorer > Settings > Repository Settings . EDIT: Just noticed you're talking about existing commits, take a look at Change commit author at one specific commit. Addition: If you want to set user.name for a repo you probably want to set user. email as well.

How do I view local history in Visual Studio code? ›

Visual Studio Code allows us to check the history of navigated files in Navigation History lists. You can open this window from “Goto–> Navigation History” or by just simply pressing Ctrl + Tab. This will bring list of all previously navigated files with in Visual Studio Code.

What is a workspace in Visual Studio? ›

A workspace is how Visual Studio represents any collection of files in Open Folder, and it's represented by the IWorkspace type. By itself, the workspace doesn't understand the contents or features related to files within the folder.

How do I open VS Code settings? ›

json and How to Open Settings. js in vscode.
...
Steps to open Workspace Settings using GUI are as follows:
  1. First, open your desired Workspace.
  2. Then Right-click on File > Preference > Settings.
  3. Navigate to Workspace tab.
  4. Then make changes on these settings that will apply to your current workspace.
18 Feb 2022

Where is settings JSON file in VS Code? ›

vscode/settings. json (shortcut: Ctrl / Cmd + P and type "settings. json").
...
Which, depending on platform, is one of:
  1. Windows %APPDATA%\Code\User\settings. json.
  2. macOS $HOME/Library/Application\ Support/Code/User/settings. json.
  3. Linux $HOME/. config/Code/User/settings. json.
26 Jan 2021

How do I change JSON settings in VS Code? ›

How To Open settings.json Mac | Visual Studio Code - YouTube

How do I create a workspace in Visual Studio? ›

Creating a New Workspace in VS Code
  1. Select the folders you would like in your Workspace.
  2. Add them to the Workspace by navigating to “File” then “Add Folder to Workspace.”
  3. With your workplace set up, save the new forum by going to “File” then “Save Workspace As.”
5 Apr 2022

How do I reset VS Code? ›

EDIT
  1. Go to Menu Bar . Click on File -> Preferences -> Settings.
  2. On the top right corner of the Settings tab, click on the 3 dots button ... -> Show Modified Settings.
  3. You can now reset all the modified settings individually.

What's the difference between Visual Studio and Visual Studio Code? ›

Visual Studio vs Visual Studio Code - Differences

Visual Studio is an Integrated Development Environment, also known as an IDE. Visual Studio Code is a code editor. A developer can easily edit their code. VS is slower when it comes to performing across different platforms.

How do you change environment in VS Code? ›

To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

How do I change debug configuration in VS Code? ›

Once you have your launch configuration set, start your debug session with F5. Alternatively, you can run your configuration through the Command Palette (Ctrl+Shift+P) by filtering on Debug: Select and Start Debugging or typing 'debug ' and selecting the configuration you want to debug.

Where are VS Code extensions installed? ›

Extensions are installed in a per user extensions folder. Depending on your platform, the location is in the following folder: Windows %USERPROFILE%\.vscode\extensions. macOS ~/.vscode/extensions.

How do I view a JSON file in VS Code? ›

install
  1. Open vscode and search extensions for 'json viewer'
  2. download.
  3. reload.
  4. Usage: open a file, Press F1 and run 'Open in json viewer' Run the command again on editor to update the view.
20 May 2018

What is json VS Code? ›

JSON is a data format that is common in configuration files like package. json or project. json . We also use it extensively in Visual Studio Code for our configuration files.

How do I create a JSON file in Visual Studio Code? ›

How to Open A JSON File In Visual Studio Code - YouTube

Top Articles
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 6050

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.