Skip to content

Claude Code’s Don’t Ask Again File Leaks Secrets on GitHub

Claude Code’s Don’t Ask Again File Leaks Secrets on GitHub

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].

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.json in 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].
How an approved command reaches a public repository Five numbered steps: you approve a command containing a secret, Claude Code saves it as an allow rule, the file is committed and pushed, the repository is public, and cleanup leaves copies in history and forks. 1 You approve a command The command has a password or token typed in, and you pick “Yes, and don’t ask again” 2 Claude Code saves an allow rule The command is stored word for word in .claude/settings.local.json 3 The file is committed and pushed The global git exclude lives on one computer and does not travel with the project 4 The repository is public Anyone can read the saved command, password included 5 Cleanup leaves copies behind Older commits and forks keep the secret, so the credential must be rotated
Figure 1. How an approved command can end up in a public repository. Conceptual diagram by UnpanicTech, based on the sequence reported in sources [1], [2] and [4]. It is not a screenshot.

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 approveWhat the saved rule holdsSecret exposed?
A pattern the prompt offers, such as a test runnerThe pattern onlyNo
An exact command that points to a variable such as $DB_URLThe variable name, not its valueNo, per Apiiro’s advice [1]
An exact command with a literal password typed inThe full command, password includedYes, in plain text [1]
A command with the secret assigned inline as a variableThe assignment as writtenYes, 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 for the Claude Code settings file Four tiles: 104,185 public copies examined across 103,617 repositories; 1,122 copies with at least one secret, about 1.1 percent; 1,379 distinct secrets in those files; 2,539 secrets across 1,994 repositories when history, shared settings and transcripts are counted. 104,185 public copies of settings.local.json across 103,617 repositories 1,122 copies hold at least one secret, about 1.1% of those examined 1,379 distinct secrets inside those 1,122 files 2,539 secrets in 1,994 repos, counting history, shared settings and transcripts
Figure 2. The scale of Apiiro’s findings as reported in sources [1], [2] and [3]. The figures are Apiiro’s claims, and the company did not test whether the secrets work.

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.

ClaimStatusSource
Claude Code saves approved Bash commands in the local settings fileDocumented by the vendor[4]
1,122 of 104,185 public copies hold a secretReported by Apiiro, relayed by three outlets, not independently replicated[1][2][3]
The exposed credentials still workNot tested; one notified company said its key was live[1][2]
Someone has used an exposed credentialNot shown in the sources reviewedNone
A CVE or vendor advisory covers the behaviorNo CVE ID appears in the sources reviewedNone
Anthropic has responded publiclyNo 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].

Split of 1,379 secrets by how Apiiro identified them Donut chart. 636 secrets, 46.1 percent, matched known provider key formats. 743 secrets, 53.9 percent, were passwords or tokens found beside a public host address. 1,379 distinct secrets 636 matched known provider key formats (46.1%) 743 passwords or tokens beside a public host (53.9%)
Figure 3. How Apiiro’s 1,379 distinct secrets split by detection method, based on the counts in source [3]. Percentages are UnpanicTech’s own arithmetic. Original chart by UnpanicTech.
Secret types found in the exposed Claude Code settings files Horizontal bar chart. Database passwords 379, Supabase service-role keys 122, Supabase account tokens 103, SSH logins 43, GitHub GitLab and npm tokens 42, AWS keys 23, private keys 6. Database passwords379 Supabase service-role keys122 Supabase account tokens103 SSH logins43 GitHub, GitLab, npm tokens42 AWS keys23 Private keys6
Figure 4. Secret types in the exposed files, from counts reported in sources [1] and [3]. The categories overlap with the totals above and do not add up to 1,379. Original chart by UnpanicTech.

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.

ProtectionWhere it livesTravels with the repo?Helps if already committed?
Global git exclude added by Claude CodeOne developer’s computerNoNo
Entry in the project’s .gitignoreThe repositoryYesNo, untrack the file first
Untracking the file with gitThe repository indexYes, once committedStops new tracking only; history remains
Rotating the credentialThe service that issued itNot applicableYes, 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].

How many secret-bearing files two scanners flagged Bar chart over 1,122 files with a secret. Gitleaks flagged 564, 50.3 percent. TruffleHog flagged 643, 57.3 percent. 215 files, 19.2 percent, were flagged by neither tool. Files with at least one secret: 1,122 Flagged by gitleaks: 564 (50.3%) Flagged by TruffleHog: 643 (57.3%) Flagged by neither tool: 215 (19.2%)
Figure 5. Scanner coverage on the 1,122 secret-bearing files, from counts reported in sources [1] and [3]. Percentages are UnpanicTech’s own arithmetic, and Apiiro ran both tools without verification. Original chart by UnpanicTech.

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].

Timeline of reports about secrets in Claude Code settings files Seven dated events from August 2025 to November 7, 2026: first bug report, a December 2025 user report, a bot closing the August report in January 2026, ironPeak in February 2026, Apiiro data collection November 1 to 3, Apiiro publication November 5, and press coverage November 7. Aug 11, 2025First bug report: approved commands withkeys and tokens stored word for word Dec 2025Another user reports a key leaked afterthe settings file reached a public repo Jan 3, 2026Bot closes the August report as “not planned”after 60 days without activity Feb 2026ironPeak describes a similar committed file(as reported by iTWire) Nov 1 to 3, 2026Apiiro collects public GitHub data andnotifies affected owners on Nov 2 and 3 Nov 5, 2026Apiiro publishes its research (date as givenby iTWire and GBHackers) Nov 7, 2026Press coverage appears; no public Anthropicstatement found in the sources reviewed
Figure 6. Timeline of reports about credentials in Claude Code settings files, from sources [1], [2], [3] and [5]. Orange marks user and press reports, blue marks Apiiro’s research. Original diagram by UnpanicTech.

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.

  1. Search your GitHub organization for .claude/settings.local.json and .claude/settings.json, including repository history where the files are gone [1].
  2. Rotate every credential those files ever held, before any cleanup [1]. iTWire says GitHub’s guidance gives the same order [2].
  3. Stop tracking the local file, then add it to the repository’s own .gitignore [1].
  4. Open the file on your own computer, even if it was never committed, and delete every rule that contains a secret [1].
  5. Keep secrets out of commands by referring to variables from a secrets manager [1].
  6. 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 /permissions dialog lists every saved rule and the settings file it came from, which makes a quick audit possible [4].
  • A Read deny rule such as Read(./.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

  1. 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
  2. iTWire, “Claude Code approval files found exposing company secrets on GitHub, says Apirro researchers,” November 7, 2026. itwire.com
  3. GBHackers, “Claude Code’s ‘Don’t Ask Again’ Feature Exposes 2,539 Secrets Across 1,994 GitHub Repositories,” November 7, 2026. gbhackers.com
  4. Anthropic, Claude Code documentation, “Configure permissions.” code.claude.com
  5. GitHub, anthropics/claude-code issue 13106, “Sensitive tokens stored in .claude/settings.local.json and not ignored by git by default.” github.com
NK

Cybersecurity Researcher & Technical Editor

UnpanicTech publishes independent cybersecurity research and defensive security analysis. Naseem Khan serves as Technical Editor, with a focus on vulnerability analysis, defensive security, incident response, cloud security, and practical security engineering.

Leave a Comment (Authenticated Users)