Yes, it can. When a developer picks “Yes, and don’t ask again” on a shell command with a password or token typed into it, Claude Code can save that command word for word in .claude/settings.local.json [1][2]. Apiiro found 1,122 public copies of that file holding at least one secret, out of 104,185 it examined, but it did not test whether any credential still works [1][3].
Published: | Last reviewed:
Key takeaways
- Claude Code stores the text of an approved command, so a password typed into that command is stored with it [1][4].
- The file is
.claude/settings.local.jsonin the project folder, and deleting it does not remove older versions from git history or forks [1]. - Apiiro classed 1,122 of 104,185 public copies, about 1.1%, as holding secrets [2][3].
- Apiiro did not test the credentials, though one notified company confirmed its key had been live [1][2].
- Rotate the credential first. Untracking the file and cleaning history comes second [1][2].
- Of the 1,122 files, gitleaks flagged 564 and TruffleHog 643, and 215 slipped past both [1][3].
Claude Code, Anthropic’s AI coding assistant, can store a complete approved shell command in .claude/settings.local.json when a developer chooses “Yes, and don’t ask again” [4]. That file is meant for personal settings, not for sharing with everyone on the project [2]. Security company Apiiro examined 104,185 public copies of it across 103,617 GitHub repositories and classified 1,122, about 1.1%, as containing at least one secret, 1,379 distinct secrets in all [1][2].
Counting git history, the shared settings.json file and saved agent transcripts, Apiiro reported 2,539 secrets across 1,994 repositories [2][3]. Apiiro did not try the credentials, so the figures describe exposure, not confirmed compromise, although one notified company said its key had been live [1]. Apiiro sells application and agent security products, and it collected the data between November 1 and 3, 2026 [2].
An allow rule in Claude Code is a saved permission entry that lets a matching tool call run without asking again. For shell commands it lives in .claude/settings.local.json at the root of the git repository, and a rule written without a wildcard matches one exact command [4].
What does Claude Code actually save when you approve a command?
Claude Code saves an allow rule. When you pick “Yes, and don’t ask again” for a shell command, the tool writes a rule to the local settings file at the repository root, and matching commands run without a prompt in later sessions. A rule with no wildcard matches one exact command string, so a password typed into that command becomes part of the saved rule.
Anthropic’s permissions documentation says Bash approvals saved this way last permanently, per repository and command [4]. The saved rule covers only what the prompt named, and the prompt offers the save option only when it can show everything that option would allow [4].
Sometimes the prompt offers a pattern such as npm test *. Sometimes it offers one exact command, and that second case is where secrets get stored [1].
Apiiro says it reproduced the behavior with the latest models, which The Hacker News names as Opus 5.5 and Fable 5.1 [1]. iTWire adds a fair caution: the reported failure happens in an ordinary, authorized workflow, not through a hostile prompt talking an AI model into stealing a password [2].
The table below shows what the Claude Code settings file ends up holding for four kinds of approval. The examples are illustrative, and the last two rows follow the researchers’ advice and iTWire’s warning.
| What you approve | What the saved rule holds | Secret exposed? |
|---|---|---|
| A pattern the prompt offers, such as a test runner | The pattern only | No |
An exact command that points to a variable such as $DB_URL | The variable name, not its value | No, per Apiiro’s advice [1] |
| An exact command with a literal password typed in | The full command, password included | Yes, in plain text [1] |
| A command with the secret assigned inline as a variable | The assignment as written | Yes, the value still sits in the command text [2] |
How many repositories are affected, and what is actually proven?
Apiiro reports that 1,122 of 104,185 public copies of the settings file hold at least one secret, about 1.1%, with 1,379 distinct secrets inside them. A wider search covering git history, shared settings and agent transcripts found 2,539 secrets in 1,994 repositories. Apiiro did not test whether the credentials work, so the numbers show exposure rather than proven compromise.
Apiiro collected its data between November 1 and 3, filtered common false positives, and then asked an AI reviewer to judge masked candidates against a rubric [2]. A value counted as a secret when it matched a known key format, or when a password or token sat beside the address of a public server [1]. iTWire points out that the extra review was part of Apiiro’s own process, not independent replication [2].
Apiiro’s headline numbers cover only one slice. Older versions of the file hold 734 more secrets across 509 repositories that no current copy contains, and 211 forks of 74 repositories carry the same secrets as the originals [1].
The shared .claude/settings.json file, which teams commit on purpose, held secrets in 298 of 76,011 copies, mostly inside allow rules [1]. At the time of Apiiro’s check, every file with a secret was still on its repository’s default branch, and in half of those repositories it had sat there for at least 217 days [1].
Exposure is a count of files. Compromise is a count of misuse. Apiiro measured the first one.
This table separates what each source supports from what the sources leave open about the Claude Code settings file.
| Claim | Status | Source |
|---|---|---|
| Claude Code saves approved Bash commands in the local settings file | Documented by the vendor | [4] |
| 1,122 of 104,185 public copies hold a secret | Reported by Apiiro, relayed by three outlets, not independently replicated | [1][2][3] |
| The exposed credentials still work | Not tested; one notified company said its key was live | [1][2] |
| Someone has used an exposed credential | Not shown in the sources reviewed | None |
| A CVE or vendor advisory covers the behavior | No CVE ID appears in the sources reviewed | None |
| Anthropic has responded publicly | No statement found; the researchers say related reports got no reply | [1] |
Which secrets turned up most often in the leaked files?
Database credentials dominate Apiiro’s findings. The researchers counted 379 database passwords, 122 Supabase service-role keys, 103 Supabase account tokens, 43 SSH logins, 42 tokens for GitHub, GitLab and npm, 23 AWS keys and six private keys. Of the 1,379 distinct secrets, 636 matched known provider key formats and 743 were passwords or tokens found beside a public host address.
Apiiro says 63 organizations own files in the set, mostly software companies of all sizes [1]. The researchers describe their strongest cases as a database vendor’s own admin-level cloud key and the owner password of a medical-records database [1].
Provider-format keys are the easier half for scanners. The 743 passwords and tokens tied to public hosts are the harder half, as the next section shows.
Why didn’t Claude Code’s own git protection stop the leak?
The Hacker News and iTWire report that Claude Code adds the settings file to the user’s global git excludes the first time it writes the file in a repository. That exclusion lives in one developer’s git configuration on one computer, so it does not travel with the project. Git ignore rules also do not apply to files already tracked, so a committed copy keeps going out.
According to Apiiro’s analysis as reported by The Hacker News, Claude Code never adds the file to the project’s own .gitignore [1]. A teammate on another laptop has no such exclusion unless they set one up themselves.
Apiiro traced 1,105 repositories and found a commit listing Claude as co-author changing the file in 539 of them, which the researchers read as Claude often committing the file itself [1]. iTWire cautions that this does not prove Claude introduced or pushed every exposed credential [2].
Not every user sees identical behavior. A user report from December 2025 describes a Windows setup where the file was not ignored by git and went to a public repository with several API tokens inside [5]. Anthropic’s documentation notes that outside a git repository, or on Windows, Claude Code does not always use the repository root [4].
The exposure path Apiiro describes has three links. First, Claude Code stores the literal text of an approved shell command as an allow rule in .claude/settings.local.json, so a password typed into that command is saved in plain text [1][4]. Second, the protection Claude Code adds is a global git exclude on the developer’s own computer, which does not travel with the repository and does not affect a file git already tracks [1][2].
Third, once a copy reaches a public GitHub repository, deleting it from the default branch leaves older versions in git history and in forks, which Apiiro found in 734 additional secrets across 509 repositories and in 211 forks of 74 repositories [1]. The chain needs a person or an agent to commit the file, and the researchers cannot say how each individual commit happened [2].
The table compares four protections against the Claude Code settings file leak, and what each one can and cannot do.
| Protection | Where it lives | Travels with the repo? | Helps if already committed? |
|---|---|---|---|
| Global git exclude added by Claude Code | One developer’s computer | No | No |
Entry in the project’s .gitignore | The repository | Yes | No, untrack the file first |
| Untracking the file with git | The repository index | Yes, once committed | Stops new tracking only; history remains |
| Rotating the credential | The service that issued it | Not applicable | Yes, the leaked value stops working |
Why do gitleaks and TruffleHog miss so many of these passwords?
Gitleaks and TruffleHog missed many Claude Code settings files because scanners match known key formats, and a password typed inside a shell command has no format to match. Apiiro ran both tools over the 1,122 files without verification: gitleaks flagged 564, TruffleHog flagged 643, and 215 files slipped past both. Most misses were passwords placed after options such as PGPASSWORD=, sshpass -p or mysql -p.
A password after PGPASSWORD= looks like an ordinary word in an ordinary command line, and GBHackers notes such passwords often lacked a recognizable provider prefix [1][3]. Because the scan skipped verification, the counts show what the tools flagged, not which secrets were live [1].
Scanners look for key formats. A password after sshpass -p just looks like a word.
Attackers know the same trick works from the other side. The Hacker News notes that in September 2025 the Shai-Hulud worm ran the TruffleHog scanner over infected computers to look for secrets [1]. Our guide to malicious npm and PyPI package mechanics covers how that kind of credential harvesting spreads.
How long has this been reported, and what has Anthropic said?
Reports of Claude Code storing credentials in approved commands go back to August 11, 2025, and an automated bot closed that first report as not planned on January 3, 2026. Apiiro says four related reports were closed by the same bot and none got a reply from Anthropic. The sources reviewed for this article contain no public Anthropic statement on the findings.
iTWire notes that the bot closure is housekeeping, not evidence of a fix [2]. It also reports that security firm ironPeak described a similar committed settings file in February 2026 and published a tool to search AI configuration files [2].
Apiiro reproduced the behavior with the latest models, but the sources do not say which Claude Code version it tested. We did not check Claude Code release notes for a fix, so the current behavior of the newest version stays unconfirmed here.
What should you do first if your repository has this file?
Rotate first. Revoke or replace every password, token and key the file has ever held, because deleting the file does not remove older commits, forks or other people’s clones. Then stop tracking the local settings file, add it to the repository’s own ignore list, delete any saved rule that contains a secret, and approve command patterns instead of exact commands.
- Search your GitHub organization for
.claude/settings.local.jsonand.claude/settings.json, including repository history where the files are gone [1]. - Rotate every credential those files ever held, before any cleanup [1]. iTWire says GitHub’s guidance gives the same order [2].
- Stop tracking the local file, then add it to the repository’s own
.gitignore[1]. - Open the file on your own computer, even if it was never committed, and delete every rule that contains a secret [1].
- Keep secrets out of commands by referring to variables from a secrets manager [1].
- Approve patterns such as
Bash(npm run:*)instead of single commands [1].
Delete the file all you like. If the secret was ever public, rotating it is the only fix that counts.
The first command below is the one Apiiro’s researchers recommend. The other two are ordinary git and shell commands we added, and we did not run them in a test repository for this article.
git rm --cached .claude/settings.local.json
echo ".claude/settings.local.json" >> .gitignore
git log --all --oneline -- .claude/settings.local.json
If a repository contains .claude/settings.local.json or .claude/settings.json with saved Claude Code approvals, the researchers’ advice and GitHub’s guidance agree on the order of work: rotate first, clean up second [1][2]. Rotate every password, token and key the files have ever held, including values that appear only in older commits, because Apiiro found 734 secrets that exist only in file history [1].
Then run git rm --cached on the local file, add it to the repository’s own .gitignore, and remove saved rules that contain secrets from each developer’s machine [1]. For prevention, refer to secrets as variables from a secrets manager so the saved rule holds the variable name, and approve patterns rather than single commands [1]. Add the file to pre-commit and CI secret scanning, including history, and confirm the scanner catches passwords inside commands [1].
Security teams have a second job. The researchers advise treating agent folders such as .claude/, .cursor/, .gemini/ and .specstory/ like .env files, and checking credentials paired with a public server first, because those give direct access [1]. Anthropic’s documentation adds several controls that help before the next approval:
- The
/permissionsdialog lists every saved rule and the settings file it came from, which makes a quick audit possible [4]. - A
Readdeny rule such asRead(./.env)blocks Claude’s file tools from reading that file, though it does not stop subprocesses that read files on their own [4]. - A PreToolUse hook can inspect the full command text with your own logic before it runs [4].
None of these removes a secret that is already saved or already public. If rotation shows a credential was used by someone else, our incident response plan template for small and midsize businesses and data breach notification response plan cover what comes next.
What does this mean for teams that let AI agents run commands?
Claude Code’s saved approvals expose a gap that will outlast this one file. The prompt asks whether a command is safe to run, and nothing asks whether the stored record of that permission is safe to publish. Teams that let coding agents run commands now have a second artifact to govern, and it sits in the project folder next to the code.
Start with an inventory, because a coding agent that developers installed on their own laptops is invisible to a review that only reads source code, which is why detecting shadow AI in enterprise networks belongs in this conversation. Then write down who may approve exact commands, since a cybersecurity policy for a small business can carry one line on agent approvals and secrets.
Keep the numbers in proportion. Apiiro’s 1.1% means about 99 in 100 public copies held nothing it classified as a secret, and private repositories were outside the study. Of the 16 coding agents whose documentation Apiiro compared, Claude Code is the only one it confirmed saves the full approved command in a project file by default [1], so other tools may leak through different files.
Credentials deserve the least-privilege thinking that a zero trust architecture applies to people. A database owner password inside a saved command is the worst version of this problem. A narrow, short-lived token turns the same leak into a smaller incident.
Sources & References
- The Hacker News, “Claude Code’s ‘Don’t Ask Again’ File Exposes Passwords and Keys in 1,122 Public Copies on GitHub,” November 7, 2026. thehackernews.com
- iTWire, “Claude Code approval files found exposing company secrets on GitHub, says Apirro researchers,” November 7, 2026. itwire.com
- GBHackers, “Claude Code’s ‘Don’t Ask Again’ Feature Exposes 2,539 Secrets Across 1,994 GitHub Repositories,” November 7, 2026. gbhackers.com
- Anthropic, Claude Code documentation, “Configure permissions.” code.claude.com
- GitHub, anthropics/claude-code issue 13106, “Sensitive tokens stored in .claude/settings.local.json and not ignored by git by default.” github.com
This article reflects the sources reviewed on November 7, 2026. Counts and vendor behavior may change, and we will update this page if they do.
Leave a Comment (Authenticated Users)