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

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

Source: original post on Blog (GitGuardian) ↗. Summarised in our own words; numbers are as stated by the source. Browse all stories.

The Honest Build. Real stories, not hype.

Every week: real stories of what building with AI actually took, the one lesson worth keeping, and the security slip-ups to avoid. Free, unsubscribe anytime. Weekly, every Friday.