Claude Code configuration files leak thousands of secrets on GitHub
A feature designed to streamline developer workflows is inadvertently saving sensitive API keys and passwords into public repositories.
The short version
- GitGuardian identified 31,088 distinct secrets in .claude/settings.local.json files across 23,276 public GitHub repositories.
- Of the secrets found, 5,343 were still valid at the time of discovery, including database strings and cloud provider tokens.
- The leak occurs when developers select 'Yes, and don’t ask again' for commands that contain hardcoded credentials.
- Docker Hub images also exposed 613 secrets because Docker does not automatically respect .gitignore files during builds.
- 67% of the valid secrets found in these configuration files were database identifiers.
Why it matters
This highlights a new class of security risk where AI coding assistants create 'hidden' configuration files that store sensitive data. Developers need to be more vigilant about how they grant permissions to these tools to avoid exposing their infrastructure.
The configuration file leak
A security investigation by GitGuardian has revealed a significant privacy flaw in Anthropic’s Claude Code. The tool's configuration file, specifically .claude/settings.local.json, has been found to contain thousands of sensitive secrets across public platforms. Researchers identified 31,088 distinct secrets in files distributed across 23,276 public GitHub repositories.
The exposed data includes a wide variety of sensitive information. This includes database connection strings, cloud provider tokens, SSH passwords, Google API keys, and AU service credentials. Of the secrets found, 5,343 were still active and functional when the security firm detected them.
The exposure is not limited to source code repositories alone. GitGuardian also discovered secrets embedded in publicly accessible Docker Hub images. This suggests that the configuration files are being moved into container environments where they can be accessed by anyone with the image tag.
How the 'don't ask again' button fails
The root of the problem lies in how Claude Code handles permissions for shell commands. When a developer uses the tool, it asks for permission before executing certain commands. If a developer clicks the option to 'Yes, and don’t ask again,' the tool creates a permanent allow rule to streamline future work.
The issue is that Claude Code saves the entire command string into the project-level configuration file. If a developer approves a command that contains an API key in an HTTP header, that key becomes a permanent part of the configuration file. The tool essentially converts a one-time permission into a stored credential.
While Claude Code attempts to protect users by automatically adding the file to local Git ignore settings, this protection is not foolproof. Researchers noted that the file can still be committed if it was already being tracked by Git or if a developer is working across different clones. This oversight allows sensitive data to move from a local machine to a public server.
The Docker Hub complication
The security risk extends beyond GitHub due to how Docker handles image builds. When developers use the 'COPY..' instruction to move an entire project directory into a Docker image, the system does not automatically check the repository's .gitignore file. This means a configuration file that is hidden from Git can still be bundled into a public container image.
GitGuardian found 613 distinct secrets in Claude Code settings files across 543 image repositories and 7,625 tags. For example, one valid Cloudflare API token appeared across 559 different image tags. This demonstrates how easily secrets can propagate through the software supply chain once they are included in a build context.
Removing a file from a GitHub repository does not fix the problem for images that have already been published. Once a secret is embedded in a Docker image, it remains accessible to anyone who pulls that image. This creates a persistent security vulnerability that requires manual intervention to resolve.
Detection and mitigation hurdles
Detecting these specific leaks is difficult for standard security tools. Many conventional secret scanners look for specific formats provided by cloud providers. However, passwords embedded in command-line arguments or environment variable assignments often lack these recognizable patterns, allowing them to slip past traditional defenses.
Database identifiers were the most common type of valid secret found, accounting for 2,280 distinct credentials. This indicates that developers are frequently using these configuration files to manage backend connections. Because of this, security experts are urging teams to treat AI coding assistant files as high-risk assets that require regular scanning.
Anthropic's lead for Claude Code, Boris Cherny, acknowledged the issue and stated the company is exploring safeguards. These potential updates include built-in secret scanning and an 'auto mode.' In the meantime, developers are advised to rotate any credentials that may have been exposed and avoid hardcoding secrets into commands.
Best practices for developers
To prevent these leaks, developers should adopt a more cautious approach to AI-assisted coding. Instead of allowing the tool to save commands with embedded keys, they should use environment variables to pass sensitive information. This ensures that the configuration files remain free of actual secrets while still allowing the tool to function.
Teams should also audit their Docker build processes to ensure that sensitive local files are explicitly excluded. Using a .dockerignore file is a necessary step to prevent the tool's configuration directory from being copied into container images. This adds a layer of protection that the standard .gitignore cannot provide on its own.
Finally, anyone who has used Claude Code should check their public repositories for the presence of the .claude folder. If the folder exists in a public repo, it is possible that secrets were saved during a previous session. Proactive scanning of these configuration files can help identify and remove credentials before they are exploited by malicious actors.
What to watch
- Whether Anthropic will release a built-in secret scanning feature for Claude Code.
- How other AI coding assistants handle command permission storage and configuration files.
Try it
Check your public GitHub repositories for a folder named '.claude' to see if any local settings files were accidentally committed.
Sources and links
- Officialblog post blog.gitguardian.com
- Reportingcsoonline.com: the article we sourced
First reported by csoonline.com. Written by the SI Agent News Desk from the reporting above.Written with AI from the source above. Every number is checked against the source. Spot a mistake? Corrections.
Liked it? Say why
Add a line for other readers.
No account needed. We never show your email. Comments with links, ads or abuse are held and not shown. Your comment shows after a quick check.