Claude Code Security Flaw Exposes Thousands of Passwords and API Keys on Public GitHub Repositories

5 Sources

Share

Anthropic's Claude Code AI coding assistant has exposed over 31,000 secrets including database passwords, API keys, and cloud credentials on public GitHub repositories. The leak stems from the tool's 'don't ask again' permission feature, which saves full shell commands containing sensitive credentials to local settings files that can accidentally become public.

News article

Claude Code Leaking Passwords and API Keys Through Permission Feature

A security flaw in Anthropic's Claude Code AI coding assistant has exposed thousands of sensitive credentials on public GitHub repositories, with researchers discovering 31,088 distinct secrets across 23,276 repositories

2

. The exposed secrets include database passwords, API tokens, cloud provider keys, and root logins from 63 different organizations

1

. Of the exposed credentials, 5,343 were still valid when GitGuardian detected them, with database identifiers accounting for 2,280 distinct working credentials

2

.

How the Don't Ask Again Feature Creates the Security Flaw

The leak stems from Claude Code's command approval system. When developers use the AI coding assistant to execute shell commands, the tool requests permission before proceeding. To streamline workflow, users can select "Yes, and don't ask again" to approve future executions without repeated prompts

4

. The problem arises because Claude Code saves the entire approved command, including any embedded credentials, to a local settings file called .claude/settings.local.json

1

.

For instance, when a developer asks Claude Code to interact with an API, they might approve a curl command containing an API key in its HTTP header. The tool then stores that complete command as an approved rule, leaving the credential in plain text within the configuration file

2

. Monthly leaks in settings.local.json peaked at 12,535 occurrences in April 2026, then fell to 959 by October 2026, though researchers haven't determined what caused this change

2

.

Why Local Settings Files End Up on Public GitHub Repositories

Anthropicโ€™s documentation states that Claude Code automatically adds the settings file to a developer's global .gitignore list, which should prevent it from being shared publicly

1

. However, this protection doesn't cover every scenario. The .gitignore setting exists in the developer's own Git configuration, not in the repository itself. If a repository is cloned to another machine or a folder becomes a repo later, that protection may not be in place

3

.

Apiiro reports that Claude Code often commits changes to the settings file without user input, further complicating the issue

1

. Researchers at Apiiro found over 100,000 cases where Claude Code's local settings files had been uploaded to public GitHub repositories

1

. The exposed credentials belonged to organizations ranging from small development teams and startups to established technology vendors, including passwords for production databases and credentials associated with applications handling medical records

4

.

Docker Hub Images Also Contain Exposed Secrets

The security flaw extends beyond GitHub. GitGuardian examined public Docker Hub images and found 613 distinct secrets in Claude Code settings files, with 99 valid when detected

2

. The credentials appeared across 543 image repositories and 7,625 tags. One valid Cloudflare API token appeared across 559 image tags, while a database password appeared in 643 tags across seven image repositories

2

.

The problem arises when developers use Docker's "COPY.." instruction to copy an entire project working directory into an image. Unlike Git, Docker doesn't automatically respect the repository's .gitignore file, meaning a Claude Code configuration file excluded from source control can still be copied into a container image unless developers explicitly exclude it through .dockerignore

2

.

Secret Scanners Miss Significant Portion of Exposed Credentials

Conventional secret scanners failed to catch a substantial portion of the exposure. Of the roughly 1,100 exposed secrets Apiiro found, 215 were not flagged by either gitleaks or TruffleHog, two widely used open-source scanners

3

. This represents close to one in five exposed credentials. Passwords embedded in command-line arguments and environment variable assignments often lack the recognizable formats that provider-specific detection rules look for

2

.

GitGuardian found that 67% of the occurrences in settings.local.json for which it could establish validity were working credentials

2

. Database identifiers accounted for the largest category of valid secrets, followed by cloud provider tokens and AI tokens.

Bug Reports Closed Without Action Despite Early Warnings

This security flaw isn't new. The issue was flagged in a Claude Code bug report as far back as August 2025

1

. Other bug reports noted that the sensitive settings file was sometimes not added to the user's .gitignore list or that Claude Code could add sensitive commands to another file not protected from git sharing. All these bug reports were closed without action after 60 days of inactivity

1

.

Anthropic Responds to Security Concerns

Boris Cherny, head of Claude Code at Anthropic, acknowledged the issue in a Hacker News discussion, stating the team is "looking into what we can do to prevent this"

5

. He noted that these settings files should almost never be checked into source control and that cases appeared when "the files were manually created and checked in"

3

.

Cherny recommended using Claude Code's auto mode, which uses classifiers to automatically route routine permission prompts without requiring manually maintaining allow/deny lists

1

. However, when another user noted that sensitive commands can still be saved to settings files in auto mode, Cherny called it a "good catch" and said the team is "thinking through what we can do to improve this"

1

.

Cherny also advised developers to use secret scanners and said the team is considering building secret scanning into Claude Code itself in the future

3

. However, Apiiro's results suggest this would be a partial fix at best, since the two leading open-source tools missed 215 of the exposed credentials

3

.

Broader Implications for AI Agent Security

This incident highlights growing concerns about corporate reliance on AI agents that can operate software and access sensitive systems. VentureBeat's October 2026 VB Pulse research survey on Agentic Security and Identity found that 24% of 101 enterprise AI and security leaders said their agents mostly operate using shared API keys or credentials associated with people or service accounts. Another 20% reported having no automated way to detect when an AI agent takes an unauthorized action

4

.

The automation risks extend beyond what an AI agent might do while running. The records it leaves behind can expose valuable information long after a task is finished. Removing an exposed settings file from GitHub may not be enough, since previous versions can remain accessible through the repository's history or copies made by other developers

4

.

What Organizations Should Do Now

Apiiro recommends that organizations search public repositories for .claude/settings.local.json and .claude/settings.json, review Git history for deleted copies, and rotate every credential the files may have contained

5

. Developers should reference credentials through environment variables, such as $DB_URL, rather than placing secrets directly in commands

5

.

GitGuardian recommends treating AI coding assistant configuration files as potential secret-bearing assets, scanning them alongside conventional environment files, and using environment variables rather than hardcoding credentials into commands

2

. For Docker users, removing the offending file from the GitHub repository doesn't help credentials already distributed through published images. Developers must rotate exposed credentials, remove sensitive configuration files from both Git and Docker build contexts, and check previously published images for lingering secrets

2

.

© 2026 TheOutpost.AI All rights reserved