Back to Blog
Hamza Farooq/December 1, 2026/6 min read

Claude Code settings.local.json secrets leak: how to audit your own repositories

Claude Code settings.local.json secrets leak: how to audit your own repositories

Security firm Apiiro reported in early November that 1,122 of 104,185 public copies of .claude/settings.local.json contained at least one secret. Claude Code writes that file when a developer chooses "Yes, and don't ask again" on a shell command, and the saved rule is the command text, so a password typed into the command is saved with it. These are Apiiro's figures, relayed by the Cloud Security Alliance and The Hacker News.

TL;DR: Per Apiiro, 1,122 public copies of.claude/settings.local.json held at least one secret, because Claude Code stores the full approved command as an allow rule. To audit your own repositories, look for tracked copies of the file, including in git history, rotate any credential that ever appeared in one, then untrack the file, add it to the project's.gitignore, and stop typing secrets into commands you approve.

Key Takeaways

  • The trigger: Choosing "Yes, and don't ask again" on a Bash command saves an allow rule in .claude/settings.local.json, and Anthropic's docs say so.
  • The claim: Apiiro reports 1,122 of 104,185 public copies held at least one secret, 1,379 distinct secrets in total. CSA says it has not replicated the search.
  • The history problem: Apiiro reports 734 more secrets that sit in older file versions that no current copy contains.
  • The scanner gap: Gitleaks and TruffleHog together missed 215 of the 1,122 files, per Apiiro, mostly passwords inside command syntax.
  • The order of work: Rotate credentials first, then untrack the file, then fix the habit.

What did Apiiro find in public settings.local.json files?

Apiiro found 104,185 public copies of the file in 103,617 repositories, and 1,122 of those copies, about 1.1%, contained at least one secret, according to the CSA research note. Together they held 1,379 distinct secrets, including 379 database passwords, 43 SSH logins, 42 GitHub, GitLab and npm tokens, and 23 AWS keys.

Two limits matter. Apiiro did not test whether the secrets still work, though one notified company confirmed its key had been live. CSA also says its note was generated with AI assistance and has not gone through official review. Treat the numbers as a vendor's claims.

Dates vary by outlet. The CSA note gives 6 November for Apiiro's post, Let's Data Science gives 5 November, and The Hacker News article is dated 7 November. I could not read Apiiro's own post, so I settle neither.

How does a "don't ask again" approval end up holding a password?

The approval becomes an allow rule that contains the exact command, so any secret typed inline is stored in plain text. Anthropic's settings documentation says Claude Code writes .claude/settings.local.json when you choose "Yes, and don't ask again" for a Bash command. Its permissions documentation lists the lifetime of that approval as "Permanently per repository and command".

The same settings page says Claude Code adds **/.claude/settings.local.json to your global git excludes file the first time it writes the file. By the CSA note's reading, that protects one developer on one machine and does not travel with the repository to a teammate's clone, a CI runner or a package tarball.

The problem was reported before. A GitHub issue filed on 11 August of the previous year described approved commands with credentials stored verbatim in the file. It was closed as not planned on 3 January 2026 after 60 days of inactivity. The Anthropic pages I read do not describe redacting stored rules.

A flat timeline of the GitHub issue, the Apiiro post, The Hacker News article and the CSA note, with dates as the sources give them

Why do Apiiro's and GitGuardian's numbers differ?

They are separate counts from separate firms, and the sources I read do not reconcile them. InfoWorld reports that GitGuardian found 31,088 distinct secrets in these files across 23,276 public GitHub repositories, with 5,343 still valid when detected. I did not read GitGuardian's own post, and the InfoWorld page does not explain how its counting differs from Apiiro's, so I treat 31,088 as secondary and unverified.

MeasureReported valueSource
Public copies of the file examined (Apiiro)104,185 in 103,617 repositoriesCSA note
Copies with at least one secret (Apiiro)1,122, about 1.1%The Hacker News
Extra secrets in older versions (Apiiro)734 across 509 repositoriesThe Hacker News
Missed by both Gitleaks and TruffleHog (Apiiro)215 of the 1,122 filesCSA note
Distinct secrets (GitGuardian)31,088, with 5,343 valid when detectedInfoWorld

How do you audit your own repositories?

Start with whether the file is tracked now or ever was, because older versions in history can hold secrets that no current copy contains. The CSA note advises searching organization-owned repositories, including forks and archived ones, for both .claude/settings.local.json and .claude/settings.json, and scanning full history, not just the default branch.

My suggestion: run these in a repository. They print file paths, commit summaries or rule numbers, not the contents of the file.

# Tracked right now?
git ls-files | grep -E '(^|/)\.claude/settings(\.local)?\.json$'

# Ever committed on any branch?
git log --all --oneline --.claude/settings.local.json

# Ignored by the project, not just your machine?
git check-ignore -v.claude/settings.local.json

# Risky-looking saved rules (prints rule numbers only)
jq -r '(.permissions.allow // []) | to_entries[] | select(.value | test("PGPASSWORD=|sshpass -p|mysql.*-p|Bearer |password|token|secret|api[_-]?key"; "i")) |.key'.claude/settings.local.json

For packages, the CSA note suggests npm pack --dry-run in release pipelines, failing the build if agent files appear.

A flat checklist diagram of four steps in order: rotate credentials, untrack the file, ignore it in the project, scan history

What should you change so it does not happen again?

Rotate first, because deleting the file or rewriting history does not revoke a credential. After rotation, the note's steps are git rm --cached.claude/settings.local.json, an entry in the repository's own .gitignore, and deleting any local allow rule that contains a literal secret.

My suggestion: pass credentials through environment variables or a credential helper, so the approved command reads $DB_URL and not a password. The CSA note also prefers pattern rules such as Bash(npm run *), which Anthropic's permissions page documents, over approving one fully specified command. It warns that broad patterns on tools such as curl, ssh or database clients widen what the agent can run without asking.

My suggestion: add .claude/, .cursor/ and .gemini/ to your ignore templates, and add custom scanner rules for PGPASSWORD=, sshpass -p and mysql -p, which the CSA note says default rulesets miss.

Frequently Asked Questions

Is my repository affected if I never click "don't ask again"?

Probably not through this path. The standing approval is what writes the rule, per Anthropic's settings page. The shared .claude/settings.json is a separate file, and the CSA note's table of Apiiro figures lists 298 of 76,011 copies of it with secrets, so check both files.

Does adding the file to.gitignore fix a leak that already happened?

No. Per the CSA note, rotation comes first because deleting the file or rewriting history does not undo a leak. Its sequence is to rotate the credential, run git rm --cached on the file, then add the entry to the repository's .gitignore.

Can the file leak without a git push?

Yes, according to the CSA note. It cites a Check Point scan, reported by SecurityBrief, that found 428 packages shipping the file, with 33 files across 30 packages holding credentials. It calls other channels, such as container builds, an inference and not observed incidents.

Has Anthropic fixed this?

I found no fix in the sources I read. InfoWorld, citing GitGuardian, says Boris Cherny said the company was looking into added safeguards, including built-in secret scanning.

Conclusion

Audit now and rotate before you clean. Check tracked files and history, treat any credential that appeared in these files as exposed, and keep secrets out of approved commands. My suggestion: until Anthropic ships a change, treat your own habit as the control.


Learn from me

Agent Engineering Bootcamp: Developers Edition

Agent Engineering Bootcamp: Developers Edition, my Maven cohort. Advanced agentic RAG, multi-agent orchestration, memory, evals, and guardrails. Take agents from prototype to production. Join the next cohort →

Hire us

Traversaal.ai. We're a team of forward deployed engineers solving the toughest AI problems for Fortune 100 companies: document intelligence, agentic data platforms, and real-time web intelligence, deployed in production. Work with our team to deploy your next agentic ecosystem. Talk to Traversaal.ai →

Join us

Want to solve these problems with us? We're always looking for forward deployed engineers who want to ship production AI. jobs@traversaal.ai

Hamza Farooq
Hamza Farooq

Former Senior Research Manager at Google and Walmart Labs, leading teams in optimization, NLP, recommender systems, and time series forecasting.