diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-08-27 22:03:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-27 22:03:09 -0400 |
commit | 1a6fd38f2f7b016714ec313ce234fd5356aa956a (patch) | |
tree | f6452c1f7f5939ff12dc4a8b99890507a4079a63 /runtime/ops | |
parent | b1b72a8a4943f9c40e253f243f9b77abf67b3faf (diff) |
fix(permissions): disallow launching subprocess with LD_PRELOAD env var without full run permissions (#25221)
Ref https://github.com/denoland/deno/pull/25215
Closes https://github.com/denoland/deno/issues/11964
Diffstat (limited to 'runtime/ops')
-rw-r--r-- | runtime/ops/process.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 9d166a801..564092454 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -229,9 +229,23 @@ fn create_command( mut args: SpawnArgs, api_name: &str, ) -> Result<CreateCommand, AnyError> { - state - .borrow_mut::<PermissionsContainer>() - .check_run(&args.cmd, api_name)?; + { + let permissions = state.borrow_mut::<PermissionsContainer>(); + 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.clear_env + && std::env::vars().any(|(k, _)| k.trim() == "LD_PRELOAD")) + { + // we don't allow users to launch subprocesses with the LD_PRELOAD + // env var set because this allows executing any code + return Err(deno_core::error::custom_error( + "PermissionDenied", + "Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable." + )); + } + } let mut command = std::process::Command::new(args.cmd); |