Skip to content

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

fix(security): map shell command classes explicitly in policy checks

Steven Enamakel2e264d684db6
diff --git a/crates/openhuman-core/src/security/policy/command_checks.rs b/crates/openhuman-core/src/security/policy/command_checks.rs
index 467b51ba70..847e94f636 100644
--- a/crates/openhuman-core/src/security/policy/command_checks.rs
+++ b/crates/openhuman-core/src/security/policy/command_checks.rs
@@ -240,7 +240,16 @@ impl SecurityPolicy {
let base = normalized_command_name(base_raw);
let args: Vec<String> = words.map(|w| w.to_ascii_lowercase()).collect();
let joined = cmd_part.to_ascii_lowercase();
- class = class.max(classify_segment(&base, &args, &joined));
+ let segment_class = match classify_segment(&base, &args, &joined) {
+ tinybox_core::shell::classify::CommandClass::Read => CommandClass::Read,
+ tinybox_core::shell::classify::CommandClass::Write => CommandClass::Write,
+ tinybox_core::shell::classify::CommandClass::Network => CommandClass::Network,
+ tinybox_core::shell::classify::CommandClass::Install => CommandClass::Install,
+ tinybox_core::shell::classify::CommandClass::Destructive => {
+ CommandClass::Destructive
+ }
+ };
+ class = class.max(segment_class);
}
// A redirect or `tee` writes a file regardless of the base command.
if contains_unquoted_char(command, '>')
diff --git a/crates/openhuman-core/src/tools/impl/system/schedule.rs b/crates/openhuman-core/src/tools/impl/system/schedule.rs
index 20ac18820a..ae277aa606 100644
--- a/crates/openhuman-core/src/tools/impl/system/schedule.rs
+++ b/crates/openhuman-core/src/tools/impl/system/schedule.rs
@@ -90,7 +90,7 @@ impl Tool for ScheduleTool {
if let Some(blocked) = self.enforce_mutation_allowed(action) {
return Ok(blocked);
}
- self.handle_create_like(action, &args)
+ self.handle_create_like(action, &args).await
}
"cancel" | "remove" => {
if let Some(blocked) = self.enforce_mutation_allowed(action) {
@@ -225,7 +225,11 @@ impl ScheduleTool {
}
}
- fn handle_create_like(&self, action: &str, args: &serde_json::Value) -> Result<ToolResult> {
+ async fn handle_create_like(
+ &self,
+ action: &str,
+ args: &serde_json::Value,
+ ) -> Result<ToolResult> {
let command = args
.get("command")
.and_then(|value| value.as_str())
diff --git a/crates/openhuman-core/src/tools/impl/system/schedule_tests.rs b/crates/openhuman-core/src/tools/impl/system/schedule_tests.rs
index 34a45264be..3f8a0ad52e 100644
--- a/crates/openhuman-core/src/tools/impl/system/schedule_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/schedule_tests.rs
@@ -157,6 +157,7 @@ async fn readonly_blocks_mutating_actions() {
let list = tool.execute(json!({"action": "list"})).await.unwrap();
assert!(!list.is_error);
+ assert!(list.output().contains("No scheduled jobs"));
}
#[tokio::test]