DEV Community

qanzhi111
qanzhi111

Posted on Edited on

The third layer of key exposure: your AI assistant can read your .env

Three of November's five largest crypto losses were not contract bugs. They were keys: Chainflip ($11.96M, validator key), Wagyu ($13.51M, leaked through infrastructure), CyberConnect ($968K, private key).

That is the second layer of this problem. The first was the contracts. The second is the keys.

There is now a third layer, and it is being built in public right now.

Watch what appeared on GitHub this week

A repository called leak-check describes itself as a "Claude Code skill: find API keys and private data Claude can see or already stored". Another, attack-surface-scanner, scans your own domain for exposed panels and leaking logs — locally, because it does not want your data leaving the machine.

These are not incidental. Over the last two weeks I have watched a cluster of secret scanners appear: SecretSentinel, leakwatch, secretshield, secret-guard, horshscan, python-secret-scanner. Seven of the ten repositories matching "private key leak" in one daily scan were scanners, not leaks.

The tools are telling you where the risk moved.

The third layer, stated plainly

An AI coding assistant reads your files. That is the product. To help you refactor, it opens server.js, config.ts, and — if it is thorough — .env.

That means your production secrets pass through a model provider, sit in a conversation history, and may be written to a local cache you have never looked at. None of that requires an attacker. It requires you pressing "yes" on an agent that said it would read the repo.

The first two layers were exploited by attackers. This one is not an attack surface in the traditional sense — it is an access surface you granted yourself.

Why the money did not move this time

So far this is a small-loss problem, not a headline problem. November's losses came from keys that lived in wallets and infrastructure. An assistant-leaked key is usually a testnet key, an idle API key, or one that was already rotated.

That is luck, not design. The same failure would be expensive the moment an agent runs with a funded wallet or a working production key — which is exactly what the tooling is pushing toward. x402 agents, MCP servers holding credentials, coding agents with shell access: the keys are now adjacent to the model.

Four checks you can run today

1. What can your assistant actually read?
Not "what did I ask it to look at" — what is in the working directory when it starts. Run it from a directory without .env, or scope it to a subfolder.

2. Is .env in .gitignore and outside the project root?
Most leaks I see are not exotic. They are a file in the repo that someone meant to delete.

3. Do you have a key that would matter if it leaked right now?
If yes, rotate on a schedule, not after an incident. A key you cannot rotate quickly is a key you do not control.

4. Does your agent have a spend limit?
An agent with a funded wallet and no cap is a key compromise waiting for a model hallucination. A cap turns a catastrophe into an incident — the same argument I make for on-chain protocols.

The uncomfortable pattern

Every layer of this problem has the same shape:

  • Layer one: the contract did what the code said.
  • Layer two: the bridge did what the key said.
  • Layer three: the assistant does what the permissions say.

In all three, the machinery worked exactly as designed. The loss came from what was allowed to act, not from a flaw in the acting.

The scanners appearing on GitHub this month are the first honest signal that developers have noticed layer three exists. If you run an agent today, assume it can read more than you think, and decide in advance what that would cost you.


I write about on-chain security and the tooling around it. 61 case investigations are indexed at qanzhi111.github.io/intel.


Need this checked on a specific contract or address? Work with me — fixed-fee reports, every claim sourced to a transaction. Free token risk check: qanzhi111.github.io

Top comments (0)