cd /news/ai-agents/claude-code-has-been-leaking-secrets… · home › topics › ai-agents › article
[ARTICLE · art-174143] src=infoq.com ↗ pub= topic=ai-agents verified=true sentiment=↓ negative

Claude Code Has Been Leaking Secrets Through Its "Don't Ask Again" Feature

Apiiro found that Claude Code's "Don't Ask Again" feature writes approved shell commands into `.claude/settings.local.json`, exposing 1,122 secrets in those files and another 1,160 in git history, shared `settings.json` files and agent chat transcripts, affecting 63 organizations. GitGuardian later found 31,088 secrets in `.claude/settings.local.json` files on public GitHub, 5,343 of them still valid at detection, plus 613 in Docker Hub images. Apiiro recommends untracking the file with `git rm --cached .claude/settings.local.json`, adding it to the repo's `.gitignore`, rotating every credential it contained, and referencing secrets through environment variables instead of typing them into commands.

recommendation

Untrack `.claude/settings.local.json` with `git rm --cached`, add it to the repo's `.gitignore`, rotate every credential it held, and pass secrets via environment variables instead of typing them into approved commands.

more in playbook: Securing agents and AI tools
by read3 min views2 publishedNov 22, 2026
Claude Code Has Been Leaking Secrets Through Its "Don't Ask Again" Feature
Image: source

Agentic security firm Apiiro found that Claude Code has been exposing secrets in public repositories due to how it stores them in local file on developers' machines to implement the "Don't Ask Again" feature. The company identified 1,122 secrets in claude/settings.local.json files and another 1,160 in git history, in the shared settings.json intentionally committed, and in agent chat transcripts stored in repos.

The problem lies in how Claude Code handles command approval. When developers reply "Yes, and don’t ask again" to approve a shell command, Claude Code saves it as a permanent permission rule in the local configuration file .claude/settings.local.json, which may end up inadvertently containing embedded credentials, passwords and API tokens.

When [Claude Code] creates the file inside a git repo, it adds it to the developer's global git ignore list. That covers the common case. It doesn’t cover a folder that becomes a repo later, a clone on another machine, or a file someone already committed. The rule never goes into the repo's own .gitignore, so nothing travels with the project to protect it.

On some occasions, the researchers found, Claude Code itself committed the file. Overall 63 organizations were affected, with exposed secrets including cloud API keys, production passwords and access tokens, and npm tokens. Generic secret scanners such as gitleaks and TruffleHog failed to flag all exposed secrets, mostly because they were embedded inside shell commands.

The same password-in-a-command pattern appears wherever an agent records what it ran: transcripts, memory files, handoff notes, and a scanner tuned to key formats misses it in all of them.

The researches also note that the way Claude Code manages secrets is a security gap in itself, as to any malware "it’s a list of the systems the developer can reach and the passwords that open them, one file search away", available at the same path in every project.

Apiiro's findings were later reinforced by GitGuardian, which found 31,088 secrets in Claude Code’s .claude/settings.local.json on public GitHub, 5,343 of which were still valid at the time of detection, as well as another 613 in Docker Hub images. GitGuardian had previously warned that "Cursor, Claude Code, and GitHub Copilot leave credentials scattered across config files, logs, and shell history".

Commenting on the findings, Reddit user T_Thriller_T observed that "Somewhere, someone said AI companies are ignoring basic cyber security principles".

User MattV0 suggested an interesting approach to the whole matter of how to deal with AI files:

While this is about secrets, I totally stopped adding AI files into my projects. Means no settings, CLAUDE.md, AGENTS.md or anything else. I even turned off Claude's memory. [...] Nowadays I use a memory/task/docs server through mcp and it really improved such documentation issues. At very very least, Apiiro recommends untracking the json file using git rm --cached .claude/settings.local.json and adding it to the repo's .gitignore, as well as rotating every credentials the file has ever contained. For a sounder approach, the researchers also recommend inspecting the file and deleting any rule that contains a secret, and avoid typing secrets directly into commands, referencing them instead through environment variables.

── more in #ai-agents 4 stories · sorted by recency
── more on @apiiro 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/claude-code-has-been…] indexed:0 read:3min 2026-11-22 · —