A Claude Code secrets leak has quietly exposed sensitive credentials in public GitHub repositories, according to research from AI security firm Apiiro. The company’s investigators found thousands of secrets, including database passwords, API tokens, and root logins, embedded in Claude Code settings files that had been pushed to public repositories.
How the Exposure Happens

The problem traces back to how Claude Code handles permission prompts for automated shell commands. When a user selects the option to approve a command and avoid being asked again, that decision is recorded as a rule in a local file named .claude/settings.local.json. The rule can be stored as a pattern, but frequently the full command is written to the file, including any sensitive values inside it.
On its own, that is not a major risk if the file stays on the local machine. Anthropic’s documentation states that this settings file is added to the developer’s global .gitignore list, which normally keeps it out of public view. The gap is that the .gitignore protection is not applied at the repository level. As a result, the file can be uploaded if a repository is cloned to another machine or if a folder becomes a repository after the settings file already exists. Apiiro also noted that Claude Code will often commit changes to the settings file without any user action.
Scale of the Problem

Apiiro’s researchers counted more than 100,000 instances in which Claude Code’s local settings file had been uploaded to a public GitHub repository. Of those, roughly 1,100 files from 63 organizations contained secrets such as public API tokens, database passwords, or private keys.
Removing an exposed file from a repository does not necessarily solve the problem. If a GitHub user is not careful, the secrets can remain accessible in forks of the original project.
Bug Reports Closed Without Action

The issue was reported in a Claude Code bug report as early as August 2025. Other reports noted that the sensitive settings file was sometimes not added to the user’s .gitignore list, or that Claude Code could write sensitive commands into a different file that was not protected from git sharing. Those reports were closed after 60 days of inactivity without any action taken.
In a Hacker News discussion, Claude Code’s Boris Cherny said the team is looking into ways to prevent the problem. He also said these settings files should essentially never be checked into a user’s git source control, and that the cases appeared to arise only when the 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 maintain allow and deny lists by hand. When another user pointed out that sensitive commands can still be saved to settings files in auto mode, Cherny acknowledged the point and said the team is considering improvements.
Cherny also advised users to employ secret scanners, which search files for sensitive information and remove it, and said the team was considering adding that kind of scanning to Claude Code itself.
Scanners Miss Some Secrets
Apiiro found that 215 of the roughly 1,100 public secrets in Claude Code settings files were not detected by two well-known secret scanners, gitleaks and TruffleHog. The incident is not the only recent case of an AI agent leaking sensitive data unintentionally. Last month, Meta suspended the sharing feature on its Muse agent after security researchers found that the URLs for shared links could be easily guessed.
