fix(claude): hide secrets at every depth and worktree #207
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "sandbox-hardening"
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
Since #205 and #206 every repository on the template runs Claude Code's
Bash sandbox. Checks on 2026-11-09 found that the secret rules reached
only the project root's top level in the sandbox, and only the shell's
directory in the Read tool, so a
.envor a key in a subdirectory or ina worktree under
.worktrees/, where all change work happens, stayedreadable. The validator also failed on the empty placeholders the
sandbox puts at absent CLAUDE paths, which Claude Code skips, and the
README named none of the settings that only a developer's own
~/.claude/settings.jsoncan hold. ShippingfailIfUnavailable,allowAllUnixSockets, or anaskrule on the retry in the template wasset aside: each would change every adopter's machine in a way only its
developer can weigh.
What changed
Each project secret rule has a twin anchored at the project root,
Read(/**/<pattern>), that hides its files at every depth, worktreesincluded, from sandboxed commands and the Read tool wherever the shell
is.
*.pemandsecrets.*keep to the top level, since deeper they nameCA bundles and source files, while
*key*.pemis hidden everywhere.Example
.envfiles are refused too;git show HEAD:<path>reads them.The validator counts a 0-byte CLAUDE file as absent.
The README's new "Your own sandbox settings" gives what a developer adds
to
~/.claude/settings.json, each with what it closes and costs, andcorrects the statements on absent policy files, git over SSH, and signed
commits;
UPGRADING.mdpoints upgrades to it.How to verify
On Linux with the sandbox running, start Claude Code at the root of a
checkout of this branch, create fictional
sub/.env.local,sub/probe.key, and.venv/lib/python3.12/site-packages/certifi/cacert.pem,and have it
cateach in its Bash tool: the first two fail withPermission deniedand the CA bundle prints, wheremainprints allthree.
bash tests/agent-config/claude-code-precedence.shpasses"accepts an empty CLAUDE.md beside AGENTS.md", which fails on
mainwith "CLAUDE.md present without an AGENTS.md import".
On the tip,
bash tests/verify-agent-config.sh(233 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 new settings assertion and the twoprecedence tests fail on
main. Not tried: macOS and WSL2.Considerations
On Linux each sandboxed command takes about 0.1 s more, and more in a
large tree, while the sandbox finds the files the new rules name. A
setup step that copies an example
.envfile now falls to the retryoutside the sandbox.