-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
[security] Hide require('fs')
API method calls behind permission & add vscode.FileSystem
arbitrary directory whitelist
#174715
Comments
@sbatten, assigning to you to start for workspace trust. |
|
|
require('fs')
with arbitrary directory whitelist, maybe whitelist PATH
I had an idea for unsafe/compatibility mode, especially for the following scenario:
Ideally in this scenario (supported lower vscode version / no extension version lock... combined with locked down vscode API), we don't error out on each run What we could do:
UX workflow to use for
|
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
Adjusted strat proposal for backwards compatibility - #174715 (comment) - thoughts @worksofliam @mattseddon |
require('fs')
with arbitrary directory whitelist, maybe whitelist PATHrequire('fs')
in favour of vscode.FileSystem
arbitrary directory whitelist, maybe whitelist PATH
require('fs')
in favour of vscode.FileSystem
arbitrary directory whitelist, maybe whitelist PATHrequire('fs')
as vscode.FileSystem
arbitrary directory whitelist, maybe whitelist PATH
Not allowing It will basically just end up being that most extensions need to request this permission and any security benefit from it will be rather small to non existent, but in return, annoying every single extension developer with this, and every single user with pointless security prompts. An OS level transparent sandbox makes more sense (Like Chromium does), as it won't require changing the code completely if it doesn't access anything it is not supposed to, or just add the small amount of additional stuff it does need. |
This change will have a significant impact. When extensions were locked down in Chrome 70 behind a website-specific permissions system, it basically brought the most useful extensions in the web store to ground 0. But the change was celebrated because people could reject "read all files" extensions & otherwise click "OK" once.As explained in #174715 (comment) these requests can be batched as much as possible and borrow as much as possible from the existing permissions UX in browsers.
UI extensions will be unaffected. People will use native APIs instead of Node.js ones.
I see. Well the security concern described in this issue is big IMHO. I also don't think such security prompts are pointless - my previous employer had an IT policy that banned marketplace access in Visual Studio Code, just to enforce a sane level of filesystem restriction. Hopefully this kind of feature can be well made - people never complain about Chrome extension security prompts. With good UI and UX work (and learning from Chromium's extension perms as a UI-UX success), this will be something the extension devs can be happy about, or just indifferent to.
EDIT: Just noting that the use of |
They are not pointless only when its not everyone asking for that permission, VS Code's primary strength come from LSPs and running other linters and so on, so most useful extensions will ask for that, once an extension can do that it breaks any sort of security this achieve in the first place... After all a native process separate from the extension host can do whatever... |
I don't think that's VS Code's primary strength.. its just one of them. VS Code is for web technologies and first and foremost.. one of its biggest USPs is the browser support and even language service features (example 1, example 2). Will sandboxing protect documents and source codes in the filesystem? I didn't think sandbox at the OS level would scale to all flavours of OS and environment either. This ticket is meant to support the server codespace described in microsoft/vscode-remote-release#6608 - how can we ensure the filesystem's integrity? The important thing is that users consent with <=1 popup ever to the extension using API methods from The VS Code app can register a conditional permission wrapper for the FileSystem Node module in the extension host worker for each extension. The change would put the user on two decision paths:
EDIT: I notice that the extension host process is already sandboxed so that won't be a technical blocker RE: app resources here.. each extension will have its own set of permissions and readwrite access |
require('fs')
as vscode.FileSystem
arbitrary directory whitelist, maybe whitelist PATHrequire('fs')
and add vscode.FileSystem
arbitrary directory whitelist, maybe whitelist PATH
require('fs')
and add vscode.FileSystem
arbitrary directory whitelist, maybe whitelist PATHrequire('fs')
behind permission & add vscode.FileSystem
arbitrary directory whitelist
This won't even lock down access to the file system. Consider the following line of code:
which can easily be run using |
That would be patched by #174714. |
It occurs to me that the solution involves wrapping every exported function in the
This will significantly reduce the impact of this issue. Thoughts? |
require('fs')
behind permission & add vscode.FileSystem
arbitrary directory whitelistrequire('fs')
API method calls behind permission & add vscode.FileSystem
arbitrary directory whitelist
I've given the thread a temperature test - it's clear there is little appetite in the extension developer community for it. Will Unsubscribe and let it run passively edit: |
This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
Replaced by #180233 per collective user request. |
This feature request is part of an "epic" suggestion in #52116 (comment)
contributes.permissions.filesystem.readFile
andcontributes.permissions.filesystem.writeFile
array to define extra IO capacities forvscode.workspace.fs
.--force
CLI command that skips the prompt but keeps the extension off until the UI okays it.We can add a secret in
vscode-test
package and a APIvscode.Extension
method that accepts the token & enables the ext.PATH
as an opt-in would be beneficial. Ideally we should be honoring PATH by default, adding some kind of OS sandbox so those can't be used.require('fs')
and any aliases+submodules after these changes - also disable the extension.Probably link to a
contributes.permissions.*File
API tracking issue in the console error.Also trigger some kind of workflow to re-enable the 1 extension that's unsafe - presumably one top-right
🧩 Extension
alert like in Chromium.Debounce permissions requests by about 5-10 seconds and if there are multiple (possibly @ startup event), do a modal.
Keywords: security, fs, filesystem, IO, extension, API, exthost, node, nodejs, permissions, sandbox, readwrite, readfile, writefile
The text was updated successfully, but these errors were encountered: