Anthropic 8 min read

Your Agent Wrote Your Password Into a Git-Tracked File

An agent approval prompt saved the command, password included, to a file git tracks. 2,539 secrets are on public GitHub. The scanners missed 215 of them.

A dark filing cabinet with one drawer pulled open, packed with identical manila folders. A single folder glows warm amber from inside, lighting the folders around it.
Photo: Generated with FLUX 3 Image Klein (Black Forest Labs, FLUX Kommunity License) via Freefield on local hardware.

The permission prompt is the security boundary in every coding agent. When it writes down its own decisions, that boundary stops being a conversation and becomes a file.

Apiiro's researchers swept GitHub for one file — .claude/settings.local.json — and found 104,185 copies in public repositories. Of those, 1,122 files held a real secret: database passwords, cloud keys, API tokens, root SSH logins. Counting git history, the shared settings.json teams commit deliberately, and agent chat transcripts saved into repos, the total came to 2,539 distinct secrets across 1,994 repositories, belonging to 63 organisations from student groups to a database vendor exposing its own admin-level key.

None of those people set out to publish a password. Here is the mechanism, because it is the whole point.

One approval, stored forever

Ask Claude Code to check why staging login fails. The command it proposes carries the connection string, because it cannot work without one. It asks before running it — correctly. The tenth interruption of a session arrives, approval fatigue sets in, you stop reading command strings, and you pick "Yes, and don't ask again."

That option records no policy. It writes the literal command, secret included, into .claude/settings.local.json inside the project folder, as an allow-rule for next time.

The file is meant to stay on your machine and Claude Code tries to keep it there: when it creates the file inside a git repository, it adds the path to the developer's global gitignore. That covers the ordinary case and misses three that are ordinary in their own right — a folder that becomes a repository later, a clone on a second machine, and a file someone already committed. The rule never goes into the repository's own .gitignore, so nothing travels with the project to protect it.

And the agent commits the file itself. In 539 of the 1,105 repositories Apiiro traced with a real secret, a commit co-authored by Claude changed that file. Claude Code's commit instructions tell the model not to commit .env or credentials.json. Its own settings file is not on that list.

The median exposure was not a moment of carelessness. In the median repository with a real secret, the file was first committed 217 days before the researchers checked, and in 118 repositories, more than a year. Deleting it now does not fix it either: 734 secrets live only in earlier revisions, in 509 repositories, and 211 forks of 74 repositories carry the same secrets forward.

The scanners did not catch it, and the reason matters

Apiiro ran gitleaks and TruffleHog across all 104,185 files. Of the 1,122 with a real secret, gitleaks flagged 564 and TruffleHog 643. 215 were flagged by neither.

That gap is not a tuning problem. Secret scanners match formats — a provider prefix, a high-entropy string. But the leak here is a password typed into an ordinary command line:

PGPASSWORD=hunter2 psql -h db.internal -U admin
sshpass -p <password> ssh root@203.0.113.10

Those are words in a sentence an engineer wrote. There is no prefix to match. If your secret-scanning strategy is "we run gitleaks in CI," this failure mode is invisible to it by construction, and the allowlist file is where your typed passwords accumulate.

Two accounts of the same bug

Anthropic's Head of Claude Code, Boris Cherny, responded on Hacker News over the weekend: the team is "looking into what we can do to prevent this," and he named what they are prototyping — "making sure auto mode catches this, building in basic secret scanning." He also argued the observed cases came only when "the files were manually created and checked in."

Both claims can be true, and the reader should know which is which:

  • Anthropic's account: the cases it saw came from files created and committed by hand. That is certainly one path.
  • What the tracing found: Claude writing to already-tracked copies in just under half the repositories examined — 539 of the 1,105 traced.

The researchers reproduced the whole flow on current models — Opus 5.5 and Fable 5.1 — which makes this a behaviour of the harness, not of a specific model generation. Their own words: "This is Claude Code's own behavior, not the model's."

The timeline is its own argument. It was filed as issue #5544 in August 2025. Related reports about the file escaping gitignore (#11982) and sensitive commands landing in another unprotected file (#91270) followed. All were closed without action after 60 days of inactivity. What changed this month was a researcher publishing counts, not a fix shipping.

One limit on the research, stated plainly: no credential was used or tested and no host was contacted. "Real secret" means a credential matching a provider format or sitting next to a public host — not a credential confirmed live. One organisation did confirm its key had been active.

Why this is a self-hosting story

It would be easy to file this under "cloud agents are careless." That reading misses what the mechanism actually is.

The leak travels through git, not through the model. Nothing about it depends on inference happening in someone else's datacentre. If your agent can run a command containing a token, and it records that command, your agent config is a credential store with a .gitignore as its only lock — whether the tokens were generated by a frontier model or by an 8B running on your own GPU.

For a team, the blast radius is the clone. Once the file is in the repository, any developer who pulls it and any CI runner that checks it out receives the secret — one approval on one workstation, now a credential in a build pipeline nobody re-read.

If anything, the local setup is more exposed in one specific way: long unattended sessions, broad shell access, and approval fatigue that pushes people toward blanket trust. Nobody is running an org-level scanner over your commits. The convenience layer that makes an agent pleasant to use is the same layer that writes the secret down, and there is no vendor between you and that decision.

The failure mode scales with the useful behaviour. An agent you never let run shell commands never leaks one into an allowlist, and also never fixes your migration.

What we changed in how we think about it

Treat agent configuration as secret-bearing, in the same category as .env. That means four concrete things, in this order:

Rotate first, clean second. Removing a file from HEAD leaves it in history, in every clone, and in every fork. A secret that has ever been committed is spent.

Pin the ignore rule at repository level. Add .claude/, and whatever your agent writes its state to, to the project's own .gitignore and commit that rule on day one. A global ignore is a convention on one machine; a repository ignore travels with the code. Treating the global one as the control is a configuration-management failure — it puts the rule where nobody can review it.

Audit history, not just the working tree. git log --all -- .claude/settings.local.json and grep every revision for PASSWORD, TOKEN, sshpass, Authorization:. The 734 secrets that only exist in old revisions are the ones a working-tree scan cannot see.

Don't let scanners carry the whole load. Format matchers are worth running and they missed one in five of these by the researchers' measure. Adding a regex pass for credential-shaped assignments inside command strings is cheap, and it is the gap that actually bit.

For our own repository work the practical version is narrower than "trust agents less." It is: know exactly which paths an agent writes state to, keep that list short, and treat the ignore rule as part of the initial commit rather than something you add after a sweep finds a hundred thousand files.

The uncomfortable part

Every one of those 104,185 files is a record of someone deciding to trust their tool. The decision was reasonable each time — that is what makes it a security problem rather than a user error. A permission system whose "quiet mode" serialises the permission it was granted will eventually store the thing the permission was granted about.

The prompt is the boundary. "Don't ask again" is a write.


Sources

D

Dallum Brown

Writer and curator exploring the impact of technology on everyday life.

View All Articles

Subscribe to
The Brief

Our curated selection of tech news and other discoveries, delivered every month.

No spam. Unsubscribe anytime.

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to share your thoughts!

Further Reading