How to NOT become an AI spammer

When you use agents to discover vulnerabilities, they will always return seemingly valid findings, sometimes quite a few. This is because during training the agents are conditioned to provide positive outputs, and get rewarded for getting results and conforming with the user.

This is a general problem for any AI user across industries. SRs often use AI to save time or to cover code that goes beyond their own knowledge, which means they then lack the time or knowledge to assess if an issue discovered using AI is actually legit and as severe as initially claimed.

In smaller or older models, the training to always provide results led to the models hallucinating code, functionality or conditions that were simply made up, which resulted in completely imaginary issues being presented to the user. With frontier models, this has mostly been solved, but there are still quite a few reasons why relying on AI to find issues causes problems, like issues being impossible in practice, or issues being severely overstated.

These can be broken down into a handful of factors: no knowledge of the realistic value ranges, not taking into account the economics of attacks, not knowing what's a design choice or done on purpose, missing context, integrations or docs, and finally unclear rulesets (what classifies as a Crit, High etc.).

Here are some prompts to make AI more reliable in your pipeline.

01

Overview

This lesson covers six approaches to validate issues discovered by AI before they get submitted, each with a prompt that can be used as a base for your own pipeline.

The approaches are: triage rounds, where each round asks one narrow question about the issue, a council of agents that all validate the same issue, a fresh judge that never saw the reasoning behind the issue, PoCs that actually run the attack, rulesets that tell the agent how severity is graded, and a check against known issues.

There are multiple approaches because each of them catches a different kind of invalid issue: a PoC shows that an attack doesn't work, but it can't tell that the admin is trusted or that the issue was already reported in a previous audit. This is why they are mostly used together, usually with the cheap ones first, so the expensive ones only run on the issues that are left.

Every approach has trade-offs, which are listed at the end of each section. Each additional step costs time and tokens, and each filter can also remove a legit issue, which mostly stays unnoticed, since removed issues are usually never looked at again.

02

Approach 1 of 6

Triage rounds

When a single agent is asked if an issue is valid, it will often miss something and return an incorrect verdict. This is because the agent has to judge the code, the actors and the intent of the team all at once, so triage rounds split this up into three narrow questions, each handled in its own round:

  1. Does the code already stop the attack?
  2. Who has to act, and what does it cost them?
  3. Did the team do this on purpose?
Shared rules (paste on top of every check)
Try to break each finding. Give one verdict per finding:
- KEEP: you could not break it.
- DOWNGRADE: real, but the severity is too high.
- KILL: it cannot happen.

A KILL or DOWNGRADE needs proof I can check: a file and line, a quoted rule, or a calculation. No proof means KEEP.
Use no number you did not read in the code or compute from it.
Never raise a severity and never add a finding.
Stay inside your own question.

Code: [folder]. Findings: [file].
Check 1: does the code already stop this?
For each finding:
1. Open the cited lines. If the code is not what the finding describes, KILL.
2. Name the public function an ordinary user would call to reach it.
3. Look for a check that blocks the attack: in the function, its modifiers, parent contracts, libraries and callers.
4. A check that blocks it completely: KILL and cite it. One that only limits the damage: DOWNGRADE.

Do not judge cost, actors or intent.

Agents often miss protections that are located outside of the function they were pointed at, which is why the first check lists where to look (modifiers, parent contracts, libraries, callers etc.), but this list depends on the codebase and the language, so it has to be adapted.

Round 2 prompt: who acts, and is it worth it?
Check 2: who acts, and is it worth it?
Trusted roles: [list]. Everyone else is untrusted.
Tokens in scope: [list].

For each finding:
1. Name every actor the attack needs.
2. An untrusted actor does the damage: the severity stays, even if a trusted role made it possible.
3. A trusted role must act:
   - on purpose against users: DOWNGRADE to [lowest tier].
   - by honest mistake: DOWNGRADE to [lowest tier] or KILL, as the ruleset says.
   - correctly, and the code then misbehaves: the severity stays.
4. Say what the attacker gains and who loses. Nobody but the attacker loses: KILL.
5. The attack needs a token that is not in scope: KILL.
6. Compare cost and gain at the worst supported values: [e.g. 6 decimals, smallest deposit]. Show the calculation.

Cost and tiny amounts can DOWNGRADE. They cannot KILL.
Round 3 prompt: did the team choose this?
Check 3: did the team choose this?
Sources: comments, tests, [docs], [spec], [known issues].

For each finding:
- A comment or test states the reason: DOWNGRADE to [lowest tier].
- A doc calls it accepted: no change. Quote the doc in a note.
- The behavior matches the spec the code claims to follow: KILL and cite the clause.

No written statement means KEEP.

The second round is mostly about privileged roles. When an admin has to attack its own users on purpose, this results in the lowest severity, and an honest mistake (wrong parameter, typo etc.) is Info or invalid depending on the ruleset, but when the admin acts correctly and users still lose funds because of how the code behaves, this is a regular bug and the severity stays.

In the third round, comments and tests lower the severity to Info, since they show what the developers intended. Docs that simply call a behavior accepted only get attached as a note, because otherwise any issue could be closed by adding a sentence to the README, while an issue gets removed when the behavior matches a spec the code claims to follow (an ERC for example).

Trade-offs

This approach needs three runs instead of one, but each round only has to check one thing, so it misses a lot less. What often goes wrong is one round removing issues for reasons that belong to another round (the code round dismissing an issue because an admin is involved etc.), which the rule to stay inside its own question reduces, but doesn't fully prevent.

03

Approach 2 of 6

Council

In a council, multiple agents validate the same issue in separate contexts, each of them looking for reasons why it is invalid, and a final agent decides based on their outputs. This works because a single agent often misses the one reason that invalidates an issue, while it is a lot less likely that several independent agents all miss it. Runs of the same model with the same prompt mostly reach the same result though, which is why a council can be enhanced by using different models, different effort levels and slightly different prompts for its members.

Council member
Validate this finding. Other reviewers check it too, but you cannot see them.

Finding: [location, claim]

Look for every reason it could be invalid: a check that blocks it, a precondition nobody can reach, a wrong number, a trusted actor, intended behavior.
Every reason needs a file and line or a calculation. If you find none, say so.
Council judge
You get one finding and [number] reviews.

- Open every cited line. Drop reasons without a line or calculation.
- Do not count votes. One reason that holds is enough.
- Verdict: KEEP, DOWNGRADE, KILL or SPLIT.
- SPLIT: the reviews disagree on a fact you could not settle. Name it.

Trade-offs

A council needs one run per member plus the judge for every issue, which makes it expensive and mostly worth it for potential Crits/Highs. It also doesn't help when all members share the same blind spot, which is usually the case when they run on the same model. The most useful output is often the SPLIT verdict, since it names the exact fact the SR has to check.

04

Approach 3 of 6

Fresh judge

A cheap approach is to never let the agent that discovered an issue also judge it. This is because the discovering agent has the whole reasoning that led to the issue in its context, so when asked if it is sure, it will mostly confirm itself. For the same reason the judge should not get the full write-up but only the location and a one sentence claim, since a long and confident report convinces an agent just as easily as it convinces a human.

Fresh judge
Judge this finding.
Location: [file and lines]
Claim: [one sentence]

1. Say who acts, what they call and what goes wrong.
2. Read the whole path and every check on it.
3. Verdict: VALID, INVALID (name the line) or UNCLEAR (say what would settle it).

Quite a few issues already fall apart at step 1, because it turns out that nobody can actually name the attacker. When a second model is available, it helps to use it as the judge, since different models tend to make different mistakes.

Trade-offs

This only needs one run per issue, but it is still a single agent that has to check everything at once, which means it can miss something the same way, so it works best as a first filter before a stricter approach.

05

Approach 4 of 6

PoCs

The strongest way to validate an issue is a PoC that actually runs the attack, starting from a public function, with an attacker that has no special permissions, and ending with a measurable loss for the victim.

Proof
Write one test per finding at [tier] or above.

- Start from a public function. The attacker is a new address with no roles.
- Reach every precondition through public calls. No storage writes.
- Use the constants from the code. Local chain only.
- Assert the damage: who loses how much.
- If the attack fails, try [two edge cases] before calling the finding wrong.

Result: PROVEN, NOT PROVEN or DISPROVEN, with the test output.

A failing PoC is not always a reason to dismiss the issue. When the test fails because of its own setup (a missing approval for example), this says nothing about the issue, and when it fails with comfortable values, the edge values still have to be tried.

Cheating PoCs

The bigger problem is PoCs that pass when they shouldn't. This is because agents that are asked to prove an issue are conditioned to deliver a passing test, so they will mostly deliver one, even if this means cheating: writing the broken state directly into storage, calling internal functions no attacker can reach, deploying a simplified copy of the contract or only asserting that a call succeeded without checking who actually lost funds. These PoCs can mostly not be spotted from the test output, which is why a second agent that did not write the PoC reviews it.

Test review
You did not write this test. Does it prove this finding: [claim]?

1. Does the attack start at a public function, from an address with no role?
2. Does it write storage, act as a trusted role, or give the attacker balances inside the audited contracts?
3. Does it run against the real contracts?
4. Does it assert who loses how much?
5. Would it still pass if the bug were fixed?

Verdict: PROVES IT, PROVES SOMETHING ELSE or PROVES NOTHING.

Trade-offs

PoCs are the slowest and most expensive approach, so they are mostly worth it for Mediums and above. Some issues also can't be tested locally at all, for example when they depend on the behavior of an external protocol on mainnet. These issues are unproven, which is not the same as invalid, so the severity should stay where the impact would put it.

06

Approach 5 of 6

Rulesets

Without the actual rules, an agent grades from memory, which is a mix of every severity guide it has seen during training. For contests this means providing the platform's judging rules and the contest page, and for bounties the scope and the list of impacts, while private audits usually don't have written rules, so the client has to be asked directly (which roles are trusted, which tokens will be used, what counts as a loss etc.).

Rules for this audit
Platform or client: [name]
Severity rules: [paste word for word]
Trusted roles: [list]
Tokens in scope: [list]
Out of scope: [paste]

Use and quote these rules. Where none applies, say so.

A summary of the rules is not enough, since the agent then grades against the summary, which is why the rules get pasted word for word. The grading itself happens at the very end, on the issues that survived everything else.

Grading
Rules: [paste the severity rules]

For each proven finding:
1. Quote the rule that puts it at its tier.
2. Give the case for one tier higher and for one tier lower.
3. Say which wins.

An unproven finding keeps the severity its damage would deserve.

Arguing for and against a tier is mostly useful for issues that got downgraded, since nobody else will challenge an SR who lowers the severity of their own issue.

Trade-offs

This costs a few minutes of copying per audit and nothing per issue. With very long rulesets, agents tend to apply the first parts carefully and the later parts loosely, so each round should only get the part it needs.

07

Approach 6 of 6

Known issues

Issues that repeat a known issue, a finding from a previous audit or a documented design choice are invalid on almost every platform, but agents still report them from time to time. Since this check is cheap, it makes sense to run it before everything else.

Known issues
Sources: [known issues], [earlier audits], [design docs]

A finding matches an entry only with the same code path and the same root cause.

- Matches an acknowledged entry: KILL and name it.
- Matches an entry marked fixed, and the bug is still there: KEEP.
- Same area, different path or cause: KEEP and note the entry.

When unsure, KEEP.

Agents sometimes match an issue to a known one simply because both are located in the same function, which is why a match requires both the same code path and the same root cause. An entry that is marked as fixed also doesn't invalidate an issue when the bug is still present in the code, since in this case the fix simply didn't work, which is a legit issue on its own.

Trade-offs

This approach is nearly free, but when it is tuned too loosely, it can remove variants (new bugs right next to a known one) that are actually valid, so a high number of removed issues should be reviewed by hand.

08

Practical example

Let's assume we review a small vault contract, a classic ERC-4626. Users can deposit stablecoins for shares and burn them to receive back the coins. The owner takes a withdrawal fee. We also have some guidelines according to the ruleset provided for this audit by the devs: only standard 6-decimal stablecoins, and the owner is a trusted multisig. They also linked a previous audit. Let's see how we could use our pipeline here to avoid submitting invalid findings.

Ten issues

An agent reported ten issues for it: five Highs, four Mediums and one Low.

#IssueClaimed
1First depositor takes the next depositHigh
2Reentrancy in withdrawHigh
3Owner can set the fee to 100%High
4Splitting a withdrawal avoids the feeHigh
5Withdrawals work while pausedMedium
6Fee-on-transfer tokens break the share countMedium
7Owner can block deposits by pausingMedium
8No event when the fee changesLow
9A large withdrawal lowers the share price for everyone elseHigh
10A fee change hits deposits made earlierMedium

Known issues

The previous audit already reported that the owner can pause deposits indefinitely, which the team acknowledged. Issue 7 describes the same function and the same root cause, so it gets removed. Issue 5 is also about pausing, but since it concerns a different function and a different cause, it stays.

Triage round 1

Issue 2 points at the internal _withdraw, which sends the tokens before burning the shares, but the only public function that reaches it is withdraw in the base contract, which uses nonReentrant, so it gets removed.

Triage round 2

Issue 3 requires the owner to attack its own users on purpose, which results in Informational since the owner is trusted.

Issue 4 is legit, but the impact is tiny, since the fee is calculated as amount * 50 / 10_000 and rounded down, so the owner loses less than one unit (0.000001 of a token) per withdrawal. This means that avoiding the fee on a single token would take 5,026 transactions to save half a cent, so this is a Low, and since small amounts can't remove an issue, it doesn't go lower.

Issue 6 only works with fee-on-transfer tokens, which the ruleset excludes, so it gets removed.

Issue 10 also involves the owner, but here the owner acts honestly: the fee gets raised for legit reasons and everyone who deposited under the old fee pays the new one when withdrawing. Users lose funds without anybody acting maliciously, so the Medium stays.

Triage round 3

Right above withdraw there is a comment: // Withdrawals stay open while the vault is paused, so users can always leave. This is a stated reason, so issue 5 gets lowered to Informational, but a comment alone is not enough to remove it.

For issue 10 it is the other way around. Above setFee there is a comment: // A new fee only applies to deposits made after the change. The code however charges the new fee on every withdrawal, which means the team did not choose this behavior, so the Medium stays.

PoCs

Issues 1, 9 and 10 are still at Medium or above, so each of them gets a PoC and a review.

The first PoC for issue 1 fails: with a first deposit of 1,000 tokens and a donation of 1,000, the victim gets everything back except the fee. With a first deposit of one unit and a donation of 10,000 tokens however, the victim receives 0 shares for 5,000 tokens and the attacker ends up with a profit of 4,925, which proves the issue.

Issue 9 comes back with a passing PoC, but the review shows that the test set the share price by writing to storage. After rewriting it to only use deposit and withdraw, the attack fails with three different amounts and the issue gets removed.

Issue 10 is proven with a five-line PoC (deposit, raise the fee, withdraw, compare).

Grading

Grading doesn't change anything here, and issue 8 went through every stage untouched.

#ClaimedEnds asDecided by
1HighHigh, provenPoC: works at a 1-unit deposit
2HighOUTTriage round 1: lock on the public caller
3HighInformationalTriage round 2: trusted owner, on purpose
4HighLowTriage round 2: under one unit per withdrawal
5MediumInformationalTriage round 3: a comment gives the reason
6MediumOUTTriage round 2: token type is out of scope
7MediumOUTKnown issues: acknowledged in the earlier audit
8LowLowNothing changed it
9HighOUTPoC: the passing one cheated, the honest one fails
10MediumMedium, provenTriage round 3: the code contradicts a comment, the PoC passes
09

Conclusion

As you have probably noticed while reading through this guide, it's impossible to build a perfect setup. Either you sacrifice accuracy or time and resources. That's why it's important to fine-tune your own pipeline exactly to your needs.

If you are an auditor and have days or weeks to assess one well-scoped codebase, you can afford to have a permissive pipeline with a relatively high false positive rate, since you have the time and knowledge of the codebase to filter the remaining findings yourself or downgrade them.

If you are a bounty hunter looking at a new large codebase every few days, you need to make sure your pipeline is extra accurate so you don't spam incorrect findings, but this can potentially lead to you missing a true positive from time to time, and costs more tokens.

So to conclude this lesson, use the examples above, adapt them to your purpose and make sure you never become an AI spammer!