Skip to content

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

fix(policy): correct policy enforcement to use deny list instead of allow list

Steven Enamakelde0fd29882c4
diff --git a/crates/openhuman-core/src/security/policy/enforcement.rs b/crates/openhuman-core/src/security/policy/enforcement.rs
index c48ffe54f5..51c222d49c 100644
--- a/crates/openhuman-core/src/security/policy/enforcement.rs
+++ b/crates/openhuman-core/src/security/policy/enforcement.rs
@@ -176,6 +176,24 @@ impl SecurityPolicy {
});
}
+ // Oversized tool outputs are saved to `<workspace_dir>/artifacts/tool-results`
+ // (`tool_result_artifacts_dir`), outside the action dir, and the model is
+ // handed the absolute path to page them back with `file_read`. Under
+ // `workspace_only` an absolute path is refused unless a trusted root
+ // covers it, so without this grant every pointer would be unreadable.
+ // Read-only: the agent reads its own outputs back; it has no reason to
+ // write there. `is_workspace_internal_path` already exempts this one
+ // directory from the internal-state boundary.
+ let tool_results = super::types::tool_result_artifacts_dir(workspace_dir)
+ .to_string_lossy()
+ .to_string();
+ if !trusted_roots.iter().any(|r| r.path == tool_results) {
+ trusted_roots.push(TrustedRoot {
+ path: tool_results,
+ access: TrustedAccess::ReadOnly,
+ });
+ }
+
// Dedicated, namespaced scratch dir (`/tmp/openhuman`) granted ReadWrite
// so the LLM's natural `/tmp/...` temp-file habit lands in a sandboxed,
// trusted location instead of the world-shared `/tmp`. Only this subdir
diff --git a/crates/openhuman-core/src/security/policy/mod.rs b/crates/openhuman-core/src/security/policy/mod.rs
index 727c075c7e..0d13b5d47f 100644
--- a/crates/openhuman-core/src/security/policy/mod.rs
+++ b/crates/openhuman-core/src/security/policy/mod.rs
@@ -12,7 +12,8 @@ pub use enforcement::validate_path_within_root;
pub use enforcement::{ensure_openhuman_scratch_dir, openhuman_scratch_dir};
pub use types::{
ActionTracker, AutonomyLevel, CommandClass, CommandRiskLevel, GateDecision, SecurityPolicy,
- ToolOperation, TrustedAccess, TrustedRoot, POLICY_BLOCKED_MARKER, POLICY_DENIED_MARKER,
+ tool_result_artifacts_dir, ToolOperation, TrustedAccess, TrustedRoot, POLICY_BLOCKED_MARKER,
+ POLICY_DENIED_MARKER,
};
#[cfg(test)]
diff --git a/crates/openhuman-core/src/security/policy/types.rs b/crates/openhuman-core/src/security/policy/types.rs
index b1ffd5a8fd..f658e5e721 100644
--- a/crates/openhuman-core/src/security/policy/types.rs
+++ b/crates/openhuman-core/src/security/policy/types.rs
@@ -200,6 +200,22 @@ 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";
+/// Where oversized tool outputs are persisted for the agent to read back:
+/// `<workspace_dir>/artifacts/tool-results`.
+///
+/// Inside the core's own state, not the agent's working directory. The action
+/// directory is often a project the agent is editing, and a tool output saved
+/// there becomes a stray file in that project (picked up by `git add -A`, shown
+/// in the diff). This is the one subdirectory of the internal `artifacts/` store
+/// agent file tools may read (`is_workspace_internal_path`), and `from_config`
+/// grants it as a read-only root so the absolute pointer the store hands out
+/// stays readable when `workspace_only` refuses other absolute paths.
+pub fn tool_result_artifacts_dir(workspace_dir: &std::path::Path) -> PathBuf {
+ workspace_dir
+ .join(ARTIFACTS_DIR)
+ .join(ARTIFACT_TOOL_RESULTS_DIR)
+}
+
/// Files directly under `workspace_dir` that hold secrets or persona config
/// and must not be writable by agent tools.
pub(super) const WORKSPACE_INTERNAL_FILES: &[&str] = &[