Security researchers published findings in early November that should make every Claude Code user stop and check one file. Apiiro published its analysis on 5 November, and GitGuardian followed on 9 November. GitGuardian found 31,088 distinct secrets in .claude/settings.local.json files across 23,276 public GitHub repositories, and 5,343 of them were still valid when detected. This guide shows you how to check whether your secrets leaked, and what to do first if they did.
This is not the Claude source code leak from about seven months ago. This one is about your own credentials ending up in a settings file that gets committed to public repositories and baked into public Docker images. Rotate the credential first, then clean up the file. Deleting the file alone changes nothing, because copies already exist in git history, in forks, and in Docker images. For the full research, see GitGuardian.
How Claude Code Leaks Your Secrets
Claude Code asks for permission before it runs a command. When you answer “Yes, and don’t ask again”, it saves the whole command as a permanent allow rule in .claude/settings.local.json. If that command contains a credential, such as an API key passed as a flag or an environment variable, the credential is saved with it, in plain text, inside the rule.
Claude Code does add that file to the global .gitignore on your machine, which is supposed to stop git from tracking it. The problem is that the global .gitignore is a setting on your machine, not part of the repository. It does not travel with the repo. The file gets committed when you move the project to another machine, when someone force-adds it, or when Claude Code itself adds the file. Once it is in a public repository, anyone can read it.
The same file also turns up in Docker images. GitGuardian found 613 secrets in public Docker Hub images, and 99 of them were still valid. A Docker image built from a directory that contains the settings file carries the secrets with it, and anyone who pulls the image can read them.
What the Researchers Actually Found
The two research teams measured different things, so do not add their numbers together. GitGuardian scanned public GitHub repositories and public Docker Hub images. It found 31,088 distinct secrets in settings files across 23,276 repositories, with 5,343 still valid at detection time, plus 613 secrets in Docker images, 99 of them valid.
Apiiro looked at the same kind of file and counted differently. It found 1,122 files holding secrets, containing 1,379 distinct secrets, in current copies of repositories, and 2,539 secrets in total once git history was included. The two sets of numbers describe different slices of the same problem, and both point the same way. This file is leaking at scale.
A “still valid” secret is one the researchers could confirm works, which means it can be used right now. A secret that is no longer valid may still be dangerous if it was valid recently, or if the same credential is reused elsewhere. Treat every secret in the file as compromised until you have rotated it. Check what is actually live before you trust it, as our guide to how to audit your backlink profile explains.
How to Check Your Own Repositories
Start with the file itself. In each project where you use Claude Code, open .claude/settings.local.json and read it. Look for anything that resembles a credential: API keys, tokens, passwords, private keys, or connection strings. If the file contains a command with a key in it, that key is exposed wherever the file has travelled.
Check whether the file is tracked. Run git ls-files .claude/settings.local.json in the project. If it returns the filename, the file is tracked and has been committed at least once. Then check the history with git log –all — .claude/settings.local.json. If you have pushed to a public repository, assume the file is public.
Search GitHub for your own repositories. Open each public repository you own or contribute to and check whether .claude/settings.local.json is visible in the file list. Search for the filename alongside your username. Do the same for any organisation repositories you have pushed to.
Check Docker Hub. If you publish images, list the images you own and check whether any of them were built from a directory that contained the settings file. GitGuardian found live secrets in public images, so this step is not optional if you ship images.
Check forks and copies. A public repository can be forked, cloned, or mirrored, and those copies keep the history. Even if you delete the file from your repository today, forks and clones still hold it. Search for the file in forks of your repositories too.
What to Do First If Your Secrets Leaked
Rotate the credential first, before you touch the file. Go to the service that issued the key or token and revoke it, then create a new one. Deleting the settings file does not remove the copies already sitting in git history, in forks, or in Docker images. Anyone who already copied the secret can keep using it until you revoke it. Rotation is the only step that actually stops the exposure.
Once the credential is rotated, remove the file from tracking with git rm –cached .claude/settings.local.json, then commit that change. Add the filename to the repository .gitignore so it cannot be committed again by accident. The repository .gitignore travels with the project, unlike the global one on your machine, which is why this step matters.
Then rebuild and republish any Docker images that contained the file, using a clean build context. Delete the old images from Docker Hub if you can. Finally, go through the allow rules in your local settings file and remove any rule that contains a credential. Replace credentials in commands with environment variables or a secrets manager, and never paste a live key into a command you approve permanently. Review what your tools can reach, as our guide to link building tools for outreach explains.
How to Stop Claude Code Leaking Secrets Again
Stop approving commands that contain credentials with “don’t ask again”. If a command needs a key, put the key in an environment variable or a local env file that is already ignored, and approve the command with the variable, not the value. Review your allow rules regularly. Open .claude/settings.local.json once a week and read what is in it. If you see a credential, rotate it and remove the rule.
Add .claude/settings.local.json to the .gitignore of every repository you work in, not just the one where you found the problem. If you work in a team, tell your colleagues to do the same, and add the file to your project template so new repositories start protected. Anthropic’s Claude Code lead, Boris Cherny, has acknowledged the issue, but no fix has shipped yet, so the protection is on you for now. For Anthropic’s own pages, see Anthropic. Keep up with the new Claude features and the Claude computer use beta for teams, and report results with our guide to how to report link building results to clients.
FAQs
Is this the same as the Claude source code leak?
No. That was a different incident from about seven months ago, involving Claude source code. This one is about your own credentials in a Claude Code settings file that gets committed to public repositories and Docker images.
I deleted the settings file. Am I safe now?
No. Deleting the file does not remove copies already in git history, in forks, or in Docker images. Rotate every credential that was in the file first, then remove the file from tracking and add it to your repository .gitignore.
Does Claude Code protect the settings file automatically?
Only partly. Claude Code adds the file to the global .gitignore on your machine, but that setting does not travel with the repository. Add the file to each repository’s own .gitignore.
How do I know if a leaked secret is still valid?
Check with the service that issued it, and assume it is valid until you have revoked it. A secret that still works can be used right now, so rotation comes before any cleanup.

