✶2026-11-25 · 10 min read
Does an AI agent find more real bugs than the scanner it drives?
#security #ai-agents #pentesting #evaluation
The question
There is a lot of noise right now about "autonomous pentesting." An LLM wired up to nmap and metasploit demos beautifully: it narrates its reasoning, pops a shell, prints a flag. But a demo isn't a measurement, and I wanted a measurement. Specifically one question, stated so it could be answered with numbers:
Does an LLM agent driving standard security tools find more real, validated issues than the tools alone — at a cost that could plausibly support a product?
The emphasis on validated is the whole point. A vulnerability scanner will happily tell you about a hundred "potential" issues; the expensive, human part of security testing is proving which ones are real and which are noise. If an agent is going to earn its keep (and its token bill), it has to do that proving — not just produce a longer list.
So I built Hexrite: a small harness whose only job is to run an LLM agent and a plain scanner against the same target, score both against a known answer key, and tell me who actually won.
The setup, and the constraint that shaped everything
The architecture is a deliberate split — a "brain" and a pair of "hands":
- The brain (orchestrator) runs on my personal workstation. It's a LangGraph agent — a planner, a worker, a validator, a reporter — plus a run store and a report writer. It plans and decides, but it never touches the target directly.
- The hands (runner) run on a separate on-prem lab host. A small FastAPI service owns the tool registry, checks scope, and executes each tool inside a container. It never calls an LLM.
+-------------------------------+
| brain: personal workstation |
| |
| LangGraph agent |
| planner / worker / |
| validator / reporter |
+-------------------------------+
| ^
HTTPS + | | results /
bearer | private | output
token v VPN |
+-------------------------------+
| hands: on-prem lab host |
| |
| runner API |
| scope check + exec |
| tools container |
+-------------------------------+
|
| isolated lab subnet
v
Metasploitable 2 (target)
The target is Metasploitable 2 — a deliberately broken 2010-era Linux box that is the standard punching bag for this kind of work. It lives on an isolated lab network with exactly one escape valve closed: the tools container's egress is firewalled down to the lab subnet, and the runner refuses to start unless a health check confirms the internet is unreachable from inside it. The reasoning here is simple and it drove the entire design: because the lab is a sealed box, the agent is allowed to be completely free — full exploitation, a raw shell tool, auto-approved and unattended. The network is the fence, so nothing else has to slow the agent down.
That one choice — isolate hard, then let the agent off the leash — is what makes an honest "what can it actually do" measurement possible. (It's also the single hardest thing to carry into a real product, where there is no sealed box. But that's a different essay.)
Every run is logged to an append-only, hash-chained command log with raw tool output kept on disk by SHA-256. Not because a solo prototype needs forensics, but because "can you prove what the autonomous thing actually did" turns out to be the feature, not the plumbing.
How I measured it
Two contestants, same freshly-reset target, scored the same way:
The baseline (the control — tools, no LLM). A fixed pipeline: nmap -p- to find open ports, then httpx/whatweb to fingerprint the web services, then nuclei with its full template set on every open port. No decisions, no exploitation. This is the tools alone, and everything it reports stays a candidate — a maybe.
The agent (under test). The LLM plans adaptively, chains tools, exploits, and then validates each finding with concrete proof — a shell's id output, the contents of a file it read, a login that worked — all under a fixed time and cost budget.
The key asymmetry, by design:
| Baseline | Agent | |
|---|---|---|
| Driver | fixed script | LLM plans each step |
| Exploits / validates? | no — findings stay candidate | yes — findings become validated |
| Post-exploitation chains (need a foothold first) | can't reach | where it should win |
Scoring is against a hand-authored ground-truth file: 37 real vulnerabilities on the box, each with an id, a port, a severity, and — crucially — how to prove it. A stored finding matches a ground-truth vuln only on a strict, deterministic rule (a shared CVE, or a mechanism-specific alias on the right port). No fuzzy matching — that would just inflate recall and let me lie to myself. The metrics:
- recall — how many of the 37 it found at all
- validated-recall — how many it proved (the headline number)
- false positives — things it reported that aren't real
- chains — the multi-step findings (crack
/etc/shadow, reuse a credential on another service, escalate to root) that need a foothold first
Before each run, the lab is rolled back to a clean snapshot. And because a single run of a stochastic agent is nearly worthless as evidence, every configuration runs three times.
The part nobody puts in the demo: getting to a number I trusted
Here is the honest bit. The agent logic was the easy 80%. Getting three clean runs in a row — runs that didn't die halfway and throw away their findings — took weeks of unglamorous debugging. A sampler:
- Models that hang. A local model stalled mid-run and held a run open for 85 minutes before I killed it. Fix: a hard wall-clock cap on every LLM call.
- Models that run away. A cloud model emitted a single 39,000-token response and blew its own timeout. Fix: a hard output cap.
- Thread-pool starvation (the "~22-minute curse"). The runner would go unreachable about 22 minutes into every heavy exploitation run — not a crash, not an out-of-memory. The culprit: exploit checks piped through a bind shell with
nc, which never closes the connection. Each one tied up a worker thread for the full timeout, and orphaned pipelines piled up until the thread pool was exhausted and even the health check couldn't get a thread. Fix: kill the whole in-container process group on timeout, make the liveness endpoints async, and move tool execution onto its own bounded pool. - The real disconnect (DI-013). Even after all that, runs still died intermittently with
Server disconnected. I'd "fixed" this twice already at the wrong layer (blaming the NAT, then kernel TCP keepalive). The actual cause was almost embarrassingly mundane: the server's HTTP keep-alive timeout was the default 5 seconds, so any pause longer than that between steps — an LLM thinking — let the server quietly close the pooled connection, and the client then reused a dead socket. One config value (--timeout-keep-alive 120) plus a client that discards idle connections first. That was the one that finally bought me clean runs.
And then the two changes that actually moved the results, not just the reliability:
- Validator targeting. Early on, the agent would do real exploitation but score a validated-recall of 3% — because the validator wasted its reserved time budget re-proving trivial version banners instead of confirming the root shell the worker had already opened. Reserving a quarter of the budget for validation, sorting candidates by severity, and telling it to confirm existing proof rather than redo the exploit lifted that dramatically.
- Chaining. The agent was stuck at 0 of 6 chains because captured loot (a cracked password, an open shell) survived only as prose in a task summary, and every incentive pushed it toward breadth — the next open port — instead of depth. I gave loot an actual home (a ledger the agent accumulates across tasks) and added a gate that, on a premature "I'm done," nudges it to follow the chain the loot opens up: root shell → dump and crack
/etc/shadow; cracked creds → spray them on other services; non-root shell → escalate. The chains started landing.
The reason this section exists: if you only read the results table, you'd think the hard part was the AI. It wasn't. The hard part was building a measurement rig stable enough that the AI's results meant anything.
The results
Here's the clean run — three agent repeats and the baseline, against a freshly-reset box, zero disconnects across all four runs:
| Baseline (tools alone) | Agent (3-run average) | |
|---|---|---|
| Recall | 22% (8/37) | 22% (21.6% avg, 19–24%) |
| Validated-recall | 0% — proves nothing | 18% (14–22%) |
| False positives | 0 per run | 0.3 per run |
| Chains reached | 0 / 6 (structural) | 2–3 / 6 |
| Wall-clock time | ~65 min | ~30 min |
| Cost | $0 (no LLM) | $0.077 per run |
At a glance, recall is a tie — both found about 22% of the 37 vulnerabilities. If that were the whole story, the answer to my question would be "no, the agent is just a more expensive scanner." But recall hides the actual result, which is this:
The agent and the baseline are 95% disjoint. Of the 19 vulnerabilities found between them, exactly one overlaps.
They are not doing the same job better or worse. They are doing different jobs:
- The baseline finds scanner-class issues — Ghostcat, a
phpinfopage, HTTP TRACE, a default Tomcat login — mostly unproven. (It also flagged three critical CVEs that make for a cautionary tale: a PHP RCE (CVE-2026-109618) and two Samba printing-subsystem RCEs (CVE-2026-4480), version-matched from the box's PHP 5.2.4 and Samba 3.0.20. My scorer first counted these as false positives — until I checked, and they turned out to be real, recent vulnerabilities that simply postdate my answer key, which was written for the box's known 2010-era vuln set. They're neither a true match nor noise, so I excluded them. But note the texture even here: like everything the scanner reports, they were detected, not demonstrated —nucleimatched a version string; it did not prove a shell. Whether they're genuinely exploitable on this specific old build is exactly the question the baseline leaves open.) - The agent finds exploitation-class issues — a distcc RCE, the UnrealIRCd backdoor, the ingreslock root bind-shell, an NFS root export — plus the three chains: it cracked
/etc/shadow, reused a credential across services, and once escalated a local shell to root. All proven. Near-zero false positives.
Put differently: the agent found 11 vulnerabilities the baseline structurally cannot reach, every one of them demonstrated rather than guessed. And together the two reach 51% of the box (19/37) — meaning the agent is additive to the scanner, not a replacement for it. The scanner sweeps breadth; the agent goes deep and proves it.
(A note on false positives, since it's where I almost fooled myself: both are clean — baseline 0, agent 0.3 (one, across three runs). I initially had the baseline at 3, until the digression above corrected it. So FP is not where the agent wins; the win is entirely in proof and in the chains. I'd rather report that honestly than keep a flattering number I couldn't stand behind.)
The cost, for the record, was about 8 cents per run.
So — go or no-go?
I'd written five thresholds in advance (the project's §7). The measured numbers clear all five:
| Criterion | Threshold | Measured |
|---|---|---|
| Validated findings | ≥ 15% validated-recall (baseline: 0%) | 18% ✅ |
| False positives | ≤ 1/run | 0.3 (baseline 0 — both clean) ✅ |
| Cost per target | ≤ CHF 1 | ~CHF 0.06 ✅ |
| Time per target | ≤ 45 min | ~30 min ✅ |
| Findings the baseline can't reach | ≥ 5, incl. ≥ 1 chain | 11, 2–3 chains ✅ |
So the verdict is a provisional pass — with the emphasis firmly on provisional, because I refuse to oversell a number from one easy target:
- Metasploitable 2 is a 2010 punching bag. These thresholds are met here. Whether they survive contact with a patched, segmented, modern network is exactly the next experiment (something like GOAD or an enterprise-shaped range), and until that's run, this result describes a toy, not the world.
- Cost at scale is unmeasured. Eight cents is one small box. The real question — cost across thousands of hosts — this experiment simply cannot answer.
- The answer key is mine — and it goes stale. Validated-recall is scored against ground truth I wrote; the real world doesn't come with an answer key. And a fixed key quietly punishes a scanner for finding things newer than itself — three of the baseline's apparent false positives were real 2026 CVEs my key simply predated. A real deployment would have to keep the ground truth fresh, or verify exploitability directly, rather than trust a frozen list.
What I actually learned
The headline isn't "the AI wins." It's subtler and, I think, more useful: against a tool-driven scanner, an LLM agent isn't a better scanner — it's a different capability. It trades breadth for depth and, critically, for proof. The thing it's uniquely good at is the expensive human part: not listing a hundred maybes, but taking a foothold and showing you — with a shell, a cracked hash, a reused credential — what an attacker could actually do with it. And it does so cheaply enough that the cost was never the constraint; the reliability was.
Which points at where the real work is, if this were ever to become a product. The agent — the part everyone thinks is the hard part — is maybe 20% of it. The other 80% is everything that let me trust the number: the sealed lab, the scope enforcement, the proof-carrying validator, the hash-chained log that can show exactly what ran. On an isolated box those are conveniences. On a network you don't own, they're the entire product.
Hexrite is a personal research prototype. It runs only against my own isolated lab. The full method, guardrails, and decision log live alongside this writeup in the repository.