Claude Code settings.local.json Secrets Leak: Check and Fix
Quick answer
.claude/settings.local.json is a personal settings file. It is not meant to be shared or committed.
"Yes, and don't ask again" saves a rule in that file. If the command had a password in it, the rule can hold that password in plain text.
Security firm Apiiro looked at 104,185 public copies of the file and flagged 1,122 of them (about 1.1%) as containing secrets.
Claude Code 2.1.323 and later keep such rules for the session only instead of saving them. Rules saved before you updated can still be in your file.
To check: look inside the file, then ask git if it ever tracked it. If a secret was exposed, change (rotate) it before anything else.
To prevent it: update Claude Code, never type secrets into commands, and add the file to .gitignore.
Key words in simple English
- Claude Code: an AI coding tool from Anthropic that works in your terminal and can run commands for you.
- Permission prompt: the question Claude Code asks before it runs a command or changes a file.
- Allow rule: a saved "yes" for a certain kind of command, so Claude Code stops asking.
- settings.local.json: your personal settings file for one project. It holds your saved allow rules.
- Git: a tool that tracks every change to the files in a project.
- Repository (repo): a project folder that git tracks, often stored on GitHub.
- Commit: a saved snapshot of your changes in git.
- .gitignore: a list of files that git should not track. It lives inside the project.
- Global git excludes file: a similar ignore list, but it lives on your computer and covers all your projects.
- Secret: a password, API key, token or connection string that gives access to something.
- Rotate a secret: change the password, or cancel the key, and make a new one.
- Git history: the full record of past commits. A file can be gone today but still sit in old commits.
What is settings.local.json in Claude Code?
In simple words: it is a private settings file for one project. It is for you only, not for your team.
Claude Code has three common settings files. The "project local" file is .claude/settings.local.json. The docs describe it as personal settings for one project, handy for overrides and for testing before you share settings. It is not meant to be committed.
File Who it is for Commit it? .claude/settings.local.json You, in one project No .claude/settings.json The whole team, in one project Yes, if it has no secrets ~/.claude/settings.json You, in every project No (it is not inside a repo)
When settings clash, the higher one wins. From highest to lowest, the order is:
- Managed settings (set by an organization)
- Command line arguments
- Project local (
.claude/settings.local.json) - Shared project (
.claude/settings.json) - User (
~/.claude/settings.json)
List settings such as permissions.allow are merged across files, not replaced. Permission rules are checked in this order: deny, then ask, then allow.
Claude Code tries to keep the file out of git. The first time it writes the file in a repo that does not already ignore it, it adds **/.claude/settings.local.json to your global git excludes file. That is the file named by git's core.excludesFile setting. If that setting is empty, git uses $XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore.
If you create the file by hand, the docs say you must add it to .gitignore yourself.
How "don't ask again" put secrets into the file
In simple words: the saved rule is a copy of the command you approved. If the command had a secret, so does the rule.
When Claude Code asks to run a command and you pick "Yes, and don't ask again", it saves an allow rule. Inside a git project, the terminal app saves it to .claude/settings.local.json at the root of the repository.
Rules look like Tool or Tool(specifier). The dialog saves the space form with a trailing wildcard (a * that matches anything), for example Bash(npm test *). These go in the permissions.allow list.
Now picture a command that had a password typed straight into it. Here is a fake example of a file with two risky rules and one safe rule:
{
"permissions": {
"allow": [
"Bash(npm test *)",
"Bash(PGPASSWORD=MyS3cretPass psql -h db.example.com *)",
"Bash(curl -H 'Authorization: Bearer abc123-fake-token' https://api.example.com/orders *)"
]
}
}
The first rule is safe. It holds no secret. The second holds a database password. The third holds an access token inside a Bearer header (a header is extra information sent with a web request). All the values above are made up. But a real rule would look the same, with a real password in its place.
Why the file still ended up on GitHub
In simple words: the protection was set on one computer, and it does not help once git has already tracked the file.
Claude Code adds the file to a global excludes file. That file lives on one computer. A teammate, a CI server (a machine that builds and tests code automatically) or a new laptop does not have it unless someone sets it up there.
There is a second problem. Ignore rules, whether in .gitignore or an excludes file, only affect files git is not tracking yet. Once a file has been committed, git keeps tracking it. The ignore rule does nothing until you run git rm --cached.
There was also a bug. Claude Code 2.1.323 fixed .claude/settings.local.json not being ignored globally when a folder became a git repository later, or on a new machine. Before that fix, those two cases could leave the file unignored.
So one stray git add . (the command that adds every changed file to the next commit) could pull the file in. After a push to a public repo, the secret was visible to everyone.
What Apiiro found
In simple words: the numbers show that secrets were exposed in public files. They do not prove anyone broke in.
Apiiro is a security firm. Its researchers Shmulik Cohen and Matan Giladi published their findings on November 5, 2026. You can read Apiiro's research and iTWire's report, which covered it on November 7, 2026.
The data came from public GitHub between November 1 and 3, 2026. Here is what they reported:
- They examined 104,185 public copies of
settings.local.json. - 1,122 of those files (about 1.1%) were classified as containing secrets.
- Those files held 1,379 distinct secret values.
- A wider look also covered git history, shared settings and agent transcripts (saved logs of what an AI agent did). It counted 2,539 distinct secrets across 1,994 repositories.
Apiiro did not test whether the secrets still worked. It sorted them by format and context. So these numbers measure exposure, not confirmed break-ins.
The advice in the coverage is simple. Rotate or revoke exposed secrets first. Stop tracking personal settings with a .gitignore entry. Use a secret manager or an environment variable instead of typing secrets. Keep standing permissions narrow. Review agent config files and transcripts, not just source code.
What Anthropic changed in Claude Code 2.1.323 to 2.1.326
In simple words: newer versions are more careful about what they save. Nothing in the changelog says they clean up your old file.
These notes come from the official Claude Code changelog, in my own words.
Version and date What changed What it means for you 2.1.323 (Nov 12, 2026) "Don't ask again" keeps a rule for the current session only, and does not save it, if the rule looks like it holds a secret or would go into a settings.local.json that git tracks. New secrets are less likely to land in the file. 2.1.323 Fixed: the file was not ignored globally when a folder became a git repo later, or on a new machine. Fewer cases where the file is left unignored. 2.1.323 Fixed: Bash prompts no longer offer "don't ask again" for commands that write to sensitive paths such as .git or .claude. The saved rule did not stop the next prompt anyway. Less confusion, and fewer risky saved rules. 2.1.323 Added: a start-up warning for Bash allow rules with a * inside a variable's value, such as Bash(PORT=* npm run dev). Helps you spot rules that are too loose. 2.1.325 (Nov 13, 2026) Fixed: a committed .claude/settings.local.json could be treated as the user's own when Claude Code started in certain subfolders of a repo. A file someone else committed is less likely to be trusted by mistake. 2.1.325 Changed: -p (non-interactive) and SDK runs in a worktree or submodule mounted into a container apply the file's allow rules only once the folder is trusted. Automated runs are stricter about trust. 2.1.326 (Nov 16, 2026) Changed: Claude's file tools refuse to write to Claude Code's own sign-in files, such as .credentials.json. Protects your login details from being overwritten.
Important: these changes control what gets saved from now on. The changelog does not say they remove rules already saved in your file. Check the file yourself.
To see your version, and to update:
claude --version
claude update
How to check if your repo leaked secrets
If you are not a developer, the Quick answer and the "Do this first" line cover what matters. The next two sections are step-by-step commands for developers.
In simple words: ask git three questions. Is the file in the project now? Was it ever? What did it hold? Run these from the root folder of your project.
Check if git tracks the file now.
git ls-files .claude/settings.local.json
If this prints the path, git tracks the file. No output means it does not.
Check if it was ever committed.
git log --all --oneline -- .claude/settings.local.json
This lists every commit that touched the file. Even one line means the file was in your history at some point.
Read every old version.
git log --all -p -- .claude/settings.local.json
This shows the contents of every committed version. A secret you removed later can still show up here.
See if any ignore rule covers the file.
git check-ignore -v --no-index .claude/settings.local.json
This shows which ignore rule matches the path. No output means no rule matches. The --no-index flag is needed because git skips tracked files otherwise.
Open the file and read the allow list. Look for passwords, tokens and keys. Search for these words:
BearerPGPASSWORD=--password- connection strings such as
postgres://user:password@host
A connection string is one line that holds the address of a database plus the login. If you find one, treat that secret as exposed.
Check the rest of the .claude folder.
git ls-files .claude
This lists every tracked file in the folder. Apiiro also found secrets in shared settings and agent transcripts, so look at those files too.
Optionally run a scanner. Tools such as Gitleaks and TruffleHog can scan a whole git history. They miss some secrets, such as plain database passwords with no known format. A clean scan does not prove you are safe.
How to fix a leaked settings.local.json
In simple words: change the secrets first, then clean up the file, then make sure it cannot happen again.
Rotate every secret you found. Go to the service (the database, GitHub, AWS, Supabase and so on). Make a new password or key, switch your app to it, then revoke the old one. That order keeps your app running. Once a secret was public, assume someone copied it. If you need help with this part, read what to do if an API key leaks.
Remove the risky rules. Type /permissions inside Claude Code to see your rules and delete the bad ones. Or edit .claude/settings.local.json by hand.
Stop git from tracking the file.
git rm --cached .claude/settings.local.json
This stops tracking but keeps your local copy.
Add the file to the project's .gitignore. Then the rule travels with the repo, not just with your computer.
.claude/settings.local.json
Commit and push.
git add .gitignore
git commit -m "Stop tracking settings.local.json"
git push
Optional: clean the history. GitHub has a guide, Removing sensitive data from a repository. It covers rewriting history with git filter-repo. Be careful: this rewrites history for everyone who uses the repo. It does not replace rotation. Clones and forks may still hold copies of the old secret.
Deleting the file, or rewriting history, does not un-leak a secret. Only rotation does.
How to stop it happening again
In simple words: keep secrets out of commands, keep the file out of git, and keep your permissions small.
Update Claude Code to 2.1.323 or later. Use claude update.
Never type secrets into commands. Use an environment variable instead. For example, run psql "$DATABASE_URL". Then the saved rule holds the variable name, not the value.
Add the file to every repo's .gitignore, and to your team's project template. Do not rely on the global excludes file alone.
Keep allow rules narrow. Look at /permissions now and then, and delete rules you no longer need.
Add deny rules for secret files. For example, put "Read(./.env)" and "Read(./.env.*)" in permissions.deny. There is a limit: these rules do not cover other programs (subprocesses) that read the file indirectly.
Turn on GitHub secret scanning and push protection. Also add a pre-commit scanner, which checks your changes before each commit. Remember that scanners miss plain passwords.
Comments
No comments yet. Start the discussion.