Claude Code GitHub Secret Leaks: The Second Count Is Much Bigger
Key Takeaways
- The claude code github secret leaks are bigger than the first report suggested: after Apiiro found 1,379 secrets in public settings files, GitGuardian counted 31,088 distinct secrets in the same kind of file, and 5,343 of them still worked when GitGuardian checked.
- The leak comes from Claude Code saving an approved shell command word for word as an allow rule in
.claude/settings.local.json. If the command contained a password, API key or token, the secret was saved with it, in plain text. - The two counts are not contradictory. Apiiro scanned the files visible on GitHub in early November 2026; GitGuardian monitored every public commit from January 2025 to 7 November 2026, including versions later deleted or rewritten.
- The leak did not stop at GitHub. GitGuardian found 613 distinct secrets from Claude Code settings files inside public Docker Hub images, 99 of them valid, because a
COPY . .instruction copies the working folder, not just what git tracks. - Deleting the file does not undo the leak. Copies survive in git history, in forks and in container images, so every exposed credential has to be rotated first.
- Anthropic’s Claude Code lead, Boris Cherny, has said the team is looking into the problem and prototyping mitigations, including built-in secret scanning. No fix had been published as of the reporting available when this article was written.
- Search interest in the story surged as a breakout rising query under “claude” on Google Trends on 12 November 2026, days after the second count was published.
The First Report Was Only the Start
On 5 November 2026, security company Apiiro published research by Shmulik Cohen and Matan Giladi titled “Coding Agents Are Leaking Your Secrets to GitHub” — the report that started the Claude Code GitHub secret leaks story. The researchers had searched public GitHub repositories between 1 and 3 November 2026 for copies of Claude Code’s local settings file, .claude/settings.local.json. They examined 104,185 public copies of the file across 103,617 repositories, and found that 1,122 of them — about 1.1 percent — contained at least one real secret, with 1,379 distinct secret values between them. When they widened the search to git history, shared settings files and agent transcripts, the total rose to 2,539 distinct secrets across 1,994 repositories.
The mechanism behind those numbers is simple, and it was already explained in detail in our earlier coverage of the “don’t ask again” approval option, which is the feature that writes the file. When a developer approves a shell command in Claude Code with “Yes, and don’t ask again,” the tool saves the approved command word for word as an allow rule in .claude/settings.local.json inside the project folder. The rule is the command string itself, so a password or API key typed into the command is saved along with it. The file is meant to stay on the developer’s machine — Claude Code adds it to the machine’s global git excludes list — but that protection does not travel with the repository, and it cannot help a file that was already committed, a folder that becomes a repository later, or a clone on another machine. For the full walkthrough of how the feature works and why the gitignore protection has holes, see our earlier article on the Claude Code “don’t ask again” setting.
What the first report could not answer was the question every developer asked next: were those secrets actually live, and how much had been exposed over time rather than in a single snapshot? Apiiro deliberately did not test any credential or contact any host, so the number of credentials still valid was unknown. The only confirmation that a leaked key was live came from a single company Apiiro notified. A second, independent investigation has now answered the validity question — and its answer is worse than the first count suggested.
Claude Code GitHub Secret Leaks: What GitGuardian Counted
GitGuardian, a code security company, published its own analysis on 9 November 2026. Its researcher, Guillaume Valadon, had been tracking the same file since early 2026, after repeatedly finding n8n API keys inside Claude Code settings files while researching something else. Rather than taking a snapshot of the files visible today, GitGuardian scanned every public commit as it was pushed, from January 2025 through 7 November 2026, recording every version of the file it saw — including versions that were later deleted, rewritten or force-pushed away.
The headline numbers from GitGuardian’s monitoring are substantially larger than Apiiro’s. In .claude/settings.local.json alone, GitGuardian found 31,088 distinct secrets across 23,276 public repositories, written by 11,336 authors. Of those, 5,343 distinct secrets passed GitGuardian’s automatic, read-only validity check when they were detected. The shared project file, .claude/settings.json, added another 8,271 distinct secrets across 6,839 repositories, with 1,283 valid at detection.
Those two totals answer different questions, and GitGuardian is explicit about that. Apiiro asked what is exposed right now, using a conservative filter and no validity check. GitGuardian asked what was ever pushed, and counted every credential its automatic check found valid at detection. Both numbers are right. The second number is the number of credentials that should have been rotated.
There is an important limit on the GitGuardian figures too. A credential that passed the validity check at detection may have been rotated since, so the count of 5,343 does not mean 5,343 credentials are live today. What it does mean is that 5,343 credentials were live at the moment they were found in a file that was never supposed to leave a laptop. GitGuardian also notes that its validity figures are floors, not ceilings: detectors without a checker are never counted as valid, so the true number of working credentials is at least as high as the reported count.
The Secrets Were Real, and Thousands Still Worked
The most consequential difference between the two investigations is validity. Apiiro’s research showed exposure; GitGuardian’s shows that a large share of the exposed credentials actually worked. Where GitGuardian’s automatic check returned a verdict, 67 percent of occurrences in settings.local.json and 57 percent in settings.json were valid. Across everything GitGuardian found, 5,343 of 31,088 distinct secrets — about 17 percent — worked at detection.
The breakdown of what worked makes the risk concrete. Database credentials were the largest live category: GitGuardian found 1,955 distinct valid Postgres connection strings, 292 valid SSH passwords, 116 valid MongoDB connection strings and 2,280 distinct valid database identifiers in total. Cloud provider tokens were the next largest live bucket, with 971 distinct valid secrets, followed by AI tokens with 583. The valid haul also included 941 Google API keys, 355 Telegram bot tokens, 142 Resend keys and 186 DeepSeek keys.
That pattern matters because of what each kind of credential unlocks. A database connection string is not a vague risk: it is a username, a password and a network address, everything needed to connect. An SSH password can open a server. A cloud provider token can control infrastructure. These are not the kind of secrets that sit harmlessly in a repository. They are the kind that turn a public file into an open door, and the validity checks show that a meaningful share of the doors were unlocked.
It is also worth being precise about what the validity checks do not prove. GitGuardian’s check was automatic and read-only, and nothing was replayed for the research post. The check establishes that a credential worked when it was detected. It does not establish that anyone used it, or that it still works today. No evidence has been published that any of these credentials was exploited. The research shows exposure at scale, not demonstrated compromise — but a database password in a public repository is a problem whether or not anyone has used it yet, because anyone could.
What Kinds of Commands Carried the Secrets
GitGuardian located each secret inside the file to see which rule carried it, using a sample of about 3,000 occurrences. Every secret it could place sat in an allow rule or an environment block. None sat in a deny rule, which is what you would expect: deny rules block commands, they do not save them.
The single biggest carrier was curl, which accounted for 50 percent of the commands carrying secrets. The secrets in those rules were bearer tokens, JSON web tokens, username-and-password pairs passed with -u, Supabase service-role keys and API keys passed in headers. The volume is curl; the valid credentials, GitGuardian notes, are database and SSH.
The next carriers were environment-variable prefixes such as PGPASSWORD=..., DATABASE_URL=... and SUPABASE_ACCESS_TOKEN=..., at 15 percent of occurrences, leaking Postgres passwords and connection strings and Supabase tokens. export commands accounted for 5 percent, database clients such as psql, mysql, mongosh and redis-cli for 4 percent, sshpass and password-bearing SSH logins for 1 percent, and one-line node, python and npx commands for 3 percent. A small share, about 1 percent, came from commands that were not shell at all: WebFetch calls with credentials embedded in a URL, and file reads of paths containing a token.
The split explains a scanner gap that Apiiro had already measured. Apiiro found that Gitleaks flagged 564 of the 1,122 secret-bearing files it identified, and TruffleHog flagged 643 — and 215 files slipped past both tools. GitGuardian’s data shows why: generic detectors that only recognise provider key formats are blind to most of this file. Passwords, high-entropy strings, JSON web tokens, bearer tokens and username-and-password pairs produce 63 percent of all occurrences in settings.local.json — 44,755 of 71,525. A password after PGPASSWORD= has no recognisable prefix to match. A scanner that only knows what an Amazon or GitHub key looks like will walk straight past it.
The Leak Did Not Stop at GitHub
The most surprising finding in GitGuardian’s analysis is where the secrets went after GitHub. Apiiro had listed Docker images as a possible exit path. GitGuardian measured it, and the measurement shows a second, independent leak that git hygiene alone cannot fix.
Public Docker Hub images carry 109,284 occurrences of secrets in .claude/settings.local.json and 29,613 in .claude/settings.json, across 543 image repositories and 7,625 tags. The distinct count is 613 secrets, 99 of them valid at detection. The reason is a single instruction: COPY . .. That instruction copies the working folder into the image, not the git index, so a file that git ignores still ships in the container unless .dockerignore lists .claude/. About 72 percent of the secrets sit under /app, /workspace or /usr/src — a repository copied wholesale into an image.
The concentration is striking. One valid Cloudflare API token appears in 559 tags of a single image, because one committed file is rebuilt into every tag. One database password appears in 643 tags across seven image repositories. Deleting the file from the repository does nothing for the images already pushed, and rebuilding an image from a cleaned repository does not remove the tags that were already published. The Docker Hub finding also explains a detail in the GitGuardian data that would otherwise look odd: some credentials that were revoked on GitHub kept appearing in images, because the images were built before the revocation and never rebuilt.
The Leak Peaked in April, Then Fell Sharply
Continuous monitoring also shows the leak over time, and the shape of the curve is unexpected. Leaks in settings.local.json start in June 2025 with 256 occurrences, pass 3,000 a month by October, and reach 12,535 in April 2026. Then they fall: 5,276 in June, 1,916 in August, 959 in October. That is a 92 percent drop from the peak. The shared settings.json file follows the same shape with a one-month lag, peaking in May at 3,084 occurrences and down 84 percent by October.
GitGuardian is candid that it does not know what changed. The candidates listed in the research are a Claude Code change to the permission prompt or its ignore handling, adoption flattening, GitHub’s push protection, or a change in GitGuardian’s own detector coverage. The researchers say they have not finished ruling out changes on their side, and that the rest is a question for Anthropic.
The decline does not make the earlier exposure go away. Apiiro found that the median leaking file had sat on its repository’s default branch for 217 days, and GitGuardian’s own data shows that history, forks and images preserve copies long after the current file is cleaned. A leak that peaked in April is still a live credential in October if nobody rotated it. The falling curve is good news about the flow of new leaks; it says nothing about the stock of secrets already out there.
It Was Not Just One File
GitGuardian’s analysis also looked beyond the two settings files, and the wider picture shows that the settings file is one symptom of a broader habit: developers paste real credentials into the files they give to AI coding tools.
The shared project file, .claude/settings.json, leaks for a second reason. A quarter of its leaking versions contain an env block pointing Claude Code at a third-party Anthropic-compatible gateway, with an ANTHROPIC_BASE_URL and an ANTHROPIC_AUTH_TOKEN. The hosts include DeepSeek, OpenRouter, Z.ai, MiniMax, Alibaba’s DashScope, Kimi and Moonshot, along with a long tail of resellers. The credential that leaks is the gateway’s: 205 valid DeepSeek keys, 62 valid OpenRouter keys and 50 valid MiniMax keys in settings.json. Real Anthropic API keys are rare in both files — 139 distinct in settings.local.json, 28 of them valid.
Two more Claude Code files deserve attention. CLAUDE.md, the instructions file developers write for the agent, holds 6,155 distinct secrets, 2,537 of them valid — the highest validity rate of any file GitGuardian looked at. Developers paste real connection strings into the instructions they give the agent. And .claude/.credentials.json, the agent’s own OAuth login to Anthropic, which lives in the home directory, appears in 371 repositories with 1,366 distinct tokens: whole home directories were committed. The problem is not unique to Claude Code either. Codex has the same issue with .codex/auth.json, which holds 1,064 tokens in 536 repositories.
Apiiro’s comparison of 16 coding agents, based on their documentation, found Claude Code to be the only one confirmed to write the full approved command to a project file by default. GitGuardian counted the config files of 30 agents on public GitHub and found that all of them leak, and all of them leak the same way: MCP server definitions with API keys in environment blocks. Judged by the mix of detector types per file, only .claude/settings.local.json is dominated by credentials typed into commands — which is what a persisted approval looks like. The settings file is the distinctive leak; the wider pattern is an industry-wide habit of putting secrets where agents can read them.
Who Was Affected
GitGuardian classified the git author’s email domain for every occurrence in both files. Personal mail providers account for 15,993 distinct secrets, 4,270 of them valid. GitHub noreply addresses add 3,084, with 773 valid. Corporate or custom domains hold 5,924 secrets across 3,338 domains, with 1,499 valid, and 266 academic domains hold 426 secrets, with 103 valid.
Matching the corporate domains against company records gives a sector view for 417 organisations. Education and research lead with 172 institutions and 75 valid credentials, followed by software and IT services with 141 companies and 69 valid credentials. Together they are three-quarters of the matched set. The rest is a long tail: telecom with 15 organisations, retail with 13, finance and insurance with 11, media and marketing with 10, industry and construction with 10, healthcare with 5, and government and defence with 4. GitGuardian notes that the sample is biased toward companies it has records for, so the ranking should be read as a ranking, not as absolute counts.
There is also evidence that the agent itself was part of the chain that moved files into public repositories. In 263 repositories, the leaking commit carries Claude’s noreply address as its git author, which means Claude Code or its GitHub action made the commit on the user’s behalf: 406 distinct secrets, 107 of them valid. Apiiro saw the same pattern as a co-author trailer in 539 of the 1,105 repositories it traced. That does not prove Claude pushed any particular secret — a co-authored commit is not proof of who pushed what — but it shows how easily an agent can be part of the chain that moves the file into a public repository.
What Anthropic Said
The response from Anthropic so far has come from Boris Cherny, the head of Claude Code, in a Hacker News discussion, as reported by iTnews and covered by InfoWorld and other outlets. Cherny said the team is looking into the problem, that Claude Code has not historically scrubbed secrets, and that mitigations are being prototyped, including auto mode and built-in secret scanning — while acknowledging that those measures may not fully solve the problem.
Cherny also said Claude Code gitignores the file when it creates it, and suggested that the exposed copies were likely created manually and committed, recommending auto mode over permission rules together with the secret scanning of GitHub and other hosts. GitGuardian’s findings push back on part of that account. In the roughly 3,000 occurrences the researchers inspected, every secret sat in an allow rule of the exact shape the permission prompt writes, not in text that looked typed by hand. And 63 percent of what GitGuardian found are passwords and tokens with no provider format, the kind of secret that a permission rule captures and a format-based scanner misses.
As of the reporting available when this article was written, Anthropic had not published a fix, and no patched Claude Code version addressing the leak had been identified in coverage. The issue itself is not new: a bug report on Claude Code’s GitHub tracker, issue #5544, described plaintext credentials being stored in approved commands as early as August 2025. That report was closed automatically after 60 days of inactivity, according to coverage of the research. For the full timeline of that earlier warning and the first research, the Apiiro report itself is the primary source, and GitGuardian’s blog post is the primary source for the second count.
How to Check Whether You Leaked Something
If you have used Claude Code, and especially if you have used “don’t ask again,” it is worth spending time checking. The sequence below is drawn from the guidance published alongside both investigations.
Search your GitHub organisation. Search GitHub for .claude/settings.local.json and .claude/settings.json in your organisation’s repositories. Each hit in a public repository is a file anyone can read right now. Search git history, not just the current files: 734 of the secrets Apiiro counted existed only in older commits, and GitGuardian’s monitoring shows that versions deleted from the current file survive in history. Also check your Docker Hub images and any other container registry, since a COPY . . build can carry the file into an image even when git ignores it.
Check your local files. Open .claude/settings.local.json in every project you have used Claude Code in, and look at what is in it. Search it for passwords, tokens and keys. Also check CLAUDE.md and .claude/settings.json — GitGuardian found thousands of live secrets in both. If you find a credential anywhere in these files, treat it as compromised from the moment the file left your machine.
Rotate first, then clean. If a secret was exposed, rotate it before you do anything else. Deleting the file does not remove the secret, because history, forks and Docker Hub images keep copies — Apiiro found 211 forks carrying copies of leaked files. Remove the file from tracking with git rm --cached, add it to the repository’s own .gitignore as well as your global excludes, and add .claude/ to .dockerignore. Rewriting history is disruptive on shared repositories and does not reach forks or published images, so assume a leaked secret has spread and rotate it regardless of whether you can delete every copy.
Use a scanner, but do not rely on it alone. Gitleaks flagged only 564 of the 1,122 secret-bearing files Apiiro found, and TruffleHog flagged 643. Both missed 215 files, mostly passwords typed inside commands. GitGuardian’s data explains why: most of the secrets in this file have no provider format for a scanner to match. A manual look at the file catches what pattern matching misses.
How to Stop It Happening Again
The fix that matters most is a habit, not a tool: never type a secret into a command that Claude Code runs. If a command needs a password, token or key, reference it as a variable from your environment or secrets manager instead. The allow rule stores the literal string, so it records the variable name, not the value — though the value can still reach the transcript if the shell echoes it. If you are about to approve a command and you can see a credential in it, approve it once if you must run it at all, and never pick “don’t ask again” for it.
Prefer narrow allow rules you write yourself. GitGuardian’s guidance is to use a narrow prefix such as Bash(curl -H "X-N8N-API-KEY: $N8N_API_KEY" https://n8n.example.internal:*) rather than Bash(curl:*), which approves any curl command — including one written by a prompt injection. You can view and edit your rules with the /permissions command, which lists every rule together with the settings file it came from. Delete every rule containing a secret.
For security teams, GitGuardian recommends treating .claude/, .cursor/, .gemini/, .codex/, .mcp.json and CLAUDE.md as secret-bearing, like .env files. Scan them in pre-commit hooks, in CI, in history and in your container registry, and make sure the scanner catches passwords inside commands, not only provider key formats. GitGuardian also offers hooks that plug its ggshield scanner into the agent’s own hook system, scanning shell commands before they execute — though the company notes that a hook fails open when the scanner is not authenticated, and that blocking a command does not fix the habit of pasting secrets into commands.
For Anthropic, GitGuardian’s recommendation is direct: the fix belongs in the tool. Never persist an exact-match rule whose command contains a variable-equals-value prefix, a header value, URL user information or a password flag; offer a session-only approval instead. That is a design change, not a documentation change, and it is the only fix that protects the developer who clicks “don’t ask again” on autopilot at the end of a long session.
The same discipline applies to other AI coding tools. Our check of a tampered Claude Code extension covers a different way an AI coding tool can go wrong — a compromised extension rather than a careless click — and the lesson is the same: the files and extensions around your coding agent deserve the same scrutiny as the code it writes.
The Bottom Line
The first count of the Claude Code GitHub secret leaks — 1,379 secrets in 1,122 public files — was alarming enough. The second count shows it was an undercount of what was ever exposed: 31,088 distinct secrets in the same kind of file, 5,343 of them still valid when detected, plus 613 more in public Docker Hub images, plus thousands more in the shared settings file, in CLAUDE.md and in credential files that were never meant to leave a home directory.
None of that means Claude Code is unsafe to use, and none of it means any particular credential was exploited — no evidence of exploitation has been published. What it means is that a convenience feature which saves literal text will eventually save something you did not mean to share, and that the copies spread further than a single repository: into history, into forks and into container images. The leak peaked in April 2026 and has fallen sharply since, but the secrets leaked in April are still secrets unless somebody rotated them.
So check your own repositories for .claude/settings.local.json today, rotate anything it ever held, add .claude/ to your .gitignore and .dockerignore, and stop putting secrets in commands. The ten minutes it takes are cheap. The database password sitting in a public repository — and in a public container image — is not.