Security researchers found thousands of instances where Claude Code's settings files exposed database passwords and API keys in public code.

This is not confirmed. It was reported by CASRAI.
When a developer uses Claude Code to execute a shell command, the tool may ask for permission. If a user selects the option to allow the command and never ask again, the tool saves this approval as a standing rule in a specific file.
This file, located at .claude/settings.local.json, stores the exact command string provided by the user. If a developer includes a password or an API key directly within that command, the secret becomes hardcoded into the settings file.
As reported by CASRAI, the file is written the first time a standing approval is granted. Because the rule is the literal command string, any sensitive information typed by the user is preserved in the configuration.
Two different security vendors conducted independent analyses of the leak in late 2026. Apiiro found 104,185 copies of the settings file across 103,617 public repositories. Their count included 1,379 distinct secrets, including SSH logins and AWS keys.
GitGuardian reported a different set of figures because they analyzed the full public history of repositories and Docker Hub images. They identified 31,088 distinct secrets in these files, with 5,343 of them being valid at the time of detection.
The data shows that a significant portion of the leaked secrets provided direct access to databases. While the numbers differ between the two reports, both confirm that the file is frequently appearing in public spaces where it should remain private.
Anthropic's documentation states that the tool attempts to protect the file by adding it to the user's global git excludes. This means the file is intended to stay on the local machine and not be shared with collaborators or uploaded to a remote server.
However, this protection does not apply to files that are already being tracked by git. Furthermore, the tool does not automatically add the file to the project's .gitignore, which is the standard way to prevent files from being uploaded to a repository.
Security researchers noted that Docker does not respect .gitignore files, which can lead to the settings file being copied into public images. Additionally, if a user creates the file manually, they are responsible for adding it to the .gitignore themselves.
Boris Cherny, who leads Claude Code at Anthropic, acknowledged the issue in a response on Hacker News. He stated that the team is currently investigating the situation and that the tool has not historically had a way to scrub secrets from these files.
Cherny noted that the team is currently prototyping auto mode and built-in secret scanning features. However, he cautioned that these features may not fully solve the problem of secrets being committed to public history.
Some analysis suggests that the exposed copies may have been created manually by users. In some cases, a commit listing Claude as a co-author was found to be the specific action that changed the settings file in a public repository.
Security experts recommend that anyone using Claude Code search their public repositories and git history for the .claude/ settings files. It is important to rotate every credential that has ever appeared in these files, as deleting the file does not revoke the key.
Users should manually add .claude/settings.local.json to both their .gitignore and .dockerignore files. They should also delete any existing allow rules that contain secrets and instead use environment variables or a dedicated secrets manager.
Finally, developers should treat agent folders like .claude/ or .cursor/ as sensitive files. They should ensure that pre-commit hooks and CI secret scanning tools are configured to detect passwords hidden inside command strings.
Developers using AI coding agents may unknowingly leak sensitive infrastructure credentials by approving commands that include secrets. This highlights a need for better secret management when interacting with autonomous AI tools.