feat(claude): narrow the sandbox to secret files #209
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/secret-rules-only"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
The sandbox the template turned on on 2026-11-09 made most git commands fail or prompt. It blocked the signing agent's socket, hid
~/.ssh, filtered the network, and write-denied the files a landing merge replaces, so each commit, fetch, and push of a workflow cost a failed first attempt or a prompt. Two ways out were tried and set aside: carrying git inside that sandbox while keeping its defences against an injected instruction, which took six trade-offs and still drew two high security findings; and no sandbox at all, where a recursive search or a glob was measured to print a nested.env. The sandbox is wanted for one thing:.envand secret files, wherever they sit in the project, do not reach Claude by mistake.What changed
The sandbox now only holds every command to the
Readdeny rules on the project's secret files, and is open to everything else: every host, every Unix socket, and writes in the home directory. A signed commit, a fetch, and a push run inside it at their first call, unasked, in Manual andacceptEditsmode too. Inside it the sixty credential variables of providers and services the settings name are still unset; those of databases and frameworks, such asDATABASE_URL, now stay set for the tests and servers that read them.It is no longer a defence against an injected instruction. The write denials on the policy files, the
askrules ongit pullandgit push, the--upload-packdeny rules, and theReadrules on the home directory's credential stores are gone, and the README says what that gives up. This breaks nothing silently for an adopter of the earlier sandbox: the Narrowed sandbox entry ofUPGRADING.mdlists each change, to leave out of the merge when rejected.git merge --ff-onlynow leaves the sandbox, since the landing merge replaces files Claude Code keeps read-only inside it, andland.mdgives the merge the form that exclusion needs. The README's account is shorter, without Your own sandbox settings.How to verify
With Claude Code 2.1.322 on Linux, commits signed through ssh-agent, in a clone of the branch:
a/b/c/.envholding a line with a marker word. Ask Claude to rungrep -rn <marker> a,cat a/b/c/.e*, andsh -c "cat a/b/c/.env". Each answersPermission deniedand the marker is never printed.git commit --allow-empty -m "chore: probe"andgit -C . push --dry-run origin HEAD:refs/heads/probe. Each succeeds at its first call, without a prompt; onmainthe commit fails withCouldn't get agent socket?.NPM_TOKENandDATABASE_URLexported and ask it to runprintenv NPM_TOKEN DATABASE_URL. It prints the second alone..claude/agents/,git -C . merge --ff-only <branch>fails withunable to unlink old, andgit merge --ff-only <branch>alone in its call fast-forwards.On
3d160dathe checks ofdocs/MAINTENANCE.mdpass, 243 tests among them, and the three rewritten or changed assertions oftests/agent-config/claude-settings.shfail onmain. Not tried: macOS, Docker, a tool that ignores the sandbox's proxy, and the excluded merge's prompt in Manual mode, for want of the machines; whether a variable a shell profile exports returns after the unset in an interactive session; and the behavioral evals, which bill, thoughland.mdchanges.Considerations
A push now rests on the rule of
AGENTS.mdthat one happens only when the user names it, with no prompt behind it. A project's own command that reads a secret file, such as a test suite loading its.env, or that takes a login from an unset variable, fails inside the sandbox and falls to the retry. The unset covers only the sixty names, so a forge token such asGH_TOKENstays set; the README says where a repository or a developer adds a name, and a run showed the lists add together. The merge in agit -Corcdspelling still fails inside;land.mdgives it one retry in the right form.