Welcome to our

Cyber Security News Aggregator

.

Cyber Tzar

provide a

cyber security risk management

platform; including automated penetration tests and risk assesments culminating in a "cyber risk score" out of 1,000, just like a credit score.

How to Build an AI Vulnerability Discovery Harness

published on 2026-11-30 06:39:55 UTC by Mayuresh
Content:

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.

AI Vulnerability Discovery Harness

What is an AI vulnerability discovery harness?

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:

The harness pipeline, from subsystem split to reported finding, with where each stage fails and what catches it.

I have summarized the learnings from building this pipeline as under:

Tip 1: No evidence, no finding

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 modeEvidence the agent must attachHow a script checks it
SASTFile path, exact line numbers, and the call graph from an external entry point to the sinkThe lines exist at that commit, and each call edge resolves in the code
DASTThe exact request, the response, and the output expected for that inputReplay 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.

Tip 2: Separate discovery from verification, and give the verifier two opposing instructions

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:

  1. Disprove the evidence. Check each assertion: does this line exist, does this call edge exist, does this input produce this output. Do not judge whether the bug feels real.
  2. A false positive is acceptable. A false negative is not. Report any unexpected behaviour, even when it is not the bug under review.

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.

Tip 3: Build the target and the proof of concept with two agents that never meet

Split the proof into two tasks.

  1. Agent one builds a standard configuration of the application in Docker: a default install from the vendor’s documentation, with no change made to help the bug. It hands back an address and nothing else.
  2. Agent two gets the finding report and that address. It never sees agent one’s Dockerfile, configuration or notes. It writes the proof of concept from the report alone.

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.

What do the conditions check for?

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:

OracleProvesWhat the conditions check?
CanaryData access, injection that reads data, access controlA random value planted at setup appears in the PoC output, raw or encoded
CallbackServer-side request forgery, code executionThe listener logs this trial’s token, sent from the target’s address
CrashDenial of serviceThe target stops or restarts during the run
ResponseAnything elseAn 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:

Every condition between a candidate finding and a report, and what stops a false finding at each one.

Sample scorecard:

Finding A: command injection in the image upload handler

  • Evidence attached: file path, lines, call graph
  • Verifier could not disprove any assertion
  • Blind PoC produced the claimed output on the default container

Confirmed

Reported with the PoC and the container image

Report it

Finding B: admin shell console

  • Matches the allowlist entry for the admin console
  • Allowlist condition re-tested: the admin role is enforced

Skipped

No verify or PoC loop spent

Allowlist

Finding C: SQL injection claim

  • Verifier showed a bound parameter at the cited line

Rejected

Closed; the disproof is kept with the finding

Close with reason

How three example findings move through the gates

Tip 4: Cover breadth with one subagent per subsystem

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.

Tip 5: Tell agents what is insecure on purpose

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.

Tip 6: Escalate between models on a hard limitation

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:

  1. Model A, an open-weight model on your own hardware, writes the PoC.
  2. A cheap pre-check rejects code that does not parse. That goes back to model A and does not count as an attempt.
  3. The real limitation: the PoC runs against the container and must produce its oracle signal.
  4. If model A fails the gate three times, model B gets the report and model A’s failed attempts, with target data redacted, so it starts from what is already ruled out.

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.

Tip 7: Let agents build Docker targets, and isolate them

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:

  • The PoC runner runs as an unprivileged user with a read-only root filesystem, a small /tmp, process, memory and CPU limits, no Docker socket, and the PoC mounted read-only.
  • Before anything runs, the harness compares the target container with its image: environment, command, mounts, privileges and networks. Any difference stops the run, so nobody, agent or human, can quietly switch on a debug flag.
  • Canary values and passwords reach helper containers on stdin, never in environment variables, where docker inspect would show them.
  • Add –read-only to the target where the application can run without writing to its root filesystem. Juice Shop writes its database, so it cannot.

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.

Tip 8: Give agents a reason to keep going

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.

Tip 9: Treat everything from the target as hostile input

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.

Article: How to Build an AI Vulnerability Discovery Harness - published about 13 hours ago.

https://pentestit.com/ai-vulnerability-discovery-harness/   
Published: 2026 11 30 06:39:55
Received: 2026 11 30 07:08:11
Feed: PenTestIT
Source: PenTestIT
Category: News
Topic: Security Tooling
Views: 1

Custom HTML Block

Click to Open Code Editor