Skip to content

feat(bin): launch external-marked workers inside a Claude sandbox - #8511

Open
volkrav-dev wants to merge 4 commits into
kunchenguid:mainfrom
volkrav-dev:fm/fm-spawn-external-sandbox
Open

volkrav-dev wants to merge 4 commits into
kunchenguid:mainfrom
volkrav-dev:fm/fm-spawn-external-sandbox

Conversation

@volkrav-dev

@volkrav-dev volkrav-dev commented Nov 16, 2026 •

Copy link
Copy Markdown

Intent

A worker launched on an untrusted or third-party repository runs today with the same unrestricted network, file, and connector access as a worker on the home's own projects.
This change lets a home mark a project or a single task as external, so the per-task Claude settings that the spawn already writes also carry a sandbox block for that worker: sensitive files such as .env are unreadable, writes outside the task are refused, account connectors are off, and the network is limited to an allowlist.
Every other worker is unchanged.
The network has to be proven closed before containment is claimed, and the same external worker is compared in bypass-permissions mode and in auto permission mode, because the domain allowlist alone does not close the network under bypass.

What Changed

  • A ship or scout can be marked external per task with fm-spawn.sh --external, or per project with a trust=external token in data/projects.md.
    fm-project-mode.sh --trust reads the token back as own or external and refuses an empty or unknown value with exit 3.
  • A marked Claude worker gets its settings in state/<id>.claude-settings.json, plus --strict-mcp-config --setting-sources user.
    The new bin/fm-external-sandbox-lib.sh builds those settings:
    • shell commands run only in the sandbox;
    • the network is limited to the GitHub hosts in the allowlist, with network.strictAllowlist;
    • .env and .env.* files anywhere on disk, and common credential stores, are unreadable;
    • writes are limited to the task's paths, plus the git object and ref paths that a commit and a local gate push need;
    • git config, hooks, and link files, the checkout's own .claude/settings*.json, and Firstmate's skills directory are write-protected;
    • the checkout's own Claude project and local settings are not loaded, so repository hooks never run;
    • connectors, MCP servers, WebFetch, and WebSearch are off;
    • Firstmate's busy hooks ride the settings file.
  • A marked task refuses to start, before any endpoint, worktree, or record exists, on a non-claude runtime, a raw launch command, backend=t3code, a missing jq, or a malformed trust= binding.
    --external is refused on secondmates.
    The mark is stored as trust=external in the task record, survives relaunch and batch spawns, and fm-control.sh re-checks the recorded mark and the project's current registry entry before it stops a running worker.
  • Workers with no mark launch exactly as before.
  • Docs: a new "External workers" section in docs/configuration.md, the vendor facts in the Claude harness reference, and the measurements in docs/verification/runtime-backends.md.

Why the allowlist alone was not enough

With only sandbox.network.allowedDomains, an unlisted host triggers a permission ask, and --dangerously-skip-permissions approves that ask, so the connection succeeds.
sandbox.network.strictAllowlist: true refuses unlisted hosts without asking.
The new live guard keeps a control arm without that key, which must still reach the unlisted host, so the guard fails if the key ever stops being what closes the network.

Testing

  • tests/fm-spawn-external-sandbox.test.sh (new), plus new cases in tests/fm-project-mode.test.sh and tests/fm-control-relaunch.test.sh.
  • tests/fm-claude-external-sandbox-live.test.sh (new) runs the installed claude against a scripted local stand-in for the model API (tests/fixtures/fm-claude-scripted-tools.py), so it spends no tokens.
    It proves the network, read, and write refusals, a working commit and gate push, that a planted checkout hook does not run, and the strictAllowlist control arm.
  • Real workers, launched by the real fm-spawn.sh in a disposable lab home, were compared in both permission modes on Claude Code 2.1.325 on macOS:
Result bypass auto
Host outside the allowlist, by proxy and by direct socket refused refused
.env files, by shell and by the Read tool refused refused
Writes outside the task, by shell and by the Write tool refused refused
Worktree writes, commit, allowlisted host allowed allowed, but the auto reviewer may also deny or ask about some of these depending on the task context
Checkout's own hook did not run did not run
  • An unmarked worker kept its inline settings, its open network, and its project hook.

Known limits

  • Go-based CLIs such as gh cannot verify TLS inside the macOS sandbox, so gh and gh-axi fail in a marked worker; publication through the no-mistakes daemon is not affected.
  • In auto mode the worker's pane can stop on an interactive auto-mode question after a turn, so this change does not switch external workers to auto; config/claude-permission-mode still selects the mode.
  • Claude Code's model traffic, Firstmate's own hooks, and the no-mistakes pipeline's agents run outside the sandbox.

A project registered trust=external, or a ship or scout spawned with
--external, now launches its Claude worker with a per-task settings file
that turns on the Claude Code sandbox: secret files are unreadable,
writes outside the task are refused for shell commands and file tools,
account connectors and MCP servers are off, web tools are denied, and
shell network access is closed to every host outside an allowlist
(config/external-allowed-domains, GitHub hosts by default). Unmarked
workers launch exactly as before.

The allowlist alone does not close the network under
--dangerously-skip-permissions, because an unlisted host only asks and
bypass approves the ask; network.strictAllowlist refuses it without a
prompt. A token-free live guard proves the refusals on the installed
Claude Code and keeps a control arm showing that key is load-bearing.

An unknown or misspelled trust binding, a runtime or backend that cannot
carry the sandbox, and a malformed allowlist refuse before any endpoint,
worktree, or record exists; the mark survives relaunch and batch spawns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant