Keep secrets out of what your AI agent can read
GitGuardian: real leaked API keys recovered from three LLMs; Claude Code commits leak more · Security incident · Blog (GitGuardian) · GitGuardian · Oct 19, 2026
What happened
A GitGuardian post dated 19 Oct describes research in which people recovered real DeepSeek and Google API keys from Qwen3-27B, GPT-Codex 5.3 and Claude Haiku 4.5 using only API output; each key also appeared in public GitHub code. GitGuardian also says Claude Code-assisted public commits leaked secrets at 3.2% versus a 1.5% baseline, and that public MCP config files held 24,008 unique secrets, 2,117 of them valid. These figures are GitGuardian's, from a company that sells secret-protection tools.
How to prevent it
Keep secrets out of files your agent can read, never commit .env or MCP config files with keys, and assume anything that reaches a public repo can end up in a model. See our API key guide.
Fix prompt for your own AI tool
Copy this into your own AI tool (Cursor, Lovable, Claude Code, Bolt…). It's general guidance written by us. Review what the AI suggests before applying it.
I use AI coding agents and want to stop secrets getting into their context or into my repos. 1) Find .env files, shell history, MCP config files (for example mcp.json), notebooks and logs in my project and home folder that contain keys, and list the file names only, never the values. 2) Show me how to keep those files out of the agent's reach, for example with ignore files and permission rules in my AI tool. 3) Check my git history and my MCP config files for committed secrets, and tell me which keys I must rotate at their providers. 4) Help me turn on GitHub secret scanning and push protection. 5) Explain how to give my agent a short-lived or limited key, with a spend limit, instead of my main key. Don't change anything until I've approved your plan. Never ask me to paste API keys, passwords or .env contents; tell me where to check them myself.
Why this keeps happening: leaked secrets & api keys
Secret keys placed in front-end code, mobile bundles or public repositories can be found by automated scanners and abused, often running up large bills on AI or cloud accounts before anyone notices.
A quick checklist before you ship
- Keep secret keys only in server-side environment variables, never in browser or app code.
- Set spend limits and usage alerts with every AI and cloud provider.
- Turn on secret scanning and push protection for your repositories.
- If a key leaks, revoke and replace it first; deleting the file is not enough.
More on this: every leaked secrets & api keys story and our related guide.
Tools involved
Claude Code stories, MCP stories, DeepSeek stories, Gemini stories
Related stories
- Protect the AI tool tokens saved on your laptop
Aoki infostealer now steals Claude, Codex, Cursor and Copilot credentials - Turn on Privacy Mode in Cursor, never paste live keys into agent chats, and rotate any key you shared with an AI tool or its support team
Cursor: a key Fireworks exposed opened coding-agent traces holding unredacted customer credentials - Search your repos and git history for .claude/settings.local.json, rotate anything in it, then gitignore it
Claude Code's 'don't ask again' saved passwords and keys into a project file: secrets found in 1,122 public copies on GitHub
Source: original post on Blog (GitGuardian) ↗. Summarised in our own words; numbers are as stated by the source. Browse all stories.