Search code examples
securityvisual-studio-codeprivacy

How to disable internet access for a particular vscode extension you don't trust


VS Code is becoming more and more awesome all along with its crazy extensions, but with all that flexibility and awesomeness comes security and privacy risks.

Thus my question if at all it is possible to block a specific extension from accessing internet.


Solution

  • The answer appears to be no, you can't block extension network access:

    Relatedly, one might ask if there is any system in place to detect or prevent malicious extension behavior. Again the answer seems to be no:

    • The question Security and Privacy of VSCode extensions and its answer basically seem to boil down to "run your own firewall".

    • The question How is VS Code Extension Security Handled? and its answer boil down to "Microsoft does nothing to ensure extensions are not malicious".

    • I have personally uploaded one extension to the Marketplace. I can report that it took about five minutes to appear there; not nearly long enough for anyone to have reviewed it. Furthermore, I inadvertently uploaded it before creating the github repo, but that didn't cause any problems, suggesting that the service does not do any checks to ensure what is on github matches what is in the extension.

    Overall, I find this a scary situation. I do a few things to try to protect myself:

    • I try to stick to extensions that have a lot of downloads, and which have not been updated recently. I then have automatic update disabled. This way, everything I'm running has had some chance to be exposed as malicious before I use it.

    • The extensions are distributed as VSIX files, which are just ZIP files with a different file name suffix. If I am at all suspicious, I download it as a file first and poke around. Especially check the package.json scripts and the Typescript or Javascript source code (if there is any). That is of course far from foolproof but it's something.

    • It may also be worthwhile to check it with Virus Total.

    2024-06-09: A new service called ExtensionTotal (with which I have no affiliation) purports to check extensions for signs of malicious intent. They claim in a 2024-06-02 blog post to have found ~1000 published extensions with known malicious code, and ~150 that were flagged by VirusTotal. I've only briefly tried it, so who knows, but at least someone seems to be taking the problem seriously even if MS isn't.