Claude Code leaks secrets on GitHub

▼ Summary
– Security researchers at Apiiro discovered that Claude Code settings files containing sensitive secrets were leaked to public GitHub repositories.
– The vulnerability arises because user approvals for automated commands are stored in local JSON files that may inadvertently include embedded credentials.
– Although the file is added to global gitignore, it can still be committed if a repository is cloned or reinitialized on different machines.
– Researchers identified over 100,000 instances of these files online, with approximately 1,100 cases from 63 organizations containing actual secrets like API tokens and passwords.
– Secrets can persist in project forks even after the original files are removed, posing ongoing risks to developers and organizations.
The Mechanics of the Data Breach
AI security researchers at Apiiro have identified a critical vulnerability in Claude Code that is exposing sensitive credentials on public GitHub repositories. The investigation revealed that thousands of secrets, including database passwords, API tokens, and root logins, are being inadvertently committed to codebases. This leakage occurs due to a specific flaw in how the tool manages user approval for automated shell commands. When a developer selects the “Yes, and don’t ask again” option to authorize a command, the system records this preference in the local .claude/settings.local.json file. While the rule itself may be stored as a pattern, the actual command containing embedded sensitive data is often written directly into this settings file without sanitization.
Why Standard Safeguards Fail
Under normal circumstances, this issue poses minimal risk because the configuration file remains on the user’s local machine. Anthropic’s documentation explicitly states that .claude/settings.local.json is added to the developer’s global .gitignore list, which should prevent it from being tracked by version control systems. However, this safeguard is not enforced at the repository level. If a project is cloned to a new environment or if an existing folder is initialized as a Git repository, the local ignore rules may not apply effectively. Consequently, developers can accidentally upload these files to public instances. In numerous observed cases, Claude Code itself commits changes to the settings file automatically, bypassing manual review and leading to unintended exposure.
Scale and Persistence of the Risk
Apiiro’s analysis uncovered more than 100,000 instances where the local settings file had been pushed to public GitHub repositories. Among these, approximately 1,100 files belonging to 63 different organizations contained valuable secrets such as public API tokens, database passwords, or private keys. The persistence of these leaks presents an ongoing threat; even after the initial files are deleted from a repository, the sensitive data can remain accessible in forks of the original project. Developers must remain vigilant, as improper handling of these configuration files allows malicious actors to retrieve credentials long after the initial commit has occurred.
(Source: Ars Technica)




