Skip to content
Apixo
Blog
news· 3 min read· via InfoQ AI & ML

Claude Code Flaw Exposes Thousands of Secret Credentials in Public Repos

A permission setting in Claude Code has exposed thousands of credentials across public Git repositories and Docker images, according to research from Apiiro and GitGuardian.

Claude Code Flaw Exposes Thousands of Secret Credentials in Public Repos

A permission management feature in Claude Code has been exposing sensitive credentials across public code repositories and container images, according to research from security firm Apiiro and follow-up data from GitGuardian. The issue originates from the way the AI assistant records command approvals when developers interact with its interactive terminal prompts.

When a developer responds with "Yes, and don’t ask again" to authorize a shell execution, Claude Code writes that command as a permanent permission rule into .claude/settings.local.json. If the approved command contains hardcoded passwords, tokens, or API keys, those secrets are stored in plain text inside the local JSON configuration file.

How the credential leak occurs

Although Claude Code attempts to prevent exposure by placing the file in a developer's global Git ignore configuration, this mechanism is insufficient. It fails to protect repositories initialized after file creation, cloned projects on other systems, or files that were already tracked by Git. Because the exclusion rule is never added to the individual repository's own .gitignore file, security settings do not travel alongside the project. In several instances documented by researchers, Claude Code itself committed the file directly into Git tracking.

Apiiro's initial investigation discovered 1,122 secrets inside claude/settings.local.json files and 1,160 credentials in Git commit histories, shared settings.json configurations, and chat transcripts. The leaks impacted at least 63 organizations, exposing cloud API keys, npm tokens, production passwords, and access credentials.

Beyond Git exposure, the static storage location creates a significant vulnerability on local machines. Security researchers pointed out that because the configuration file resides at the exact same relative path across all projects, any local malware can easily read it as an inventory of accessible developer systems and their corresponding authentication credentials.

Scope of exposure and scanner limitations

Standard secret scanning tools failed to flag many of these credentials. Tools like gitleaks and TruffleHog missed secrets because they were embedded directly inside shell command strings rather than structured key-value pairs. This pattern of saving plain-text credentials in execution histories also appears in agent memory files, handoff notes, and conversation transcripts.

Following Apiiro's initial findings, security firm GitGuardian conducted a broader scan and detected 31,088 secrets inside .claude/settings.local.json files on public GitHub repositories, of which 5,343 remained active at the time of discovery. An additional 613 secrets were found in Docker Hub images. GitGuardian previously warned that AI tools including Cursor, Claude Code, and GitHub Copilot regularly leave credentials scattered across configuration files, logs, and shell histories.

Developer community discussions reflect growing frustration over AI security practices. Reddit user T_Thriller_T noted, "Somewhere, someone said AI companies are ignoring basic cyber security principles." Another developer, Reddit user MattV0, shared a workflow adjustment: "While this is about secrets, I totally stopped adding AI files into my projects. Means no settings, CLAUDE.md, AGENTS.md or anything else. I even turned off Claude's memory. [...] Nowadays I use a memory/task/docs server through mcp and it really improved such documentation issues."

What it means for developers

These findings highlight the necessity for software engineering teams to carefully audit local configuration files and build processes when adopting AI tools. As teams integrate autonomous agents into daily workflows, leveraging unified and cost-efficient API access is critical. Developers can try top AI models cheaply through one API at https://apixoai.online to streamline their development stack across multiple LLM providers.

To address existing Claude Code leaks, Apiiro recommends immediately untracking the configuration file by executing git rm --cached .claude/settings.local.json and adding .claude/settings.local.json to the project's own .gitignore file. Any secret or credential ever saved into that file should be revoked and rotated immediately.

To maintain long-term security, developers should manually inspect .claude/settings.local.json and erase any permission rules containing credentials. Additionally, developers should avoid typing raw secrets directly into terminal commands, relying instead on environment variables to reference sensitive keys.


Source: Claude Code Has Been Leaking Secrets Through Its "Don't Ask Again" Feature — InfoQ AI & ML. Written by the Apixo team from that report.

#ai-news#ai-security#claude-code#cybersecurity#devops#apiiro
Try it with your own tools

One key for Claude, GPT, GLM, DeepSeek and more. Pay per token with crypto.

Get your API key

Keep reading