Repository navigation
fix(mocactl): sbx claude denies Claude Code's local tools (#702) - #703
Conversation
`sbx claude` passed only --mcp-config and --strict-mcp-config. The second limits which MCP servers load; it leaves Claude Code's built-in tools (Bash, Read, Edit, Write, ...) enabled, and those act on the user's machine. Only the permissions.deny list that `sbx up` writes into .claude/settings.json turned them off, so `sbx claude` was contained only when started in a repository `up` had set up. From anywhere else, including `--sandbox ID` outside a repository, the agent could read, write and run commands locally. claudeArgs() now passes --disallowed-tools with CLAUDE_DENY, the same list `up` writes, as one comma-separated value placed before --strict-mcp-config, so a prompt in the caller's arguments is never read as a tool name. In a repository `up --cortex` set up, the deny is left out and the Cortex note is printed, as `up` does: Cortex blocks the local tools in sessions with the sandbox's tools, and a Read deny would stop CLAUDE.md loading. Outside a repository, or with a record that cannot be read, the tools are denied. The "claude is not on PATH" fallback now prints the full command, deny included, so running it by hand does not undo the fix. Fixes rossoctl#702 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Ed Snible <[email protected]>
…soctl#703 review) The test made its directory with mkdtempSync directly, which bypasses the helpers' `made` list, so afterEach(cleanupTmp) never removed it and each run left a sbx-not-a-repo-* directory behind. Export tmp() from helpers/sbx.ts and use it, so cleanupTmp takes the directory back. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Ed Snible <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Approving. claudeArgs() now passes CLAUDE_DENY as one --disallowed-tools value ahead of --strict-mcp-config, so a trailing prompt can't be read as a tool name. That makes sbx claude contained from any directory, --sandbox ID outside a repository included, which closes #702. The not-on-PATH fallback now prints the full quoted command, and the Cortex exception matches up and doctor. The tests cover inside a repo, outside a repo, an un-up'd repo, Cortex from a subdirectory, and an unreadable record. CI is green except deploy-scripts-bash32, which was still pending when I drafted this.
One suggestion inline: dropping the deny relies only on the working-tree record .sbx/agent-config.json saying cortex: true. Nothing checks that Cortex is actually there.
Assisted-By: Claude Code
| deps.claude ?? {}, | ||
| values.sandbox, | ||
| values['control-plane-url'] !== undefined ? ctx.url : undefined, | ||
| await repoRoot(cwd).then(cortexMode, () => false), |
There was a problem hiding this comment.
suggestion: Since #702, --disallowed-tools is the only thing keeping the agent off the laptop in a directory up didn't configure. This line switches it off whenever .sbx/agent-config.json in the work tree says cortex: true. up adds .sbx/ to info/exclude, but nothing stops a repository from committing that file. A clone carrying {"version":1,"cortex":true,"files":[],"dirs":[],"json":[],"markdown":[]} passes manifestProblem, so sbx claude --sandbox ID run there gets every local tool. It also prints the Cortex note, so the user thinks they're covered, even on a machine with no Cortex at all. up --cortex refuses in that case (agentopProblem, sync.ts:340), and doctor reports it (cortexCheck), but the launcher checks nothing. This is no worse than before the PR, but it's the one way left to get around the new flag. Two cheap options: (a) leave the deny in place unless .sbx/agent-config.json is untracked (git ls-files --error-unmatch fails); (b) only drop the deny when agentopProblem/mocaSandboxStatus say moca-sandbox is installed and loaded, and fall back to denying with a warning otherwise. (b) also covers a stopped Cortex service.
Summary
Fixes #702.
mocactl sbx claudeleft Claude Code's built-in tools (Bash, Read, Edit, Write, …) enabled, so the agent could act on the user's machine as well as the sandbox.--strict-mcp-configlimits which MCP servers load, not the built-in tools. Only thepermissions.denylist thatsbx upwrites into.claude/settings.jsonturned them off, sosbx claudewas contained only when started inside a repouphad set up. With--sandbox IDfrom anywhere else, it wasn't contained.claudeArgs()now passes--disallowed-toolswithCLAUDE_DENY, the same listupwrites. It's one comma-separated value placed before--strict-mcp-config, which ends the variadic flag, so a prompt after--is never read as a tool name.sbx up --cortexset up, the deny is left out and the Cortex noteupprints is shown, matchingupanddoctor. Cortex blocks local tools in sessions that have the sandbox's tools, and aReaddeny would stop CLAUDE.md loading (sbx up's agent config: the CLAUDE.md steering never loads (Read deny), and stale deny names warn on every startup #568). Outside a repo, or with an unreadable.sbx/agent-config.json, the tools are denied.claudecommand without the deny. It now prints the full command, quoted, so it can be copied.claude.tscomment that called--strict-mcp-config"the same containment" asup, updated thesbx claudehelp text, and added notes indocs/sbx/user-guide.md.One behavior change: with
Readdenied, plainsbx claudesessions no longer load the project's CLAUDE.md, the same trade-offsbx upmakes.up --cortexis the way around it.Testing
test/sbx-claude.test.tshas five new tests:--strict-mcp-config;uphasn't set up;The existing assertions and the not-on-PATH fallback check the new flag too. 13/13 pass; against the old source, 9 of the 13 fail.
make lintandmake check-linkspass.sbx pushtest, all on 5 s timeouts and none in code this PR touches. Rerun on their own, all 5 files pass (216/216).claude --helpfor 2.1.306, but a run against a live sandbox hasn't confirmed local tools are refused.Checklist
git commit -s).make lintand the tests for the touched packages pass. The 5 full-suite timeouts above pass when rerun on their own.docs/page, with the right maturity label (seedocs/CONTRIBUTING-DOCS.md).make check-linkspasses if any Markdown changed.docs/specs/README.mdordocs/adrs/README.md. (N/A: no new spec or ADR.)Assisted-By: Claude Code