How it happens
When you choose "Yes, and don't ask again" for a shell command, Claude Code can save it as a rule in .claude/settings.local.json. If you approve a command that includes a password, the rule may look like this fake example:
{
"permissions": {
"allow": [
"Bash(PGPASSWORD=example-only psql -h db.example.com:*)"
]
}
}The password is now in a file. If the file is pushed to a public repo, other people can read it.
Claude Code's documentation says the tool adds this file to your personal Git ignore settings when needed. This helps on that computer, but it does not protect the whole project. It may not help if:
- Git is already tracking the file.
- You use another computer.
- The folder becomes a Git repository later.
What researchers found
Apiiro published its research on 5 November 2026. GitGuardian did a separate study. They counted different things, so do not add the numbers together.
| Study | What it found |
|---|---|
| Apiiro: local settings files | 1,122 of 104,185 public copies had likely secrets. They contained 1,379 different secrets |
| Apiiro: wider search | 2,539 different secrets in 1,994 repositories. This also includes Git history, shared settings and agent transcripts |
| GitGuardian: local settings files | 31,088 different secrets in 23,276 public GitHub repositories, from January 2025 to 7 November 2026. 5,343 worked when they were found |
| GitGuardian: Docker Hub | 613 different secrets in public images, including 99 that worked when they were found |
Apiiro identified likely secrets by their format and nearby text. It did not test whether they worked. Some news reports say that 1,122 is the number of secrets, but other detailed reports say it is the number of files.
Apiiro also traced 1,105 repositories. In 539 of them, commits that listed Claude as a co-author changed the settings file. This does not prove that Claude added every secret. We read GitGuardian's original post. Apiiro's post did not load for us, so its numbers come from the news reports listed below.
Check your repository
First, see if Git is tracking the file:
git ls-files | grep -E '(^|/)\.claude/settings\.local\.json$'
Then check the history of every branch and tag in your local copy:
git log --all --oneline -- \ ':(glob)**/.claude/settings.local.json'
If either command shows a result, open the file or commits in a private place. Do not paste secrets into a ticket, chat or AI tool. No results only means that these commands found nothing in your local copy. They do not check forks, deleted branches or other copies.
Also check:
.claude/settings.json, which teams may share on purpose.- Saved chats, memory files and handoff notes from AI tools.
- Container images and their older layers. Deleting a file in a later layer does not remove it from an earlier one.
- Package files and build downloads.
If you find a secret
- Replace it first. Turn off the old password or key, and check its access logs for activity you do not recognise.
- Remove the secret from the rule. Also remove permissions you no longer need.
- Stop tracking the file and add it to the project's
.gitignore:
git rm --cached .claude/settings.local.json printf '\n**/.claude/settings.local.json\n' >> .gitignore git add .gitignore git commit -m "Stop tracking local Claude settings"
This keeps the file on your computer. If it is in another folder, change the path in the first command. git rm --cached does not remove the secret from older commits. If you need to clean the Git history, plan it with your team. Other people may still have copies, so you must always replace the secret.
- Protect container builds. Add this to
.dockerignore, then rebuild the image without the old layers:
**/.claude/settings.local.json
Remove affected image tags from your registry too. People who already downloaded the image will still have their copy.
Stop it happening again
- Do not type passwords or keys directly into a command. A command such as
PASSWORD=value commandstill contains the password. - Let the program get its password from a secrets manager, or set it safely before you start the AI tool. Remember that an agent may be able to read environment variables.
- Use passwords and keys with limited access, especially during development. Do not use production passwords with AI tools.
- Read the full command before you choose "don't ask again". Keep saved permissions narrow.
- Scan for secrets before each commit and again in CI.
What scanners can and cannot find
Secrets scanners are good at finding keys with a clear format. They can miss a simple password inside a long shell command. Reports on the Apiiro research say that common scanners missed some of these secrets. So if this file is in your repo, review it yourself even if the scan finds nothing.
Check older commits as well as current files. A scanner that only looks at the latest commit will miss a secret that was deleted last week.
Sources
Find passwords and keys in your code
Secrets scanning is in every AquilaX plan, including Free. Secrets are masked in the results.
See secrets scanning →