🛡️ Safety & Reliability

Claude Code settings.local.json leaked secrets: check your repos and fix it

Security firm Apiiro found 1,379 real secrets in public copies of Claude Code's `.claude/settings.local.json` file, and the wider count reaches 2,539 once git history and related files are included. The Claude Code settings.local.json leaked secrets came from one button: when a developer approves a shell command with "Yes, and don't ask again", Claude Code saves that approved command as an allow rule in the file. If the command carried a password or a token, the secret is saved with it in plain text. Apiiro counted 104,185 public copies of the file, and 1,122 of them held a real secret. This guide shows how to check your own repos, rotate what leaked, and remove the file from history.

Claude Code settings.local.json leaked secrets: check your repos and fix it
Quick Answer

Check every repo you push to GitHub for a tracked .claude/settings.local.json, read the file for passwords and tokens, and rotate every secret you find before you delete anything. Then untrack the file, add it to the repo .gitignore, scan the full history with gitleaks, and rewrite history with git filter-repo if the file sits in an old commit. The whole fix takes under an hour for one repo, and the rotation step is the one that actually protects you.

Why this matters now

Apiiro published the research on 5 November 2026 and updated it on 8 November, and Ars Technica reported it on 9 November. The numbers come from a read-only scan of public GitHub between 1 and 3 November. Apiiro did not test whether the credentials still worked, so the count measures exposure rather than confirmed break-ins. One company it notified did confirm its exposed key was live.

The exposure is old, not fresh. The median file carrying a secret had sat on its repository's default branch for 217 days, and in 118 repositories it had been there for more than a year. GitGuardian counted a larger pile by a different method: 31,088 distinct secrets in the same file across 23,276 repositories between January 2025 and 7 November 2026, with 5,343 still valid when checked. It also found 613 secrets from the file inside public Docker Hub images, with 99 still valid.

The protection Claude Code provides does not travel with the repo. The first time Claude Code writes the file inside a git repository, it adds **/.claude/settings.local.json to your global git excludes file. That entry lives on one machine. It never reaches the repo's own .gitignore, it never untracks a file that is already tracked, and it does nothing on a second machine that clones the repo. In 539 of the 1,105 repositories Apiiro traced, a commit co-authored by Claude changed the file. The first bug report about this dates to August 2025. Boris Cherny of the Claude Code team replied on Hacker News on 7 November that the team is looking at prevention. That prevention landed in part on 12 November. Claude Code 2.1.323 changes "don't ask again" so an allow rule that looks like it holds a secret, or would be saved to a settings.local.json that git tracks, lasts for the session only and is not saved. It does not redact a secret, and it does not clean a secret already saved or already pushed to git history. On 13 November, 2.1.325 fixed a related case: a committed settings.local.json could be treated as the user's own when Claude Code was started in certain subfolders of a repository. That closes one more way the file can be trusted when it should not be, and it still does not clean a secret already saved or pushed. The check, rotation, and history clean-up in this guide still apply to anything saved before you update.

Scanners are not a safety net here. Apiiro ran gitleaks and TruffleHog over all 104,185 public copies. Gitleaks flagged 564 of the 1,122 files with a secret, TruffleHog flagged 643, and 215 were flagged by neither. A password typed inside a command often has no known key shape, so a clean scanner run does not clear a file you have not read.

Claude Code settings.local.json leaked secrets, in numbers

The largest groups in the 1,122 files with a secret were database passwords, cloud keys, and tokens for developer services.

Secret type Count
Database passwords 379
Supabase service-role keys 122
Supabase account tokens 103
SSH credentials for public servers 43
GitHub, GitLab, and npm tokens 42
AWS keys 23
Private keys 6

The current copies held 1,379 distinct secrets in total: 636 provider-format keys and 743 passwords or tokens for public hosts. Counting git history, the shared settings file, and saved agent transcripts as well, the total reaches 2,539 secrets across 1,994 repositories and 63 organizations. The shared .claude/settings.json, a file teams commit on purpose, held secrets in 298 of 76,011 copies.

What you need

You need a terminal with git, and the repos you want to check cloned locally. You need read access to the secret providers, such as the database, AWS, GitHub, or Supabase, so you can rotate keys. You need gitleaks, free and open source, for the history scan. Install it with brew install gitleaks on macOS, or take the binary from its releases page. You need git filter-repo only if the file is in history, installed with pip install git-filter-repo. You also need a GitHub account, signed in, for the org-wide code search in step 7.

Step 1: Check whether the file is tracked in your repos

Run these three commands in each repo root:

git ls-files .claude/settings.local.json
git log --all --oneline -- .claude/settings.local.json
git check-ignore -v .claude/settings.local.json

The first prints the path if git tracks the file. The second lists every commit that touched it, including old ones. The third prints the ignore rule that covers it, or prints nothing with exit status 1 when git would commit the file. Also check the shared file with git ls-files .claude/settings.json, and read that one too. Repeat for every repo you have pushed to, including demo repos, forks, and workshop repos. A demo repo counts the same as a production repo once it is public.

Step 2: Read the file and look for secrets by hand

Open the file and read it:

cat .claude/settings.local.json

Allow rules sit under permissions.allow. Look for a rule that repeats a command you approved, shaped like this:

"Bash(mysql -u admin -pREDACTED *)"

That shape is the leak: the password sits inside the command string. A grep helps, but it is a second pass after reading, not a replacement for it:

grep -iE 'password|passwd|token|secret|api[_-]?key|sshpass|PGPASSWORD' .claude/settings.local.json

On Claude Code 2.1.319, the dialog offers a wildcard prefix instead of the full command, but the prefix can still carry a secret. A test on 2.1.319 found the saved rule kept whatever sat in front of the program, including an environment variable holding a password. Updating lowers the risk. It does not remove it.

Step 3: Rotate every secret before you delete anything

For each secret you find, revoke or replace it at the provider first. Database passwords, AWS access keys, GitHub personal access tokens, and Supabase service-role keys each have a rotate or revoke control, and the old value must stop working. Do this before untracking the file or rewriting history.

Deleting the file removes your copy. It does not remove the copies in git history, in forks, or in clones other people hold. Apiiro found 734 secrets that exist only in earlier versions of the file, and 211 forks of 74 repositories carrying the same secrets. GitHub's own guidance after a credential is published is to revoke or replace it first.

Step 4: Untrack the file and ignore it in the repo

Remove the file from the index, keeping your local copy:

git rm --cached .claude/settings.local.json

Then add this line to the repo's .gitignore:

.claude/settings.local.json

Then commit the .gitignore change. The repo-level line is the part that travels: every clone gets it, unlike the global excludes entry on your machine. If you created the file by hand, the docs say to add it to .gitignore yourself, since Claude Code only adds the global entry when it writes the file.

Step 5: Scan the full history with gitleaks

Install gitleaks, then scan the working tree and the full history:

brew install gitleaks
gitleaks detect --source . --verbose
gitleaks detect --source . --log-opts="--all"

The first scan covers the working tree. The second walks every commit. Exit code 1 means it found something. Treat a clean result as a second opinion, not a clearance: 215 of the 1,122 files with a secret were missed by both gitleaks and TruffleHog, which is why step 2 comes first.

Step 6: Remove the file from history when it is there

Do this only if step 1 or step 5 found the file in an old commit, and only after step 3. Work on a fresh clone:

git clone https://github.com/OWNER/REPO.git repo-clean
cd repo-clean
git filter-repo --path .claude/settings.local.json --invert-paths
git remote add origin https://github.com/OWNER/REPO.git
git push origin --force --all

Filter-repo rewrites every commit that contained the file, and it removes the origin remote so you cannot push by accident. You add it back before the force-push. Every commit hash changes from the earliest rewritten commit onward, so every collaborator must re-clone instead of pulling. Coordinate with the team first. Rotation still matters, because forks and old clones keep the old history. If the repo is private and only you hold a copy, the rewrite still matters, because the history is the copy that leaks the next time the repo goes public or gets shared.

Step 7: Check every repo in your org

One repo is rarely the whole story. On GitHub, signed in, use code search to list every copy of the file across an org:

filename:settings.local.json org:YOUR-ORG

Run the same check for the shared file:

filename:settings.json path:.claude org:YOUR-ORG

Code search needs a signed-in personal account to search public repos. If your team publishes Docker images, check those too. GitGuardian found the file's secrets inside 613 public images.

Step 8: Stop it happening again

Keep the repo .gitignore line from step 4 in every repo. It is one line and it travels with the clone.

Never type a secret into a command you approve with "don't ask again". Put the password in a gitignored .env file and reference the variable instead of the value, so the saved rule holds the variable name and not the password itself.

Add deny rules for credential files in the committed .claude/settings.json, so Claude Code never reads them into a prompt:

{
  "permissions": {
    "deny": [
      "Read(./.env)"
    ]
  }
}

Deny rules apply at once and leave nothing stored in a settings file.

For unattended runs, set denyInsteadOfPrompting in your user settings file, ~/.claude/settings.json. It needs Claude Code 2.1.319 or later:

{
  "permissions": {
    "denyInsteadOfPrompting": true
  }
}

A call that would wait on a prompt is denied instead, so no allow rule is saved. The setting is read from user or managed settings, not from a repo's settings file. Update with claude update and check the version with claude --version.

Review the allow rules in .claude/settings.local.json now and then, and delete any rule that holds a secret. A rule you no longer need is a secret you no longer have to worry about.

What to do if it fails

If git check-ignore prints nothing, the file is not ignored anywhere. Add the repo .gitignore line and run the check again.

If git log shows the file in old commits, go to step 6 after rotating. Untracking alone leaves history untouched.

If gitleaks finds secrets in a file you already deleted, the findings are in history. Step 6 again, after rotation.

If filter-repo refuses to run, it wants a fresh clone. Clone again and run it there. Do not run it on a working repo with uncommitted changes.

If the force-push is rejected, branch protection may block force-pushes. A repo admin can allow it for the rewrite, then turn protection back on.

If a fork still shows the secret, you cannot rewrite someone else's fork. Rotation is the fix, and you can ask GitHub Support about removing the exposed content from the fork.

If you find signs the key was used, check the provider's logs, such as AWS CloudTrail, database logs, or the GitHub audit log, for access you do not recognise. Then rotate and review.

Frequently asked questions

No. The secret stays in git history, in forks, and in clones. Rotate first, then clean up. Deleting the file only removes your current copy.

Mostly, but check anyway. The file can reach git another way: a Claude-coauthored commit, a manual commit, or a file you created by hand. Step 1 takes a minute per repo.

Gitleaks and TruffleHog both missed 215 of the 1,122 files with a secret. Passwords typed inside commands often have no known key shape, so a generic scanner has nothing to match. Read the file by hand.

Updating to 2.1.325, released 13 November, stops the leak going forward: a "don't ask again" allow rule that looks like it holds a secret, or would be saved to a tracked settings.local.json, lasts for the session only and is not saved. The same release also fixes a committed settings.local.json being treated as the user's own when Claude Code starts in certain subfolders of a repository. It does not redact secrets, and it does not remove a secret already saved or already in git history. Rotate and clean those as this guide shows. Updating still helps in other ways: 2.1.319 added `denyInsteadOfPrompting` for unattended runs, and 2.1.307 fixed self-hosted runner sessions committing a leftover settings file. Checked 18 November 2026: 2.1.326 (16 November) and 2.1.327 (17 November) exist, and neither changes the fixes above.

Yes. Apiiro found secrets in 298 of 76,011 copies. It is a file teams commit on purpose, so review it before it goes in, and never put a real secret in it.

Conclusion

Claude Code settings.local.json leaked secrets because one convenient button saved the whole command, password included, into a file that git was never meant to see. The fix has an order that matters: rotate the secret, untrack the file, scan the history, rewrite it if needed, and put the .gitignore line in every repo so the next "don't ask again" cannot do the same thing. The check takes minutes per repo. The rotation is the part that actually protects you, because history, forks, and clones keep every copy you delete. Do it now, while the leak is still a quiet one.

This is the second Claude Code security problem PromptStaging has covered this month. The first was malicious SKILL.md downloads that hijack an agent, covered at https://promptstaging.site/article-malicious-agents-md-downloads-hijack.html, and the same habit applies here: audit what you install and what you approve before it runs. If you install agent skills from the internet, audit the SKILL.md file first, as explained at https://promptstaging.site/article-audit-skill-md-before-install.html. And for the habit that stops most of this at the source, keeping real keys out of the commands and files an agent reads, PromptStaging covers shim-cli at https://promptstaging.site/article-shim-cli-mask-secrets.html, which masks secrets before they reach the model.

Sources and references

  • Apiiro research, published 5 November 2026, updated 8 November 2026, as reported by Ars Technica on 9 November 2026 (counts, mechanism, scanner gap, Cherny response, August 2025 first report)
  • DevOps.com, "The Convenience Click That Put 2,539 Secrets on Public GitHub", https://devops.com/the-convenience-click-that-put-2539-secrets-on-public-github (breakdown: 379 database passwords, 122 Supabase service-role keys, 103 Supabase account tokens, 43 SSH credentials; orgs notified 2-3 Nov)
  • Anthropic, Claude Code settings docs, https://code.claude.com/docs/en/settings (settings.local.json scope, global git excludes, "don't ask again" allow rule)
  • Anthropic, Claude Code settings reference, https://code.claude.com/docs/en/settings-reference (permissions.denyInsteadOfPrompting scope: user or managed settings, requires 2.1.319)
  • Claude Code changelog, https://code.claude.com/docs/en/changelog (2.1.323 on 12 Nov 2026; session-only allow rule for secret-looking or tracked settings.local.json saves; 2.1.307 runner fix; 2.1.319 denyInsteadOfPrompting; 2.1.325 on 13 Nov 2026, GitHub releases page: committed settings.local.json treated as own in some subfolders fixed; 2.1.326 on 16 Nov 2026 and 2.1.327 on 17 Nov 2026 checked 18 Nov 2026, neither changes the claim)
  • Max Nardit, "Claude Code settings.local.json secrets", https://max.nardit.com/articles/claude-code-settings-local-json-secrets (2.1.319 wildcard prefix test; 734 secrets only in earlier versions; 211 forks of 74 repos)
  • Ain.ua, "Passwords and API keys from Claude Code settings ended up in public GitHub repositories", https://en.ain.ua/2026/11/10/passwords-and-api-keys-from-claude-code-settings-ended-up-in-public-github-repositories/ (GitGuardian count: 31,088 secrets, 23,276 repos, 5,343 still valid; Docker Hub 613 secrets, 99 valid)
  • GitHub docs, "Searching code", https://docs.github.com/en/search-github/searching-on-github/searching-code (filename and org qualifiers; sign-in required)
  • Gitleaks docs and guides, https://github.com/gitleaks/gitleaks (detect --source, --log-opts="--all", exit code 1 on findings)
  • git filter-repo docs and guides (filter-repo --path --invert-paths; fresh clone; origin remote removed)
TJ Singh

TJ Singh

Creative Technologist, AI Systems Architect, and author of the PromptStaging suite. Focused on Generative Engine Optimization (GEO), agent developer workflows, and client-side web utilities.