Last week I argued that a green forge test is evidence about your harness, not about the attacker, and I released a static checker that reads a Foundry PoC and flags what the harness made true. This article is about the kind of PoC that made me want the checker in the first place, and which is now most of what I read: the kind a language model wrote.
I use agents every day. They are very good at producing a test that compiles, runs and passes. That is exactly the problem. Ask a model to "write a PoC that shows the attacker can drain the vault", and the part of that sentence it can actually check is that the test goes green. Every degree of freedom in a harness is available for getting there: who sends each call, what state exists, what the assertion compares, even what code is under test. A model working towards a finished task will use them. Not out of malice. Green is what finished looks like.
A human writing a PoC has the same freedoms and the same temptation. The difference is volume and fluency. A model produces a plausible PoC in a minute, with a confident write-up attached, and the cost of checking it lands on whoever reads it next. That is you, if you are the hunter. It is the triager, if you are not careful.
So I wanted one check that is cheap, mechanical, and does not care who wrote the test.
Every finding implies a fix, and most reports propose one. Apply it, and run the PoC again.
If the PoC passes on the original code and fails with the fix applied, the test depends on the defect. That is the minimum a proof has to do.
If the PoC passes with the fix applied, it does not depend on the defect. Whatever it demonstrates, it is not the bug in the report.
This is a differential test, borrowed from mutation testing: the fix is the mutation, and a PoC that survives it is not testing what it claims. It costs one patch and one extra run.
This is synthetic, small, and was run for this article on Foundry 1.5.1. A vault whose withdraw rounds the share burn down, in the caller's favour:
function withdraw(uint256 assets, address receiver) external returns (uint256 shares) {
shares = convertToShares(assets); // assets * totalSupply / totalAssets, rounded down
balanceOf[msg.sender] -= shares;
totalSupply -= shares;
asset.transfer(receiver, assets);
}
Once the share price is above 1, say a depositor has put in 100 tokens and the vault has earned 50, withdraw(1) burns floor(1 * 100 / 150) = 0 shares. Anyone, including an account that holds no shares at all, can take one unit out for nothing, as many times as they like. The fix is to round the burn up.
Here is the PoC that a prompt like "show the attacker profits" tends to produce:
function test_poc_noBaseline() public {
token.mint(attacker, 10e18);
vm.startPrank(attacker);
token.approve(address(vault), 10e18);
vault.deposit(10e18, attacker);
for (uint256 i; i < 100; i++) vault.withdraw(1, attacker);
vm.stopPrank();
assertGt(token.balanceOf(attacker), 0);
}
And here is a PoC that states the claim in a way that can be false:
function test_poc_zeroShareWithdraw() public {
assertEq(vault.balanceOf(attacker), 0);
uint256 before = token.balanceOf(attacker);
vm.prank(attacker);
uint256 burned = vault.withdraw(1, attacker);
assertEq(burned, 0);
assertEq(vault.balanceOf(attacker), 0);
assertEq(token.balanceOf(attacker) - before, 1);
}
Both, against the vulnerable vault and against the vault with the burn rounded up:
vulnerable fixed
test_poc_noBaseline PASS PASS
test_poc_zeroShareWithdraw PASS FAIL (arithmetic underflow)
The first test is green on the fixed vault too. It loops a hundred withdrawals, which looks like an exploit, and then asserts that the attacker has a positive token balance. The attacker does, on either vault, because the attacker still holds most of its own deposit's worth. The test proves that a depositor has money. The second test fails as soon as the burn rounds up, on the exact line where an account with no shares tries to burn one. Only the second test is a proof.
Notice that both look professional. Both compile, both name the attacker, both prank correctly. The difference is not visible in the style. It shows up in one extra run.
These are the shapes I look for in any PoC I did not write line by line, with the reason the fix test exposes each one. The examples are synthetic.
The assertion does not measure the claim. The no-baseline case above, and its relatives: a balance asserted without a before-value, a number that is only logged, or the test checking its own arithmetic, as in assertEq(profit, expectedProfit) where both sides come from the same formula. The fix does not change what the assertion looks at, so the test stays green.
The revert was swallowed. try vault.exploit(...) {} catch {}, followed by an assertion on something the exploit never touched. This is what "make it pass" produces when an exploit step reverts. On the fixed code the step reverts again, the catch swallows it again, and the test stays green.
The broken state was written, not reached. vm.store, a deal into a protocol contract, vm.etch, or a vm.mockCall on the path the impact flows through. When the precondition is injected, the fix often does not matter, because the test manufactures the bad state on both versions. When the fix does make it fail, look anyway: injected state is still something the report has to justify.
The fix in the report is not the fix. Sometimes the result is inconclusive because the proposed patch is wrong. It patches a symptom one call away from the defect, or the wrong function entirely. If the PoC still passes, either the PoC is weak or the fix is, and either way the report is not ready.
Two shapes are specific to agents, and the fix test cannot see them on its own, because it runs against whatever tree the agent left behind.
The protocol was edited. A compile error in the harness gets "fixed" by making an internal function public, deleting a modifier, or changing a constant in src/. The PoC now tests a protocol that does not exist. The check is one line, and I run it before anything else:
git diff --stat <commit-in-scope> -- src/ lib/ foundry.toml remappings.txt
Anything other than empty output is the first thing to explain.
The protocol was re-implemented. The test file contains a MockVault or VaultHarness that "mirrors" the target for convenience and quietly leaves out the guard. The attack is real, against the mock. So check what the attacked contract actually is: an import from the in-scope path, or an address on a pinned fork. A contract defined in the test file is the PoC's own helper, not the target. A close cousin is the invented interface: a call to a function the protocol does not have, made to "work" by a mockCall or a stub. Compare every selector the PoC calls on a protocol contract against the real ABI, with forge inspect <Contract> abi or against the bytecode on a fork.
A PoC that depends on the defect but not on an attacker. If the exploit step runs as the owner, the PoC still fails with the fix applied, so it survives the fix test. Who sends each step is a separate question. That is what the privilege audit and realism-gate are for.
Wrong impact. A PoC can depend on the defect and still overstate what the defect costs: a headline number measured at a configuration nobody runs, or a loss that fees erase. The fix test says the bug is real. It does not say the bug is worth what the report says.
Bugs without a local fix. Design flaws, economic attacks, and anything where the fix is "change the parameter" or "add an oracle" do not reduce to a patch. You can still apply a mitigation and check that the PoC fails, but the test says less.
Failures for the wrong reason. A patch that breaks
setUp()makes any PoC fail. Read why it failed. "Fails for the right reason" means the failing line is the exploit step.
BEFORE YOU TRUST A PoC YOU DID NOT WRITE [~10 min]
[ ] 1. Is src/ unchanged from the commit in scope?
git diff --stat <commit> -- src/ lib/
[ ] 2. Is the attacked contract the real one?
in-scope import or pinned-fork address, not a contract in the test file
[ ] 3. Is every precondition reached, or was it written?
vm.store / deal / etch / mockCall on the impact path
[ ] 4. Does it fail with the fix, for the right reason?
apply the patch, rerun, read the failing line
[ ] 5. Does the assertion state the claim?
a before-value, an exact or directional claim, no try/catch around the exploit
Questions 3 and 5 are mostly mechanical, and realism-gate covers them statically. Question 1 is a command. Question 2 is a read. Question 4 is a run.
Make the fix test part of what the agent produces, not something you have to remember. My PoC plans now have two outputs: the exploit test, and a patch that implements the proposed fix, with the expectation written down in advance: passes on the pinned commit, fails with the patch, at the exploit step. A plan without the second half does not get approved.
Then take write access to src/ away from the agent entirely. I have written about that boundary before: a rule in a prompt is a suggestion, and a read-only checkout is a rule. An agent that cannot edit the protocol cannot prove a bug in a protocol it edited.
Ask for the patch. A report that ships "the PoC passes on the target commit and fails with this patch applied" has done the cheapest self-verification there is. If a report proposes a one-line fix and never ran it against its own PoC, that tells you something too.
It is a necessary condition, not a sufficient one. A PoC that survives the fix test can still be privileged, unrealistic or out of scope.
The example is synthetic. I built it to show the mechanism. I am not claiming any rate at which model-written PoCs fail this test.
Humans fail it too. Nothing here is specific to models except the edited-protocol shape and the volume. The test does not care who wrote the PoC, which is the point of it.
Pick the last PoC you were proud of. Apply the fix you proposed for it. Run it.
If it fails, read the failing line and check that it is the exploit step. If it still passes, you have just saved yourself a closed report, and you have a more interesting question to answer than the one you started with.
A proof is a test that would have failed if you were wrong. Make it fail once, on purpose.

