-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Extension Permissions, Security Sandboxing & Update Management Proposal #52116
Comments
(Experimental duplicate detection) |
Thanks, @RMacfarlane, for tagging with suggested feature-request label. |
Any thoughts on this proposal for Extension Permissions & Update Management, especially from those who have been involved in extension management development and discussions in the past? CC @RMacfarlane, @roblourens, @joaomoreno, @sandy081, @egamma, @Tyriar, @bpasero, @ramya-rao-a, @octref, @alexhass, @kasajian, @mjbvz, @chrmarti, @isidorn, @IlyaBiryukov, |
|
Hi @yume-chan, Though Chrome and Firefox aren't perfect when comes to notifying users of permissions, I think recently they have done a good job, and even disable extensions until user authorizes newly required permissions after an update (though without ability to reject a specific optional permission as proposed here). In any case, Chrome and Firefox are at least a good reference as a starting place for UI and how this has been implemented (and considered critical to do so) elsewhere for extension management, though I've outlined a few ways I think this could be done a bit differently with VSCode. Do you have any specific suggestions on other applications that allow install of extensions and require users to authorize permissions for those extensions (upon install or when new permissions are requested upon update) that you would suggest as a better reference than Chrome or Firefox? |
Read, write, networking, and automation (VSCode command use) are the critical basic permissions to support, but I believe there are others, as can see in those proposed. Ability to limit many code extensions to just modifying contents shown in doc tab, allowing user to control if/when those edits are saved after seeing them should suffice for many extensions. I don't want extensions able to delete folders on hard drive or connecting to internet if it's a formatting or syntax extension as is the cast for most of the many I've installed. Other extensions which just register a new action to manually invoke on open document via F1 or context menu (as are the majority of other extensions installed, eg for formatting, deleting duplicate lines, sorting lines, etc) shouldn't be using APIs to automate messing with project files or source control or invoking save/delete commands and so forth. |
What, if anything, has already been done to provide or attempt extension sandboxing or security with VSCode? As I understand, VSCode is based on Electrum which, by design, disables much of Chromium's facility for sandboxing to enable native API access. However, Electron and Node.js both have some facilities for sandboxing and security, and there are a few projects extending support for these, as detailed below: Electron/Node.js Sandboxing/Security References and Options to Consider
Node.js / JavaScript Sandboxing ProjectsWould any of Node.js's facilities for sandboxing / security possibly be applicable here, or any of the following projects providing sandboxing for Node.js or otherwise?
|
Is this a possibility or something being considered currently? Does anyone have any thoughts on sandboxing extensions and enabling users to manage permissions for them (or even auto-update permission, to start with)? |
@RMacfarlane, @roblourens, @joaomoreno, @sandy081, @egamma, @Tyriar, @bpasero, or @ramya-rao-a, Is extension security sandboxing something you would be willing to consider for VSCode? I've provided, in my previous reply, a list of Electron and Node.js VM projects which you might be able to integrate or use as a reference for how this could be achieved with VSCode. I've detailed in this proposal how permission management could be exposed to users, similar to how it's been done with success for Chrome and Firefox, along with other suggested enhancements for extension auto-update options, prompts, and categorization. Though it's been a month, I haven't had any feedback from any of the VSCode developers (just one user) so any comments here would be much appreciated. Thanks, |
@RMacfarlane, @roblourens, @joaomoreno, @sandy081, @egamma, @Tyriar, @bpasero, or @ramya-rao-a, and other vscode devs dealing with extension management, Any update on whether this is being considered? As shown in links provided, there are methods and frameworks that would allow extension sandboxing even with it being based on Electron. |
The amount of trust/review needed is insane without basic sandboxing for extensions. I agree with @yume-chan
Are there any plans to implement it? |
Specifically
is by far the most important security threat. Please correct me if I'm wrong: |
Is VSCode extension sandboxing (for security and reliability) and extension permissions something that is being considered or can be considered by the VSCode team? In addition to helping improve security of such extensions, sandboxing may also help improve reliability. Potentially Preventing Current Widespread, Reoccurring Extension Host Crashing Occurring Now Across Many ExtensionsThis is especially important considering how frequently, especially recently, "Extension host terminated unexpectedly" has been occurring with a wide range of different extensions. In such cases, due to lack of sandboxing or isolation, one extension will crash all other extensions. Worse still, such extension host crash ends up preventing even the fact that the extension host had crashed from ever getting logged, as is occurring right now for me. It also prevents the original error which caused the crash from getting logged, as well as even what extension might have caused it, as even the relevant extension activation then fails to get logged as well, it seems. As it stands now, it is nearly impossible to identify which extension was causing the crashes. Even one-by-one disabling of extensions isn't feasible, when there 170 extensions installed, and especially when it doesn't reliably occur on every single startup (just ever few startups). Hence why I have had to put up with frequent VS Code crashes on startup for months now before identifying the extension causing them. Reliability Benefits and Critical Fixes Possible with Extension Isolation/SandboxingThough IMO something should be done in the VSCode extension host implementation to reduce the frequency of such issues (as well as logging improvements/fixes to identify the extension causing the issue), sandboxing could potentially isolate extensions in a way that would prevent them from crashing all other extensions, or at least prevent them from crashing core parts of the VSCode like the extension host itself. This could also prevent that extension from causing critical diagnostic/error logging info from not occurring, making it actually possible to identify which extension had caused the crash – even if simply by looking at which extension failed to get activated, though likely with the ability to directly report to the user the problematic extension, prompting them to disable it. VSCode could potentially even optionally auto-disable such VSCode-crash inducing extensions it if such critical crashes occur a 2nd time within a short span of time. 800+ Outstanding Issue Reports and Many (Even Official) Extensions with Frequent, Reoccurring Extension Host CrashesMany others are reporting the same, such as my recent report (ritwickdey/vscode-live-server#285) as well as #72476, #75267, microsoft/live-share#1510, ritwickdey/vscode-live-server#285, Live Share Chat review, and 250+ other "Extension host terminated" bug reports just in the VSCode repo, 133 open issues under chrmarti/testissues and 850+ "Extension host terminated unexpectedly" bug reports across all GitHub VSCode extension repos. A few of the extensions (including official/core/Microsoft extensions) which have frequent, reoccurring reports of causing of Extension Host Crashes include: Live Share Audio, Live Server, Live Share Chat, Live Share, Live SASS Compiler, Typed Test, Java Language Server, and Mocha Sidebar. And that is just based on one specific type of error that such sandboxing could potentially help address, in addition to other reliability and security benefits. |
See #79782 for more details about proposed use of Sandboxing for Reliability (more than Security) and how it may be needed especially now in light of the many recent reoccurring issues with many different popular extensions repeatedly crashing Extension Host (and therefore all other extensions) on VSCode startup, without any way to reliably or easily workaround for many extensions, let alone determine which extensions are causing the crashes. |
In 2019, this really should be on the list. It isn't clear there is even an obvious way to REPORT a malicious extension easily (which is it's own nontrivial problem). The permission model @PowerAccess describes is complete for an implementation, but perhaps too complex for what would be presented to a user. Something grouping of the fine grained permissions into end-user groups like,
Perhaps with a details panel that would display the detailed permissions being granted. @yume-chan says:
I understand that this is a VERY large undertaking: developing and documenting a permission model, developing or adopting a sandbox facility for node.js, and migrating all plugins. I also agree that other efforts in other domains (Chrome, Microsoft Store) are imperfect or require resources that are not appropriate for an open source undertaking like vscode. But in 2019 I fear that this is a real problem - malicious code being injected into random developer environments - that is probably already happening. As an aside, I wanted to be able to print from vscode, I found pdconsec.vscode-print Looking at the plugin I noticed that it was internationalized to ru, fr, en which put me (reasonably?) a little on edge. I examined the plugin code and it seems benign. But then I realized there could be modifications to any of the code under node_modules, and without a package-lock.json couldn't think of any reasonable way to verify the packages under node_modules against the npm repository |
Memory leak issue reported from @tvvignesh in #175249.
|
@FBoucher - Apologies for the confusion, but what do Profiles have to do with Extension permissions? |
Agreed, also crossposting #180233 - "OS-level readwrite sandboxing for filesystem readwrites" |
@ghnp5 you are right! I rectified my previous message. Sorry for the confusion. |
Since it doesn't seem like this is going to be fixed any time soon, does anyone have a workaround for the totally hackable and vulnerable extension system? (besides resorting to not installing extensions 😅) |
@dudicoco You can either containerize it or block network traffic, if that's enough for you. For containerization on Linux, there are different tools available like AppArmor and Firejail or even Docker or simply setting up a new user with limited file permissions. I am using x11docker to help with the latter: Regarding network blocking, there's https://github.com/evilsocket/opensnitch for Linux and Little Snitch for MacOS. Curious to see other solutions too. |
Thanks @phil294, unfortunately i'm on mac and docker is too slow due to it running on VM (slow file sync issues). Opensnitch might be a good workaround for network traffic, what about local filesystem manipulation though? Can extensions manipulate files outside of the current vscode workspace? |
It's a shame VSCode extensions can make arbitrary damage to the host system. |
The devcontainers extension allows for both filesystem and network sandboxing. The containers provide the filesystem sandboxing, and by running DNS for the devcontainer through a pihole (setup in docker-compose), you get the network sandboxing.
|
So, any update on this? https://blogs.microsoft.com/blog/2024/05/03/prioritizing-security-above-all-else/
|
|
@marcelsauer4711 They mentioned here ETA 6 months #84756 (comment) |
@marknuzz No they didn't. |
( I planned to use devcontainers for security sandboxing, |
I have a question regarding vscode extensions. Would love any help and explanations. Thanks you! |
Hey @isidorn if any work has not been done for this I would like to take up this issue to build a sandboxing environment for extensions (probably without breaking any current functionality), and a permission system. |
How is this not high in priority? |
I believe that Visual Studio Code should support some kind of "Extension Permission Management", complete with prompts, warnings, opt-in, and opt-out, similar to what has been supported for some time now with Chrome, Firefox, and other browsers.
Reference Screenshot
I've provided, for reference, some screenshots showing Extension Permission and update prompts and management UIs in the below screenshot, as well as others torwards the end of this proposal.
Chrome prompting to approve additional permissions when updating an extension:
(See additional screenshots at the very bottom.)
Scope and Benefits
I have proposed, in detail here, how Extension Permissions management could function and be exposed to users, including descriptions of dialogs for prompting users to allow/deny permissions on extension install vs. updating, changes to Extensions Sidebar and Extension Details Marketplace pages, grouping/managing extensions by Category/Collection in VSCode, specific warnings and when to show them, types of permissions could define (and whether may default to opt-out or opt-in for them), APIs could provide, how extensions could operate with more limited or conditional functionality, and how could crowdsource extension safety reporting.
I'm also proposing that users can disable Auto-Update behavior for specific extensions, which, besides being useful in its own right, could allow users to stick with previous versions which require fewer permissions, manually review updates for higher-risk extensions, or avoid updating to problematic versions of extensions until issues are resolved.
Related Issues & Discussions
As discussed in Issue #9539 ("Visual Studio Code should update itself silently") regarding enabling silent, auto-updates of VSCode and Extensions) by @alexhass, @kasajian, myself and others, there are some security concerns regarding what permissions are granted to extensions when installing or updating them. As seen there, without such controls, some users aren't even comfortable installing many extensions, allowing them to auto-update once they have, or even allowing VSCode core itself to auto-update.
Proposed User Stories / Features for Extension Permissions Management
Specifically, I propose the following extension permission management features, prompts, and use cases:
1. Display Extension Permission requirements
Clearly labels what permissions are required by each extension in Extensions Details page, with Permission Name (plus Icon) shown underneath the Disable/Uninstall buttons for each permission required/requested.
Clearly label extension permissions, ideally via Icons (along with Name, Author, Description and Rating) in Extensions Sidebar (showing Installed and Available Extensions), at least as Icons next to either A) to left of # of Downloads (Cloud icon), B) to left of Settings (gear icon), or C) to right of Name and Version #, with them grayed out if denied
2. Prompt Users to Approve High-Risk Permissions
Notify user on extension install of potentially dangerous extension permissions and provide ability to opt-out of optional permissions or cancel install, by showing an "Approve Permissions for (ExtensionName)?" (or "Allow (ExtensionName) To?" or "Approve Extension Permissions") dialog:
When Updating Extensions, show users "Approve New Permissions for (ExtensionName)?" prompt
3. Extensions functioning with Optional Permissions denied
Extensions should be able to run with limited functionality when optional permissions are denied, yet be able to prompt user when try to use a feature disabled by denied permissions:
You could provide an API allowing extension to show the Approve Extension Permissions dialog together with a custom message (maybe even custom title too) together with API allowing extensions to check what permissions are currently approved for the extension
Possibly could limit extensions from checking permissions available to other extensions, in case would be security risk with them polling other extensions to find other extensions to automate/interact with as a workaround to their own denied permissions.
Provide "Never Ask Again" button so that a prompt is never shown again for an extension, possibly with option to disable prompts just for just a) specific feature (permission use case/prompt message), b) specific permission, or c) all permissions for this extension.
Can (disabled in VSCode Options) show status bar message and/or play error sound whenever attempt to use a feature (eg. hotkey, F1 action, etc.) unavailable due to denied permissions
Provide API making it flag an action or context menu item as requiring a permission so that will automatically show "(Disabled due to Permissions)" or "(Disabled)" after action names (eg. in F1 command line, menus, etc.), and/or show permission prompt if clicked (or hotkey is used) anyways.
4. Disable higher-risk permissions by default
5. Safety Reporting
6. Modify Permissions Anytime
7. Auto-Update options per Extension
Could provide Undo Update button or choose from version history (like with Chrome/Firefox extension stores) on extension details page, to enable rollback to previous version after an update causes issues, instead of just disabling until if/when ever fixed.
8. Extension Categories Enhancements
Extension Type Categories benefits and use cases:
Show "Extension Type/Category" near the top of the Extension Details Page:
A) to right of Extension Name/ID at top, in parenthesis, B) to right of Author Name, C) a separate Line below Author, D) to the left of the Permissions Names/Icons row, or E) a separate line above the Permissions row.
Group Extensions by Category in Extensions Sidebar
With grouping enabled/disabled via Icon next to "Clear Extensions Input", possibly allowing Expand/Collapse Groups, with options to group by:
- Extension Type/Category (overall, like Language Syntax, etc.)
- Permission (eg. File System, Auto-Save, Auto-Complete, On-Demand Actions), with extensions able to be shown multiple times under multiple groups.
Possible Additional Extension Categories / Subcategories could include
9. Specific Permission Types could include
On-Demand Document Actions
Automated Document Actions
On-Demand Non-Document Actions
Automated Non-Document Actions (or just "Automation")
Document Rendering (or Document/Editor Rendering/Display)
User Interface Extension permissions
File System Permissions
Warning: This is a potential dangerous permission usually not needed for most extensions (such as most Language Syntax extensions) which, when approved, allows the extension to delete, move, rename, create, read, and modify any files or folders on your system (Instead of just those installed with it or otherwise modify contents of opened document tabs user can choose to save), so you should only enable it for extensions you trust and may want to deny this permission when optional or cancel install of extensions which don’t allow opt-out, especially if seems like this wouldn't be necessary for the type of extension.
Networking (or Internet, or Web Service Use)
Open Files (as Document Tabs)
Auto-Save (Opened Documents)
Manage Document Tabs
Create New Documents (opened as Document Tabs)
Task Management
Source Control
Process Control
Full System Control
Launching Processes
Alternative Names: "Execute" or "Run/Debug Code/App" or "Launch / Run / Debug"
Description: Allow to start new processes or launch applications in background, such as is often required to Run, Build, or Debug code.
You could possibly allow extensions requiring this or similar permissions (or provide to any extension, if/when needed) the ability to save contents of an open document with unsaved changes to a temporary file, and provide the file path to that temp file to the extension - but without providing the extension the ability to modify/overwrite that temp file by default. This would reduce risk of a malicious extension being able to save and execute arbitrary code into a temp file without that code being first shown in the opened document tab.
You can even, if necessary, delay any process launching until X milliseconds after any extension-automated changes (eg. auto-formatting) made to opened document contents.
Possibly can restrict, as defined in extension manifest and shown in Extension Details Page, what executable names are allowed. Then, at worst, the extension would have to inject malicious code into an open script document and require user
Possibly can restrict (without requiring separate higher-risk permission) whether any variable command line args are allowed for it other than file name and pre-declared ones to prevent passing arbitrary code via command line to execute.
Possibly separate permission for launching processes for exe's that are just bundled with extension vs. already installed on the system.
10. Sandboxing Extensions
What, if anything, has already been done to provide or attempt extension sandboxing or security with VSCode?
As I understand, VSCode is based on Electrum which, by design, disables much of Chromium's facility for sandboxing to enable native API access. However, Electron and Node.js both have some facilities for sandboxing and security, and there are a few projects extending support for these, as detailed below:
Electron/Node.js Sandboxing/Security References and Options to Consider
Might the following be useful references for implementing Sandboxing in VSCode?
Node.js / JavaScript Sandboxing Projects
Would any of Node.js's facilities for sandboxing / security possibly be applicable here, or any of the following projects providing sandboxing for Node.js or otherwise?
Additional Reference Screenshots
You can see some additional good examples of Extension Permission prompts and management in the screenshots below:
Chrome prompting user to confirm higher risk permissions (and in language very clear to the user), when installing an extension:
Chrome prompting user to enable additional requested permissions when updating an extension:
Chrome allowing modifying some permissions for installed extensions, like "Allow in incognito":
Firefox allowing managing Auto-Update behavior for installed extensions:
Firefox allowing changing permissions from sidebar for installed plugins, such as to control "Ask to Activate" behavior:
Labels
Suggested additional labels for this issue:
install-update
Possible additional labels:
api-proposal, extension-host
The text was updated successfully, but these errors were encountered: