-
Notifications
You must be signed in to change notification settings - Fork 129
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
Executing incomplete commands is too dangerous #8
Comments
whitelisting commands should be the default IMHO |
White/black lists are a possible solution. Alternatively, consider running the command only after the user has typed a |
How about not executing the command until the user types a space? If you add a shell parser you could recognize quoting and not execute the command until the quote is closed (to avoid executing with quoted arguments with space). Its also possible to try to do this only for program names (not their arguments) and allow incomplete execution with arguments (again, a shell parser is useful to recognize pipelines). Otherwise there is a small downside of requiring a space after the last argument, but I think that is could be easy for users to learn. I find the current behavior of running incomplete commands to be dis-orienting. At first I had the text I wanted, but now I have to look at this while typing:
up could instead offer auto-complete while typing a program name. |
Someone on news.ycombinator.com suggested to use Linux namespaces to make the filesystem read-only by default. IMHO his is a cleaner solution although it's Linux only. https://news.ycombinator.com/item?id=18293931 |
In my opinion, neither whitelisting nor blacklisting would be a good solution (by which I mean, not good enough to induce me to use the tool or recommend it to anyone else). Either whitelisting or blacklisting means I have to maintain a list of commands that are considered "safe" or "dangerous". No such list can be complete and accurate, and I'll very likely want to be able to execute (carefully) a command that's considered "unsafe". (I just ran a script and found several thousand cases of a command in my It happens that I don't have commands in my rubenbe suggested making the file system read-only. Not all dangerous or undesirable actions necessarily involve modifying the file system -- and I might very well want to execute a command that modifies the file system. The only solution that would let me use this tool, or recommend it to anyone else, is to require explicit user action to execute a command. Automatically executing commands as I type them is a dealbreaker. I'm not sure that TAB is the best way to request executing a command. Tab completion would be a useful feature. Typing ENTER doesn't currently see to do anything; perhaps ENTER could cause the current command to be executed while leaving the command in place to permit more typing. |
rm -rf /home/$USER/tmp/* |
For the record: based on ideas from good people on lobste.rs, HN, here, reddit, etc, my current quick thoughts are like this:
I'll try to see if anyone brings some more ideas somewhere, and to think about it some more. Please note I can't promise how fast I'll implement anything in this area. I'm not sure to what extent I'll be excited or tired with the project once the "release adrenaline" weathers off. Thanks a lot for your patience! I totally super appreciate all your ideas, thoughts, and contributions! They already opened my horizons to some ideas I wasn't aware of, as well as helping me see the main concerns you're having with the tool, as well as the things you seem to like about it! :) @gregwebs As to the disorienting behavior, I'm trying to ponder various options for retaining the output for longer time, esp. over failed commands. See especially #4 for some interesting idea that didn't occur to me earlier at all! Also your idea about auto-completion is not something I thought of earlier either, I believe; noted in my notebook, for sure, thanks! Though I'm generally kinda on the fence to what extent the up's editor should be developed... I like to fancy the idea of some kind of integration with general purpose editors, like vim/emacs/VSCode/... and keeping up only as a kind of a hidden service for them... Thanks a lot again! There will be a lot of thinking to process for me after the dust settles... |
I found this related to unshare with go:
maybe it helps |
Ehhh, Ctrl-Enter won't work, because on Linux Enter is already Ctrl-M..... grrrrrrr >:-| |
Since this hasn't been mentioned before: seccomp You can disable certain syscalls by loading a seccomp filter that denies any call to unlink(2), unlinkat(2) or the various open calls that have O_RDWR|O_WRONLY|O_CREAT set. This filter also applies to grand-children, grand-grand-children etc. If done correctly you can ensure that no child process can alter the system, but setting up this filter correctly requires some work and only works on linux. This approach would work better than namespaces though since you either need to be root to setup a namespace or a kernel that has user namespaces enabled, which most distros don't do due to security reasons. |
Some general thoughts. This tool is not exactly a shell, but it's very similar to one. In particular, it's a tool that can be used interactively to execute arbitrary commands on behalf of the user who's running it. Based on that, I suggest that:
In my opinion, playing OS-level tricks to intercept system calls by child processes should be considered outside its scope. Shells don't have or need blacklists or whitelists; I don't think Tentatively executing commands as they're typed (e.g., attempting to run I'd like to see this tool simply execute commands and show their output when I type Enter, and not before. That's how shells behave. The "special sauce" is that after I've typed Enter, I can continue typing and see the result of changing or extending the command. And it's in a curses-like window, so if the output is 1000 lines long it doesn't clobber my scrollback. Let it do that one thing well. |
Just pressing Note: Enabling auto-completion with |
I wrote
All kidding aside, |
Fixed in v0.2 / v0.2.1, by changing the default behavior to "Press Enter to run". For sketching potential alternative approaches for future, I added a wiki page titled: idea: limiting permissions. I made the wiki open for editing & collaboration, if you like to contribute some ideas. Please keep it terse so it won't get overworded (I reserve myself the right to cleanup and "censor" the wiki). Please note I am not sure if I will implement any of those ideas, but I am not sure that I won't either. They are certainly interesting, inspiring, and intelectually stimulating! And the tool would not exist without a lot of inspiration sources! Thanks to everybody for a lot of ideas and a great discussion! |
This looks like a very useful tool, but I won't use it on my system as long as it automatically executes incomplete commands as they're being typed.
It shouldn't execute a command until it's explicitly told to do so. Hitting the TAB key might be one reasonable way to do that.
The text was updated successfully, but these errors were encountered: