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
docs(security/policy): add README for security policy module
Steven Enamakelfbb06a24544e
diff --git a/crates/openhuman-core/src/security/policy/README.md b/crates/openhuman-core/src/security/policy/README.mdindex d7338c06cc..bf2a6f9bbb 100644--- a/crates/openhuman-core/src/security/policy/README.md+++ b/crates/openhuman-core/src/security/policy/README.md@@ -6,6 +6,23 @@ every invariant AGENTS.md lists for the autonomy policy is actually enforced:fail-closed command classification, always-forbidden system/credential paths,trusted roots, and the per-hour action budget.+## Autonomy is off by default++`SecurityPolicy::enabled` mirrors `[autonomy] enabled` in config and defaults+to `false`. With the policy disabled, `SecurityPolicy::from_config`+(`enforcement.rs`) still builds the struct, but `can_act()`,+`record_action()`, and `is_rate_limited()` all short-circuit: command+classification, the approval gate, the command allowlist, the hourly action+budget, `workspace_only`, `forbidden_paths`, and the workspace-internal+boundary are all inert. `is_always_forbidden` is not gated on `enabled` and+still applies either way: credential stores (`~/.ssh`, `~/.gnupg`, `~/.aws`,+and platform equivalents) and system roots stay unreachable, and so do `..`+traversal and null bytes in a path. Setting `[autonomy] enabled = true`+restores the full policy. Note the asymmetry with `Default`: a policy built+from config defaults to disabled, while a policy built with no config at all+(`SecurityPolicy::default()`) defaults to enabled; see the comment on that+impl in `types.rs`.+## Responsibilities- Build a `SecurityPolicy` from `AutonomyConfig` (`SecurityPolicy::from_config`).@@ -17,8 +34,8 @@ trusted roots, and the per-hour action budget.(`is_workspace_internal_path`), or covered by a `TrustedRoot`.- Track and enforce the hourly action budget (`ActionTracker`).- Own the two stable string markers (`POLICY_BLOCKED_MARKER`,- `POLICY_DENIED_MARKER`) the agent harness's repeated-failure middleware- keys on to stop retrying a provably-futile call.+ `POLICY_DENIED_MARKER`) that the agent harness's repeated-failure+ middleware keys on to stop retrying a provably futile call.## Key files@@ -39,13 +56,13 @@ Re-exported through `policy/mod.rs` and then through `security/mod.rs`:`POLICY_DENIED_MARKER`, `validate_path_within_root`,`ensure_openhuman_scratch_dir`, `openhuman_scratch_dir`.-`security/live_policy.rs` (a sibling of this directory) holds the *current*+`security/live_policy.rs` (a sibling of this directory) holds the current`SecurityPolicy` in a process-global cell: new sessions `install` the latest-policy and `reload_from` / `reload_privacy` swap it the moment the config is+policy, and `reload_from` / `reload_privacy` swap it the moment the config issaved. `security_for_tool_context` (`tools/impl/filesystem/mod.rs`,`tools/impl/system/mod.rs`) clones a tool's policy per call and, when the runcarries a workspace descriptor, sets `action_dir` to that root and pushes it-as a `ReadWrite` `TrustedRoot`; `is_always_forbidden` and+as a `ReadWrite` `TrustedRoot`. `is_always_forbidden` and`is_workspace_internal_path` are evaluated before any trusted-root shortcut,so the grant cannot widen them.@@ -53,30 +70,30 @@ so the grant cannot widen them.Each of these must not be weakened to make a feature work:-- **`action_dir` vs `workspace_dir`.** `action_dir` is the agent's action- sandbox root — tools resolve relative paths and default their cwd there.+- `action_dir` vs `workspace_dir`. `action_dir` is the agent's action+ sandbox root; tools resolve relative paths and default their cwd there.`workspace_dir` holds core-internal state (memory DBs, sessions, tokens);the workspace root itself is a permitted containment root(`is_resolved_path_allowed_for`), but its internal-state subtree is refusedby `check_resolved_against_forbidden` before any trusted-root grant isconsulted. Kept as two separate fields on `SecurityPolicy` (`types.rs`) sothe two roots can diverge.-- **`is_workspace_internal_path`** (`path_checks.rs`) — true for any path+- `is_workspace_internal_path` (`path_checks.rs`) is true for any pathwhose first component under `workspace_dir` is in `WORKSPACE_INTERNAL_DIRS`or `WORKSPACE_INTERNAL_FILES` (`types.rs`), or starts- with `memory-`, `memory_tree-`, or `session_raw-`. Checked against the+ with `memory-`, `memory_tree-`, or `session_raw-`. It is checked against thecanonicalized form of both paths when possible, falling back to the rawpaths for not-yet-existing targets.-- **`is_always_forbidden`** (`path_checks.rs`) — case-insensitive,+- `is_always_forbidden` (`path_checks.rs`) does a case-insensitive,segment-based match against `SENSITIVE_COMPONENTS` (`.ssh`, `.gnupg`,`.aws`, `.azure`, `.kube`, `keychains`, Windows DPAPI dirs) plus a prefixmatch against `SYSTEM_PREFIXES` (`/etc`, `/root`, `/boot`, `/proc`, `/sys`,`/system`, `C:\Windows`, `C:\Program Files[ (x86)]`, `C:\ProgramData`).- Unconditional — a `trusted_root` grant can never reach these paths. Gray-area- directories (`/usr`, `/opt`, `/var`, `~/Library`) deliberately stay in the- user-overridable `forbidden_paths` list instead, so a grant can still reach- e.g. `/usr/local/...`.-- **`classify_command`'s fail-closed floor** (`command_checks.rs`) — a+ It is unconditional; a `trusted_root` grant can never reach these paths.+ Gray-area directories (`/usr`, `/opt`, `/var`, `~/Library`) deliberately+ stay in the user-overridable `forbidden_paths` list instead, so a grant can+ still reach, for example, `/usr/local/...`.+- `classify_command`'s fail-closed floor (`command_checks.rs`): acommand that is not provably read-only (and not a recognizednetwork/destructive command) is at least `CommandClass::Write`. The highestclass across `;`/`|`/`&&`/`||`/newline-separated segments wins, and any@@ -85,29 +102,30 @@ Each of these must not be weakened to make a feature work:escalate-only: `agent/tinyagents/host/security_gate.rs` combines it as`class = check_gated_command(cmd)?.max(declared)`, so the model can raisethe gate but never lower what the runtime determined.-- **Approval gate default-on, marker semantics.** `POLICY_BLOCKED_MARKER`- (`[policy-blocked]`) prefixes a *permanent* rejection — the identical call+- Approval gate default-on, marker semantics. `POLICY_BLOCKED_MARKER`+ (`[policy-blocked]`) prefixes a permanent rejection: the identical callcan never succeed in the current tier (read-only blocking a write, aforbidden/credential path, a disallowed high-risk or hidden-execution- command). `POLICY_DENIED_MARKER` (`[policy-denied]`) prefixes a *this-turn*- denial — the user said no to an approval prompt, or it timed out. The agent+ command). `POLICY_DENIED_MARKER` (`[policy-denied]`) prefixes a this-turn+ denial: the user said no to an approval prompt, or it timed out. The agentharness's `RepeatedToolFailureMiddleware` keys on these to halt on the first- verbatim repeat instead of reiterating a provably-futile call. See+ verbatim repeat instead of reiterating a provably futile call. See[`../approval/README.md`](../approval/README.md) for the gate itself and its10-minute default TTL.-- **Hourly action budget.** `ActionTracker` (`types.rs`) is a sliding+- Hourly action budget. `ActionTracker` (`types.rs`) is a slidingone-hour window; `enforce_tool_operation`'s `Act` arm(`enforcement.rs`) calls `record_action` and refuses once the count exceeds`max_actions_per_hour`. `enforce_write_tier` alone (tier only, no budget) is- used by callers that write at a finer grain than one tool call, e.g. the- kernel memory guard under `MemoryCore::store`.+ used by callers that write at a finer grain than one tool call, for example+ the kernel memory guard under `MemoryCore::store`.## Tests- `policy_tests.rs`, `policy_allowlist_tests.rs`, `policy_injection_tests.rs`,`policy_paths_and_risk_tests.rs`, `policy_trusted_roots_tests.rs`, and- `policy_workspace_internal_tests.rs` — behavior tests for classification,+ `policy_workspace_internal_tests.rs`: behavior tests for classification,path checks, and tier enforcement.-- `proptest_tests.rs` — property tests over command classification.-- `enforcement_scratch_dir_tests_tests.rs` — `openhuman_scratch_dir` is+- `policy_disabled_tests.rs`: behavior with `[autonomy] enabled = false`.+- `proptest_tests.rs`: property tests over command classification.+- `enforcement_scratch_dir_tests_tests.rs`: `openhuman_scratch_dir` isnamespaced on every platform and `ensure_openhuman_scratch_dir` creates it.