claude_cli: sandboxed by default, outside only with user consent #165

Merged
hermes merged 1 commits from feat/claude-cli-sandbox into main 2026-10-16 20:30:57 +00:00
Collaborator

With sandbox.mode = on, the claude CLI backend now runs inside the sandbox (bwrap/seatbelt) by default instead of unconfined. Granted inside: ro on the claude binary dir (PATH lookup, symlink target) and the hx binary dir; rw on ~/.claude, ~/.claude.json, ~/.config/claude and the permission socket; network on; env ANTHROPIC_/CLAUDE_/NODE_/XDG_/proxy/SSL_CERT_*/HX_PERMIT_SOCK. Leaving the sandbox needs the user's yes: the TUI asks once per run ('run claude outside the sandbox'), 'always' is stored as rule claude:unsandboxed in .hx/allow.json. In -p mode there is no prompt: only a stored rule lets claude out, else it stays sandboxed. Sandbox off: unchanged. Code: new sandbox::command_with(program, &Extra) (per-program ro/rw/network/env on top of the policy), ClaudeCli::with_spawner, tool::gate reused for the question. Tested: unit test for Extra, claude_cli e2e, sandbox e2e. NOT tested with real bwrap + real claude (bwrap not on dev box); the allowed paths for claude's install layout may need a tweak.

With `sandbox.mode = on`, the `claude` CLI backend now runs inside the sandbox (bwrap/seatbelt) by default instead of unconfined. Granted inside: ro on the claude binary dir (PATH lookup, symlink target) and the hx binary dir; rw on ~/.claude, ~/.claude.json, ~/.config/claude and the permission socket; network on; env ANTHROPIC_*/CLAUDE_*/NODE_*/XDG_*/proxy/SSL_CERT_*/HX_PERMIT_SOCK. Leaving the sandbox needs the user's yes: the TUI asks once per run ('run claude outside the sandbox'), 'always' is stored as rule `claude:unsandboxed` in .hx/allow.json. In -p mode there is no prompt: only a stored rule lets claude out, else it stays sandboxed. Sandbox off: unchanged. Code: new `sandbox::command_with(program, &Extra)` (per-program ro/rw/network/env on top of the policy), `ClaudeCli::with_spawner`, `tool::gate` reused for the question. Tested: unit test for Extra, claude_cli e2e, sandbox e2e. NOT tested with real bwrap + real claude (bwrap not on dev box); the allowed paths for claude's install layout may need a tweak.
hermes added 1 commit 2026-10-16 20:29:48 +00:00
hermes merged commit 785effef11 into main 2026-10-16 20:30:57 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#165