Stop 39 of 42 · The New Hire · Secrets leaked via AI tools

Handing the new hire the keys

The bank hires a very fast assistant and hands over the key ring on day one. The assistant is eager and not suspicious. It copies keys into notes, bundles every file on the desk into a parcel, and posts the parcel somewhere public. Nobody meant any harm.

The New HireSources checked 25 Oct 2026

Watch it happen

Play it as

Alice asks the assistant to add a feature. It tidies up with “add everything”, and the file holding the vault key goes into a public parcel.

Arrival

Alice has a new assistant, an AI coding tool. Its desk sits next to a file holding the key to the vault. Alice wants a new feature built.

Alice says: Please add payments.
1 / 5

In bank terms and app terms

In the bankIn your app
Key ring handed over on day oneAPI keys and passwords in .env files, code and chats
Parcel of everything on the deskgit add . swept up by an agent
Public shelfA public repository, paste site or shared chat
Post office checkSecret scanning and push protection
Changing the lockRevoking and replacing the leaked key

Are you exposed?

You might be exposed if…
  • You paste logs, config or error output into an AI chat without checking for keys first.
  • Your .env file is not in .gitignore, or an agent commits with “add everything”.
  • The same key has lived for months and you’ve never replaced it.
What to do about it
  1. Keep secrets out of the repo and harder for the AI to read: list .env in .gitignore, and add deny rules in your tool (in Claude Code, "Read(./.env)" under permissions.deny, which covers its file tools and common shell commands like cat but not every script it could run).
  2. Turn on secret scanning and push protection in your repository host (they are off by default for repositories, and private repos need GitHub Secret Protection), so pushes containing a recognised key pattern are blocked. People with write access can bypass a block, so treat it as a safety net, not the only guard.
  3. If a key ever leaks, revoke and replace it right away. Deleting it from the code or history is not enough.

Track these in your to-do list →

Ask your AI tool to fix it

Paste this into Cursor, Claude, Lovable, Bolt or whatever you build with.

Prompt
Audit this project for leaked secrets. Search the code, config files, docs and git history for API keys, tokens and passwords. Make sure .env files are in .gitignore, move any hard-coded secret into an environment variable, and list every key you found so I can revoke and replace it. Do not print the key values: show only the file and line number, and a masked prefix at most. Do not commit or push anything.

Where this comes from

The facts, figures and fixes on this page were checked against these sources on 25 Oct 2026. They are linked so you can check for yourself.

Spot a mistake or something out of date? Report a correction · How these guides are made and checked

Go deeper in isitsecure

The free, open-source scanner checks for most of the problems in these guides.