Security researchers have found that the AI coding assistant Claude Code has been inadvertently exposing thousands of credentials, including cloud API keys, production passwords and access tokens, on public GitHub repositories because of how its "Don't Ask Again" feature stores permission rules on developers' machines.
Agentic security firm Apiiro 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 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.
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 but does not 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 researchers 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.
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".
At a minimum, 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 credential 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.
Analysis
Why This Matters
- Developers and organizations using AI coding assistants may be unknowingly exposing critical credentials, increasing the risk of account compromise, data breaches and supply-chain attacks.
- The finding shows a systemic security gap in agentic tools that record commands: the same pattern is likely to affect other assistants that log shell commands, config files and memory.
- Organizations affected by this issue now face the immediate task of rotating exposed credentials and hardening their development workflows, which could represent a significant operational burden.
Background
Autonomous coding agents like Claude Code, Cursor and GitHub Copilot assist developers by executing shell commands directly. To streamline approval, Claude Code offers a "Don't Ask Again" option that saves permanent permission rules in a local configuration file, a convenience mechanic that can inadvertently embed secrets when those commands include credentials. Security firms Apiiro and GitGuardian independently scanned public repositories for these leaks, uncovering the scale of the problem.
Key Perspectives
Apiiro: Found that secrets in .claude/settings.local.json are vulnerable because the file isn't added to a repo's .gitignore, and the mechanism gives attackers "a list of the systems the developer can reach and the passwords that open them, one file search away".
GitGuardian: reinforced Apiiro's findings, detecting 31,088 secrets in Claude Code's settings file on public GitHub, and warned generally that "Cursor, Claude Code, and GitHub Copilot leave credentials scattered across config files, logs, and shell history".
Reddit user T_Thriller_T: commented that "Somewhere, someone said AI companies are ignoring basic cyber security principles".
Reddit user MattV0: 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.
What to Watch
- Adoption of Apiiro's recommendations by Anthropic and other AI-assistant vendors: whether they change default behavior to prevent the "Don't Ask Again" feature from storing secrets.
- Further independent audits of similar agentic tools (Cursor, GitHub Copilot) to see how widespread the credential-leakage pattern is.
- Regulatory or customer-driven pressure on vendors to provide automated secret-scanning as part of the assistant, rather than relying on external scanners that miss embedded credentials.