Skip to content

Security Alert | Claude Code's "Don't Ask Again" Feature Writes Passwords and Keys Straight to Public GitHub Repos

Nov 9, 20261 min
TL;DRApiiro published research on Nov 5 showing that choosing "don't ask again" in Claude Code saves the full approved shell command — including any password or key typed into it — verbatim into a project's .claude/settings.local.json. That file regularly ends up committed to public GitHub repos; scanning over 100,000 public copies turned up 2,539 secrets across 1,994 repos and 63 organizations, with at least one confirmed still live. Fixes: rotate every exposed credential, untrack the file from git, and reference secrets as environment variables instead of typing them into commands.

Look up & save

Loading dictionary…

🌏 中文版

What Happened

Application security firm Apiiro published research on November 5 showing that when a user picks "Yes, and don't ask again" on a shell command in Anthropic's Claude Code, the tool can save that exact command into the project's .claude/settings.local.json, to be auto-approved on future runs. The problem: if the command the user typed or approved already contained a password, API key, or token — something like mysql -pYourPassword — that secret gets written into the file verbatim along with the rest of the command. And that file is often committed to public GitHub repos, sometimes by Claude Code itself. Apiiro scanned 104,185 public copies of the file on GitHub and found 1,122 containing at least one secret, 1,379 secrets in total. Add older versions still sitting in git history, .claude/settings.json files teams share on purpose, and saved agent transcripts, and the total climbs to 2,539 secrets across 1,994 repositories and 63 organizations. Apiiro notified one of the affected companies, which confirmed its leaked key was still live.

Basics

FieldValue
Incident typeSecret exposure (design flaw in a coding agent's permission cache)
ScopePublic GitHub repos where Claude Code was used with "don't ask again"; 63 organizations affected
SeverityHigh
CVENone (research disclosure, no CVE assigned)
SourcesApiiro research, The Hacker News

Attack Surface Analysis

The root cause is that Claude Code's permission cache only remembers what got approved, not why. The first time a user runs a command that touches sensitive data — connecting to a database, logging into a server with sshpass, calling a cloud API — Claude Code asks for approval. If the user picks "don't ask again," the rule it saves is sometimes a pattern like npm test *. But if what got approved was one specific, complete command rather than a pattern, Claude Code writes that entire command string — hardcoded password or token included — character for character into .claude/settings.local.json. Apiiro reproduced the same behavior with the current Opus 5.5 and Fable 5.1 models, confirming this isn't limited to older versions.

What turns this into a bigger problem is that the git-level protection is only half-built: the first time Claude Code writes this file inside a git repo, it adds the file to that one computer's global git exclude list — but it never writes an entry into the project's own .gitignore. That means the protection travels with "this computer, this user," not with the project. The moment the file exists on a different machine, or was already committed before the global exclude took effect, the protection does nothing — and Apiiro found that in 539 of the 1,105 repos it traced, the commit that touched this file listed Claude as a co-author, suggesting Claude Code often commits the file itself. Worse, deleting the file doesn't undo the leak: old versions persist in git history and in forks. Apiiro separately found 734 secrets across 509 repos' historical versions that no longer appear in the current copy, and 211 forks that carried the same leaked secrets forward from their originals.

How an approved command leaks a password through Claude Code
How an approved command leaks a password through Claude CodeAn approved command with a password gets saved verbatim; the global git-exclude rule only protects the one machine it was set on, so a different machine, CI, or a prior commit still exposes it to a public repo, where history and forks keep it alive. User approves a command it may contain a password Pattern or exact? e.g. npm test * Pattern only no password Full command saved verbatim password included Exclude rule active? this machine only Safe for now this machine Committed to a public repo History and forks still hold the leaked secret pattern full command active not protected leaks anyway
  1. User approves a command containing a password, picking "don't ask again"
  2. Decide whether what got approved was a pattern or a full command
  3. A pattern gets saved as just the pattern, no password included
  4. A full command gets saved verbatim, password and all, into the settings file
  5. Decide whether the global exclude rule is active on this copy of the file
  6. Active means temporary safety on this machine; inactive or already committed means it leaks straight to a public repo
  7. Temporary safety doesn't last — a different machine or a fork leaks it just the same
  8. Once leaked, history and forks keep the secret alive even after the current file is deleted

Simplified; based on Apiiro's Nov 5, 2026 research.

Mapped onto the OWASP LLM Top 10, this incident hits both LLM02 Sensitive Information Disclosure (secrets improperly retained and exposed) and LLM06 Excessive Agency (when an agent is granted the ability to auto-rerun a command, failing to separate "the command's operating pattern" from "the sensitive parameters embedded in it" hands too much autonomy to a caching mechanism that just copies whatever the user typed). Notably, Apiiro compared the documentation of 16 coding agents and found Claude Code is the only one confirmed to save the full approved command into a project file by default.

Defenses

Immediate actions

  • Search your GitHub organization for .claude/settings.local.json and .claude/settings.json, including each repo's git history, even where the file has since been deleted
  • For any file containing a secret, rotate first, clean up second: assume every password, token, and key it ever held has leaked, and revoke and reissue each one
  • Run git rm --cached .claude/settings.local.json to untrack the file, and add a repo-level .gitignore rule — don't rely solely on the global exclude list Claude Code writes

Long-term architecture

  • Approve patterns rather than exact commands wherever possible (e.g. Bash(npm run:*)); reference passwords as environment variables (like $DB_PASSWORD) in commands so the cached rule only ever stores the variable name
  • Treat agent config folders like .claude/, .cursor/, .gemini/, and saved agent transcripts as secret-bearing, the same as .env files, and add them to pre-commit and CI secret scanning, including git history
  • Standard secret scanners often miss this pattern: Apiiro found gitleaks and TruffleHog caught only 564 and 643 of the 1,122 problem files respectively, with 215 missed by both, because passwords following PGPASSWORD=, sshpass -p, or mysql -p don't match typical key-format rules. To close that gap, a runtime governance platform from watchlist B7 like WitnessAI — built to continuously capture and audit what agents actually do, including shell commands and tool calls — can intercept a command before it's approved and cached, rather than relying on scanning after the commit already happened

Impact

At the time Apiiro checked, every file containing a secret was still sitting on its repo's default branch, and half had been there for at least 217 days untouched. Most of the 63 affected organizations are software companies; researchers specifically called out two of the more severe cases: a database vendor's own admin-level cloud key, and the owner password for a medical-records database. Researchers didn't test whether the secrets still worked and didn't contact any server to verify, so the one confirmed-live key came only from a single notified company — meaning the real scale of exploitable exposure is likely harder to pin down than the "2,539" headline number suggests. Worth noting: GitHub issues reporting this same behavior date back to at least August 2025, but every related report was closed by an automated bot without any reply from Anthropic.

If you or your team use Claude Code — or any coding agent that caches and reruns approved commands — this incident means "don't ask again" itself is an attack surface worth re-evaluating. It was built to cut down on approval friction, but it can just as easily turn the secrets you habitually paste into a terminal into a leak that sits quietly in a public repo for months.

Today's Takeaway

What makes this incident interesting is that it didn't need an attacker at all: no malware, no prompt injection, no supply-chain poisoning. A design decision made purely for convenience — caching whatever the user typed — stacked on top of a protection boundary drawn in the wrong place — tied to one user's local machine instead of the project — was enough on its own to leak secrets at scale. Compared to the deliberate attack chains covered here before, this is a reminder to ask, of any agent feature that "remembers what you approved last time": is it remembering how you did something, or is it also remembering exactly what you typed while doing it?

References