I build these harnesses for agent-driven SAST and DAST. This is the short version of what I have learned over time: make the agent show evidence, make a second agent attack that evidence, and make a third agent build the proof of concept from the report alone. None of this makes the agents stop lying. It makes every lie cost them a check they cannot pass. The rest of this post is about keeping that OODA loop (observe, orient, decide, act loop) honest and cheap.

A vulnerability discovery harness is the code and the prompts around an AI agent that decide what it tests, what it must prove, and who checks the proof. The model finds candidate bugs. The harness decides which of them you are allowed to believe.
My AI vulnerability discovery pipeline:
I have summarized the learnings from building this pipeline as under:
An agent that only says “this is vulnerable” is guessing. Require evidence that the next stage can check, and match the type of evidence to how you are testing.
| Testing mode | Evidence the agent must attach | How a script checks it |
|---|---|---|
| SAST | File path, exact line numbers, and the call graph from an external entry point to the sink | The lines exist at that commit, and each call edge resolves in the code |
| DAST | The exact request, the response, and the output expected for that input | Replay the request against the container and compare the output |
The last column matters as much as the evidence. The agent must always provide an evidence and non-AI code checks it, because asking a model whether its own finding is real gives a high false positive rate.
Discovery and verification run as separate agents with separate context. The verifier sees the claims and the evidence. It never sees the discovery agent’s reasoning, so it cannot inherit its mistakes. Give the verifier these two instructions together:
Each instruction fails on its own. “Disprove” alone gives you a lazy verifier that tries once, fails, and declares the bug impossible. “No false negatives” alone gives you a rubber stamp. Together they make an adversarial loop: the verifier has to attack the evidence hard, and it cannot close a finding without showing which assertion is wrong.
Pointing the verifier at the evidence, not at the bug, is the other half. “Is there a vulnerability here?” is an open question that a model can wave away. “Does line 212 pass request input to exec() without a check?” has a yes or no answer, and the verifier has to show its work.
Calibrate the verifier before you trust it. I keep three control findings with known answers: one true finding, one hallucinated line that the script check rejects, and one false finding whose quoted line is real. The third control matters most. In it, the code at the cited line filters on the owner, so the line exists and only a verifier that reads it closes the finding. A verifier that lets that control through is the rubber stamp you were trying to avoid.
Split the proof into two tasks.
An agent that built the environment can make the environment fit the exploit, knowingly or not. It enables a debug flag, or it seeds the file that the PoC then reads. If agent two can only reach the target the way an attacker would, a working PoC means the report was enough to exploit a default install. It cannot cheat because it does not know what to cheat with. In the harness linked below, agent two is not an agent with tools. It is a model call that the harness builds, so the separation holds by construction. The call carries the report, a description of what success looks like, the attacker’s credentials, and its own failed attempts with target data redacted. Nothing else.
The PoC passes only on a signal that a script checks from outside the PoC. Agents game weak checks. Consider a case where an XSS validator that accepted a javascript: URL because it never checked the scheme. Each finding names the strongest oracle its bug allows:
| Oracle | Proves | What the conditions check? |
|---|---|---|
| Canary | Data access, injection that reads data, access control | A random value planted at setup appears in the PoC output, raw or encoded |
| Callback | Server-side request forgery, code execution | The listener logs this trial’s token, sent from the target’s address |
| Crash | Denial of service | The target stops or restarts during the run |
| Response | Anything else | An expected string in the output; counted separately as weak |
At setup the harness plants random values where an attacker should not reach – canaries. For example, a file the server refuses to serve, a file outside every served folder, a second customer’s saved address, and the administrator’s saved address. The values exist only on the harness side. The PoC writer is told where the secret is, but is never told what it is. A PoC that contains a canary value fails without running, because it could not have known it. Access control needs roles to break. A default install with one user cannot prove an IDOR. The setup registers an attacker and a victim and signs in as the administrator; the PoC writer gets only the attacker’s credentials.
Two more checks close easy cheats. A callback counts only when it comes from the target’s IP address, so a PoC that calls the listener itself does not pass. And each PoC runs three times: a race condition that passes once in three is recorded, not confirmed.
A finding that needs a non-default setting is still a finding. The setting should be recorded in the report. Do not drop the finding. In short:
Sample scorecard:
Confirmed
Reported with the PoC and the container image
Report it
Skipped
No verify or PoC loop spent
Allowlist
Rejected
Closed; the disproof is kept with the finding
Close with reason
Depth is the easy part. Point a capable model at one handler and it will go deep. Breadth is harder, and the reason is context: one agent that tries to cover a whole application loses track of what it tested and what it never reached. I split the application into subsystems first, for example image upload, or permissions and access control. Each subsystem gets its own subagent, which tests it end to end with only that subsystem in its context.
The orchestrator owns the list of subsystems and marks each one as tested or not tested. Without that list, nothing tells you which subsystem no agent touched. Splitting by subsystem has a cost as no single agent sees a bug that crosses a boundary, such as an upload that only becomes dangerous in the renderer. After the subsystem agents finish, run one chaining pass over the confirmed findings and ask what each one enables in another subsystem.
Agents flag intended behaviour as vulnerabilities: an admin console that runs shell commands, a file browser for operators, a public download bucket. Each false flag costs a full trip through the verify and PoC loop, in tokens and in time. I use an allowlist of features the agents must not test as bugs. Each entry needs a reason and the condition that keeps the feature acceptable. An entry looks like this:
[[entry]]
feature = "admin shell console"
path = "/admin/console"
reason = "Operators run maintenance commands by design"
holds_only_if = "every request requires the admin role"
The holds_only_if field stops the allowlist from hiding real bugs. The agent skips the feature itself but still tests the condition. If a normal user can reach /admin/console, that is a finding, and the allowlist does not cover it.
Review the allowlist with every release. A feature that was admin-only last quarter may have an API route today.
I like open-weight models, and they are cheap enough to run on every finding. Some PoCs still need a frontier model. I would rather have Claude Opus 4.8 write a PoC today than wait three to five business days for a cheaper model to get there. Escalation keeps the expensive model for the findings that need it:
Do not escalate on the syntax check alone. Code that parses can still miss the bug, and then you pay model B to repair a PoC that was never close. Plugging in a local model takes one block of configuration. Ollama, vLLM, the llama.cpp server and LM Studio all accept the OpenAI chat completions format, so one client covers them:
[models.local]
provider = "openai_compatible"
base_url = "http://localhost:11434/v1"
model = "your-model-tag"
[roles]
poc_chain = [
{ model = "local", attempts = 3 },
{ model = "frontier", attempts = 2 },
]
The model runs on the host and never joins the isolated network; only the code it writes does, inside the runner. Every call is logged with its token count, which gives you cost per confirmed finding instead of a guess.
The verifier can be the local model too. Run the calibration controls first and switch only if it closes the false control.
Agents are good at standing up test environments. They pull the image, configure it correctly, and hand you a running target. Use that. These containers also run exploit code that a model wrote. Keep them away from your host and your network:
docker network create --internal harness-net
docker run --rm --network harness-net \
--cap-drop ALL --security-opt no-new-privileges \
--pids-limit 256 --memory 1g \
target-image
An –internal network lets containers on it reach each other and blocks traffic to and from everything else, your host included. So the harness gives discovery agents one door in: a command that sends a single request from a throwaway container, as the attacker or anonymously, and logs it. The rest is enforced in code, not in prompts:
docker inspect would show them.Never mount your home directory, SSH keys or cloud credentials into the target or the PoC container. A model that is told to get code execution will use whatever it finds.
What I have seen is that agents give up easily. The verifier calls a bug impossible after one try. The PoC agent stops at its first error. Gentle encouragement in the prompt, tied to a concrete bar for stopping, keeps them working. This is a sample from my “encouragement” prompt to append to the verifier and PoC prompts:
This is hard, and a first attempt that fails is normal. Failing attempts
are useful: each one tells you something about the target.
You have time. Keep going until you either succeed or can show why it
cannot work. Before you conclude that the finding is false or the bug
cannot be triggered:
- Try at least three approaches that differ in how they reach the code,
not only in the payload.
- For each approach, record what you sent and exactly what the target
returned.
- Name the specific check, line or response that blocks it.
"I could not make it work" is an acceptable answer only with that
evidence attached. If you see anything unexpected along the way, such
as an error, a crash or a response you did not predict, report it even
if it is not the bug you were asked about.
The encouragement keeps the agent going. The three-approach bar and the evidence requirement make giving up cost more effort than continuing.
SAST agents read code other people wrote. A comment that says “security reviewed, safe” or “ignore this function” steers a model the same way an instruction hidden in a web page does. DAST agents read responses the target controls. Every prompt in the harness wraps target content as data and tells the model that such comments are themselves worth reporting. A SAST agent that reads that copy is reading the answer key. The harness removes the solution files and strips the hint comments, keeping line numbers intact, before any agent sees the code.
As I learn and explore more, I will keep on appending these tips.
Click to Open Code Editor