Text of code.visualstudio.com › blogs › 2021 › 07 › 06 › workspace-trust as Styx crawled it on Nov 18, 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

Workspace Trust

Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. On this page Can I trust myself? This is the existential question facing many Visual Studio Code users since the 1.57 update . 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? 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: The ESLint vulnerability was a doozy because it runs when the workspace loads (this was our first modal dialog). 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. 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. 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: 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

The rest of this page is on the live site.