ai-devtools —

Claude Code leaks secrets in public repos via "Don't Ask Again" feature

The practice by Claude Code of storing information locally to facilitate its "Don't Ask Again" functionality has resulted in the exposure of sensitive credentials within publicly accessible code…

Claude Code leaks secrets in public repos via "Don't Ask Again" feature

The practice by Claude Code of storing information locally to facilitate its "Don't Ask Again" functionality has resulted in the exposure of sensitive credentials within publicly accessible code repositories, according to an investigation by the agentic security firm Apiiro.

This issue stems from how the platform manages command approvals; when developers respond with "Yes, and don’t ask again" to authorize a shell command, Claude Code permanently records this as a permission rule inside the local configuration file, specifically .claude/settings.local.json. This file can inadvertently house embedded passwords, API tokens, and other credentials. While the system does place this file into the developer's global git ignore list when it creates it within a repository, this protection is not comprehensive. It fails to account for scenarios where a folder subsequently becomes a repository, when a clone is made on a different machine, or if a file was committed prior to the rule being set. Furthermore, the rule itself never enters the repository's dedicated .gitignore file, meaning the protection does not travel with the project. On certain instances, the researchers observed that Claude Code itself was responsible for committing the file.

Apiiro identified a total of 1,122 secrets within the claude/settings.local.json files, alongside another 1,160 secrets found in git history, the shared settings.json which was intentionally committed, and in agent chat transcripts residing within repositories. These exposed secrets encompassed cloud API keys, production passwords, access tokens, and npm tokens, affecting 63 distinct organizations.

The mechanism by which Claude Code manages secrets presents a security vulnerability in its own right, as it effectively creates a centralized directory containing a list of systems the developer can reach and the necessary passwords to access them, accessible via a simple file search within every project. Generic secret detection tools, such as gitleaks and TruffleHog, were unable to flag all the exposed secrets, primarily because they were embedded within the shell commands themselves. This pattern of placing passwords inside commands is replicated wherever an agent logs its execution details: in memory files, handoff notes, and transcripts; consequently, a scanner configured only for key formats overlooks these instances.

These initial findings were subsequently corroborated by GitGuardian, which discovered 31,088 secrets within Claude Code’s .claude/settings.local.json across public GitHub instances, with 5,343 of those still being valid at the time of the detection. Additionally, GitGuardian located 613 secrets within Docker Hub images. GitGuardian had previously issued a warning stating that "Cursor, Claude Code, and GitHub Copilot leave credentials scattered across config files, logs, and shell history."

In response to these disclosures, a Reddit participant, T_Thriller_T, commented that "Somewhere, someone said AI companies are ignoring basic cyber security principles." Another user, MattV0, proposed a preventative measure regarding AI-related files, stating, "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." MattV0 further noted that utilizing a memory/task/docs server via mcp has significantly improved documentation issues in their workflow.

From an operational standpoint, Apiiro advises two key remediation steps: first, untracking the json file using the command git rm --cached .claude/settings.local.json and subsequently adding it to the repository's .gitignore; concurrently, all credentials previously contained within that file must be rotated. For a more robust security posture, the researchers also suggest examining the file to eliminate any rule containing a secret and adopting the practice of referencing secrets through environment variables rather than typing them directly into commands.

This development underscores a broader industry concern regarding the integration of sophisticated agentic workflows into development environments, where the convenience of automated interaction risks creating persistent, unmanaged vectors for credential leakage across the platform infrastructure.

Why it matters

This incident highlights significant security gaps in how AI coding tools manage local configuration and command approvals. Operators must immediately review and rotate credentials stored in local files and agent transcripts to prevent unauthorized access.

Earlier coverage

Reported by infoq.com.

ai-devtoolssecurity

Related coverage

Elsewhere in this edition