Skip to content

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

chore: files changed crates/openhuman-core/src/sandbox/README.md,crates/openhuman-core/src/sandbox/c

Steven Enamakeld77cb46911e4
diff --git a/crates/openhuman-core/src/sandbox/README.md b/crates/openhuman-core/src/sandbox/README.md
index 83fc53ffa4..7ec88cc96c 100644
--- a/crates/openhuman-core/src/sandbox/README.md
+++ b/crates/openhuman-core/src/sandbox/README.md
@@ -26,7 +26,8 @@ backend, and delegates local OS-level confinement to `cwd_jail`.
- `pub struct ElevatedOp` / `pub const ELEVATED_TOOLS` — `types.rs` — tools
(`git_operations`, `install_tool`, `docker_management`,
`process_management`) that always require host access and must be audited
- via `build_elevated_op` rather than silently bypassing the sandbox.
+ via `build_elevated_op` rather than silently bypassing the sandbox. No
+ code outside this domain calls `is_elevated_op`/`build_elevated_op` yet.
- `pub const SANDBOX_ENV_PASSTHROUGH` — `ops.rs` — the allowlisted
environment variables (`PATH`, `HOME`, `TERM`, ...) forwarded into
sandboxed execution; no other host env leaks in.
@@ -34,7 +35,10 @@ backend, and delegates local OS-level confinement to `cwd_jail`.
— `ops.rs` — `SandboxMode::None`/`ReadOnly` resolve to `SandboxBackendKind::None`;
`Sandboxed` resolves to `Docker` when `runtime_config.kind == "docker"` or
the session is remote (channel/cron), else `Local` (OS jail via
- `cwd_jail`).
+ `cwd_jail`). `allow_network` is `!is_remote_session` for `Sandboxed` and
+ `true` otherwise; `workspace_root` is `action_dir`; `read_only_mounts` is
+ always empty; `docker_overrides` is populated from `[runtime.docker]` only
+ for the `Docker` backend.
- `pub async fn create_sandbox_backend(policy) -> SandboxBackendHandle` —
`ops.rs` — instantiates/probes the resolved backend.
- `pub async fn execute_in_sandbox(policy, command, working_dir, extra_env, timeout) -> anyhow::Result<SandboxExecResult>`
@@ -65,10 +69,13 @@ backend, and delegates local OS-level confinement to `cwd_jail`.
some backends (macOS Seatbelt) rebuild the command and drop piped stdio.
- **Docker** — `docker::docker_exec` runs `docker run --rm` with the host
`action_dir` mounted read/write at `/workspace`, network `none` by
- default, `--cap-drop ALL` (plus policy-specified extra drops), a
- read-only rootfs with `/tmp` and `/var/tmp` tmpfs mounts, memory/CPU
- limits, and only the explicit env passthrough list injected. Containers
- carry `openhuman.sandbox=true` for orphan cleanup.
+ default, `--cap-drop ALL` (plus policy-specified extra drops),
+ `--security-opt no-new-privileges`, a read-only rootfs with `/tmp` and
+ `/var/tmp` tmpfs mounts, memory/CPU limits (512 MB / 1 CPU defaults),
+ and only the explicit env passthrough list injected. Containers carry
+ `openhuman.sandbox=true` for orphan cleanup. `validate_docker_policy`
+ rejects host networking and `/`, `/etc`, `/proc`, `/sys`, or the Docker
+ socket as mount roots.
## Security invariant
@@ -77,11 +84,11 @@ policy. Rust path checks in `security` (`is_workspace_internal_path`,
`is_always_forbidden`, `classify_command`) still apply even when
`resolve_sandbox_policy` falls back to `SandboxBackendKind::None` — either
explicitly (`SandboxMode::None`/`ReadOnly`) or implicitly when the `Local`
-backend has no usable OS jail and `create_sandbox_backend`/
-`execute_local_jail` in `ops.rs` fall back to `cwd_jail::NoopBackend` (an
-unenforced passthrough, reported as `SandboxStatus::Inactive` rather than
-`Ready` so callers can tell the difference). Do not treat a resolved
-`SandboxBackendKind` as a security boundary on its own.
+backend has no usable OS jail: `cwd_jail::default_backend()` substitutes
+`NoopBackend`, `execute_local_jail` in `ops.rs` spawns through it, and
+`create_sandbox_backend` reports the handle as `SandboxStatus::Inactive`
+rather than `Ready` so callers can tell the difference. Do not treat a
+resolved `SandboxBackendKind` as a security boundary on its own.
## Dependencies
@@ -98,9 +105,12 @@ unenforced passthrough, reported as `SandboxStatus::Inactive` rather than
— resolve a policy and call `execute_in_sandbox` per invocation.
- `crates/openhuman-core/src/flows/tinyflows/caps/code.rs` — sandboxed code
execution capability.
-- `crates/openhuman-core/src/agent/platform_shell.rs`,
- `agent/profiles/guard.rs` — reference this domain when documenting
- confinement guarantees for shell-spawning sites.
+- `crates/openhuman-core/src/agent/platform_shell.rs` — doc references
+ only; it is the shared Windows-aware command builder that
+ `execute_unsandboxed`/`execute_local_jail` call into.
+- `crates/openhuman-core/src/agent/profiles/guard.rs` — doc comment noting
+ that its profile-path scan is not an OS sandbox and pointing at
+ `cwd_jail` as the confinement layer.
- `crates/openhuman-core/src/config/ops/sandbox.rs` — RPC settings surface
(`get_sandbox_settings`) reads `SANDBOX_ENV_PASSTHROUGH` and
`[security.sandbox]` config.
diff --git a/crates/openhuman-core/src/sandbox/cwd_jail/README.md b/crates/openhuman-core/src/sandbox/cwd_jail/README.md
index 6c17ea682a..4f8e60e238 100644
--- a/crates/openhuman-core/src/sandbox/cwd_jail/README.md
+++ b/crates/openhuman-core/src/sandbox/cwd_jail/README.md
@@ -14,7 +14,7 @@ Cross-platform directory-jail facade. Given a declarative description of a works
| File | Role |
| --- | --- |
-| `crates/openhuman-core/src/sandbox/cwd_jail/mod.rs` | Module docstring + the thin facade: `spawn` / `spawn_with` / `default_backend` (cached via `OnceLock`). Re-exports the public surface. Inline tests. |
+| `crates/openhuman-core/src/sandbox/cwd_jail/mod.rs` | Module docstring + the thin facade: `spawn` / `spawn_with` / `default_backend` (cached via `OnceLock`). Re-exports the public surface. |
| `crates/openhuman-core/src/sandbox/cwd_jail/jail.rs` | Core types: the `Jail` description struct (builder + `canonicalize`/`canonicalize_or_log`) and the `JailBackend` trait (`name`/`is_available`/`spawn`). |
| `crates/openhuman-core/src/sandbox/cwd_jail/detect.rs` | `pick_backend()` — cfg-gated platform selection; returns the first available backend or `NoopBackend`. |
| `crates/openhuman-core/src/sandbox/cwd_jail/noop.rs` | `NoopBackend` — no enforcement, plain `Command::spawn`. Always available. |
@@ -22,14 +22,14 @@ Cross-platform directory-jail facade. Given a declarative description of a works
| `crates/openhuman-core/src/sandbox/cwd_jail/macos.rs` | `SeatbeltBackend` — wraps the command in `/usr/bin/sandbox-exec -p '<profile>'`. Renders an allow-default-reads / deny-default-writes Seatbelt profile. |
| `crates/openhuman-core/src/sandbox/cwd_jail/windows.rs` | `AppContainerBackend` — `CreateAppContainerProfile` + DACL grant + `STARTUPINFOEX`/`CreateProcessW` via `windows-sys`. |
| `crates/openhuman-core/src/sandbox/cwd_jail/registry.rs` | `JailRegistry` + `JailRecord` — multi-jail manager persisted to `index.json`, with atomic-rename writes and containment checks. |
-| `crates/openhuman-core/src/sandbox/cwd_jail/registry_tests.rs` | Sibling test suite for the registry (`#[path]`-included from `registry.rs`). |
+| `crates/openhuman-core/src/sandbox/cwd_jail/{mod,jail,noop,macos,windows,registry}_tests.rs` | Sibling test suites, each `#[path]`-included from its source file. |
## Public surface
Re-exported from `mod.rs`:
- `Jail`, `JailBackend` — the declarative jail description and the OS-enforcement trait.
-- `NoopBackend` — the unenforced fallback backend.
+- `NoopBackend`, `NOOP_BACKEND_NAME` — the unenforced fallback backend and its `name()` string (`sandbox/ops.rs` compares against it to report `Inactive`).
- `JailRecord`, `JailRegistry` — persisted multi-jail manager.
Free functions in `mod.rs`:
diff --git a/crates/openhuman-core/src/sandbox/cwd_jail/mod.rs b/crates/openhuman-core/src/sandbox/cwd_jail/mod.rs
index a923a141f0..60f22d0f64 100644
--- a/crates/openhuman-core/src/sandbox/cwd_jail/mod.rs
+++ b/crates/openhuman-core/src/sandbox/cwd_jail/mod.rs
@@ -71,7 +71,7 @@ pub fn default_backend() -> Arc<dyn JailBackend> {
DEFAULT_BACKEND.get_or_init(detect::pick_backend).clone()
}
-/// Spawn `cmd` inside the jail described by `spawn`, using the default backend.
+/// Spawn `cmd` inside the jail described by `jail`, using the default backend.
///
/// `jail.canonicalize()` is called once here so the backends never see
/// `..` or symlinks. If the root does not exist, the spawn fails with
@@ -83,7 +83,7 @@ pub fn spawn(jail: &Jail, cmd: Command) -> std::io::Result<Child> {
default_backend().spawn(&jail, cmd)
}
-/// Same as [`jail`] but with a caller-supplied backend. Useful in
+/// Same as [`spawn`] but with a caller-supplied backend. Useful in
/// tests and for callers that want to opt into a weaker backend
/// explicitly (e.g. forcing [`NoopBackend`] during local dev).
pub fn spawn_with(backend: &dyn JailBackend, jail: &Jail, cmd: Command) -> std::io::Result<Child> {