1. Home
  2. Blog
  3. Secrets in agent allowlists

Artificial intelligence · 9 min read

1,122 public files,2,539 secrets.

The "Yes, and don't ask again" button saves the command you just approved. When that command contains a password, the password is written into a config file sitting next to your code. An audit of 104,185 public copies of that file finds 1,122 holding a real secret, across 63 identified organisations.

By Kaleido LabPublished

TL;DR

  • The permission rule Claude Code saves is the approved command string. Approve a PGPASSWORD=… psql command once and the password is stored in clear text in .claude/settings.local.json.
  • The file is meant to stay local, but Claude Code only adds it to the machine's global gitignore: a folder that becomes a repo later, a clone on another machine or an already-committed file are not covered. Result: in 539 of the 1,105 repos with a secret, a Claude co-authored commit changed the file.
  • Classic scanners are not enough: of the 1,122 compromised files, gitleaks flags 564 and TruffleHog 643, while 215 are flagged by neither, because the dominant pattern is a password inside a command, not a key in a recognisable format.

The button that writes a secret into a file

On November 5, 2026, the security team at Apiiro published an audit that starts with something very mundane. You ask the agent to check why the login fails on staging. The command it proposes carries the connection string, because it cannot work without it. Claude Code asks for confirmation, several times per session. By the third interruption you click "Yes, and don't ask again".

That click does two things: it runs the command, and it adds a permission rule to .claude/settings.local.json at the project root. The rule is not a pattern — it is the command string itself, secret included. The model does not decide this: Apiiro reproduced the behaviour with Opus 5.5 and Fable 5.1, so it is the harness persisting what it approved.

The file is supposed to stay on the machine, and Claude Code tries to keep it there. When it creates the file inside a git repo, it adds it to your user account's global gitignore. That is not the repository's .gitignore: it is a local list, and nothing carries it with the project. Three cases slip through:

  • a folder that becomes a git repo after the file was created;
  • a clone on another machine, where the global gitignore does not exist;
  • a file committed once already — and here the docs are explicit: a tracked copy is treated as repository-supplied, and the debug log records that "gitignore rules do not apply to tracked files". The user is not told, and the next approval is appended to the tracked file.

One last detail stings. Claude Code's commit instructions tell the model not to commit .env or credentials.json. Its own settings file is not on that list. Of the 1,105 repos with a real secret that Apiiro traced, 539 have a commit co-authored by Claude that changed the file — commits naming every recent model, from Sonnet 4.5 to Opus 5.5.

What the public corpus actually holds

Apiiro scanned 104,185 public copies of .claude/settings.local.json across 103,617 repositories. 1,122 of them (1.1%) hold a real secret, 1,379 distinct values in total: 636 provider-format keys and 743 passwords or tokens tied to a public host. More than a third open a database directly.

Inside the 1,122 filesCount
Database passwords379
Supabase service-role keys122
Supabase account tokens (every project on the account)103
SSH logins, some of them root via sshpass43
GitHub, GitLab and npm tokens42
AWS keys23
Private keys6

This file is not the only one leaking. Widening the net to shared settings, git history and agent transcripts brings the total to 2,539 distinct secrets across 1,994 repositories:

FileCheckedWith a real secret
.claude/settings.local.json104,1851,122
Shared .claude/settings.json76,011298
Agent transcripts (.specstory, aider, Cursor)2,523120 (87 repos)
Handoff and deploy notes2,09533
Memory files such as MEMORY.md1,2009
VS Code Copilot auto-approve1739

The named cases show the scale: a database vendor exposed its own cloud key with manage access and no expiry claim, a B2B startup its production Azure Postgres password, an agency its Square production token, an open-source project with over 1,000 stars an OpenAI-format API key, and an IT services firm the owner password of a medical-records application database.

Two numbers explain the dynamic. Density: one in ten files above 8 KB holds a real secret, against fewer than one in 500 below 500 bytes. The more you click "don't ask again", the more the file grows, the denser it gets. And time: in the median repo the file was first committed 217 days before November 2, 2026; in 118 repos, more than a year before. This is not a fresh incident, it is a silent accumulation nobody re-reads.

Why gitleaks and TruffleHog miss 215

The natural reflex is to say platform secret scanning should have caught this. Apiiro tested it: run over all 104,185 files, gitleaks flags 564 and TruffleHog 643 of the 1,122 compromised files. 215 files are flagged by neither.

The reason is structural. Those tools look for key formats: a provider prefix, a long random string. A password typed after PGPASSWORD=, sshpass -p or mysql -p, or an Authorization: Bearer header in a curl call, is an ordinary word inside an ordinary command line. A generic detector has nothing to latch onto.

The line to keepA saved permission rule is not a tool pattern, it is a receipt. Everything the command contained at the moment of the click is kept, and scanners are blind to half of what a command contains.

The same blind spot shows up everywhere an agent records what it ran: transcripts, memory files, handoff notes. If your detection only covers key formats, it covers roughly 60% of this problem.

Anthropic's answer, and what it does not cover

Boris Cherny, who leads Claude Code, replied on Hacker News on November 7 and 8. Three points: Claude Code has historically not done secret scrubbing, the team is "looking into what we can do to prevent this" and prototyping "making sure auto mode catches this, building in basic secret scanning"; the file is meant to stay local and is gitignored automatically; and permission rules are old hat, auto mode being safer. Asked whether auto mode can itself approve a sensitive command, he answers "good catch".

Two objections from the thread deserve a hearing, because they aim at the substance. First, allowlists are exactly the deterministic part of the system. Answering "use a model to judge whether the command is risky instead" swaps a verifiable rule for a probability — and Apiiro's own audit shows auto mode asks the same question about sensitive commands, so the persistence risk does not go away. Second, approval fatigue is the root cause, not a detail. An agent that writes a different Python script on every prompt and asks permission to run it gets a "yes" without review; at that point the allowlist is not what protects you, the sandbox is.

The most solid recommendation in the reply is the most boring one: turn on the host's secret scanning and push protection. It is the only control that acts before the commit leaves the machine — the others just observe.

When it is an incident, when it is not

Method first, because it changes how you read the numbers. Apiiro used no credential and contacted no host; "real secret" means "matches a provider format or points at a public host", not "verified valid". So 1,122 is a floor. And the sample only contains public repos: the 1.1% rate describes public repos, not your estate.

It is an incident if you have public repos, agents that run migrations or deploy scripts, and a .claude/settings.local.json that was versioned even once. The test takes two minutes: git log --all -- .claude/settings.local.json in each public repo, plus a look at the forks. If the file shows up, the secret is out — history is replicated with every clone.

It is a theoretical risk if you are one or two people on private repos, with short-lived credentials and databases not reachable from the internet. That warrants a gitignore line, not an incident channel.

And keep this apart from the compromised-extension attack of November 2: there, someone was distributing malicious code. Here, no attacker is required. The file grows through normal use and only becomes a problem when someone finds it — a crawler, a fork, a git clone on a CI box. That is why it matters to engineers: it is not a vulnerability, it is an ergonomics side effect.

Remediation checklist

  1. Search history, not the working tree. git log --all --full-history -- .claude/settings.local.json on every public repo, then check forks (211 forks of 74 repos carried the same secrets in the audit). A file deleted today can still hold 734 secrets in its earlier versions.
  2. Rotate before cleaning. Keys, tokens and database passwords first, history rewrite second. A secret revoked within the hour is a hygiene incident; a secret alive for 217 days is an incident, full stop.
  3. Put the rule in the repository's .gitignore. .claude/settings.local.json and, if your team puts credentials there, .claude/settings.json — committed by a human, not by the agent. The machine-level global gitignore only protects that machine.
  4. Scan for passwords inside commands. Add CI patterns for PGPASSWORD=, sshpass -p, mysql -p, Authorization: Bearer and postgres:// over agent config files and transcripts. gitleaks and TruffleHog stay useful; they are just not sufficient.
  5. Get credentials out of the command line. Environment variables injected by the shell or direnv, a .env file read by the application, or a vault CLI that fetches the secret at runtime. An allowlist rule cannot contain a secret it never saw.
  6. Turn on push protection. Hosted secret scanning with push blocking is the only control that runs before the commit leaves. Failing that, a local pre-commit hook with a home-made scan of added lines.

Need help designing reliable AI workflows, auditing an LLM architecture, or training your engineering team? Explore how we work at Kaleido-Lab.

FAQ

Another question? Write to me.

Does Claude Code really write my passwords into a file?

Yes, when you create a permission rule: the saved rule is the exact command string you just approved. If that command contains PGPASSWORD=, sshpass -p or a bearer token, the secret lands in the project's .claude/settings.local.json. This is harness behaviour, not model behaviour: Apiiro reproduced it with Opus 5.5 and Fable 5.1.

Isn't that file gitignored?

Only partly. When Claude Code creates the file it adds it to your machine's global gitignore, not to the repository's .gitignore, which is the only list that travels with the code. A folder that becomes a repo later, a clone on another machine, or a file already committed all slip through, and the debug log then states that gitignore rules do not apply to tracked files.

How many secrets are actually exposed?

2,539 distinct secrets across 1,994 public repositories, with 63 identified organisations. Of 104,185 public copies of .claude/settings.local.json, 1,122 (1.1%) hold a real secret: 379 database passwords, 122 Supabase service-role keys, 103 Supabase account tokens, 43 SSH logins and 23 AWS keys.

What is the first thing to do?

Rotate first, clean second. A secret pushed to a public repository is copied into forks and clones (211 forks of 74 repos here), and deleting the file leaves 734 secrets that exist only in history. Rewriting history does not recall what already left: rotation is the only control that resets the risk.

Agents touching your secrets?

Rolling coding agents onto your repositories, or want to scope their permissions and access before going wider? Describe your context, and I will reply with a first opinion and the next steps, with no commitment.

Read next