-
Notifications
You must be signed in to change notification settings - Fork 503
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
Force shell option #2552
Comments
Regardless of which shell is used, doesn't a justfile potentially contain arbitrary code which might be dangerous? |
I was assuming no but perhaps that is not correct? If we assume that the shell is safe (because this would be a custom shell that is designed to be safe... or perhaps the shell is a wrapper to making a call inside a container), then are there native justfile commands that could be unsafe? Hm, maybe an easier alternative would be to have a standalone justfile parser and have the caller parse the justfile before running, and raise an error if it contains import or shell-set commands... |
Note also that the shell for a justfile can be anything: what if you end up forcing a In the interest of avoiding a XY problem in this issue, could you please explain what is the end goal you would like to achieve? |
Are you sure? The shell could be a wrapper to a sandbox, in which case it could try to run python but best case, it would still run in the sandbox.
Yea, but then your bash-like shell isn't safe and is not the one I would choose to force. There are many other ways to achieve a "safe" shell without permitting circumvention. The "safe" shell could simply be a wrapper to which runs bash inside a safe container-- e.g. docker or wasmtime-- in which case even if the shell invokes Python, it is still contained. Or it could be a custom shell such as is the subject of this discussion.
A simple example use would be an online Justfile playground. This isn't exactly my use case but faces similar requirements (and could probably be pretty useful to add to this repo!). The user can enter whatever justfile they want, and hit "Run", and then they see the output of that. Typically, "playground" means it runs on the client via e.g. JS and/or wasm. However, there are a few problems with this when it comes to
A force-shell option would be a simple solution by making it possible to ensure that the shell is always invoked inside a container even if the |
Thanks for the clarification! For cases like that, it would definitely be best to sandbox/containerize the entire And having |
Yea, but that can't always work. For example, |
How does this prevent being able to sandbox/containerize the |
My target sandbox-- for where shell commands run (does not need to be where |
So I'm honestly pretty skeptical of this 😅 But for the sake of the discussion: Just has three sources of commands which it invokes:
If you control or can audit, with a custom shell, the arguments and environment variables passed to nested
You could add new flags which could force the second two somehow. But probably the best thing would be to add a single flag or environment variable which forced the command in all cases to match a given path, like:
And then invocation of any command which wasn't This seems pretty dangerous though, since |
Thanks again liquidaty for providing more details.
In the absence of being able to sandbox the
What makes
Would a CLI option to run all subprocesses via a custom "wrapper command" help? (which as noted is not a complete solution, but would seem to be more comprehensive and less issue-prone than forcing shell?) |
(updated to respond to @laniakea64's contemporaneous post)
Could probably get it to run but it would not be able to invoke any shell at all because of wasm limitations (fork, threading etc). But, maybe this is a compatible goal with the experimental no-shell version and could be a key part of the solution described below
That would definitely be sufficient
If all occurrences of read/write/invoke in the source are centralized and any safety issues handled there, is anything else left? But I understand the concern. To work with a wasmtime version, the problem is that I need some If those three things could be done, then I would be set:
So maybe I should first be trying to prod those other issues along...
Will put some more thought into this
see above-- main limitation is that it basically has to be single-process, single-threaded. But, that does not have to be a fatal limitation for my purposes-- see above
Yes! 100% |
I'm looking for a way to safely run arbitrary Justfiles. I've considered several approaches and they generally require being able to specify a custom "safe" shell that cannot be subsequently changed (i.e.
set shell
in a Justfile would be disregarded, and the custom shell must be propagated for any nestedjust
calls).For example, the shell might be specified in the invocation e.g.
just --shell-force X --shell-force-arg Y
, or in an environment variable such as JUSTFILE_SHELL_FORCE (which perhaps requires less work to ensure propagation to nestedjust
calls).Thoughts? Is there a better way to do this? If we submit a PR for this or otherwise assist in the work to implement, would you consider accepting?
The text was updated successfully, but these errors were encountered: