code-server
code-server copied to clipboard
Is there a way to disable the terminal?
Hi. I was wondering if it was possible to disable the terminal. This would involve both removing from the UI and preventing terminal requests from being processed by the server. Or if you could direct me to the part of the code where terminal requests are handled, that would be helpful. I've been looking at the code for a few days now, but am finding the execution flow very difficult to follow. Thx.
There's no way to disable it at the moment so we'd need to add it.
The terminal requests are handled via the extension host protocol. The server-side implementation is in lib/vscode/src/vs/workbench/api/node/extHostTerminalService.ts so maybe we could just throw errors if those methods are called and terminals are disabled.
Terminals are used for debugging as well so doing this will also disable debugging.
In terms of the UI I think it might be better to leave everything in and show a message when trying to access the disabled functionality. Something like "terminals have been disabled" just to prevent anyone from thinking the missing terminals are a bug or something like that especially if they're familiar with VS Code already.
For the terminal we can write a message in lib/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts by adding an xterm.write("message")
.
You might have already considered this but just in case you'll also probably need to disable installing new extensions (or whitelist extensions in some way) and make the extensions directory read-only (or restrict the file picker, see https://github.com/cdr/code-server/issues/1834) so users can't add an extension that just bypasses all this and gives them access to run commands on the system.
Depending on your goal it might be easier to run code-server in some kind of jail but I think we plan on doing this for collaboration eventually anyway (we'd disable all the "dangerous" stuff for the guests) so it wouldn't be bad to get a start on it.
Any updates?
No work has been done here yet.
Regarding the security aspect, also consider the VS Code tasks system, Git hooks, and probably a lot more. The attack surface here is extremely large.
Any updates?
No updates. For now it's still in the backlog and I think it's unlikely we will get to it any time soon.
Any update?
No, the issue is still on the backlog.
If someone picks this up here are some investigation notes: https://github.com/coder/code-server/discussions/6138#discussioncomment-5585235