feat(claude): deny secrets and sandbox commands #205
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "sandbox-settings"
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 Claude Code settings file the template seeds into adopters held
hooks and switches but no rule on files and no sandbox: Claude's file
tools and shell commands could read
.envfiles, private keys, and thecredential stores of the home directory, and a prompt injection in an
issue or pull request the workflows read could have them sent out.
Claude Code's
Readdeny rules and its sandboxed Bash tool close thatgap, but each adopter had to work the rules out alone, though they hold
for most projects. Set aside: shipping the sandbox lists without turning
the sandbox on, which leaves OS-level protection opt-in and unused; the
built-in environment scrub, which turns auto-allow off and refuses
excluded commands on Linux, so
run-sandboxed.shcould not run.What changed
.claude/settings.jsonnow refuses reads of the files that hold secretsin most web, mobile, and infrastructure projects and on most
workstations, asks before
git fetch,git pull, andgit push, andturns Claude Code's Bash sandbox on: credential variables are unset
inside it, the policy's own files are write-denied, and git's network
commands and
.agents/scripts/run-sandboxed.shrun outside it, sincethe script builds a stronger bubblewrap sandbox of its own and cannot
nest inside Claude Code's. The script takes
-C <dir>, so an umbrellaruns a member's commit without a
cd, which would keep the call insidethe sandbox, and the
run-sandboxedskill names the call form. Theevals' agent runs with Claude Code's sandbox off, the runner's
bubblewrap being its boundary. The README's Hooks and settings describes
the rules, which commands fail inside the sandbox and retry outside it,
and how a repository or a developer drops or adds to them;
UPGRADING.mdgains the Sandbox settings migration;
docs/MAINTENANCE.mdsays how torun the bubblewrap tests and the evals under the source's own sandbox.
How to verify
From a fresh checkout of the branch on Linux with bubblewrap and socat,
start Claude Code at the root, add a fictional
.env, exportAWS_SECRET_ACCESS_KEY=fictional, and ask Claude to runcat .env,sh -c 'cat .env', andenv | grep -c AWS_SECRET_ACCESS_KEY, each inits own command: the two reads fail with
Permission deniedand thecount is
0, wheremainprints the file and counts1. Then ask it torun
.agents/scripts/run-sandboxed.sh HEAD -- sh -c 'echo ok': itprints
okfrom outside Claude Code's sandbox, wheremainhas noexclusion and the call fails with
the sandbox cannot start.On the tip,
bash tests/verify-agent-config.sh(231 tests),bash tests/check-work-folder.sh,.agents/hooks/shellcheck.sh repo,prettier --check '**/*.md',scripts/verify-agent-config.sh, andgit diff --check mainpass; the four regression assertions oftests/agent-config/claude-settings.sh, the two-Ctests ofsandbox-run.sh, and the extendedevals-runner.shtest fail onmain. Not tried: the behavioral evals, billed and the maintainer'sbefore a merge that changes a skill and
AGENTS.md; a sandboxed sessionon a host whose bubblewrap mounts a fresh
/proc, since the containerthis ran in needed a copy of
bwrapfirst inPATHandenableWeakerNestedSandboxfor the session.Considerations
Every developer meets a prompt on each fetch and pull: an
askrulewhose pattern equals the exclusion's is the one guard against a quoted
or escaped
--upload-pack, which runs a program on the host and which atext rule alone cannot stop. Inside the sandbox an app that loads
.envitself, a release build signed from the repository, the cloud CLIs, and
a shell command on
.env.examplefail and retry outside it, the lastaccepted since the Read tool still reads the example; a container that
refuses bubblewrap a fresh
/procor a nested user namespace fails everysandboxed command until the developer's own settings allow for it, as
the README says. On Linux a write-denied file is protected once it
exists, so a sandboxed command can still create an absent
CLAUDE.md.