· AI dev tools
Apiiro finds Claude Code leaks 1,122 secrets in settings.local.json files
Security experts uncovered that Claude Code has been inadvertently broadcasting sensitive information in publicly accessible code repositories.
This vulnerability stems from the method the tool employs to retain user preferences under its "Don't Ask Again" functionality, which involves saving data to local files on the developer's workstation.
Apiiro, an agentic security firm, discovered a substantial number of exposed secrets: 1,122 were located within files named claude/settings.local.json, and an additional 1,160 were found across git history, the shared settings.json that was intentionally committed, and chat transcripts generated by the agent and stored within repositories.
The root of this issue resides in how Claude Code processes command authorizations. When a developer responds with "Yes, and don’t ask again" to grant permission for a shell command, Claude Code permanently records this as a rule within the local configuration file, specifically .claude/settings.local.json. This file runs the risk of containing embedded API tokens, passwords, and credentials.
While the system typically places this file into the developer’s global git ignore list when it creates it inside a repository, this protection is not absolute. It fails to safeguard against scenarios where a folder later becomes a repository, when a copy is made on a different machine, or if the file was committed previously. Critically, the rule is never added to the repository’s own .gitignore, meaning the protection does not travel with the project itself. Furthermore, the researchers noted on some instances that Claude Code itself committed this file.
Across the investigation, 63 different organizations were impacted, with the exposed sensitive data encompassing cloud API keys, production passwords, access tokens, and npm tokens. Standard secret-hunting utilities, such as TruffleHog and gitleaks, were unable to detect all the exposed secrets, largely because these credentials were embedded directly within shell commands. This pattern of embedding passwords within commands is replicated wherever an agent logs its actions: in memory files, handoff notes, and transcripts; consequently, a scanner configured only to look for specific key formats misses these instances.
The researchers also pointed out that the manner in which Claude Code manages secrets constitutes a security flaw in its own right. They observed that for any form of malicious software, this file essentially functions as a catalog of the systems the developer can access, along with the necessary passwords to unlock them, all accessible through a simple file search at the identical path in every project.
These initial findings from Apiiro were subsequently backed up by GitGuardian, which located 31,088 secrets within Claude Code’s .claude/settings.local.json files on public GitHub. Of these, 5,343 were still active when the discovery was made, and GitGuardian also identified another 613 secrets within Docker Hub images. Prior to this, GitGuardian had issued a caution stating that "Cursor, Claude Code, and GitHub Copilot leave credentials scattered across config files, logs, and shell history."
In response to these findings, one user on Reddit, T_Thriller_T, remarked that "Somewhere, someone said AI companies are ignoring basic cyber security principles." Another user, MattV0, proposed an alternative strategy regarding AI-related files: "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."
For a more robust defense, Apiiro advises two key actions: first, using the command `git rm --cached .claude/settings.local.json` to stop tracking the JSON file and subsequently adding it to the repository's .gitignore; second, rotating every single credential that the file has ever held. For an even more secure setup, the researchers suggest examining the file to eliminate any rule containing a secret and adopting the practice of referencing credentials via environment variables rather than typing them directly into commands.
Why it matters
This highlights a critical security vulnerability in developer tooling where local configuration files can inadvertently leak sensitive credentials. Developers must immediately take action, such as untracking the settings file and rotating any exposed credentials, to prevent compromise.





