Claude Code Secrets Leak: What the Apiiro Findings Mean for Your Enterprise

Apiiro found 2,539 real secrets leaked to public GitHub via Claude Code's Don't Ask Again feature. Here's the enterprise audit and response playbook.


TLDR: Apiiro’s November 2026 research found 2,539 real credentials sitting in public GitHub repos, leaked through Claude Code’s “Don’t Ask Again” permission feature. The mechanism is simple: approve a command containing a secret once, and the full command - secret included - lands in .claude/settings.local.json, which gets committed like any other project file. Anthropic’s head of Claude Code says fixes are being prototyped, but nothing has shipped. Don’t wait for a patch. Audit your org’s repos for agent config files on Monday morning, rotate anything you find, and push enforcement into managed settings and pre-commit hooks this week.

Why This Matters Now

On November 5, application-security vendor Apiiro published research that hit 556 points and 387 comments on Hacker News within days. The headline number: 1,122 public copies of Claude Code’s .claude/settings.local.json containing a real, usable secret, out of 104,185 public copies scanned. Counting git history, shared settings files, and agent transcripts, the total reaches 2,539 distinct secrets across 1,994 repositories - including a database vendor’s own admin-level cloud key, a production Azure Postgres password, a Square production token, and the owner password of a medical-records database.

But the number isn’t the story. The mechanism is. This isn’t a model jailbreak or a supply-chain backdoor like the Cursor marketplace incident StackScout covered in October. It’s a UX default: a convenience feature doing exactly what it was designed to do, with nobody thinking through where the output lands. Anthropic’s head of Claude Code, Boris Cherny, responded on HN on November 7 saying the team is “looking into what we can do to prevent this” and prototyping fixes. That means there’s no patch today, and the 63 affected organizations Apiiro identified are cleaning up on their own.

If your developers use Claude Code - and statistically, many of them do - this is your Monday-morning audit.

The Leak at a Glance

DimensionWhat Apiiro Found
Files scanned104,185 public .claude/settings.local.json copies
Files with a real secret1,122 (about 1.1%)
Total secrets, all sources2,539 across 1,994 repos
Git history only734 secrets in 509 repos where the file was already deleted
Forks carrying secrets211 forks of 74 repos
Organizations affected63, from student groups to established vendors
Standard scanner catch rateGitleaks caught 564 of 1,122; TruffleHog caught 643; 215 caught by neither
Other agent files leakingShared settings.json (298 files), chat transcripts (120), handoff notes (33), Copilot auto-approve settings (9)
Anthropic’s responseAcknowledged Nov 7; fixes in prototype, nothing shipped

How a Secret Ends Up in a Settings File

Ask Claude Code to check a database or call an API, and the command it proposes carries the secret straight from your config or your typed input. Something like PGPASSWORD=s3cret psql -h prod-db.internal. Claude Code does ask before running it. Fair enough.

Here’s the catch: pick “Yes, and don’t ask again” and Claude Code saves that exact command - secret included - as an allow rule in .claude/settings.local.json inside the project folder. Nothing about that file signals “private.” It sits next to your source code, and unless someone added it to .gitignore, it gets committed with everything else.

Claude Code’s own docs confirm the gap: “Claude Code keeps it out of git when it creates the file; if you create it by hand, add it to .gitignore yourself.” The protection only applies when Claude Code creates the file - plenty of copies get tracked anyway. And deleting the file doesn’t fix it. Apiiro found 734 real secrets living only in git history. Every fork and clone carries them too.

Earned insight: I’ve watched this exact pattern play out with .env files for a decade - the file everyone agrees should never be committed, committed anyway by someone in a hurry on a Friday. The difference here is scale and invisibility: a developer never typed a secret into a file at all. They clicked a convenience button in a CLI prompt. Your existing “don’t commit secrets” training never covered this, because the secret went into version control without anyone making a conscious decision to put it there.

What Standard Scanners Miss

You’d think secret scanning would catch this. It mostly doesn’t. Apiiro ran both gitleaks and TruffleHog across all 104,185 files. Gitleaks flagged 564 of the 1,122 secret-bearing files. TruffleHog flagged 643. And 215 files were flagged by neither tool.

The problem is what these scanners look for. They’re tuned to key formats: an AKIA prefix, a long random string, a known provider pattern. But a password typed after PGPASSWORD=, sshpass -p, or mysql -p is an ordinary word in an ordinary command line. A bearer token in a curl header looks like any other header value. Both tools mostly wave those through.

If your org relies on GitHub secret scanning or a pre-commit hook running default gitleaks rules, you’ve got a blind spot shaped exactly like this leak. The same password-in-a-command pattern shows up in transcripts, memory files, and handoff notes - and format-tuned scanners miss it in all of them.

The Monday-Morning Audit: Check If You’re Affected

Do these four things before lunch, adapted from Apiiro’s remediation guidance and reordered for enterprise speed.

1. Search your org for the files

Search every GitHub organization you own for .claude/settings.local.json and .claude/settings.json. Each hit on a public repo is a file anyone on the internet can read right now. Don’t stop at Claude Code: Apiiro found secrets in .cursor/ folders, .gemini/ folders, .specstory/ transcripts, agent memory files, and VS Code Copilot auto-approve settings. Treat every agent config directory as secret-bearing, the way you already treat .env.

2. Check git history, not just the current tree

For each repo with a hit, search history for the file even if it’s gone today. If history has it, so does every fork and clone. Apiiro’s data says deleted files still held 734 live secrets. git log --all --full-history -- .claude/settings.local.json is the command. Run it across your estate with whatever repo-inventory tooling you have.

3. Read the allow lists on developer machines

Ask developers - or better, push a script through your device-management tooling - to dump every local copy of the file and read its allow list. Each entry is a command someone approved, with whatever they typed into it. Look for passwords, tokens, keys, and connection strings. The file is plain JSON in the project folder. It takes thirty seconds to read.

4. Rotate first, clean up second

If you find something: rotate the credential before you do anything else. Removing the file doesn’t clear history, forks, or clones. Triage credentials paired with public hosts first - those are the ones that give an attacker direct access. Then untrack the file (git rm --cached .claude/settings.local.json), add it to the repo’s .gitignore, and scrub history with git filter-repo or BFG where the exposure warrants it.

Warning: Rotating a database password that eleven microservices share without coordinating the rollout will cause an outage that dwarfs the original leak. Map every consumer of a credential before you rotate it. Triage order is: externally reachable credentials first, then shared internal ones with a coordinated rotation plan, then everything else.

Locking It Down: Policy and Tooling That Actually Work

The audit stops the bleeding. These five controls keep it from happening again - and they assume developers will keep clicking convenient buttons, which they will.

Push agent folders into managed settings

Claude Code supports managed-settings.json deployed by IT - the enterprise policy lever that users can’t override. Use it to set default deny rules for commands containing credential patterns, and to restrict who can create permanent allow rules. If you’re rolling out Claude Code org-wide without managed settings deployed, you’re distributing the loaded gun without the safety. This is the single highest-leverage control on the list.

Ban literal secrets in commands, not just in files

The root habit is typing a secret into a command line that an agent then records. The fix is referencing secrets as $VAR from whatever secrets manager you use - HashiCorp Vault, AWS Secrets Manager, 1Password CLI, Doppler, whatever your standard is - so the allow rule records $DB_URL, not the credential. Make this a written rule in your secrets-management policy, and add AI-coding-agent clauses alongside your existing .env and CI-secret language.

Approve patterns, not literal commands

Claude Code allow rules support wildcards. Bash(npm run:*) never contains a secret. An allow rule with a full connection string always does. Train developers to write pattern rules, and consider linting committed settings.json files for literal credential shapes in CI. This one habit eliminates the entire class of leak.

Extend secret scanning to agent folders and command-shaped secrets

Add .claude/, .cursor/, .gemini/, .specstory/, and agent memory files to your pre-commit and CI scanning scope, including history scans. Then go further: add custom rules for the password-in-command shapes Apiiro documented - PGPASSWORD=, sshpass -p, mysql -p, bearer headers in curl invocations. Default gitleaks and TruffleHog rules miss these. Custom rules targeting command-shaped secrets are the control most orgs are missing, and Apiiro’s 215-caught-by-neither number is the proof.

Enable GitHub push protection org-wide

Push protection blocks the commit at push time rather than alerting after the secret is already public. It doesn’t catch everything - see the scanner-gap section above - but it converts silent leaks into blocked pushes with developer education attached. If you haven’t enabled it with delegated bypass for break-glass cases, this incident is your justification memo.

Earned insight: In every org I’ve seen roll out AI coding tools, security finds out months after engineering adopted them. The developers didn’t hide anything - they just never thought of a CLI coding assistant as a secrets-handling surface. If your software inventory doesn’t list which AI coding agents are installed on developer machines, you can’t scope this audit. Asset inventory for AI tools is the prerequisite nobody mentions, and it’s the reason most orgs will undercount their exposure on the first pass.

Responding with policy + tooling Strengths:

  • Fixes the whole class of leak, not just this file - transcripts, memory files, and handoff notes get covered by the same controls
  • Managed settings and push protection work silently; developers keep their velocity
  • Most controls are free or already licensed (gitleaks, TruffleHog, GitHub push protection, .gitignore templates)

Responding with policy + tooling Weaknesses:

  • History scrubbing and coordinated rotation are labor-intensive for large estates - budget days, not hours
  • Custom scanner rules for command-shaped secrets need ongoing tuning as agent output formats change
  • Managed-settings deployment requires MDM or endpoint tooling maturity some orgs don’t have yet

Waiting for Anthropic’s fix Strengths:

  • Zero effort today; native secret scrubbing would be cleaner than bolted-on scanner rules
  • Anthropic has acknowledged the issue publicly, which is more than the ignored GitHub issues since August 2025 got

Waiting for Anthropic’s fix Weaknesses:

  • “Prototyping” with no ship date, and the same concerns sat unanswered in GitHub issues (#5544, #11982, #13106) for over a year
  • A vendor fix can’t scrub your git history, your forks, or secrets already committed - the audit is unavoidable regardless
  • Auto-mode flows have the same flaw by Anthropic’s own admission (“good catch”), so the fix surface is bigger than one prompt button

Pricing Reality: What the Response Actually Costs

No new vendor purchase is required. Here’s the honest accounting of what each layer costs, verified November 8, 2026.

ControlTooling costReal cost
Org-wide repo + history auditFree (scripts + existing inventory)1-3 engineer-days for a mid-size estate; more if you lack repo inventory
Credential rotationFreeThe coordination cost - mapping consumers, sequencing rollouts, handling shared secrets. This is where the real budget goes.
Gitleaks / TruffleHog in pre-commit + CIFree (open source)Half a day to deploy, ongoing rule-tuning as agent formats evolve
GitHub push protectionIncluded in GitHub Advanced Security ($49/user/year) or free for public reposIf you don’t already license Advanced Security org-wide, this incident is the business case - but price it for the whole program, not this fix alone
GitGuardian / Nightfall-style monitoringRoughly $20-30/developer/month at enterprise tiersWorth pricing if you want continuous monitoring beyond pre-commit; overkill if your audit finds zero hits
Managed-settings deploymentFree (Claude Code feature)Requires endpoint-management maturity - Intune, Jamf, or equivalent already in place

The expensive part isn’t tooling - it’s rotation coordination and policy work. Budget a sprint, not a purchase order.

Who Should Act Monday, and Who Can Breathe

Act on Monday morning if any of these describe you:

  • Your developers use Claude Code, Cursor, Gemini CLI, or any agent that records approved commands - which, per Apiiro’s data, is the only agent confirmed to write full commands to a project file by default, but the transcript-leak pattern applies broadly
  • You have public repos in your GitHub org and no org-wide .gitignore template covering agent folders
  • Your secret scanning runs default rules only, with no command-shaped-secret coverage
  • You rolled out AI coding tools without managed-settings or equivalent policy enforcement

You can deprioritize if:

  • Your org bans public repos entirely and your private-repo audit comes back clean - the mechanism still exists locally, but the blast radius is malware-on-laptop rather than internet-visible
  • You already enforce secrets-via-environment-variables and pattern-only allow rules - you’ve accidentally implemented the fix
  • Your developers don’t use agentic coding tools at all - check anyway, because shadow adoption is exactly how these tools spread, and Apiiro found affected orgs that likely didn’t know

Tip: The fastest scoping question you can ask on Monday: “Who here has clicked Don’t Ask Again in the last month?” Anyone who says yes gets their allow list reviewed first. It turns an estate-wide audit into a prioritized queue in one standup question.

Bottom Line

This is a UX-default problem, not a model problem - and that’s good news, because the fix is enterprise policy plus tooling, not banning the tool or waiting for a vendor patch. Apiiro’s 2,539 secrets are the visible tip; your private repos and developer laptops are the part that matters to you. Audit for agent config files the way you audit for .env files, rotate what you find, then push the five controls in this guide starting with managed settings and pattern-only allow rules.

The single biggest prerequisite: knowing which AI coding agents are installed in your estate. And the point worth carrying into your next security review: every new agentic tool your developers adopt is a new secrets-handling surface until proven otherwise. Treat agent folders as secret-bearing by default.

Your 30-day action: complete the four-step audit this week, deploy managed-settings restrictions and command-shaped scanner rules within 30 days, and add an AI-coding-agent clause to your secrets-management policy before your next policy review cycle.

FAQ

Does Claude Code’s Don’t Ask Again feature send secrets to Anthropic?

No - that’s not the mechanism here. The secret stays local; the problem is that the full approved command, secret included, gets written to .claude/settings.local.json in your project folder, which then gets committed to git. Anthropic’s servers aren’t the exposure path. Your repository is. This distinction matters because it means network DLP and API logging won’t catch it - you need repo-side and endpoint-side controls, not network monitoring.

How do I check if my organization is affected?

Search every GitHub org you own for .claude/settings.local.json and .claude/settings.json, including public repos first. Then check git history in each hit repo - Apiiro found 734 secrets living only in history after the file was deleted. Then review local allow lists on developer machines. Rotate anything you find before cleaning up, since deletion doesn’t clear forks or clones. The full four-step sequence is in the audit section above.

Will gitleaks or TruffleHog catch these leaked secrets?

Only partially. Apiiro ran both across all 104,185 files: gitleaks flagged 564 of the 1,122 secret-bearing files, TruffleHog flagged 643, and 215 were caught by neither. The gap is passwords inside commands - PGPASSWORD=, sshpass -p, bearer headers - which don’t match the key formats these scanners target. You need custom rules for command-shaped secrets on top of default scanning, plus GitHub push protection as a backstop.

Has Anthropic fixed the secrets leak?

Not yet. Boris Cherny, Anthropic’s head of Claude Code, responded on Hacker News on November 7 saying the team is “looking into what we can do to prevent this” and prototyping approaches including auto-mode detection and built-in secret scanning. But GitHub issues reporting this exact mechanism (#5544, #11982, #13106) have sat unanswered since August 2025. Don’t plan around a vendor patch - implement the policy and tooling controls in this guide now.

Does this affect Cursor, Copilot, and Gemini CLI too?

The confirmed default-write-to-project-file behavior is specific to Claude Code, per Apiiro’s review of 16 coding agents’ documentation. But the broader pattern - agents recording secrets into committed files - showed up across tools: 120 secrets in agent chat transcripts, 33 in handoff notes, 9 in VS Code Copilot auto-approve settings. Audit every agent’s config and output folders, not just Claude Code’s. The habit that leaks - typing secrets into commands agents record - is tool-agnostic.

Should we ban Claude Code over this?

No. Banning the tool pushes usage underground, where you lose all visibility - that’s the shadow-AI trap. The leak is a policy and defaults problem with known fixes: managed settings, pattern-only allow rules, secrets via environment variables, and command-shaped scanner coverage. Orgs that implement these keep the productivity gains with the exposure closed. Save bans for tools whose vendors won’t engage; Anthropic has at least publicly acknowledged this one.


James Whitfield — Enterprise AI Strategy Advisor
James Whitfield Enterprise AI Strategy Advisor

James has 23 years in enterprise IT strategy, the last decade focused on helping large organizations move AI initiatives from pilot to production. He has designed AI centers of excellence, built governance frameworks adopted across regulated industries, and advised on enterprise AI risk at the board level. He has seen more "transformational" AI deployments stall at 90% than most vendors would admit exist. His writing focuses on the organizational and procurement realities that determine whether AI investments actually deliver.

Discussion