-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Remove --allow-run .. rather people should use --allow-all #3378
Comments
I wonder if there could be a way to restrict the run, in the same way net/read etc. e.g. starts with how are most people using |
+1 I've pointed this out before. I guess the downside is losing any way of having more granular run permissions... but when would untrusted remote code be using your carefully written project-local scripts? I think they would normally want access to arbitrary common OS utilities which are often more powerful than they seem and just broadly not compatible with any sandboxing attempt. It's too easy to deceive upon. |
Hmm but this means we are gaining extra privilege besides all |
Because the permissions of the child process cannot be restricted. Running a child process means that it has all the permissions. So I think this makes sense. #!/usr/bin/env -S deno --allow-run
const { run, args, env } = Deno;
// get all permission
if (args.includes("--with-all-permission") == false) {
const command = ["deno", "--allow-all"]
.concat(args)
.concat(["--with-all-permission"]);
const ps = run({
args: command,
stdin: "inherit",
stderr: "inherit",
stdout: "inherit"
});
await ps.status();
} else {
// do the staff with all permission
console.log(env());
} $ deno demo.ts --allow-run |
@ry Yes, this is what I was talking about in #2128 in April - totally true that it makes no sense to have But I see a value in having By the way, as I explained in #2128 I think that there should be a separate permission to run child process of Deno programs with the same interpreter and the same (or with a subset of) privileges than the current process has. This will be the only way to run subprocesses safely without privilege escalation and I think running Deno subprocesses safely will be an important feature to have. In #2128 I also was thinking about the flag names. If we have two flags for:
then I see either:
My idea was either: Keeping the existing
or changing the current
Edit: See also my comments in #2081 (1, 2) where I originally came up with the idea for more examples. |
How about run({
args: ["/bin/bash", "-c", "do what ever you want"]
}) The same reason, once the child progress is turned on, there is no way to bind |
@axetroy of course when you allow to spawn a shell then all bets are off, but this is at least explicit and obvious. If bare |
I still see Deno is useful for config generation because you can lock it down. For instance, you don't want a config program to be able to read environment variables so that the output is consistent. But you may wish to allow the program to run |
@ry Now that |
use But there are libraries that need to be cross-platform, and each platform runs a different script Once more libraries are referenced by the project Then the For example a library I wrote deno_machine_id Then to run this library, you need
Imagine that, this is just a reference to a library What if 10 libraries or more are referenced? This command will become very, very long and unmaintainable This is a problem that i worry about |
It could parse as a CSV list to keep the whitelist args approach shorter. I like the flexibility. If you must maintain a long list you could put the whitelist in code before calling the library. |
A proposal: Change the help text to look like this:
This does the following
If Beyond all that, it would be interesting if users could specify specifc subcommands in the whitelist. For example:
That would allow a script to run Restricting the whitelist to specific subcommands also covers @rsp's use case of allowing a Deno subprocess with specific permissions. |
As noted in my duplicate filed issue - this is very misleading (a false sense of security is worse than no security), so the allow-run flag is very dangerous. |
I know it is a bit of a pain, but better UX to have |
I'm still very much against removing it. As explained many times above it is still a useful feature outside of security. Further, taking a binary whitelist approach as I propose above does make this a secure feature. Improve the help text messaging and consider a change to allow-unsafe and it is done. |
This thread's a bit stale huh 😟 I'm also a big fan of the Some examples of how I'd use a scoped run permission:
This doesn't prevent a passlisted program from letting you read an arbitrary file, like you could have a Dockerfile that adds I don't see reason to require an absolute path; A prior art on the usefulness of limited-scope subprocesses would be the sudoers file on Linux: Prior Art: sudoers file## Allows members of the users group to mount and unmount the cdrom as root
%users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom
## Allows members of the users group to shutdown this system
%users localhost=/sbin/shutdown -h now
## Allows users to export SMART statistics from any connected hard drive
%users ALL=/usr/sbin/smartctl -a -- *
## Allows admin users to start or stop WireGuard tunnels
%wheel ALL=/bin/systemctl start wg-quick@*, /bin/systemctl stop wg-quick@*
## Groups of commands to allow
Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp
Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall This file is a list of commands that allows non-root users to run commands as root (among other arrangements). The granted commands could be a very specific whole command, or a specific binary to run with whatever, or just a straight wildcard to do anything. This amount of wildcard expressiveness is probably overkill for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
This has never happened. You can still use |
Sorry @bartlomieju, I think this issue was maybe the wrong place to comment so I filed a more thorough issue because it did just happen to me:
Sorry, but this is seems like a major security regression to me. |
When you execute a subprocess there's no guarantees of what it can do - all security bets are off.
--allow-run
masks this and is an extra command line flag. Therefore I suggest removing it entirely and requiring users to supply--allow-all
.The text was updated successfully, but these errors were encountered: