Claude Code Leaks Secrets via "Don't Ask Again" ~ Ibrahim Kaya
×
AI Security

Claude Code Leaks Secrets via "Don't Ask Again"

İbrahim Kaya Published: Updated: 2 min read
Claude Code Leaks Secrets via "Don't Ask Again"
Contents

Anthropic's command-line tool, Claude Code, has leaked credentials into public GitHub repositories because of how it caches terminal permissions, according to research from cybersecurity firm Apiiro.

How the permission cache causes leaks

Claude Code prompts developers for confirmation before running shell commands. When an engineer selects "Yes, and don't ask again", the tool stores the command as a persistent authorization rule inside .claude/settings.local.json.

When terminal commands include inline secrets, such as cloud API keys, database connection strings, or production tokens, Claude Code saves the exact string to the JSON file in plain text. A predictable file path containing developer credentials across projects also makes local workstations an easy target for malware.

The global gitignore flaw and scanner blindspots

Claude Code adds the settings file to the developer's global Git ignore list. That rule does not cover directories initialized as repositories later, repositories cloned across machines, or files committed by the agent itself. Because the ignore rule is never added to the project's own .gitignore, the exclusion does not travel with the repository.

Apiiro reported that 63 organizations were directly affected. In follow-up scans, GitGuardian found over 31,000 secrets inside Claude Code settings files on public GitHub, with more than 5,300 active credentials at the time of discovery. Traditional secret scanners like Gitleaks and TruffleHog regularly miss these leaks because the tokens are embedded inside shell parameters instead of standard key-value pairs.

Remediation steps for developers

Teams using Claude Code should inspect their repositories. The settings file should be untracked from Git and added to the project's local exclusion file.

bash
git rm --cached .claude/settings.local.json
echo ".claude/settings.local.json" >> .gitignore

Engineers should rotate any credentials that were ever passed through Claude Code prompts. Moving forward, sensitive values should come from environment variables rather than hardcoded command-line arguments.