Claude Code Secrets Leak: 2,539 Keys on Public GitHub

How one "don't ask again" click in Claude Code pushed 2,539 real credentials onto public GitHub

Published Updated

The Claude Code secrets leak that Apiiro published on November 5, 2026 did not start with a bug. It started with a button. When you approve a shell command in Claude Code with "Yes, and don't ask again", the CLI records that command verbatim, character for character, in a project file named .claude/settings.local.json. If you typed a database password or an API token inside the command, that credential is now written in plaintext into a file sitting in your working tree, and that file is not excluded by the project's own .gitignore by default. Push the project to GitHub, and the secret is published with it. Apiiro, an application-security research firm, counted 2,539 distinct exposed secrets across 1,994 public repositories (The Hacker News).

What the Claude Code secrets leak looks like, step by step

Four ordinary steps, none of which looks dangerous on its own:

  1. You ask the agent to run something that needs a credential: a database call with PGPASSWORD=... in front of it, or an sshpass -p ... login.
  2. The permission prompt appears, and you pick "Yes, and don't ask again", because you are going to run this twenty more times today.
  3. Claude Code stores the approval by saving the entire command, secret included, into .claude/settings.local.json.
  4. The .claude folder lives inside your project, so a routine git add . picks the file up. The word "local" in the file name describes where the settings apply, not where the file stays.

That is the catch of this whole story in one sentence: nothing in that flow tells you a permission click just wrote a password into a tracked file.

Who counted the 2,539 exposed secrets, and how?

The numbers are Apiiro's own measurement, not a vendor estimate and not an Anthropic disclosure. The firm searched GitHub for public copies of .claude/settings.local.json and examined 104,185 of them. Real secrets turned up in 1,122 of those files. Widening the sweep to git history and agent transcripts, the total came to 2,539 distinct exposed secrets across 1,994 public repositories, collected between November 1 and November 3, 2026 (The Hacker News).

The published breakdown of credential types includes 379 database passwords, 122 Supabase service-role keys and 43 SSH logins, some of them with root passwords. A Supabase service-role key is the one that bypasses row-level security, so a single hit of that kind is not a dusty test credential.

One more figure deserves attribution: Apiiro reports that TruffleHog and GitHub's own secret scanning missed 215 of these secrets. That is Apiiro's check of existing detectors against its own corpus, not an independent audit, and nobody outside the firm has published a replication of the count. This channel has not rerun the scan either.

Why do coding agents leak credentials that scanners usually catch?

Developers already know the old failure modes: committing a .env file, hardcoding a key in a config. GitHub secret scanning and open-source tools like Gitleaks and TruffleHog exist precisely for those, and they work reasonably well, because the secret appears in a shape they expect, roughly NAME=value or a provider-specific key prefix.

An agent's permission file breaks that shape. The secret is not a config value, it is a fragment inside a shell command string: PGPASSWORD=hunter2 psql -h db.internal ..., or sshpass -p hunter2 ssh root@.... The credential is surrounded by flags, quotes and JSON escaping. Detectors tuned for key-value patterns partly slide off it, which is how 215 live secrets survived two scanners.

There is a second, quieter surface in the same count: agent transcripts. The session log of what you and the agent said to each other is also written into the project, and Apiiro's total includes secrets found there and in git history, not only in the current settings file. So an agent-driven leak can outlive a cleanup of the one file everyone now knows about.

What the defenses cost, what they need, and where they stop

The first defense costs nothing and runs anywhere, because it is a line of text. Add the agent's state to your ignore list before the first push:

echo ".claude/settings.local.json" >> .gitignore

No hardware requirement, no API key, no account. It applies on any operating system where you already run git.

The second defense is behavioral and also free: stop putting the credential on the command line at all. If the password is never in the string the agent is asked to approve, there is nothing for the approval record to capture. The same applies to the prompt itself, since transcripts are part of the exposed corpus.

The third layer is scanning, and here the honest accounting matters. Gitleaks and TruffleHog are the tools the research names as the existing line of defense, and GitHub's secret scanning is built into the platform. The research note does not list their install commands, pricing tiers, versions or hardware requirements, so treat those as unstated here rather than assume they are all free in every configuration. What the research does state is the limit: against this specific leak shape, those detectors missed 215 secrets out of the corpus.

Where all of this stops: an ignore rule prevents the next commit, not the last one. Apiiro counted secrets in git history and transcripts separately from the live files, which means a repository can be clean today and still carry a valid key three hundred commits back. Nothing in the materials describes a way to un-publish a credential that has already been fetched, so the only reliable end state for an exposed key is rotation.

Use an explicit .gitignore entry instead of trusting GitHub secret scanning when the credential is embedded in a shell command, because that is exactly the case the scanners were shown to miss. Do not rely on the ignore entry alone if the repository was ever public, because the exposure may already be in history.

Verdict: who needs to act on this, and in what order

If you run Claude Code on any repository that is public, or that could become public, you are the target audience for this report, and the order of operations is simple. Check whether .claude/settings.local.json exists in your project and read it. Search your git history and your agent transcripts for the same strings. Rotate every credential you find, starting with database passwords, Supabase service-role keys and SSH logins, since those are the three categories Apiiro found most often. Then add the ignore line, and change the habit that put the password in the command.

If your work is entirely in private repositories, the urgency drops but does not vanish: the file still stores credentials in plaintext in the working tree, and private repositories get forked, archived and made public by accident.

If you have never clicked "Yes, and don't ask again" on a command containing a secret, you have nothing in this particular pile. The fix is cheap enough that it is still worth spending the sixty seconds to confirm that.

And a note on proportion: this is a convenience feature with a bad default, not evidence that agents are unusable. Apiiro's own framing is that the agent faithfully saved what the developer typed. The lesson generalizes past Claude Code to any coding agent that persists approvals or transcripts inside your project folder.

FAQ

Does this mean Claude Code is insecure?

Not in the sense of a vulnerability being exploited against you. The agent saves the command you approved, exactly as you typed it, which is what an approval record is for. The problem is that the saved file is not ignored by git by default, so a private convenience setting becomes a public artifact on push.

How do I check whether my own repository is affected?

Look for .claude/settings.local.json in the project and read its contents for anything that resembles a password, key or token inside a stored command. Then check git history and agent transcripts, because Apiiro's total of 2,539 secrets includes findings from both of those places, not only from current files.

Will Gitleaks, TruffleHog or GitHub secret scanning catch it?

Partly. Apiiro reports that TruffleHog and GitHub's own scanner missed 215 of the secrets it found, because the credentials sit inside shell-command strings rather than in the key-value shape those detectors expect. Keep the scanners, but do not treat a clean scan as proof.

Does fixing this cost anything?

The two defenses that matter here are free: an entry in .gitignore and the habit of keeping credentials out of commands you approve. Rotating leaked keys costs whatever your providers charge for the services involved, which the research does not quantify.

Who published these numbers, and have they been verified?

Apiiro, an application-security research firm, published the report on November 5, 2026, with data collected November 1 to 3, 2026, and the figures are its own scan and classification. No independent replication of the 2,539 count has been published in the materials covering this report.

Sources