AivexaNewsSearch
AI news for builders and product teamsChecked every hour

Claude Code Has Been Leaking Secrets through its "Don't Ask Again" Feature

Collected Nov 22, 2026

Agentic security firm Apiiro has reported that Claude Code leaks secrets in public repositories because of the way it implements its "Don't Ask Again" command-approval feature. When a developer approves a shell command with "Yes, and don't ask again," Claude Code writes the command into a permanent permission rule in the local configuration file .claude/settings.local.json. If the command itself contains a credential, a password or an API token, that secret is written into the file as well. Apiiro found 1,122 secrets in claude/settings.local.json files and a further 1,160 in git history, in a shared settings.json that was intentionally committed, and in agent chat transcripts stored inside repositories. In total 63 organizations were affected. The exposed material included cloud API keys, production passwords, access tokens and npm tokens.

The mechanism of the leak is worth understanding, because it is not a simple case of a file being committed by mistake. Claude Code does try to protect the file: when it creates settings.local.json inside a git repository, it adds the path to the developer's global git ignore list. That handles the common case of a fresh repository on the machine where the file was created. It does not handle a folder that becomes a repository later, a clone on a different machine, or a file that someone has already committed. The rule is written to the global ignore list rather than to the repository's own .gitignore, so nothing travels with the project to protect other people who check it out. In some cases, the researchers found, Claude Code itself committed the file.

Apiiro also argues that the practice is a security gap in its own right. The file lives at the same path in every project, so to any malware on the machine it is a single file search away from a list of the systems the developer can reach and the passwords that open them.

Detection is a further problem. Generic secret scanners such as gitleaks and TruffleHog did not flag all of the exposed secrets, largely because they sit inside shell commands rather than in the key-value form scanners expect. The same pattern — a password written inline in a command — shows up in every place an agent records what it ran: transcripts, memory files and handoff notes, where a scanner tuned to key formats will miss it.

The findings were reinforced by GitGuardian, which counted 31,088 secrets in Claude Code's .claude/settings.local.json files on public GitHub, 5,343 of which were still valid at the time of detection, plus 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.

Apiiro's minimum recommendation is to stop tracking the file with git rm --cached .claude/settings.local.json, add it to the repository's .gitignore, and rotate every credential the file has ever contained. For a sounder fix, the researchers suggest inspecting the file and deleting any rule that contains a secret, and avoiding typing secrets directly into commands by referencing environment variables instead. The last point is the durable one: if a command refers to $API_TOKEN rather than the token itself, the approval rule records nothing sensitive even when it is stored.

In practice, the risk is highest for teams that adopted Claude Code early and casually. A global ignore entry is invisible to anyone auditing a repository, so a teammate cloning the project has no signal that a sensitive file may be present or may once have been committed. And once a secret is in git history, removing the file in a later commit does not remove the exposure; history rewrites or credential rotation are the only remedies. This suggests that the shared settings.json committed to a repository deserves separate scrutiny, since that file was explicitly intended to be versioned and shared.

Why it matters: any team using Claude Code, or other agents that persist approved commands, should treat local agent configuration as a potential credential store. Concrete actions follow directly from the findings: untrack the local settings file, add the path to the repository's own ignore rules rather than relying on a global list, scan transcripts and memory files as well as config, and rotate anything that has been exposed. Developers who keep secrets in environment variables rather than inline in commands avoid the pattern entirely, and are the least affected by this class of leak.

Read at InfoQ · AI, ML & Data Engineering

Based on reporting from the original publisher. Visit the source for full context and later updates.

Publisher excerpt

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 "Don't Ask Again". The company identified 1,122 secrets in claude/settings.local.json files and another 1,160 in git history, in the shared settings.json, and in agent chat transcripts stored in repos. By Sergio De Simone