Claude Code is accidentally exposing secrets all over GitHub

AI security researchers at Apiiro have found thousands of credentials exposed in Claude Code settings files that were pushed to public GitHub repositories. The finding, reported by Ars Technica, covers secrets including database passwords, API tokens, root logins and private keys. The exposure traces back to how Claude Code records a user's approval of automated shell commands rather than to a flaw in how the agent executes them.
When a developer approves a command and picks the "Yes, and don't ask again" option, Claude Code saves that choice as a rule inside a local file at .claude/settings.local.json. The rule is sometimes written as a pattern, but the command text itself often lands in the file verbatim, including any credential embedded in it, such as a password passed on a command line or a token set as an environment variable.
On a single developer machine this is largely harmless. The problem is portability and version control. Anthropic's documentation states that this settings file is added to the developer's global .gitignore, which normally keeps it out of public repositories. But that entry exists only in the global ignore configuration, not at the repository level, so the file can travel with a repo when it is cloned to another machine or when an existing folder is turned into a repo later. Apiiro also reports that in many cases Claude Code itself commits changes to the settings file without user input.
At the scale Apiiro measured, more than 100,000 instances of the local settings file had been uploaded to public GitHub repositories. Roughly 1,100 of those, spread across 63 organizations, actually contained secrets: public API tokens, database passwords or private keys. Deleting the file from a repository does not necessarily close the hole, because the material can survive in forks of the original project if other GitHub users are not careful, and git history retains past commits unless it is rewritten.
The issue is not new. A Claude Code bug report raised it as far back as August 2025, and other reports noted that the sensitive file was sometimes not added to the user's .gitignore or that Claude Code could write sensitive commands into a different file without git protection. Those reports were closed without action after 60 days of inactivity. The current attention follows Apiiro's research.
On a Hacker News thread over the weekend, Claude Code's Boris Cherny said the team is looking into what it can do to prevent the leak. He maintained that these settings files should essentially never be checked into git source control and that observed cases appeared to arise when files were manually created and checked in. Cherny recommended using Claude Code's auto mode, which relies on classifiers to route routine permission prompts automatically instead of requiring users to hand-maintain allow and deny lists. When another commenter pointed out that sensitive commands can still be saved to settings files under auto mode, Cherny acknowledged it as a good catch and said the team is thinking about how to improve.
Cherny also advised running secret scanners, tools that trawl files for credentials and scrub them, and said the team is considering building secret scanning into Claude Code. That would not be a complete answer on its own: Apiiro found that 215 of the roughly 1,100 exposed secrets in Claude Code settings files were not flagged by two widely used scanners, gitleaks and TruffleHog. Detection tooling, in other words, reduces the blast radius but does not guarantee coverage.
This fits a broader pattern of AI coding agents interacting badly with version control defaults. Agent tools that reduce friction by persisting approvals, snippets and context to disk create files that look innocuous to a developer and to a generic secret scanner but contain exactly the strings attackers want. The exposure here also illustrates a gap between a vendor-managed global setting and repo-level hygiene: a .gitignore entry on one machine does not protect a repository cloned elsewhere or a directory promoted to a repo after the fact, and the agent may commit the file on the user's behalf.
A likely trade-off for Anthropic is between convenience and safety in permission handling. Storing exact commands makes approvals precise and reproducible; storing patterns is more forgiving but can grant broader access than the user intended. Whichever route the team takes, a fix probably needs to combine safer storage of approved commands, stronger default ignore rules at the repository level, and possibly built-in scanning.
Why it matters: Developers who use Claude Code should check whether .claude/settings.local.json or similar agent state has ever been committed, add it to the repository's own .gitignore, and treat any credential that passed through an approved command as potentially exposed. Product teams building agentic tools face the same design question: any persisted approval record can capture secrets, so ignore rules and scanning need to be enforced at the repository level, not just globally on one machine. Expect vendors to add secret scanning and tighter defaults; based on the report, that work at Anthropic is still in discussion rather than shipped.
Based on reporting from the original publisher. Visit the source for full context and later updates.
Publisher excerpt
"Do not ask again" prompt leads to passwords, API keys, and more being shared.