← Back to all articles
Challenges

Claude Code Security: 1,122 of 104,185 Public settings.local.json Files Held a Secret. Check Yours, Then Ask Your Vendor

Related service: AI-built app to production

Claude Code security has a new item on the list: a settings file. When you answer «Yes, and don't ask again» to a shell command, Claude Code saves that command as an allow rule in .claude/settings.local.json. If the command carried a password, the file now carries it too. On 5 November, Apiiro reported that 1,122 of 104,185 public copies of that file on GitHub held a real secret: about one in 93.

The file is meant to stay on your laptop, and Claude Code tries to keep it there. I am a DevOps engineer by trade; Conectia's engineers work inside client repositories with Conect AI Dev, our internal engineering platform, and with coding agents such as Claude Code; and taking AI-built apps to production is work we sell. Read what follows knowing my seat. My claim is that the configuration of your vendor's coding agent is part of your attack surface, and checking your own takes about ten minutes.

The short answer. Should you commit .claude? Commit .claude/settings.json (shared permissions, hooks and the environment variables the project needs) and .mcp.json, both reviewed like code and with ${VAR} references in place of values. Never commit .claude/settings.local.json: list it in the repository's own .gitignore and .dockerignore, not only on your machine. If the file was ever committed, rotate every credential it held before you think about rewriting history.

A «don't ask again» click saves the command, secret included

Four ordinary steps put a password in the file:

  1. You ask the agent why login fails on staging. The command it proposes needs the database password, so the password is in it: PGPASSWORD=… psql -h ….
  2. Claude Code asks before running it, and you choose «Yes, and don't ask again».
  3. Claude Code writes the command string itself as an allow rule in .claude/settings.local.json at the repository root (settings documentation).
  4. The first time it writes that file in a git repository that does not already ignore it, it adds **/.claude/settings.local.json to your global git excludes file.

Step four protects your machine. It does not protect a clone where Claude Code never wrote the file, a folder that became a repository afterwards, or a copy someone already committed, because ignore rules do not affect files git already tracks. Nor does it protect a Docker image: GitGuardian found 613 distinct secrets from these files in public Docker Hub images, because COPY . . takes the working tree and not the git index.

Apiiro's researchers, Shmulik Cohen and Matan Giladi, collected the data between 1 and 3 November and counted 1,379 distinct secrets in those 1,122 files: database passwords, cloud keys, API tokens and SSH logins, more than a third of them opening a database directly. Adding the file's history, the shared settings.json and committed agent transcripts, the total reaches 2,539 distinct secrets in 1,994 repositories. GitGuardian published its own count on 9 November, from every public push since January 2025: 31,088 distinct secrets in settings.local.json across 23,276 repositories, 5,343 of them valid when detected.

One in 93 is a small number, and the right one to act on

Read the anchor both ways. 98.9% of the public files Apiiro read held no secret. The rate climbs with use: one in ten files over 8 KB held one, against fewer than one in 500 under 500 bytes. The exposure builds up one approval at a time, so it is a habit to change as much as a default to fix.

Four limits go with the numbers. Apiiro never tried the credentials, so its study shows exposure, not breach; GitGuardian's read-only checks found 17% of its secrets working. Both counts cover public repositories only, although the file also sits on the laptop of everyone who approved a command. Both firms sell security products, so this is vendor research. And GitGuardian's own curve cuts against the alarm: monthly leak occurrences peaked at 12,535 in April 2026 and fell to 959 in October, a 92% drop it cannot yet explain.

Anthropic deserves the credit its default earns: the global exclude covers the common case, and the documentation says what the file is for. On 7 November Boris Cherny, who leads Claude Code, replied on Hacker News: «Historically Claude Code has not done secret scrubbing (there are many good tools for that), but we are looking into what we can do to prevent this.» He read the exposed files as created by hand; GitGuardian replied that, in the 3,000 or so occurrences it inspected, every secret sat in an allow rule of the exact shape the prompt writes. A default that lives on one laptop protects one laptop.

settings.json and settings.local.json are different files with different jobs

The documentation lists four scopes, and the difference between them is the whole question of what to commit:

  • ~/.claude/settings.json is yours, in every project on the machine.
  • .claude/settings.json is the shared project file, which the documentation says to commit so teammates get the same permissions, hooks, plugins and environment variables. Hooks run commands automatically during the agent's lifecycle, so review its diff like a CI pipeline. GitGuardian counted 8,271 distinct secrets in it, and the VS Code extension's approval card can save a rule here, for everyone.
  • .claude/settings.local.json is personal, for one project, and it is where your approvals accumulate.
  • Managed settings carry an organisation's security policy and take precedence over the others, with a few documented exceptions.

Two neighbours belong in the same review. .mcp.json defines project-scope MCP servers, is meant to be checked in, and supports ${VAR} expansion, so a shared file can reference an API key without containing it (MCP documentation). CLAUDE.md held 6,155 distinct secrets in GitGuardian's data, because people paste connection strings into the instructions they give the agent.

In its own repositories Conectia keeps the whole .claude/ folder out of version control, because it holds internal tooling that is not part of any product. For most teams the shared settings.json is worth committing.

The ten-minute check on your own repositories

Run these from the root of each repository you own; they read only your tree, your history and your machine.

  1. Which agent files does git track today? The local file should not be in the list.

    git ls-files | grep -E '(^|/)\.(claude|cursor|gemini|codex)/|(^|/)\.mcp\.json$'
    
  2. Was the local file ever committed, on any branch? Any line here means every value it held is in every clone.

    git log --all --format='%h %ad %an %s' --date=short -- ':(glob)**/.claude/settings.local.json'
    
  3. Who ignores it, the repository or only you? If the rule printed comes from your global excludes file, a teammate's clone has no protection; if nothing prints, nobody ignores it.

    git check-ignore -v --no-index .claude/settings.local.json
    
  4. What do your local copies hold? This prints only file names. Open each, delete the rules that hold a secret (or use /permissions), and paste the contents nowhere.

    find ~ -path '*/.claude/settings*.json' -not -path '*/node_modules/*' 2>/dev/null \
      | xargs grep -l -E -i 'PASSWORD=|sshpass|bearer|token|secret|api[_-]?key|://[^/ ]+:[^@ ]+@|mysql .*-p'
    
  5. Does your image build copy the folder? With COPY . . and no .claude line in .dockerignore, the file ships.

    grep -n '\.claude' .dockerignore
    
  6. Does your scanner see a password inside a command? Apiiro ran gitleaks and TruffleHog over all 104,185 files: of the 1,122 with a real secret, gitleaks flagged 564, TruffleHog 643, and 215 were flagged by neither. A password after PGPASSWORD= has no key format to match. Scan agent folders and history in pre-commit and in CI, and turn on your code host's secret scanning.

  7. Stop typing secrets into commands. Reference $DATABASE_URL from the environment or a secrets manager, so the saved rule records the name and not the value; an inline PGPASSWORD=value still puts the value in the text. Approve narrow prefixes, not Bash(curl *).

If steps 1 to 3 found something, the repository side of the fix is three lines:

git rm --cached .claude/settings.local.json
printf '%s\n' '**/.claude/settings.local.json' >> .gitignore
printf '%s\n' '**/.claude/' >> .dockerignore

If a secret was ever in the file, rotate before you touch history

Deleting the file fixes nothing that already left: Apiiro found 734 real secrets that survive only in earlier versions of it. GitHub's guidance puts revocation first, because a rotated secret opens nothing, and warns of recontamination after a rewrite: one colleague with an old clone runs git pull and git push, and the data is back. Forks and published images keep their copies whatever you rewrite.

So the order is rotate, untrack and ignore, then decide whether a rewrite is worth it.

We lived this once with .env, and it settled when the ignore line moved into the template. GitHub's Node.js .gitignore template ignores .env and .env.*, and today it has no line for .claude. Add one to your organisation's templates, and every new repository inherits it.

A backdoored extension shows the same surface one layer down

The agent itself arrives through a supply chain. On 30 October Phorion published an analysis of a backdoored build of the Claude Code for VS Code extension on the Cursor Marketplace, versions 2.1.312 and 2.1.313, which tried to plant a persistent SSH backdoor and sent out host details. Cursor's notice says those versions were not developed by Anthropic and were available for about eleven hours on 29 October. Which marketplace, which version, installed by whom: that is the tool supply chain I wrote about in July, now on developer laptops.

What to require of a vendor whose engineers run agents in your code

The conflict of interest is mine to declare: Conectia is such a vendor, and you can hand this list to us. In plain words, the contract or its security annex should say:

  1. Personal agent files never enter your repositories. settings.local.json, transcripts and memory files are ignored in the repository itself.
  2. No credential is typed into an agent's prompt or command. Secrets come from the environment or a secrets manager you control.
  3. Shared agent configuration is reviewed like code. Changes to .claude/settings.json, .mcp.json, CLAUDE.md or hooks go through your normal review and carry no secret values.
  4. Agents get least privilege. No standing approval for production credentials, and no agent with write access to production.
  5. Secret scanning covers agent folders and history, in pre-commit and CI, including passwords inside commands.
  6. The vendor names its agents: which tools, extensions and versions touch your code, from which source, with notice within 24 hours of a known compromise.
  7. Exposure is reported and cleaned up: notice within 24 hours of any credential of yours found in an agent file, and local agent files holding your data deleted when the engagement ends, confirmed in writing.

The confidentiality side, from the no-training clause to returning copies, belongs in the agreement you sign before anyone reads the code, which I covered in what the NDA should say before you show your code to a vendor. Rotating every key an outsider could have seen is also the first item on the fix list of any AI-built MVP.

The agent remembered what you told it to remember

Nobody attacked anyone in this story, and secrets still leaked through a coding agent's files. An engineer approved a reasonable command, the tool kept its promise not to ask again, and the record of that approval became a second copy of the password. Coding agents make good engineers faster, and they write things down; what they write down is configuration you own. If you want a second pair of eyes on what the agents in your repositories have been writing down, talk to a CTO.


Sources:

  • Apiiro, Shmulik Cohen and Matan Giladi. Coding Agents Are Leaking Your Secrets to GitHub (5 November 2026, updated 8 November). apiiro.com
  • GitGuardian, Guillaume Valadon. Claude Code settings.local.json Secrets: GitHub, Docker Hub (9 November 2026). blog.gitguardian.com
  • iTWire, David M Williams. Claude Code approval files found exposing company secrets on GitHub (7 November 2026). itwire.com
  • CSO Online, Shweta Sharma. Claude Code's 'don't ask again' button has a secrets-spilling problem (11 November 2026). csoonline.com
  • Boris Cherny on Hacker News (7 November 2026). news.ycombinator.com
  • Anthropic. Claude Code documentation: settings, permissions, MCP.
  • Phorion. Official Claude Code Extension Compromise: Security Advisory (30 October 2026). phorion.io
  • Cursor. Security notice: malicious version of Anthropic.claude-code (2.1.312 and 2.1.313) (29 October 2026). cursor.com
  • GitHub Docs. Removing sensitive data from a repository. docs.github.com
Work with the authors

The CTOs who write this also build

Fractional CTO engagements, AI engineering squads and an AI development platform we install on your codebase in 24 hours. If this piece matched how you think, the conversation is short.