Claude Code Permission Settings Leak Over 31,000 Secrets

By Renato LosioOriginal title: Claude Code 被曝其“不再询问”功能会泄露密钥
78AI Score

Research from Apiiro and GitGuardian shows Claude Code's "Don't Ask Again" feature persists approved shell commands, including embedded credentials, into .claude/settings.local.json, which can end up in public repositories. GitGuardian found 31,088 secrets in public repos, while Apiiro found 2,682 more across local files, git history and chat logs, affecting 63 organizations. Standard secret scanners miss these because keys are embedded in command text.

Full Report

Security vendor Apiiro found that Claude Code has been exposing secrets in public code repositories, because to implement the "Don't Ask Again" feature, it stores this content in some way in local files on the developer's machine. Apiiro detected 1,122 secrets in the claude/settings.local.json file, and additionally found 1,160 secrets in git history, in settings.json files that were deliberately committed and shared, and in agent chat logs stored in code repositories.

The problem lies in Claude Code's command approval mechanism. When a developer replies "Yes, and don't ask again" to approve a shell command, Claude Code saves it as a permanent permission rule and writes it to the local .claude/settings.local.json configuration file, which may inadvertently contain embedded credentials, passwords, and API tokens.

When Claude Code creates this file inside a git repository, it adds the file to the developer's global git ignore list. This covers common scenarios, but there are exceptions: a folder that is added to the repository later, a clone on another machine, or a file that someone else has already committed. The rule never enters the repository's .gitignore, so the protection for the file does not travel with the project.

The researchers found that in some cases, Claude Code even commits this file itself. Overall, 63 organizations were affected, and the exposed secrets included cloud API keys, production passwords, access tokens, and npm tokens. General-purpose secret scanning tools such as gitleaks and TruffleHog failed to flag all of the exposed secrets, mainly because the secrets were embedded within shell command text.

This "password smuggled inside a command" pattern appears anywhere the agent records what it has run: conversation logs, memory files, handoff notes; and scanners that match against common secret formats cannot detect any of it.

The researchers also pointed out that the way Claude Code manages secrets is itself a security gap: for malware, "it is a manifest of which systems the developer can reach, along with the passwords to open them, and it can be obtained with a single file lookup," and its path is the same in every project.

Apiiro's findings were subsequently corroborated by GitGuardian. GitGuardian found 31,088 secrets in the .claude/settings.local.json files of public GitHub repositories for Claude Code, of which 5,343 were still valid at the time of detection; it also found another 613 in Docker Hub images. GitGuardian had previously warned that "Cursor, Claude Code, and GitHub Copilot scatter credentials across configuration files, logs, and shell history".

Reddit user T_Thriller_T commented on the matter: "People have been saying this for a while—AI vendors are ignoring basic cybersecurity principles".

User MattV0 proposed an interesting approach for dealing with AI file-related issues:

I have completely stopped adding AI files to project repositories. That means no settings, CLAUDE.md, AGENTS.md, or any other files. I even turned off Claude's memory feature. Now I run standalone memory/task/documentation services through MCP, which has solved the security problems caused by this kind of documentation very well.

Apiiro's minimum remediation plan: use git rm --cached .claude/settings.local.json to untrack the json file and add it to the repository's .gitignore; at the same time, rotate every credential that has appeared in that file. To be safe, the researchers also recommend reviewing the file, deleting any rules that contain secrets, and avoiding entering secrets directly in commands by referencing them through environment variables instead.

[Disclaimer: This article is translated by InfoQ and may not be reproduced without permission.]

View the original English article: https://www.infoq.com/news/2026/11/claude-code-leaking-secrets/