In the last post I wrote about the idea behind my audit method: borrow taint analysis from web security and ask, for every value that matters, who can influence it, and how cheaply?
This post is about how that idea became a working method. I call it Taintline. It is a set of skills that an AI agent (or I, by hand) runs one after another. Each skill owns exactly one question. I’ll explain what each one asks and why it exists, without the prompts or the tooling. It’s still research in progress.
Why one question per skill
A single “find the bugs” pass behaves like a tired reviewer. It skims, it notices what looks scary, and it writes up the first few things it finds. Whole bug classes get no attention because nobody was responsible for them.
So I split the audit into questions, and gave every question an owner. Coverage then comes from the list of questions, not from how clever any one pass is. If a class of bug has no owner, I know about it, because the list says so.
Here is the whole set:
| Skill | The one question it owns |
|---|---|
| Substrate | What is this protocol, in plain English, and what does it track? |
| Conservation | Did the recorded total move when the value moved? |
| Provenance | Who can influence this value, and how cheaply? |
| Asymmetry | Do paired flows mirror each other? |
| Arithmetic | Does the math preserve what it claims? |
| Judge | Is this claim actually true? |
| Last user out | If everyone leaves in the worst order, is the last one paid in full? |
Substrate: draw the map before hunting
The first skill doesn’t look for bugs at all. It builds the shared picture that every later skill reads.
It starts with four questions a non-developer could follow. What does a user give? What claim do they get back? What is that claim worth, and which numbers decide it? When the protocol comes up short, who absorbs the loss?
Any point where that plain-English story goes vague gets written down as an open question. I call it the fuzzy-spot rule: the places you can’t explain simply are where bugs tend to live.
Then it fills in a table for every tracked total, such as total shares or total debt: which functions increase it, which decrease it, and whether value can move without that total being written. A static-analysis pass has already listed every writer mechanically. The substrate checks that list against the source. It never redraws the list by eye, because that is exactly how writers get missed.
A wrong map is worse than no map, because every later skill trusts it.
Conservation: did the total move when the value moved?
This is the biggest single source of high-severity bugs I’ve seen. Value leaves the contract, and the variable tracking it is never decremented, or is decremented on only one of several exit paths. Early users then withdraw more than they should, and the last user out is short.
Conservation starts from the substrate’s table, not from the file list, and turns each suspicious row into either a proven loss or an honest “this is fine”. A claim needs a balance sheet: after these steps, users can claim this much, the contract holds that much, and here is the gap. With no numbers, it stays a lead.
Provenance: who can influence this value?
This is the taint idea from the last post, made strict. Every value gets the cheapest class of influence that applies, from “nobody can move it” up to “the attacker controls whether the update happens at all”.
Two rules keep it honest. Report the cheapest way in, not the first one you notice, because the quiet classes (timing and absence) are where the interesting bugs are. And nobody may call a value “protocol-derived” without walking every function that writes it.
Before it finishes, provenance lists every value each contract treats as trustworthy, with the class it really has. A row where the two match is a sound assumption. A row where they differ is a finding or a lead. An empty list means nobody looked.
Asymmetry: do paired flows mirror each other?
Most of the worst bugs are code that isn’t there. You can’t search for a missing line, but you can demand symmetry and see where it breaks.
The unit here is a flow: an entry point plus everything it calls, modifiers included. A withdraw that calls a burn that calls an update is one flow, three levels deep. Comparing functions by name misses state written at the bottom of that chain.
Asymmetry checks four kinds of symmetry:
- Inverse. Whatever deposit writes, withdraw must unwrite. The same goes for mint and burn, borrow and repay, lock and unlock.
- Sibling. Every function in a family must handle the same cases. The forgotten one is never the main path. It’s the emergency variant, the expiry variant, or the one added last.
- Branch. Both arms of every condition must leave state consistent, including early returns and skipped loop steps.
- Refresh. Every function that reads accrued or indexed state must update it first. Some do, and one always forgets.
When one asymmetry turns up, the skill hunts for every other place the same pattern repeats before moving on.
Arithmetic: does the math preserve what it claims?
This skill exists because I once missed an arithmetic bug on a target where everything else had worked. No skill owned math, so nobody looked.
Every division decides who absorbs the remainder. The safe directions for a protocol that must never be short are simple: shares minted round down, assets paid out round down, debt rounds up, fees round up. The question that turns precision loss into a finding is who the rounding favours, whether it can be repeated, and whether it compounds. A rounding error a user can trigger in a loop is a drain, not a nit. Division before multiplication goes to the front of the queue.
Routing, not dropping
Each skill owns one question, which means each one will see problems that aren’t its job. The rule is that “not mine” is a routing decision, never a dead end. The skill files a lead tagged with the owner’s name, and the owner takes those leads first.
Every skill also gets a mandatory work list from the stages before it. Every item comes back as a claim, a lead, a note, or “this belongs to that skill”. Nothing gets dropped silently. Leads that nobody owns yet are carried into the report as a visible, unjudged list, so they can be counted.
This came from a real failure. The map once flagged a missing oracle check correctly, and the next skill reasonably decided oracles weren’t its job. The bug was found and then thrown away.
The judge: refute first, and never read the argument
Every finding is written in two parts: the claim (what is wrong, where, and how bad) and the argument (how the finder got there). The judge only ever sees the claim. It runs in a fresh session, so none of the finder’s reasoning can leak into it.
If the claim is true, the judge can rebuild the path from the source. If it can’t, that is evidence too. A judge that reads the argument tends to check whether the argument is coherent, and a well-written wrong argument passes.
The judge then runs four gates, in order, without going back:
- Refutation. Build the strongest case that the claim is wrong. Find the guard, check or modifier that kills it, and quote the line. A vague “probably fine” doesn’t count.
- Reachability. Can an attacker create the state the claim needs, and at what cost?
- Trigger. Can an unprivileged account actually do it, profitably?
- Impact. Name who loses. If there’s no victim, it isn’t a finding.
An uncertain guard counts as no guard. Only medium severity and above survive, so the report stays short enough to read.
Last user out: a test instead of an argument
Most AI audit output argues that something is exploitable. The last skill runs it.
The property is simple to say. Have every group of users exit in the worst possible order. Is the last one paid in full, and if not, by how much is the protocol short?
The deployment setup is prepared once per target, outside the AI’s budget, because wiring up a protocol is where an agent wastes most of its effort. The skill only writes the exit sequence. A failing test is the strongest thing the method can produce, because a protocol team can run it themselves. A passing test proves much less. It only means the orders I tried didn’t break it, and the report says exactly that.
What I’d keep without any AI
Strip out the models and the method still works as a checklist I follow by hand:
- Draw the map in plain English first, and write down where the story goes fuzzy.
- Give every question an owner, and know which ones have none.
- Never drop a lead silently. Route it to whoever owns it.
- Try to refute your own finding before you write it up, ideally without rereading your own argument.
- Prefer a failing test to a convincing paragraph.