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(user_agents): block caller-chosen working folders for saas users
Steven Enamakel3a534d0e7800
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 34ebda32e9..4ee8f4e8df 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -945,7 +945,7 @@ pub fn schema_for_rpc_method(method: &str) -> Option<ControllerSchema> {let found = view.iter().chain(internal_registry().iter())- .find(|g| g.controller.rpc_method_name() == method && group_allowed(g.group))+ .find(|g| g.controller.rpc_method_name() == method && visible(g)).map(|g| g.controller.schema.clone());found}diff --git a/crates/openhuman-core/src/threads/schemas/handlers.rs b/crates/openhuman-core/src/threads/schemas/handlers.rsindex 324936d1f7..2ccf00e8fe 100644--- a/crates/openhuman-core/src/threads/schemas/handlers.rs+++ b/crates/openhuman-core/src/threads/schemas/handlers.rs@@ -37,6 +37,9 @@ pub(super) fn handle_upsert(params: Map<String, Value>) -> ControllerFuture {pub(super) fn handle_create_new(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let p = parse::<CreateConversationThreadRequest>(params)?;+ // A SaaS user acts only in their own sandbox; a caller-chosen working+ // folder would point the thread at the host.+ crate::user_agents::surface::check_working_dir(p.action_dir.as_deref())?;to_json(ops::thread_create_new(p).await?)})}diff --git a/crates/openhuman-core/src/user_agents/surface.rs b/crates/openhuman-core/src/user_agents/surface.rsindex d1255d3575..3fd4ea09ed 100644--- a/crates/openhuman-core/src/user_agents/surface.rs+++ b/crates/openhuman-core/src/user_agents/surface.rs@@ -88,14 +88,31 @@ pub fn validate_user_thread_id(id: &str) -> Result<(), String> {Ok(())}+/// Whether the current work runs for a SaaS user.+fn in_user_scope() -> bool {+ is_saas()+ && CoreContext::current()+ .as_deref()+ .and_then(CoreContext::session_agent)+ .is_some()+}++/// A SaaS user cannot pick a thread's working folder: their threads always+/// act in their own sandbox. Any folder is refused in user scope; outside it+/// nothing changes.+pub fn check_working_dir(action_dir: Option<&str>) -> Result<(), String> {+ match action_dir.map(str::trim).filter(|dir| !dir.is_empty()) {+ Some(_) if in_user_scope() => {+ Err("a thread's working folder cannot be chosen here".to_string())+ }+ _ => Ok(()),+ }+}+/// [`validate_user_thread_id`] when the current work runs for a SaaS user;/// otherwise every id the single-user core accepts stays accepted.pub fn check_thread_id(id: &str) -> Result<(), String> {- let user_scope = CoreContext::current()- .as_deref()- .and_then(CoreContext::session_agent)- .is_some();- if is_saas() && user_scope {+ if in_user_scope() {validate_user_thread_id(id)} else {Ok(())diff --git a/tests/saas_mode_e2e.rs b/tests/saas_mode_e2e.rsindex 06e45bc10c..8f301a64f9 100644--- a/tests/saas_mode_e2e.rs+++ b/tests/saas_mode_e2e.rs@@ -493,6 +493,27 @@ fn each_user_sees_only_their_own_threads() {assert_eq!(bob_ids, vec!["shared-id".to_string()], "bob: {bob_list}");assert!(bob_list.to_string().contains("bob's"), "{bob_list}");assert!(!bob_list.to_string().contains("alice's"), "{bob_list}");+ // And the other way: alice keeps her own `shared-id`, untouched by bob's.+ assert!(+ alice_ids.contains(&"shared-id".to_string()),+ "alice: {alice_list}"+ );+ assert!(alice_list.to_string().contains("alice's"), "{alice_list}");+ assert!(!alice_list.to_string().contains("bob's"), "{alice_list}");++ // A SaaS user cannot point a thread at a host folder.+ let (_, body) = call(+ "alice",+ "openhuman.threads_create_new",+ json!({ "action_dir": "/etc" }),+ );+ assert!(body.get("error").is_some(), "{body}");++ // A hidden method answers unknown-method even with bad params, rather+ // than its parameter errors.+ let (_, body) = call("alice", "openhuman.threads_regenerate", json!({}));+ let error = body["error"].to_string();+ assert!(!error.contains("missing"), "{body}");// Each user's threads live in their own workspace.for (agent, owner) in [(&alice, "alice"), (&bob, "bob")] {