Claude Code secrets leak via allowlist

Apiiro counted 1,122 secrets sitting inside files named .claude/settings.local.json in public Claude Code repositories. Another 1,160 turned up in git history, in a shared settings.json someone committed on purpose, and in agent chat transcripts checked into repos. Sixty-three organizations affected.

Then GitGuardian scanned GitHub at a larger scale and found 31,088 in the same file type, 5,343 of them still valid at detection time, plus 613 inside Docker Hub images. The gap between the two counts is scope, not disagreement.

No prompt injection did this. No malicious package. The Claude Code secrets leak is the approval feature doing exactly what its label promises.

What “don’t ask again” actually writes to disk

Answer “Yes, and don’t ask again” on a shell command and Claude Code stores that command as a permanent permission rule in .claude/settings.local.json. The rule is not a category. It is the command text, verbatim, ready to be matched against the next invocation.

That works cleanly for npm test. It fails the moment the command carries the credential in its own arguments, which is how a large share of the admin commands an engineer runs in a day are written:

  • a curl call with an Authorization: Bearer header
  • psql "postgres://user:password@host/db"
  • a deploy wrapper exporting a cloud provider key
  • docker login -p inside a helper script

Nothing exotic is required here. The tool persists what it was told to allow. What people allow tends to include the password that makes the command work. The file is plaintext, readable by anything running as that user, at an identical path in every project on the machine.

The gitignore covers the laptop, not the repo

This is the part that reads like a mitigation until you trace it. When Claude Code creates the file inside a git repository, it adds the file to the developer’s global git ignore list. Every later commit on that machine ignores it. Silent, machine-local, and gone the moment the repository is cloned somewhere else.

Three cases walk straight past that guarantee. A folder that becomes a repository after the file already exists. A clone on a second machine, where the global ignore list was never populated. A file someone already staged, because the ignore rule arrived too late to matter. The rule never goes into the repository’s own .gitignore, so nothing travels with the project to protect the next person who clones it. In some of Apiiro’s cases Claude Code committed the file itself.

A global ignore list is a preference on one machine. A repository needs a rule inside the repository.

Scanners miss it because the secret is a command argument

Both Apiiro and GitGuardian reported that gitleaks and TruffleHog missed a large share of these findings. The reason is structural. Those tools match credential formats: an AWS access key ID, a JWT, a Stripe live key, a PEM private key block. A password embedded in a connection string or an HTTP header matches no format, because it is a password.

ArtifactWhat it holdsFormat scanner hit rate
.claude/settings.local.jsonApproved commands, credentials includedRarely
.claude/settings.jsonThe same rules, deliberately shared with the teamRarely
Agent transcript in a repoThe command, its output, sometimes an env dumpSometimes
Committed .envKey-value secretsUsually

This is why the count keeps climbing as scanners improve. Better scanners, same blind spot. A pattern library tuned to key formats returns clean on a file full of curl -H 'X-Api-Key: ...' lines, and a clean report on a dirty file is worse than no report at all, because it ends the investigation.

The settings file is a map of everything you can reach

Strip the leak question for a second and look at what the file is. It is an inventory of the systems that developer can touch and the credentials that open them. Same relative path in every project on the machine, so one file search finds it without knowing which projects exist.

Any process that lands on a developer workstation gets a guided tour of production from a file the vendor wrote for convenience, not for storage. That is the part worth fixing, and it survives rotating every key in the file.

Compare that with shell history, which has the same weakness but at least sits in one place and gets cleared by people who know it exists. This one travels with the project.

Untracking the file is not rotation

Untrack the file. Add it to the repository’s ignore list. That is Apiiro’s minimum recommendation, and it is correct as far as it goes, which is not far: it stops the next commit and nothing else, because history stays and nothing already pushed comes back.

git rm --cached .claude/settings.local.json
printf '.claude/\n' >> .gitignore
git commit -m "stop tracking agent permission files"

# see every commit that carried the file before rotating anything
git log --all --oneline -- .claude/settings.local.json

Treat every credential that appeared in those rules as disclosed from the timestamp of the first commit that carried the file. Order matters more than speed: revoke first, rewrite history second, because the rewrite does not reach forks, mirrors, or whatever cloned the repo in between. Revoking a token takes a minute. Chasing every copy of it takes a week and finishes incomplete.

I would also stop approving commands that carry secrets. Export the token into the session environment, then let the approved rule match the bare command. One extra step per session. The whole class of finding disappears from the file on the next approval.

Where the same pattern lands next

Claude Code is the current headline because it has the largest install base, but the pattern is the agent loop, not the vendor. Any tool that records what it ran so it can replay or explain it later will store the arguments. Transcripts, memory files, handoff notes, CI debug logs. Agent artifacts accumulate in repositories the way build directories did in 2015, and the cleanup argument is identical: the artifact is easier to ignore than to delete.

The 613 Docker Hub findings deserve their own sentence, because that is the case with no cleanup path. An image layer is immutable and cached on other people’s machines. Deleting the file from the repository removes nothing from a layer that was already pulled, and the registry keeps it until someone overwrites the tag.

The canary prompt experiment made the provider-side version of this point. Retention nobody asked for is still exposure. The client-side version is easier to fix and almost nobody has.

Two checks worth running this week. Does the repository ignore .claude/ as a directory rather than one filename inside it, so the next artifact the tool invents is covered before anyone has to remember it exists? And does the secret scanner have a rule for credentials embedded in command strings, or does its clean report only mean it recognized the key formats it already knows?

The per-agent leftovers on Windows and this file on macOS and Linux come from the same design decision at two vendors: record everything, let the user clean up. One of them will eventually ship retention limits. Until then the ignore rule is yours to write, and it belongs in the repository, not on the laptop.

Source: InfoQ on Apiiro’s findings, which also carries GitGuardian’s counts.

Press ⌘K to search & switch themes