Repository navigation
feat(bin): launch external-marked workers inside a Claude sandbox - #8511
Open
volkrav-dev wants to merge 4 commits into
Open
volkrav-dev wants to merge 4 commits into
volkrav-dev wants to merge 4 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.envare 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
fm-spawn.sh --external, or per project with atrust=externaltoken indata/projects.md.fm-project-mode.sh --trustreads the token back asownorexternaland refuses an empty or unknown value with exit 3.state/<id>.claude-settings.json, plus--strict-mcp-config --setting-sources user.The new
bin/fm-external-sandbox-lib.shbuilds those settings:network.strictAllowlist;.envand.env.*files anywhere on disk, and common credential stores, are unreadable;.claude/settings*.json, and Firstmate's skills directory are write-protected;backend=t3code, a missingjq, or a malformedtrust=binding.--externalis refused on secondmates.The mark is stored as
trust=externalin the task record, survives relaunch and batch spawns, andfm-control.shre-checks the recorded mark and the project's current registry entry before it stops a running worker.docs/configuration.md, the vendor facts in the Claude harness reference, and the measurements indocs/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-permissionsapproves that ask, so the connection succeeds.sandbox.network.strictAllowlist: truerefuses 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 intests/fm-project-mode.test.shandtests/fm-control-relaunch.test.sh.tests/fm-claude-external-sandbox-live.test.sh(new) runs the installedclaudeagainst 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
strictAllowlistcontrol arm.fm-spawn.shin a disposable lab home, were compared in both permission modes on Claude Code 2.1.325 on macOS:.envfiles, by shell and by the Read toolKnown limits
ghcannot verify TLS inside the macOS sandbox, soghandgh-axifail in a marked worker; publication through the no-mistakes daemon is not affected.config/claude-permission-modestill selects the mode.