Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix: reject empty sandbox environment values

Steven Enamakel72dbec885557
diff --git a/crates/openhuman-core/src/agent/platform_shell.rs b/crates/openhuman-core/src/agent/platform_shell.rs
index 6be83e15a5..36e804b87e 100644
--- a/crates/openhuman-core/src/agent/platform_shell.rs
+++ b/crates/openhuman-core/src/agent/platform_shell.rs
@@ -97,32 +97,40 @@ pub fn assert_forwards_windows_bootstrap(allowlist: &[&str], launcher: &str) {
/// Add Windows bootstrap variables to a host child. Keep these out of the
/// sandbox policy because that policy is also forwarded into Linux containers.
#[cfg(windows)]
-pub fn forward_windows_bootstrap_env(cmd: &mut tokio::process::Command) {
+pub fn forward_windows_bootstrap_env(cmd: &mut tokio::process::Command) -> anyhow::Result<()> {
for var in WINDOWS_PROCESS_ENV_VARS {
if let Ok(val) = std::env::var(var) {
- if !val.is_empty() {
- cmd.env(var, val);
+ if val.is_empty() {
+ anyhow::bail!("Windows bootstrap environment variable {var} is empty");
}
+ cmd.env(var, val);
}
}
+ Ok(())
}
#[cfg(not(windows))]
-pub fn forward_windows_bootstrap_env(_cmd: &mut tokio::process::Command) {}
+pub fn forward_windows_bootstrap_env(_cmd: &mut tokio::process::Command) -> anyhow::Result<()> {
+ Ok(())
+}
#[cfg(windows)]
-pub fn forward_windows_bootstrap_env_std(cmd: &mut std::process::Command) {
+pub fn forward_windows_bootstrap_env_std(cmd: &mut std::process::Command) -> anyhow::Result<()> {
for var in WINDOWS_PROCESS_ENV_VARS {
if let Ok(val) = std::env::var(var) {
- if !val.is_empty() {
- cmd.env(var, val);
+ if val.is_empty() {
+ anyhow::bail!("Windows bootstrap environment variable {var} is empty");
}
+ cmd.env(var, val);
}
}
+ Ok(())
}
#[cfg(not(windows))]
-pub fn forward_windows_bootstrap_env_std(_cmd: &mut std::process::Command) {}
+pub fn forward_windows_bootstrap_env_std(_cmd: &mut std::process::Command) -> anyhow::Result<()> {
+ Ok(())
+}
/// Whether the Unix arm prefixes `set -o pipefail`.
#[derive(Clone, Copy, PartialEq, Eq)]
diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rs
index 6c4f83bfdf..344719b9c1 100644
--- a/crates/openhuman-core/src/sandbox/ops.rs
+++ b/crates/openhuman-core/src/sandbox/ops.rs
@@ -273,12 +273,13 @@ async fn execute_unsandboxed(
cmd.env_clear();
for var in SANDBOX_ENV_PASSTHROUGH {
if let Ok(val) = std::env::var(var) {
- if !val.is_empty() {
- cmd.env(var, val);
+ if val.is_empty() {
+ anyhow::bail!("sandbox passthrough environment variable {var} is empty");
}
+ cmd.env(var, val);
}
}
- platform_shell::forward_windows_bootstrap_env(&mut cmd);
+ platform_shell::forward_windows_bootstrap_env(&mut cmd)?;
for (k, v) in extra_env {
cmd.env(k, v);
}
@@ -404,12 +405,13 @@ async fn execute_local_jail(
cmd.env_clear();
for var in SANDBOX_ENV_PASSTHROUGH {
if let Ok(val) = std::env::var(var) {
- if !val.is_empty() {
- cmd.env(var, val);
+ if val.is_empty() {
+ anyhow::bail!("sandbox passthrough environment variable {var} is empty");
}
+ cmd.env(var, val);
}
}
- platform_shell::forward_windows_bootstrap_env_std(&mut cmd);
+ platform_shell::forward_windows_bootstrap_env_std(&mut cmd)?;
for (k, v) in extra_env {
cmd.env(k, v);
}