Claude Code can persist an approved Bash command verbatim into project .claude/settings.local.json. Secrets typed into that command become plain JSON. Apiiro found 104,185 public copies of the file; 1,122 held secrets (1,379 in those files). Protection lives in the user's global git excludes - not the repo .gitignore. Anthropic has acknowledged the issue. No shipped fix yet.
# The Leak Pipeline
This is not a remote exploit. It is a permission UX footgun that turns a convenience click into a committed secret.
Claude asks before the command
You click once for convenience
Password still inside the string
Plain JSON in the project
History + forks keep it
Claude asks before the command
You click once for convenience
Password still inside the string
Plain JSON in the project
History + forks keep it
Safe rules look like patterns: Bash(npm test:*). Dangerous rules look like the exact command Claude just ran - including PGPASSWORD=, sshpass -p, mysql -p, or a bearer header.
"Bash(npm run:*)" "Bash(psql $DATABASE_URL *)"
No literal secret. Env var name only. Pattern covers the family of commands.
"Bash(PGPASSWORD=hunter2 psql -c 'select 1')" Exact string. Password in plain text. One commit away from public search.
{ "permissions": { "allow": [ "Bash(npm test:*)", "Bash(curl -H 'Authorization: Bearer glpat-XXXX' ...)" ] } }
Illustrative shape from public writeups. The red line is the failure mode.
# Why the "Protection" Failed
Claude Code does try to keep the file local. The protection is the wrong layer.
- →Adds path to user global git excludes when it creates the file
- →Stays on one laptop / one user config
- →Does nothing if the file was already tracked
- →Repo
.gitignorechecked into the project - →Travels with clones, CI, and teammates
- →
git rm --cachedif already committed
Apiiro also found Claude co-authored commits touching the file in 539 of 1,105 traced repos - so this is not only "someone manually force-added a local file."
# What Apiiro Measured
Researchers Shmulik Cohen and Matan Giladi published Nov 5, 2026. The Hacker News, Ars Technica, and GitLab covered it within days.
Scope: public GitHub search for .claude/settings.local.json, then secret-format matching plus an AI reviewer.
Bar widths relative to 379 (DB passwords). Nearly three in ten secrets in those files were database passwords.
Misses were mostly passwords buried inside command strings - exactly the don't-ask-again shape.
Apiiro did not live-test credentials. Treat the dataset as an exposure census.
One notified company confirmed a key was still live. Every secret-bearing file Apiiro checked was still on the default branch.
# Not Just Another Secret-in-Repo Story
Of 16 coding agents Apiiro compared, Claude Code was the only one confirmed to save the full approved command into a project file by default.
User reports of this pattern go back to August 2025. The Nov 2026 research made the scale public.
No shipped product fix for this persistence path.
Boris Cherny (Claude Code lead) on HN: team looking into prevention; plans to prototype auto-mode catch + basic secret scanning - no date.
Anthropic advice: prefer auto mode and host secret scanning. Apiiro notes auto mode can still leave secrets in the file.
# What To Do Tonight
Order matters. Rotate before you clean history theater.
| Step | Action | Why |
|---|---|---|
| 1 | Search org + git history for .claude/settings*.json | Deleted files still live in history and forks |
| 2 | Rotate every password / token the file ever held | Cleanup without rotation leaves attackers a window |
| 3 | git rm --cached + add to repo .gitignore | Global excludes do not travel with the project |
| 4 | Scrub local allow rules that embed secrets | Even never-committed files sit on disk |
| 5 | Approve patterns / $ENV vars - never literal secrets | Stops the next don't-ask-again from re-leaking |
Org + history for .claude/settings*.json
History and forks keep deleted files
Every secret the file ever held
Before cleanup theater
git rm --cached + project ignore
Global excludes stay on one laptop
Delete allow rules with secrets
Even if never pushed
Approve Bash(npm run:*) / $DATABASE_URL
Never literal passwords in the rule
If the command shows a secret, choose plain Yes (one-shot) or refuse and rewrite with an env var. Do not click don't-ask-again on that line.
Require repo ignore for .claude/settings.local.json. Turn on host secret scanning. Treat agent allowlists like credential stores.
Agent permission UX is now a secrets surface. Don't-ask-again is convenient until it writes your production password into a project file that git ships to GitHub - Apiiro's 1,122 hits plus one confirmed live key make that concrete. Rotate, gitignore at the repo, and stop approving commands that embed secrets.
Enjoyed this?
New episodes Mon, Wed, Sat.