Allowlist is not enforced when hx uses the claude_cli provider #17

Closed
opened 2026-11-13 18:58:20 +00:00 by hermes · 0 comments
Collaborator

orch is an orchestrator that runs hx coding agents headless (hx -p TEXT --mode json). Profiles can set allow = [...] (tool allowlist, see docs/safety.md). The allowlist is enforced by orch guard, an hx extension subscribed to tool_call events, and re-checked by orch on every tool_call event in the NDJSON stream.

Problem

With hx' claude_cli provider (auto-on when claude is in PATH) the official claude -p binary runs its own tools (Read, Edit, Bash, ...). hx then emits NO tool_call / tool_result events for them. Observed on a real box: hx -p "run 'ls' in the shell and tell me the first file" --mode json | grep -E '"type":"(tool_call|tool_result)"' prints nothing. Result: a profile with allow = ["read"] silently does not restrict anything, and max_turns counts nothing useful. The run looks guarded but is not. Also hx stats shows 1 request per run in this mode.

Related facts: hx asks permissions in this mode through the MCP tool mcp__hx__approve (--permission-prompt-tool) via a unix socket; in -p mode there is no permit hook, so hx approves everything. Config key claude_cli = ["--flag", ...] passes extra args to the claude binary. claude_cli = false selects the direct API provider, but Claude OAuth direct calls are billed as extra usage, so that is not a general answer for Claude subscriptions.

Do

  1. Find out (read hx code, then test against the real hx binary + fake claude, hx has tests/fake_claude.py and tests/claude_cli_e2e.sh) whether the approve calls pass through hx' event bus, so the guard extension can decide on them. If yes: make orch guard and the stream check understand the approve request (tool name and input of the claude tool) and apply the same Policy::decide.
  2. If not possible: never run unguarded silently. When a profile has allow and hx is in claude_cli mode, fail the run at setup as needs-human with a clear reason (or map allow to claude's --allowedTools via the worktree .hx/config.toml claude_cli = [...], whichever is verifiable).
  3. Detect the mode reliably (no tool events while the transcript shows tool use is NOT reliable; prefer asking hx, e.g. checking the config or the claude binary resolution) and document the result in docs/safety.md.
  4. Telemetry: note that in this mode turns/requests are not comparable with the direct provider; add the provider mode to the telemetry record so orch eval does not compare across modes.

Done when:

  • A test with the REAL hx binary in claude_cli mode (fake claude binary that tries to read a secret file / run a disallowed bash command) shows the call denied and the run needs-human with policy:, OR the run is refused at setup with a message naming this limitation. No path leaves allow set and silently unenforced.
  • tests/all.sh stays green; docs/safety.md states what is enforced in each provider mode.

Update: claude_cli must stay usable. Interim: orch refuses allow in this mode (PR #18). The real fix is in hx: johannes/hx#182.

orch is an orchestrator that runs `hx` coding agents headless (`hx -p TEXT --mode json`). Profiles can set `allow = [...]` (tool allowlist, see docs/safety.md). The allowlist is enforced by `orch guard`, an hx extension subscribed to `tool_call` events, and re-checked by orch on every `tool_call` event in the NDJSON stream. ## Problem With hx' `claude_cli` provider (auto-on when `claude` is in PATH) the official `claude -p` binary runs its own tools (Read, Edit, Bash, ...). hx then emits NO `tool_call` / `tool_result` events for them. Observed on a real box: `hx -p "run 'ls' in the shell and tell me the first file" --mode json | grep -E '"type":"(tool_call|tool_result)"'` prints nothing. Result: a profile with `allow = ["read"]` silently does not restrict anything, and `max_turns` counts nothing useful. The run looks guarded but is not. Also `hx stats` shows 1 request per run in this mode. Related facts: hx asks permissions in this mode through the MCP tool `mcp__hx__approve` (--permission-prompt-tool) via a unix socket; in `-p` mode there is no permit hook, so hx approves everything. Config key `claude_cli = ["--flag", ...]` passes extra args to the `claude` binary. `claude_cli = false` selects the direct API provider, but Claude OAuth direct calls are billed as extra usage, so that is not a general answer for Claude subscriptions. ## Do 1. Find out (read hx code, then test against the real hx binary + fake claude, hx has `tests/fake_claude.py` and `tests/claude_cli_e2e.sh`) whether the `approve` calls pass through hx' event bus, so the guard extension can decide on them. If yes: make `orch guard` and the stream check understand the approve request (tool name and input of the claude tool) and apply the same `Policy::decide`. 2. If not possible: never run unguarded silently. When a profile has `allow` and hx is in `claude_cli` mode, fail the run at setup as `needs-human` with a clear reason (or map `allow` to claude's `--allowedTools` via the worktree `.hx/config.toml` `claude_cli = [...]`, whichever is verifiable). 3. Detect the mode reliably (no tool events while the transcript shows tool use is NOT reliable; prefer asking hx, e.g. checking the config or the `claude` binary resolution) and document the result in docs/safety.md. 4. Telemetry: note that in this mode turns/requests are not comparable with the direct provider; add the provider mode to the telemetry record so `orch eval` does not compare across modes. Done when: - A test with the REAL hx binary in `claude_cli` mode (fake claude binary that tries to read a secret file / run a disallowed bash command) shows the call denied and the run `needs-human` with `policy:`, OR the run is refused at setup with a message naming this limitation. No path leaves `allow` set and silently unenforced. - `tests/all.sh` stays green; docs/safety.md states what is enforced in each provider mode. --- Update: claude_cli must stay usable. Interim: orch refuses `allow` in this mode (PR #18). The real fix is in hx: johannes/hx#182.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/orch#17