openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Wire cwd_jail into shell, node_exec, and npm_exec tools

Open CodeGhost21 opened this issue 6 months ago • 0 comments

Summary

Wire cwd_jail::spawn into ShellTool, NodeExec, and NpmExec so shell-family tools run inside an OS-level jail (Landlock on Linux, Seatbelt on macOS) rooted at Config.action_dir — or, if jailing is deferred, explicitly document the path-hardening-only fallback in CLAUDE.md and the capability catalog.

Problem

#3051 acceptance criterion 3 ("Jailed execution") was the headline of the original request: "Shell-family tools run inside cwd_jail (or documented noop + path hardening on unsupported OS) with root = actions dir."

The implementing PR #3074 shipped the path-split and the in-Rust deny-list, but cwd_jail:: is never invoked from any tool: grep -r 'cwd_jail::' src/openhuman/tools/ returns zero hits. build_shell_command (src/openhuman/agent/host_runtime.rs:96) sets current_dir(action_dir) on a plain tokio::process::Command with no jail wrapper. Shell, node_exec, and npm_exec all go through the same code path.

The fallback in #3051 ("documented noop + path hardening on unsupported OS") would also be acceptable, but the noop is currently undocumented — a reader looking at cwd_jail/ and the PR body would reasonably assume the jail is wired.

Who it hurts: anyone relying on OS-level isolation as a defense against a runaway agent process. The Rust-side is_workspace_internal_path check is bypassed if a child process is spawned that reaches outside the action root via a path the parent never sees (symlink races, relative paths from a writable trusted-root, etc.). Landlock/Seatbelt closes that.

Solution (optional)

  • Add a cwd_jail::spawn-wrapped variant to host_runtime::build_shell_command (or a sibling) that takes the action dir as the jail root and falls back to the plain command on unsupported platforms (current behavior of cwd_jail::default_backend).
  • Route ShellTool::run_with_security, NodeExec, and NpmExec through it. code_executor should inherit automatically since it ends up at the same shell invocation.
  • If full wiring is out of scope for this iteration, land a short documentation block in CLAUDE.md under "Command permission model" that names the gap, and call it out in the capability catalog (about_app).

Acceptance criteria

  • [ ] Shell-family tools spawn through cwd_jail — ShellTool, NodeExec, NpmExec use a jail-aware spawn helper rooted at security.action_dir.
  • [ ] Platform fallback documented — on platforms where cwd_jail is a noop, the path-hardening fallback is documented in CLAUDE.md and surfaced in the capability catalog.
  • [ ] Tests — Rust test that asserts a jailed shell process cannot cat a file outside action_dir (on a platform where the jail backend is active in CI), plus a unit test that the noop backend is the one selected on unsupported OS.
  • [ ] Diff coverage ≥ 80% — the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/pr-ci.yml).

Related

  • Parent issue: #3051
  • Implementing PR: #3074
  • Audit: PR #3074 satisfies 4/8 of #3051's criteria fully; this is gap #1 (criterion 3, "Jailed execution").
  • Relevant code: src/openhuman/cwd_jail/, src/openhuman/agent/host_runtime.rs, src/openhuman/tools/impl/system/shell.rs, node_exec.rs, npm_exec.rs.

CodeGhost21 avatar Jun 02 '26 21:06 CodeGhost21