diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-09-17 00:08:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 23:08:02 +0000 |
commit | b0525edd6fb2fa414407ec73c981051d692d1c26 (patch) | |
tree | 0e21ef4b2667f6882d6c52f24d27cc26d3696403 /cli/args/mod.rs | |
parent | f7ddea3af7a9f4dfef23aa544f05348dabbad20d (diff) |
feat: warn when using `--allow-run` with no allow list (#25215)
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 0e4004a53..db8cf149e 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -809,6 +809,8 @@ impl CliOptions { } } + warn_insecure_allow_run_flags(&flags); + let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache); let deno_dir_provider = Arc::new(DenoDirProvider::new(flags.cache_path.clone())); @@ -1688,6 +1690,27 @@ impl CliOptions { } } +/// Warns for specific uses of `--allow-run`. This function is not +/// intended to catch every single possible insecure use of `--allow-run`, +/// but is just an attempt to discourage some common pitfalls. +fn warn_insecure_allow_run_flags(flags: &Flags) { + let permissions = &flags.permissions; + if permissions.allow_all { + return; + } + let Some(allow_run_list) = permissions.allow_run.as_ref() else { + return; + }; + + // discourage using --allow-run without an allow list + if allow_run_list.is_empty() { + log::warn!( + "{} --allow-run can be trivially exploited. Prefer specifying an allow list (https://docs.deno.com/runtime/fundamentals/security/#running-subprocesses)", + colors::yellow("Warning") + ); + } +} + /// Resolves the path to use for a local node_modules folder. fn resolve_node_modules_folder( cwd: &Path, |