Skip to content
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

fix(permissions): disallow any LD_ or DYLD_ prefixed env var without full --allow-run permissions #25271

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions runtime/ops/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ fn create_command(
permissions.check_run(&args.cmd, api_name)?;
// error the same on all platforms
if permissions.check_run_all(api_name).is_err()
&& (args.env.iter().any(|(k, _)| k.trim() == "LD_PRELOAD")
&& (args.env.iter().any(|(k, _)| k.trim().starts_with("LD_"))
|| !args.clear_env
&& std::env::vars().any(|(k, _)| k.trim() == "LD_PRELOAD"))
&& std::env::vars().any(|(k, _)| k.trim().starts_with("LD_")))
{
// we don't allow users to launch subprocesses with the LD_PRELOAD
// env var set because this allows executing any code
// we don't allow users to launch subprocesses with any LD_ env var set
// because this allows executing code (ex. LD_PRELOAD)
return Err(deno_core::error::custom_error(
"PermissionDenied",
"Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable."
"Requires --allow-all permissions to spawn subprocess with any LD_* environment variable."
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/run/ld_preload/env_arg.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: Uncaught (in promise) PermissionDenied: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
error: Uncaught (in promise) PermissionDenied: Requires --allow-all permissions to spawn subprocess with any LD_* environment variable.
}).spawn();
^
at [WILDCARD]
2 changes: 1 addition & 1 deletion tests/specs/run/ld_preload/set_with_allow_env.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: Uncaught (in promise) PermissionDenied: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
error: Uncaught (in promise) PermissionDenied: Requires --allow-all permissions to spawn subprocess with any LD_* environment variable.
const output = new Deno.Command("echo").spawn();
^
at [WILDCARD]
Loading