AI

Claude Code: 1,122 public GitHub files expose saved secrets

Key takeaways

  • Approving an exact command with "Yes, and don't ask again" can store any password inside it in plain text in .claude/settings.local.json
  • Apiiro found 1,122 public copies of the file holding at least one secret, 1,379 in total, and common scanners missed many of them
  • Rotate every credential the file has held before cleaning up, and approve patterns or use variables instead of exact commands

A developer using Claude Code has two ways to answer the permission prompt for a shell command, and one of them can quietly write a password into a file that ends up on public GitHub. Choosing "Yes, and don't ask again" on an exact command saves that command, secret included, in plain text. Choosing to approve a pattern, or keeping the secret out of the command altogether, does not. Security firm Apiiro has now counted how many public files hold secrets saved this way.

The contenders

The comparison here is between two ways of working with Claude Code, Anthropic's AI coding assistant. By default it asks before running most shell commands. If the user picks "Yes, and don't ask again," it saves an allow rule in .claude/settings.local.json inside the project, and matching commands run without asking in later sessions.

What gets saved depends on what the prompt offered. Sometimes that is a pattern, such as npm test *. Sometimes it is one exact command. When it is the exact command, any password or token typed into it is stored word-for-word.

The alternative is the discipline Apiiro's researchers recommend: refer to secrets as variables from a secrets manager, such as $DB_URL, so the saved rule holds the variable name rather than the secret, and approve patterns such as Bash(npm run:*) instead of single commands.

Head-to-head comparison

FeatureApproving exact commands with secrets typed inPatterns and secrets-manager variables
What is saved in the settings fileThe full command, including the password or token, in plain textThe pattern or the variable name, such as $DB_URL
Risk if the file reaches GitHubLive credentials readable by anyone; one notified company confirmed its key was liveNo secret in the file
Effect of deleting the file laterDoes not undo the leak; old versions stay in git history and forksNothing sensitive to recover
Detection by gitleaks and TruffleHogOf 1,122 files with a secret, gitleaks flagged 564, TruffleHog 643, neither flagged 215Not applicable
ConvenienceFewer prompts in later sessionsNot covered in the sources

Where exact-command approval wins

It is quick. One click and the same command never prompts again, which is the point of the feature. For commands with no sensitive content, such as a build or test invocation, an exact-command rule is harmless and needs no extra tooling.

That is the whole case for it. The trouble is that the prompt does not distinguish between a harmless command and one with a database password embedded in it, and the saved rule looks the same either way.

Where patterns and variables win

On the exposure evidence, they come out ahead. Apiiro's search of public GitHub found 104,185 copies of the file in 103,617 repositories. About 1.1% of them, or 1,122 copies, hold at least one secret, and together they hold 1,379 different secrets. More than a third open a database directly, including 379 database passwords. Others include 43 SSH logins for public servers, 42 tokens for GitHub, GitLab and npm, and 23 AWS keys. Apiiro did not test whether the secrets still work, though one company it notified confirmed its key had been live.

The owners include 63 organisations, mostly software companies of all sizes. The strongest cases, the researchers say, include a database vendor's own admin-level cloud key and the owner password of a medical-records database. As of Monday, every file with a secret was still on its repository's default branch, and in half of those repositories it had been there for at least 217 days.

Claude Code does try to keep the file out of git. The first time it writes the file in a repository, it adds it to the user's global git excludes. But that protection lives on one computer, does nothing for a file already committed, and never reaches the project's own .gitignore. In 539 of the 1,105 repositories the researchers traced, a commit listing Claude as a co-author changed the file, which they take to mean Claude often commits it itself.

Cleaning up afterwards is unreliable. Older versions of the file contain 734 more secrets across 509 repositories that are absent from any current copy, usually because the file was deleted. Forks spread the files further: 211 forks of 74 repositories carry the same secrets as the originals. Counting the shared .claude/settings.json file, older versions and saved agent chat logs, Apiiro's total is 2,539 secrets across 1,994 repositories.

Scanners are not a safety net either. They look for known key formats, and a password after PGPASSWORD=, sshpass -p or mysql -p reads like an ordinary word in an ordinary command. Of 16 coding agents whose documentation Apiiro compared, Claude Code is the only one confirmed to save the full approved command in a project file by default.

What this means for UK and US teams

The finding is not confined to one country. Any organisation whose developers approve exact commands containing secrets and publish the project files could be exposed, and the credentials involved (database passwords, cloud keys, SSH logins) are the kind that trigger incident response. It is also a supply-chain question for anyone holding contractor code, an area covered in the UK cyber security compliance guide for IT teams.

Credential theft by attackers is already an established pattern. Malware has previously looked for secrets on developer machines: in September 2025 the Shai-Hulud worm ran the TruffleHog scanner over infected computers, where it flagged more than half of the files as secret. Plain-text keys in a predictable file path are an easy target.

Apiiro's checklist for developers is specific:

  • Search your GitHub organisation for .claude/settings.local.json and .claude/settings.json, and check git history even where the files are gone.
  • Rotate every password, token and key the files have ever held, before cleaning up.
  • Stop tracking the local file with git rm --cached .claude/settings.local.json and add it to the repository's own .gitignore.
  • Open the file on your own machine, even if never committed, and delete every rule containing a secret.

For security teams, the advice is to treat agent folders such as .claude/, .cursor/, .gemini/ and .specstory/, and agent memory files, like .env files, on laptops as well as in repositories. Add them to pre-commit and CI secret scanning, including history, and make sure the scanner catches passwords inside commands. Check credentials paired with a public server first, since those give direct access. The file can also be left inside an npm package, a Docker image, a zip archive or a synced folder, so copies that never reach GitHub still matter.

The verdict

Use patterns and variables. The convenience of exact-command approval is a few saved clicks; the cost, shown by 1,122 public files and one confirmed live key, is a credential that anyone can read. Teams that cannot yet move every secret into a manager should at minimum stop choosing "Yes, and don't ask again" on any command containing a password, and rotate first if a file already exists. Exact-command rules are fine only for commands that carry nothing sensitive.

The practical order is rotate, then clean, then prevent. Deleting the file before rotating gives false comfort, because git history and forks keep the old copies.

Frequently asked questions

What file does Claude Code leak secrets into?

It is .claude/settings.local.json in the project folder. Choosing "Yes, and don't ask again" can save the approved command, including any typed password or token, in plain text.

Does deleting the file fix the leak?

No. Older versions stay in git history and in forks. Rotate every password, token and key the file has held first, then clean up.

More from Future Technology HQ