Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 10 additions & 1 deletion crates/osoosi-sandbox/src/tiered_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,16 @@ pub fn spawn_tier2_appcontainer_command(
use std::os::unix::process::CommandExt;
let _ = (agent_id, scratchpad_root, job);
let mut cmd = std::process::Command::new(&verified_exe.metadata.canonical_path);
cmd.args(args);
if verified_exe.metadata.normalized_stem == "cmd"
&& args
.first()
.map(|s| s.eq_ignore_ascii_case("/c"))
.unwrap_or(false)
{
cmd.arg("-c").arg(args[1..].join(" "));
} else {
cmd.args(args);
}

// Pre-exec isolation: PR_SET_NO_NEW_PRIVS and optional cgroup.procs binding
unsafe {
Expand Down
26 changes: 22 additions & 4 deletions crates/osoosi-sandbox/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,28 @@ pub fn execute_confined_windows_process(
policy: &WindowsConfinementPolicy,
) -> Result<ConfinementTransitionOutcome, String> {
verify_windows_confinement_invariants(policy)?;
let output = std::process::Command::new(program)
.args(args)
.output()
.map_err(|e| e.to_string())?;
let output = if program.eq_ignore_ascii_case("cmd.exe") || program.eq_ignore_ascii_case("cmd") {
let remaining_args: Vec<&str> = if let Some(first) = args.first() {
if first.eq_ignore_ascii_case("/c") {
args[1..].to_vec()
} else {
args.to_vec()
}
} else {
Vec::new()
};
let joined = remaining_args.join(" ");
std::process::Command::new("/bin/sh")
.arg("-c")
.arg(joined)
.output()
.map_err(|e| e.to_string())?
} else {
std::process::Command::new(program)
.args(args)
.output()
.map_err(|e| e.to_string())?
};

Ok(ConfinementTransitionOutcome {
resume_thread_allowed: true,
Expand Down
Loading