Live Nov 18 · Cohort 3Nov 18, 19:00 MSK — free hands-on AI agents live workshop · Live Cohort 3 starts Nov 23Join Nov 18 Live →Cohort 3 (Nov 23)
ReleaseInsight · On RadarHabr AI→ original

Claude Code saved passwords from commands: secrets found in 1.1% of settings files on GitHub

Click "don't ask again" in Claude Code on a command that contains a password, and the entire command gets written to .claude/settings.local.json. Apiiro found 104 185 such files on GitHub, and 1 122 of them (1.1%) held a secret. Version 2.1.323 closes the hole, but the update does not revoke keys that have already leaked. Update, then rotate everything that ended up in the file.

AI-processed from Habr AI; edited by Hamidun News
Claude Code saved passwords from commands: secrets found in 1.1% of settings files on GitHub
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Key metric #1Gitleaks and TruffleHog together missed 215 of the 1 122 files containing a secret
Key metric #2In 539 of 1 105 repositories, the file was changed by a commit with Claude as co-author
Key metric #3First rotate the compromised key, and only then clean up git history

Picture this: you ask Claude Code to check staging, the agent proposes running psql with the password right in the command, and for the tenth time you click "Yes, and don't ask again." The whole command, password included, is written to .claude/settings.

local.json inside the project. If that file later lands in git, the password is exposed publicly.

That is how, according to Apiiro, 104 185 copies of this file ended up on public GitHub, and 1 122 of them (about 1.1%) contained at least one password, token or key. Anthropic has already shipped a fix in version 2.

1.323, but it does not undo the damage: anything that has already leaked will have to be rotated by hand. So it is worth opening this file in your projects right now.

How a password ends up in a project file

In manual mode, Claude Code asks for permission on almost every shell command. If you choose "don't ask again," the rule is saved to .claude/settings.local.json in the repository root and applies in all later sessions. The rule copies whatever was in the prompt. Sometimes that is a harmless pattern such as "npm test *". Sometimes it is one specific command in full, for example a psql call with the password in a PGPASSWORD variable. In that case the password sits in the file in plain text.

The scenario is mundane. You have already approved a safe command ten times, you are tired, and you click "don't ask again" on the eleventh, where the agent checks staging using a password from a local config. A secret that used to live in a secrets manager or an environment variable now also sits in a JSON file inside the project.

According to The Hacker News, citing Apiiro, the 104 185 copies of the file were found in 103 617 repositories. 1 122 copies contained at least one secret. In total there were 1 379 secrets belonging to 63 organizations. More than a third give direct access to databases, including 379 database passwords. Researchers also found 43 SSH logins, 42 GitHub, GitLab and npm tokens, and 23 AWS keys. Ars Technica rounds the same data to "more than 100,000" files and "about 1,100" with secrets. There is no contradiction here.

An important caveat: the researchers did not check whether the secrets they found are still valid, and they do not claim anyone has already used them. One of the notified companies confirmed that its key was live. This is an exposure risk, not a proven breach. Also, Apiiro sells security tools, which is worth keeping in mind when judging the scale.

Why a "local" file ended up in someone else's clone

The name settings.local.json sounds safe. When Claude Code creates the file, it adds the path to the global git excludes, but only on that computer. No entry appears in the project's own .gitignore. On a new laptop, in CI, on a colleague's machine after cloning, or in a folder that became a repository later, that protection may be missing. And if the file has already been added to the git index, ignoring it does not help at all.

Boris Cherny, head of Claude Code, wrote on Hacker News that the file is supposed to stay local and that in such cases it was created and committed manually. But according to Apiiro, in 539 of 1 105 traced repositories the file was changed by a commit that lists Claude as co-author. And Anthropic's own changelog acknowledges the new-machine scenario and the "folder that became a repository later." Blaming it all on careless users would be inaccurate.

Standard scanners fall short too. Gitleaks found a secret in 564 of the 1 122 files, TruffleHog in 643, and 215 files were missed by both. The reason is simple: scanners are good at catching known key formats, while a password after PGPASSWORD= or sshpass -p looks like an ordinary word.

What changed and what to check

In Claude Code 2.1.323 (November 12), "don't ask again" no longer saves rules that look like a secret, or rules that would land in a file git already tracks. Such an approval applies only to the current session. The release also fixes the file's ignore handling on a new machine and in repositories created later. The update does not delete old rules, clean git history or revoke keys.

What a developer should do:

  • Check your version with claude --version and update to at least 2.1.323.
  • Open .claude/settings.local.json in every project and delete rules containing passwords, tokens and connection strings.
  • Approve patterns like "Bash(psql *)", and in the command itself reference a variable such as $DATABASE_URL rather than the value.
  • Search for the file in history: git log --all --full-history -- .claude/settings.local.json.
  • If a secret was ever there, rotate it first, and only then run git rm --cached and add the file to the repository's .gitignore.

There is no need to scrub the shared .claude/settings.json indiscriminately: it is committed on purpose. But it is worth checking too, since according to Apiiro, secrets turned up in 298 of 76 011 public copies.

For teams: add settings.local.json to the organization's .gitignore template, search for the file across all repositories along with their history, account for forks, and configure scanners to catch passwords inside commands. The .cursor and .gemini folders and agent logs can also store secrets.

The takeaway is practical. We trust coding agents with more and more actions, and their settings files are becoming a new place where secrets accumulate, much as .env once was. The update lowers the risk of new leaks, but old ones are closed only by rotating keys.

Story

Key Questions Answered

How a password ends up in a project file?

In manual mode, Claude Code asks for permission on almost every shell command. If you choose "don't ask again," the rule is saved to .claude/settings.local.json in the repository root and applies in all later sessions. The rule copies whatever was in the prompt. Sometimes that is a harmless pattern such as "npm test ". Sometimes it is one specific command in full, for example a psql call with the password in a PGPASSWORD variable. In that case the password sits in the file in plain text. The scenario is mundane.

Why a "local" file ended up in someone else's clone?

The name settings.local.json sounds safe. When Claude Code creates the file, it adds the path to the global git excludes, but only on that computer. No entry appears in the project's own .gitignore. On a new laptop, in CI, on a colleague's machine after cloning, or in a folder that became a repository later, that protection may be missing. And if the file has already been added to the git index, ignoring it does not help at all.

What changed and what to check?

In Claude Code 2.1.323 (November 12), "don't ask again" no longer saves rules that look like a secret, or rules that would land in a file git already tracks. Such an approval applies only to the current session. The release also fixes the file's ignore handling on a new machine and in repositories created later. The update does not delete old rules, clean git history or revoke keys. What a developer should do: Check your version with claude --version and update to at least 2.1.323.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Hands-On AI Engineering · Hamidun Academy

Build & Ship Production AI Agents Without Boilerplate Code

Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.

Start 72h Free Trial →Vibe-Coding Intensive
What do you think?
Loading comments…