The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix: block direct credential paths in execution tools
Steven Enamakelaf6a303ea8ae
diff --git a/crates/openhuman-core/src/security/policy/command_checks.rs b/crates/openhuman-core/src/security/policy/command_checks.rsindex 49091d6ff3..0935496bb4 100644--- a/crates/openhuman-core/src/security/policy/command_checks.rs+++ b/crates/openhuman-core/src/security/policy/command_checks.rs@@ -1,4 +1,5 @@use crate::util::floor_char_boundary;+use std::path::{Path, PathBuf};use super::types::{AutonomyLevel, CommandClass, CommandRiskLevel, GateDecision, SecurityPolicy,@@ -201,6 +202,7 @@ impl SecurityPolicy {/// Returns the classified [`CommandClass`] on success.pub fn check_gated_command(&self, command: &str) -> Result<CommandClass, String> {let class = self.classify_command(command);+ self.check_protected_path_literals(command)?;if !self.enabled {return Ok(class);}@@ -222,6 +224,49 @@ impl SecurityPolicy {Ok(class)}+ /// Refuse literal references to the protected-path floor before launching+ /// a command, including when the autonomy policy is disabled. This is a+ /// guard for direct path arguments and source literals; arbitrary shell or+ /// interpreter code still needs a filesystem sandbox to enforce the floor.+ pub fn check_protected_path_literals(&self, input: &str) -> Result<(), String> {+ let home = dirs::home_dir();+ let mut expanded = strip_quoted_heredoc_bodies(input).into_owned();+ if let Some(home) = home.as_ref().and_then(|p| p.to_str()) {+ expanded = expanded.replace("${HOME}", home).replace("$HOME", home);+ expanded = expanded.replace("%USERPROFILE%", home);+ }++ for word in expanded.split(|c: char| {+ c.is_whitespace() || matches!(c, '\'' | '"' | '(' | ')' | '[' | ']' | ',' | ';' | '=')+ }) {+ let word = word.trim_matches(|c: char| matches!(c, ':' | '<' | '>' | '&' | '|'));+ if word.is_empty() || word.contains("://") {+ continue;+ }+ let candidate = if word == "~" || word.starts_with("~/") {+ PathBuf::from(self.expand_tilde(word))+ } else {+ PathBuf::from(word)+ };+ let candidate = if candidate.is_absolute() {+ candidate+ } else {+ self.action_dir.join(candidate)+ };+ if Self::is_always_forbidden(&candidate)+ || candidate+ .canonicalize()+ .ok()+ .is_some_and(|path| Self::is_always_forbidden(Path::new(&path)))+ {+ return Err(format!(+ "{POLICY_BLOCKED_MARKER} Command references a protected path"+ ));+ }+ }+ Ok(())+ }+/// Parse an LLM-declared command category. This is an **escalate-only**/// hint: callers combine it with the deterministic floor via/// `classify_command(cmd).max(declared)`, so the model can *raise* the gatediff --git a/crates/openhuman-core/src/security/policy/path_checks.rs b/crates/openhuman-core/src/security/policy/path_checks.rsindex 2ce9295819..954f80a5f2 100644--- a/crates/openhuman-core/src/security/policy/path_checks.rs+++ b/crates/openhuman-core/src/security/policy/path_checks.rs@@ -475,6 +475,20 @@ impl SecurityPolicy {if segments.iter().any(|s| SENSITIVE_COMPONENTS.contains(s)) {return true;}+ // Single-file credential stores have no protected parent directory.+ const SENSITIVE_FILES: &[&str] = &[".netrc", ".git-credentials", ".pgpass", ".npmrc"];+ if segments.iter().any(|s| SENSITIVE_FILES.contains(s)) {+ return true;+ }+ if segments.windows(2).any(|w| w == [".docker", "config.json"]) {+ return true;+ }+ if segments+ .windows(2)+ .any(|w| w == [".cargo", "credentials.toml"])+ {+ return true;+ }// Windows DPAPI / credential stores live under `…\Microsoft\{Protect,// Credentials,Crypto,Vault}` — match the pair so the generic second// name can't false-positive an unrelated project directory.diff --git a/crates/openhuman-core/src/tools/impl/system/node_exec.rs b/crates/openhuman-core/src/tools/impl/system/node_exec.rsindex 76b647388c..8405de5e49 100644--- a/crates/openhuman-core/src/tools/impl/system/node_exec.rs+++ b/crates/openhuman-core/src/tools/impl/system/node_exec.rs@@ -194,6 +194,15 @@ impl NodeExecTool {));}let path_policy = super::security_for_tool_context(&self.security, context, "node_exec");+ for input in inline_code+ .iter()+ .chain(script_path.iter())+ .chain(extra_args.iter())+ {+ if let Err(reason) = path_policy.check_protected_path_literals(input) {+ return Ok(ToolResult::error(reason));+ }+ }if self.security.is_rate_limited() {return Ok(ToolResult::error("Rate limit exceeded: too many actions in the last hour",diff --git a/crates/openhuman-core/src/tools/impl/system/npm_exec.rs b/crates/openhuman-core/src/tools/impl/system/npm_exec.rsindex f542aab6a5..28714eb946 100644--- a/crates/openhuman-core/src/tools/impl/system/npm_exec.rs+++ b/crates/openhuman-core/src/tools/impl/system/npm_exec.rs@@ -210,6 +210,11 @@ impl NpmExecTool {));}let path_policy = super::security_for_tool_context(&self.security, context, "npm_exec");+ for input in extra_args.iter().chain(cwd_override.iter()) {+ if let Err(reason) = path_policy.check_protected_path_literals(input) {+ return Ok(ToolResult::error(reason));+ }+ }let cwd = match resolve_cwd(&path_policy.action_dir, cwd_override.as_deref()) {Ok(p) => p,Err(msg) => return Ok(ToolResult::error(msg)),diff --git a/crates/openhuman-core/src/tools/impl/system/python_exec.rs b/crates/openhuman-core/src/tools/impl/system/python_exec.rsindex d78261a606..1d5fc4c76b 100644--- a/crates/openhuman-core/src/tools/impl/system/python_exec.rs+++ b/crates/openhuman-core/src/tools/impl/system/python_exec.rs@@ -224,6 +224,15 @@ impl PythonExecTool {);let path_policy = super::security_for_tool_context(&self.security, context, "python_exec");+ for input in inline_code+ .iter()+ .chain(script_path.iter())+ .chain(extra_args.iter())+ {+ if let Err(reason) = path_policy.check_protected_path_literals(input) {+ return Ok(ToolResult::error(reason));+ }+ }let command = if let Some(code) = inline_code.as_deref() {format!(