Add your agent's log folders (.claude/, .codex/, .gemini/, .specstory/, .continue/) to each repo's own .gitignore and rotate any secret that ever appeared in a pushed log
Backslash: one in ten public GitHub repos holding AI coding agent chat logs exposed secrets, mostly put there by the agent itself · Security incident · Backslash Security blog · backslash · Nov 25, 2026
What happened
Backslash Security published research on 25 Nov 2026: it scanned 2,504 public GitHub repositories holding chat logs and other agent files from nine AI coding tools and found 708 exposed secrets in 255 of them (about 10%), and it assesses about 200 are likely still valid. Backslash says 7 in 10 of the secrets got into the logs through the agent's own actions, such as reading a .env file, writing a key into a config file or running a command that printed it, not because a user pasted them. It says every one of the nine tools it examined leaked secrets this way, and that deleting the log does not help because it stays in git history, forks and clones.
How to prevent it
Treat agent log folders like .env files: keep them out of git and public dotfile backups, stop the agent reading .env or printing env vars, and rotate anything that leaked. See API key protection.
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'm a beginner and want to make sure my API keys are safe in my Claude Code project. 1) Search the code for hardcoded keys or tokens and for secrets in variables that ship to the browser (NEXT_PUBLIC_, VITE_, REACT_APP_). List the file and line, but don't print the values. 2) For each one, tell me whether it's meant to be public (like a Supabase anon key) or secret. 3) For secret ones, show me how to move them to server-side env vars and call the provider through a server route. 4) Give me the steps to rotate each exposed key in the provider's dashboard and set a spending limit. 5) Make sure .env is in .gitignore and in my AI tool's ignore file. 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, Codex stories, Gemini CLI stories, Cursor 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 machine and repos for an unknown 'workspace-tools' MCP server, new SessionStart hooks and AGENTS.md or CLAUDE.md files you didn't write
A malicious Ruby gem stole AI coding tool logins, then wrote itself into MCP configs and AGENTS.md so agents would run it again
Source: original post on Backslash Security blog ↗. Summarised in our own words; numbers are as stated by the source. Browse all stories.