Skip to content

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

fix(security): treat the account config beside the workspace as internal

M3gA-Mind8c810c141605
diff --git a/crates/openhuman-core/src/security/policy/path_checks.rs b/crates/openhuman-core/src/security/policy/path_checks.rs
index 7d2409ef6d..2ce9295819 100644
--- a/crates/openhuman-core/src/security/policy/path_checks.rs
+++ b/crates/openhuman-core/src/security/policy/path_checks.rs
@@ -2,7 +2,8 @@ use std::path::{Path, PathBuf};
use super::types::{SecurityPolicy, TrustedAccess, POLICY_BLOCKED_MARKER};
use super::types::{
- ARTIFACTS_DIR, ARTIFACT_TOOL_RESULTS_DIR, WORKSPACE_INTERNAL_DIRS, WORKSPACE_INTERNAL_FILES,
+ ACCOUNT_CONFIG_FILE, ARTIFACTS_DIR, ARTIFACT_TOOL_RESULTS_DIR, WORKSPACE_INTERNAL_DIRS,
+ WORKSPACE_INTERNAL_FILES,
};
impl SecurityPolicy {
@@ -393,6 +394,16 @@ impl SecurityPolicy {
(Ok(w), Ok(p)) => (w.as_path(), p.as_path()),
_ => (self.workspace_dir.as_path(), path),
};
+ // The account config (`<openhuman_dir>/config.toml`, the workspace's
+ // sibling) holds the autonomy policy itself and the files folders the
+ // artifact escape guard trusts (`files_dir_override`,
+ // `files_dir_history`, #5505). A trusted root over the account or data
+ // dir must not let the agent rewrite either.
+ if let Some(account_dir) = ws.parent() {
+ if check_path == account_dir.join(ACCOUNT_CONFIG_FILE) {
+ return true;
+ }
+ }
if !check_path.starts_with(ws) {
return false;
}
diff --git a/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs b/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs
index 674fa22537..b01c572d60 100644
--- a/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs
+++ b/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs
@@ -242,3 +242,40 @@ async fn the_turn_root_grant_never_reaches_a_credential_store() {
"unexpected error: {err}"
);
}
+
+/// #5505: the account config beside the workspace holds the autonomy policy
+/// and the files folders the artifact escape guard trusts, so a trusted root
+/// over the account dir must not make it readable or writable, while other
+/// files there stay reachable.
+#[tokio::test]
+async fn the_account_config_beside_the_workspace_is_internal() {
+ let tmp = tempfile::tempdir().expect("tempdir");
+ let account = tmp.path().join("users").join("u1");
+ let ws = account.join("workspace");
+ std::fs::create_dir_all(&ws).expect("create workspace");
+ let config = account.join("config.toml");
+ std::fs::write(&config, "files_dir_history = []").expect("write config");
+ let notes = account.join("notes.txt");
+ std::fs::write(&notes, "hello").expect("write notes");
+ let policy = SecurityPolicy {
+ workspace_dir: ws.clone(),
+ action_dir: ws.clone(),
+ workspace_only: false,
+ trusted_roots: vec![TrustedRoot {
+ path: account.to_string_lossy().into_owned(),
+ access: TrustedAccess::ReadWrite,
+ }],
+ ..SecurityPolicy::default()
+ };
+
+ assert!(!policy.is_path_string_allowed(&config.to_string_lossy()));
+ assert!(policy
+ .validate_path(&config.to_string_lossy())
+ .await
+ .is_err());
+ assert!(policy
+ .validate_parent_path(&config.to_string_lossy())
+ .await
+ .is_err());
+ assert!(policy.validate_path(&notes.to_string_lossy()).await.is_ok());
+}
diff --git a/crates/openhuman-core/src/security/policy/types.rs b/crates/openhuman-core/src/security/policy/types.rs
index 661ccb4966..fa2787e078 100644
--- a/crates/openhuman-core/src/security/policy/types.rs
+++ b/crates/openhuman-core/src/security/policy/types.rs
@@ -215,6 +215,9 @@ pub(super) const WORKSPACE_INTERNAL_DIRS: &[&str] = &[
/// internal state (see `is_workspace_internal_path`); only
/// [`ARTIFACT_TOOL_RESULTS_DIR`] inside it stays agent-readable.
pub(super) const ARTIFACTS_DIR: &str = "artifacts";
+/// The account config file, stored beside `workspace_dir` (see
+/// `is_workspace_internal_path`).
+pub(super) const ACCOUNT_CONFIG_FILE: &str = "config.toml";
/// Where oversized tool outputs are persisted for the agent to read back.
pub(super) const ARTIFACT_TOOL_RESULTS_DIR: &str = "tool-results";