DEV Community

Pharon
Pharon

Posted on

Decoy API keys: catch the AI agent that uses them

Last month the wfx-loot campaign pushed a secret stealer into tens of thousands of GitHub repositories. If you ran one of the affected packages or Actions, your CI secrets and .env files may have been copied.

Pharon, the plugin I build, could already tell people "you might be exposed". What it couldn't tell them is the thing that actually matters: did anyone use what was stolen? Rotating every secret you own on a "maybe" is expensive. Ignoring it is worse.

This post is about the feature I built to answer that question: decoys.

TL;DR

  • A decoy is a fake copy of one of your own credentials or endpoints. Nobody legitimate ever uses it, so the first use tells you, within seconds, which place leaked.
  • Pharon Decoys are built from your own app's routes and key format, live on your own domain, and catch scripts, people and AI agents alike.
  • When an AI agent bites, the decoy keeps it busy with fake data, gets it to reveal what it was sent to do, and slows it down while you rotate.

What is a decoy key?

The idea is old: honeytokens, canary tokens, tripwires. You plant something that looks valuable and has no legitimate use. Anyone who uses it is, by definition, someone who shouldn't have it.

A decoy key sits next to your real secrets, in a CI secret store, a developer's .env, the team wiki. It looks exactly like the keys around it. The day it's used, you learn two things at once: that place leaked, and someone is actively trying what they found.

That's a very different signal from "a package you use was compromised". It turns "maybe" into "yes, and here's where".

Why classic honeytokens miss AI agents

Most honeytoken services hand you a fake key that calls home to their domain. That worked when a human attacker tried keys one by one.

Agents change two things. They read everything they find, and they learn. Known trap domains end up on blocklists, and an agent that has seen one decoy pattern can skip the next. A decoy that looks the same across thousands of companies is a decoy that stops working.

So Pharon Decoys follow three rules:

  1. They live on your domain. A decoy key is one of your keys, used against your API. The attacker never sees a third-party domain to avoid.
  2. No two projects share a pattern. Decoy endpoints and fake files are made from your app's own routes and vocabulary. Pharon refuses decoys that look too much like another project's.
  3. Pharon never sees a decoy. Every decoy is sealed with a key that only you hold. If Pharon itself were breached, the attacker still couldn't tell your decoys from your real keys.

How do you set it up?

In Claude Code, in your app's repo:

/pharon:decoys
Enter fullscreen mode Exit fullscreen mode

Claude reads how your app routes requests and checks credentials, then:

  • writes a small check into your app, in your own framework and style, with tests (you approve every edit)
  • creates decoy keys in your real key format, and a few decoy endpoints that look like they belong next to your real ones
  • tells you exactly where to plant each decoy, and records the names (never the values) of the real secrets stored next to it, so you know what to rotate if it fires

There's no SDK to install, which also means there's no Pharon package running in your production app that could itself become a supply-chain target.

What happens when someone takes the bait?

Your app answers normally, so the intruder notices nothing. In the background it reports the hit, and your team gets an alert within seconds by email, Slack, webhook, and in Claude Code the next time someone opens the repo.

The alert says which decoy was used, from where, and what was requested. It also says what kind of caller it looks like: a script, an AI agent or a person, with the reasons. A used key reads as a leak, with a checklist of the secrets to rotate. A probed endpoint reads as someone scanning your site.

When the caller is an AI agent, the decoy doesn't just log it. It plays along. It feeds the agent fake data, gets it to say what it was sent to do, and slows it down, buying you time to rotate before it moves on.

I let Claude attack my own site

To see whether this actually fools an agent, I pointed Claude at one of the decoy endpoints on getpharon.com.

It read the API's error message, did exactly what the error asked, explained its task in a full sentence, and kept following "next page" links until I stopped it. Nothing in the responses gave the trap away. A few seconds later, the alert landed: AI agent, with its own explanation of what it was trying to do quoted underneath.

That explanation is the part I didn't expect to be so useful. A script tells you nothing. An agent tells you its goal.

What decoys don't do

  • They don't hack back. Everything happens on your own server. Pharon never touches the attacker's machine, and never asks the agent to run anything or hand over anything from it.
  • They don't stop the attack. A fired decoy means you rotate the secrets stored next to it and find how it leaked. Decoys buy you time and certainty, not immunity.
  • The "who is it" label is a best guess, shown with a confidence and its reasons. Treat it as a lead.

Where to start

  1. Run /pharon:decoys in the repo of the app whose keys matter most.
  2. Plant your first decoy key in your CI secrets: that's where the current wave of secret stealers looks first.
  3. Add one to a developer .env and one to your team wiki, so an alert tells you which of the three leaked.
  4. Test it with the command Pharon gives you. Test hits never alert anyone.
  5. Leave it alone. The best decoy is the one that stays quiet for years.

Docs and setup details: getpharon.com/docs#decoys. What Pharon stores when a decoy fires: getpharon.com/what-we-see.


Has a leaked key ever been used against you? How long did it take you to notice, and how did you find out?

Disclosure: I build Pharon. The plugin is open source; alerts are a paid service. I wrote this with AI assistance and checked every claim against the product.

Top comments (0)