Oleksandr Kuzmenko, EditorPublished 6 min readAI-assisted · editor-reviewed
TL;DR
- Claude Code stores entire approved shell commands with API keys into .claude/settings.local.json by default.
- COPY . . in Dockerfiles bypasses gitignore and bakes local Claude Code settings into public container images.
- CLAUDE.md files leak high rates of valid database credentials pasted directly into context prompts.
Key facts
- Distinct Secrets on GitHub
- 31,088 across 23,276 repos
- Live Valid Secrets
- 5,343 confirmed at detection
- Docker Hub Secret Exposures
- 109,284 across 7,625 tags
- Peak Monthly Leaks
- 12,535 in April 2026
- Postgres Strings Exposed
- 1,955 distinct valid strings
The Mechanism: Persistent Approvals Store Raw Commands
When Claude Code proposes running an external command like curl with authorization headers, answering Yes, and don't ask again persists the exact string into .claude/settings.local.json. Every secret GitGuardian mapped sat inside an allow rule or an env block. Generic secret scanners routinely miss these strings because variables like PGPASSWORD= or JWT tokens lack common vendor-specific prefixes; generic detectors accounted for 63% (44,755 of 71,525) of occurrences.
The Exposure Surface Across Registries
GitGuardian's automated scans across public GitHub from January 2025 to November 2026 revealed:
- 31,088 distinct secrets across 23,276 repositories in
.claude/settings.local.json. - 5,343 valid secrets at discovery (a 17% validity floor), including 1,955 distinct Postgres connection strings, 941 Google API keys, 292 SSH passwords, and 186 DeepSeek keys.
- `CLAUDE.md` leaks: 6,155 distinct secrets, of which 2,537 were valid, driven by developers pasting live database connection strings directly into instructions.
- Container leakage: Public Docker Hub images contained 109,284 secret exposures in
.claude/settings.local.jsonacross 7,625 tags, with 72% located under/app,/workspace, or/usr/srcbecause standardCOPY . .instructions copy the unindexed local filesystem.
Monthly leak volumes peaked at 12,535 in April 2026 before dropping 92% to 959 occurrences in October 2026, though active risk remains high across unrotated credentials.
Try it in 2 minutes
echo -e "\n.claude/\n.claude/settings.local.json" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
echo ".claude/" >> .dockerignoreWhen to use
- Configure Claude Code environments using system environment variables exported outside project repositories.
- Enforce strict .dockerignore patterns before building deployment images.
When NOT to use
- Do not use persistent command approvals ('Yes, and don't ask again') for commands containing inline API tokens or passwords.
- Do not paste production database URLs into CLAUDE.md instructions.
What to do today
- Add .claude/ to your system-wide ~/.gitignore_global and local .dockerignore files.
- Audit existing .claude/settings.local.json and CLAUDE.md files for hardcoded connection strings.
- Rotate any database passwords, Supabase keys, or API tokens previously approved via Claude Code command prompts.
Step names are taken from What to do today.
Step names are taken from What to do today. Add .claude/ to your system-wide ~/.gitignore_global and local .dockerignore files.. Audit existing .claude/settings.local.json and CLAUDE.md files for hardcoded connection strings.. Rotate any database passwords, Supabase keys, or API tokens previously approved via Claude Code command prompts.
- Add .claude/ to your system-wide ~/.gitignore_global and local .dockerignore files.
- Audit existing .claude/settings.local.json and CLAUDE.md files for hardcoded connection strings.
- Rotate any database passwords, Supabase keys, or API tokens previously approved via Claude Code command prompts.
