AI pentesting guides / Free, open-source and AI pentesting

Under the hood

How an LLM pentesting agent works, and where it goes wrong

An LLM pentesting agent is a program that gives a large language model a set of security tools and a loop: the model looks at what is known about the target, chooses a tool call, reads the result, and repeats until it has proven findings or run out of budget. The model supplies judgement; the surrounding harness supplies tools, memory, safety and reporting.

Most of what makes an agent good or bad lives in the harness, not the model. This page explains the parts of an LLM pentesting agent, the ways they fail, and the design choices that reduce those failures, which is useful whether you are building one or choosing one.

The core loop

  • Observe: gather current state, such as discovered hosts, endpoints, credentials and earlier findings.
  • Decide: the model chooses the next action and emits a structured tool call (native function calling).
  • Act: the harness checks the call against scope and safety rules, then runs the tool.
  • Record: output is parsed and stored so later steps and other agents can use it.
  • Stop: when objectives are met, budget is spent or a person stops the run, then report.

Memory and coordination

A single long chat transcript quickly overflows the model's context window. Agents therefore keep structured memory outside the model. Common designs are a planner that hands tasks to worker agents, or a shared blackboard that all agents read from and write to. On a blackboard, findings can be weighted so the most promising leads attract attention first, an approach inspired by how ants coordinate through pheromone trails (stigmergy).

Failure modes to expect

  • Hallucinated findings: the model claims a vulnerability from ambiguous output.
  • Loops: the agent repeats the same unproductive action.
  • Context loss: earlier discoveries fall out of the window and are forgotten.
  • Scope drift: the agent follows a link or redirect to a host it was not authorised to test.
  • Prompt injection: text on the target tries to change the agent's instructions.
  • Unsafe actions: a destructive command proposed during exploitation.

Design choices that help

  • Verify findings with signals the model cannot fake: out-of-band callbacks, response differences, timing.
  • Enforce scope and destructive-command blocks in code, outside the model's control.
  • Use deterministic playbooks for known procedures and keep the model for decisions.
  • Cap spend and steps, and make the stop path always produce a report.
  • Log every tool call so a human can audit the run.

Build or adopt?

Building a basic agent is a weekend project; building one you would trust against a real application is much more work, mostly in scope enforcement, tool parsing, verification and reporting. Unless the agent itself is your research topic, it is usually faster to adopt an open-source harness and extend it with your own tools or playbooks.

With Pentest-Swarm

How Pentest-Swarm implements the agent

Pentest-Swarm is an open-source LLM pentesting agent harness written in Go. It describes itself as the harness, not the model: you plug in the model.

  • Recon, classify, exploit and report agents coordinate through a pheromone-weighted, stigmergic blackboard; the sequential runner is the stable default and the concurrent swarm scheduler is alpha.
  • Models: Claude, Gemini, OpenAI-compatible APIs, Together AI, or local Ollama and LM Studio; all must support native tool calling.
  • Non-LLM verification oracles and sandboxed Python proof-of-concept generation.
  • Fail-closed scope, egress guard, --safe-mode, --budget and a full audit trail.

Where it falls short

Pentest-Swarm is not the only blackboard-based design (Cairn also uses one) and is not a research framework for training new models. It is alpha, focused on web applications and APIs, and its free edition deliberately limits its most powerful capabilities. If you want to experiment with agent architectures in Python, a general research framework may suit you better.

Questions

Which LLM is best for a pentesting agent?

Frontier models generally perform best, but the harness matters as much as the model. The model must support native tool calling.

Why do LLM pentesting agents produce false positives?

Because models infer from incomplete output. Independent verification, such as a callback or measurable response difference, filters these out.

Can I build my own LLM pentesting agent?

Yes, but most of the effort goes into safety, parsing, verification and reporting. Extending an open-source harness is usually quicker.