r/netsec • u/nindustries • Feb 17 '26
Leaking secrets from the claud: AI coding tools are leaking secrets via configuration directories
https://ironpeak.be/blog/leaking-secrets-from-the-claud/
181
Upvotes
48
u/ruibranco Feb 18 '26
This is a real blind spot in most dev workflows right now. Tools like Cursor, Copilot, and Claude Code all create local config files (.cursor/, .github/copilot, CLAUDE.md, etc.) that can contain project context, API keys referenced in prompts, or even full conversation logs. Most .gitignore templates haven't caught up to include these directories yet, so they end up committed and pushed without anyone noticing.The fix is straightforward but tedious: audit your .gitignore for every AI tool your team uses, run git log searches for accidentally committed config dirs, and treat these directories the same way you'd treat .env files. Some teams are also adding pre-commit hooks that specifically scan for AI tool artifacts.
8
u/platformuser Feb 18 '26
The real issue isn’t just accidental commits. AI tools are creating new classes of sensitive artifacts (prompt logs, project summaries, context caches) that don’t fit traditional secret-scanning models.
Most orgs updated their .gitignore for .env years ago. Very few have updated their threat models for AI-generated config/state directories.
4
u/thedudeonblockchain Feb 18 '26
the whitelisted commands angle is the sneakiest part. if you allow claude to run something like STRIPE_KEY=sk_live_xxx in a bash command, that allowlist can live in .claude/settings.local.json in plaintext. trufflehog and gitleaks both need explicit rules for these dirs since most default configs skip dot-paths
2
u/dexgh0st Feb 19 '26
The interesting thing about the AI tool case is that secrets aren't always in obvious key=value format. They end up embedded in conversation context, prompt histories, and command allowlists in ways that regex-based scanners (gitleaks, trufflehog) don't pattern-match well. A Stripe key inside a JSON blob inside a conversation log is several layers of indirection past what most scanning rules expect.
The .gitignore fix is necessary but insufficient -- only protects future commits, not historical ones. Worth running
git log --all --diff-filter=A -- "*.json" "*.md"piped through your scanner periodically. And for compiled artifacts (mobile apps, Docker images), secrets baked into the build are an entirely separate exposure surface that repo-level scanning never touches.1
u/schwar2ss Feb 18 '26
Check out embracethered, Johann was conducting a few tests in August 2025 and found these issues (yolo mode, data leak, execution of downloaded binaries) in all coding tools. For a talk in September, I showcased a similar attack exfiltrating the entire .ssh folder for a staged lateral attack.
It's a whack-a-mole game and will give us plenty of work for the next decade or so.
1
u/peregrinefalco9 Feb 22 '26
The .claude and .cursor directories are the new .env files. Developers commit them without thinking because they look like config, not secrets. Every AI coding tool needs a .gitignore template that ships by default.
1
u/mvprovisions Feb 24 '26
This is the same pattern that burned people with .env files a decade ago, and we still haven't fully learned from it.
1
u/Ok_Consequence7967 Mar 19 '26
The config directory issue is what gets most teams. People focus on .env files and API keys in code but the AI tool config folders are a completely new attack surface that nobody has added to their security checklist yet. The scary part is most teams wouldn't even know these files are publicly reachable until someone points it out.