Breaking
SecurityDeveloping Story

Claude Code's consent shortcut leaks secrets

GitGuardian found 31,088 secrets in Claude Code settings files on public GitHub and Docker Hub, with thousands still valid.

··2 weeks ago·5 min read
code editor displaying react source code
Photo by Juanjo Jaramillo on Unsplash

A permission prompt designed to save developers a few keystrokes inside Anthropic's Claude Code has instead been quietly copying API keys, database passwords and cloud tokens into configuration files that end up public. GitGuardian, a code security firm, reported that it identified 31,088 distinct secrets inside .claude/settings.local.json files spread across 23,276 public GitHub repositories. When GitGuardian checked, 5,343 of those credentials were still live.

The finding matters because the file in question is not an exotic artifact. It is generated by ordinary use of the tool, and the secrets it carries are the kind that open databases, cloud accounts and internal services. GitGuardian detailed the results in a blog post.

How a yes click becomes storage

Claude Code asks developers for permission before running certain shell commands. One of the options presented is “Yes, and don’t ask again.” Choosing it tells the tool to remember the approval, and Claude Code writes an allow rule into .claude/settings.local.json, a project-level configuration file.

The problem is what gets written. The saved rule holds the actual command string, including whatever credentials were embedded in it. If a developer approved a curl command with an API key sitting in an HTTP header, that entire command, key included, becomes the stored rule.

GitGuardian researcher Guillaume Valadon explained the mechanism in the blog post. Claude Code “automatically adds the file to its local Git ignore settings,” Valadon said, but that protection “does not necessarily carry over to other machines or repositories.” Developers can commit the file by accident, especially when they work across different clones or when the file has already been tracked by Git.

Most stored secrets were still working

GitGuardian did not just count strings. It checked which credentials actually worked, and the results were not reassuring: 67% of the occurrences in settings.local.json for which the firm could establish validity turned out to be working credentials.

Database identifiers made up the largest category of valid secrets, at 2,280 distinct credentials. Cloud provider tokens and AI tokens followed.

Conventional secret scanners catch only part of the problem. Passwords embedded in command-line arguments and environment variable assignments often lack the recognizable formats that provider-specific detection rules look for, GitGuardian noted, which means a repository can pass a standard scan while still carrying live credentials in this file.

The leak curve nobody has explained

The volume of exposed secrets was not constant over time. Valadon described a sharp rise and fall in the data.

“Monthly leaks in settings.local.json peaked at 12,535 occurrences in April 2026, then fell to 959 by October, and we do not yet know what changed,” GitGuardian researcher Guillaume Valadon said in a blog post.

— Guillaume Valadon, researcher at GitGuardian

That gap in understanding is itself part of the story GitGuardian published. The firm did not attribute the drop to a specific fix, change in developer behavior or platform update.

Secrets hiding in container images

GitHub was not the only place the credentials surfaced. GitGuardian also examined public Docker Hub images and found 613 distinct secrets in Claude Code settings files, 99 of which were valid at the time of detection. Those credentials appeared across 543 image repositories and 7,625 tags.

The Docker path has its own mechanics. According to Valadon, the problem arises when developers use Docker’s “COPY..” instruction to copy an entire project working directory into an image. Unlike Git, Docker does not automatically respect the repository’s .gitignore file. A Claude Code configuration file excluded from version control can therefore still be copied into a container image unless the developer explicitly excludes it through .dockerignore.

Some exposures repeated at scale. One valid Cloudflare API token appeared across 559 image tags, and a database password appeared in 643 tags across seven image repositories.

The delete button is not enough

Removing the file from a GitHub repository does not undo the damage for credentials already distributed through published images. The secret has traveled: into layers, tags and pulls that may sit outside the developer's control.

GitGuardian's recommended response has several parts. Developers should rotate exposed credentials, remove sensitive configuration files from both Git and Docker build contexts, and check previously published images for lingering secrets.

The firm also advises treating AI coding assistant configuration files as potential secret-bearing assets and scanning them alongside conventional environment files. Where possible, credentials should come from environment variables rather than being hardcoded into commands in the first place.

What Anthropic has said

Anthropic did not immediately respond to CSO’s request for comment. GitGuardian said that Anthropic’s Claude Code lead, Boris Cherny, acknowledged the issue and said the company was looking into it and exploring additional safeguards, including built-in secret scanning and an auto mode.

Those measures, as described by GitGuardian, are under exploration rather than confirmed as shipped. The source material does not specify a timeline for either feature.

The numbers behind the exposure

  • 31,088 distinct secrets found in .claude/settings.local.json files
  • 23,276 public GitHub repositories affected
  • 5,343 secrets still valid at detection time
  • 67% of checkable occurrences were working credentials
  • 2,280 distinct valid database credentials, the largest valid category
  • 613 distinct secrets found in public Docker Hub images, 99 still valid
  • 543 image repositories and 7,625 tags carrying those Docker secrets
  • 12,535 occurrences in April 2026, falling to 959 by October

Why this matters beyond one tool

The pattern GitGuardian describes is not tied to a single vendor's bug. It comes from a convenience feature that persists the exact text of an approved command into a file that developers may not think of as a secrets store. As AI coding assistants become a regular part of the workflow, the files they generate sit in the same repositories and build contexts as application code.

For teams, this suggests a review of what their assistants write to disk. A settings file that looks like local housekeeping could be carrying live cloud tokens, and a container build that copies the working directory could be publishing them. GitGuardian's findings indicate that standard secret scanning alone may not catch credentials embedded in command-line arguments, which means the file itself warrants a look.

For developers who have already clicked “don’t ask again” on a command containing a credential, the practical question is whether that file was ever committed or copied into an image, and whether the credential still works. GitGuardian's data shows that in most checkable cases, it did.

#claude code#gitguardian#secrets management#docker hub#anthropic#developer security

Sources

Iliyas

Founder & Editor, Xploitwire

This article was written and reviewed against the sources listed above before publication, under editorial policies set by Iliyas. Read our Editorial Policy →

← Back to all stories