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

> Source: <https://www.infoq.com/news/2026/11/claude-code-leaking-secrets/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global>
> Published: 2026-11-22 11:00:00+00:00

**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 the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

Agentic security firm [Apiiro found that Claude Code has been exposing secrets in public repositories](https://apiiro.com/blog/coding-agents-leaking-secrets-github-dont-ask-again) 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](https://blog.gitguardian.com/claude-code-settings-local-json-secrets-docker-hub/), 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](https://blog.gitguardian.com/ai-coding-agents-credential-security/)".

Commenting on the findings, Reddit user [T_Thriller_T observed](https://www.reddit.com/r/blueteamsec/s/QkDodyeQks) that "Somewhere, someone said [AI companies are ignoring basic cyber security principles](https://www.ibm.com/think/podcasts/security-intelligence/ai-labs-ignoring-cybersecurity)".

User [MattV0 suggested an interesting approach](https://www.reddit.com/r/ClaudeAI/s/37GDkBjFjP) 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.
