Design a Pentest Agent Like Artex

⚠️ WARNING & LEGAL DISCLAIMER — EDUCATIONAL & AUTHORIZED USE ONLY
This article and the architectural concepts described herein are strictly for educational purposes, defensive research, and authorized security assessments. Never run autonomous security tooling or test any system without explicit prior written permission from the system owner, and always enforce strict safety precautions—including isolated lab environments, containerized worker sandboxes, CIDR scope firewalls, and human oversight.
Unauthorized access to computer systems, networks, or data is illegal. The author assumes no responsibility or liability whatsoever for any misuse, service disruption, data loss, or damage resulting directly or indirectly from applying any design, pattern, or workflow discussed in this post. You are solely responsible for complying with all applicable laws and rules of engagement.
Autonomous offensive security frameworks like ARTEX popularized a compelling idea: connect a Planner LLM to specialized Worker agents over a shared exploration graph, wire up standard security tooling, and let agents triage, pivot, and verify vulnerabilities at machine speed.
The problem is that most “AI for pentesting” implementations collapse the moment they leave a polished demo. Not because the underlying models lack reasoning ability, but because teams hand an LLM an interactive shell and a 40,000-token chat history and call it an architecture.
If you want to design a pentest agent that works reliably on real authorized labs and internal assessments, you don’t start by building a flashier exploit runner. You start by building a control plane.
1. Why Most Pentest Agent Demos Fail
In practice, naive AI security agents fail in one of three predictable ways:
- Blind Autopilots: Without strict module boundaries, the agent turns into a noisy brute-force loop—spraying huge generic wordlists, launching redundant scanners, and hallucinating “confirmed vulnerabilities” off ambiguous HTTP status codes.
- State Thrashing & Worker Collisions: When context grows past a few dozen tool calls, the model forgets what failed 20 minutes ago. It re-tests dead endpoints, loses track of which credentials belong to which principal, or—if you parallelize tasks—spawns two workers that clobber the same authenticated web session.
- Shortcut Memorization Instead of Technical Research: Agents exposed to unfiltered external blogs or public lab discussions try to pattern-match known writeups instead of fingerprinting the running stack and reasoning from first principles.
A real control plane eliminates all three failure modes with one guiding rule:
Research the technology, not the answer key.
2. Architecture: A Control Plane, Not an Exploit Framework
Our design is a lightweight Python CLI (python3 -m harness) paired with structured, file-locked YAML state under engagements/<target>/. Every module has a hard boundary designed to keep both deterministic scripts and LLM workers honest:
scan(Discovery Only): Identifies listening services and captures clean banners. It does not probe application vulnerabilities.creds(Bounded Auth Verification): Tests known or explicitly recovered credentials only. Default-password checks run strictly when requested; massive brute-force wordlists (rockyou-style spraying) and automatic remote-desktop sprays are disabled by design.web(Surface Mapping & Benign Canaries): Maps routes, headers, frameworks, and safe smoke signals without blind auto-exploitation.- Agent Workers (Verification & Reasoning): Pick up discrete graph nodes, confirm hypotheses manually, save isolated PoCs under
exploits/, record engagement-specific memory, extract sanitized framework patterns into a sharedplaybook/, and handle privilege-escalation checks.
By drawing a crisp line between automated telemetry and agent reasoning, scripts never overstep authorization boundaries, and LLM workers never waste tokens parsing raw port-scan noise.
3. Why YAML State Beats Long-Context Chat Memory
Relying on an LLM’s conversation history as primary state guarantees drift. Once a session compacts or splits across parallel workers, nuance vanishes. Instead, all truth lives in structured files on disk:
| File / Directory | Role in the Engagement |
|---|---|
STATUS.yaml |
Active phase, discovered services, known/validated/failed credentials, confirmed findings, and current session principal |
PATHS.yaml |
Coarse Directed Acyclic Graph (DAG) of candidate attack paths, Expected Value (ev) scores, leases, dependencies, and negative proofs |
NOTES.md |
Short human-readable narrative summarizing verified breakthroughs |
scans/, recon/, loot/, exploits/ |
Raw outputs, captures, retrieved artifacts, and isolated verification scripts |
memory.yaml |
Structured log of exact tactics, scripts, and results tried on this specific target |
Repo-level playbook/ |
Reusable, technology-scoped verification patterns shared across future engagements |
Separating Engagement Memory From Reusable Playbooks
A critical architectural distinction sits between memory.yaml and playbook/:
memory.yamlis target-local: Lab IPs, custom tokens, hostnames, and target-specific findings belong here.playbook/is strictly product-scoped: It stores generic engineering facts (e.g., how Go Echo handles%2Fvs.nginx, or how to fingerprintgofpdfmetadata). Hostnames, lab IPs, credentials, secret strings, and target identifiers are forbidden—an automated sanitizer rejects any write containing target leakage.
4. PATHS.yaml: The Heart of the Harness
The core invention is treating penetration testing not as a flat checklist, but as a concurrently schedulable attack-path graph. Each node in PATHS.yaml captures explicit state:
- id: web.80.ticket-pdf-inject
parent: web.80.idor-schedules
status: pending # pending | active | done | blocked | dead
kind: web # shell | exploit | creds | web | service | enum
target: http://192.0.2.10:80/tickets/
evidence: null
hypothesis: "Ticket download renders user-controlled fields; verify generator engine"
tried: []
next: "Inspect PDF Producer metadata; verify escaping across template layers"
unlocks: []
reason: null
ev: 68 # Expected Value 1-100
resource: web80-session # Exclusive lock tag (missing or 'offline' = unlimited concurrency)
claimed_by: null
claimed_until: null # Lease expiration timestamp
requires:
parent: done
depends_on: []
noise: low
principal: user_2
tech: go.pdf-render
playbook_ref: go-echo:enum
skills: []
Expected-Value Ranking & Parallel Dispatch (harness next)
Every kind carries a baseline Expected Value (shell=80, exploit=70, creds=60, web=40, service=30, enum=20), tuned per hypothesis. Running harness next computes an effective schedule across the entire graph:
- Deterministic Gating: Automatically suppresses paths that cannot execute yet—returning explicit gate reasons like
needs-creds,parent-dead,signal-unconfirmed,wrong-principal, orcreds-exhausted. - Phase Awareness: Once
STATUS.yamltransitions to post-exploitation or privilege escalation, noisy credential checks and early web smoke nodes are automatically demoted. - Uncontended Parallel Dispatch (
-n 3 --json): Selects up to N top-ranked paths whoseresourcetags do not collide. Anofflinecryptography or artifact-analysis worker runs safely alongside an activeweb80-sessionworker without interfering with session cookies or rate budgets. - Atomic State Locking: Every read-modify-write against
STATUS.yamlorPATHS.yamlacquires.state.lockso concurrent workers never overwrite each other’s updates.
5. The Orchestrator & Worker Loop
With state decoupled from chat history, running parallel AI workers (for example, subagents spawned by an orchestrator session) follows a strict, repeatable contract:
Orchestrator Responsibilities
- Read
STATUS.yaml,PATHS.yaml, andNOTES.md. - Call
harness next <target> -n 3 --jsonto fetch an uncontended dispatch batch. - Spawn one isolated worker per dispatched node—never scheduling two workers on the same named
resource.
Worker Contract (WORKER.md)
- Acquire a timed lease:
harness claim <target> <path-id> --ttl 15m. - Execute only that node’s scoped
nextstep. - Record artifacts and update
PATHS.yaml,STATUS.yaml, andNOTES.md. - Log one sanitized event via
harness remember. - If a reusable framework lesson emerged, save a clean product snippet via
harness playbook add. - Release the node cleanly (
harness release). - Hard Rule: Never retry
creds.failedorstatus: deadpaths blindly. Adeadnode can only re-enter the queue viaharness reopen --evidence <artifact>when concrete new evidence (such as a recovered signing key or leaked config) invalidates the earlier dead end.
Essential Operator Ergonomics
- Auditable Negative Proofs: Marking an injection path
deadisn’t a free pass to skip work. Workers must log exact tested parameters, baseline response hashes, and canary outcomes so a human reviewer—or later agent—can verify why a surface was ruled out. - Maintenance & Scope Windows (
lock/unlock): Pauses active workers immediately during customer freeze windows or sensitive production windows. - Masked Visual Telemetry (
viz): Generates a standalone local HTML graph ofPATHS.yamlandSTATUS.yamlwith passwords, tokens, and session cookies automatically masked.
A Session in Practice
python3 -m harness new lab-portal 192.0.2.10 --cred 'jdoe:TempPass99!'
python3 -m harness run lab-portal # scan -> creds -> web -> estimate -> next
python3 -m harness estimate lab-portal --dry-run
python3 -m harness next lab-portal -n 3 --explain
python3 -m harness remember lab-portal --path svc.80 --tactic enum --result 'nginx + Go Echo v4' --reuse
python3 -m harness playbook search go-echo
python3 -m harness viz lab-portal
6. Guardrails & Research Hygiene as Architecture
Real client networks have no answer keys. To keep agents grounded in engineering analysis rather than shortcutting:
- Allowed Research Scope: Official software documentation, RFCs, CVE advisories, framework source behavior, and public vendor patches for the fingerprinted technology (e.g.,
labstack/echorouter normalization quirks). - Hard Stops Over Guesswork: If every high-signal path hits a verified block (such as strict HMAC validation with no key leak), the agent marks the node
blocked, documents the exact boundary, and halts cleanly instead of spiraling into noisy fuzzing. - Product-Scoped Skills (
skills search/show/import): Optionally pulls modular, vulnerability-class research checklists (e.g., JWT auditing, Gogobdecoding, PDF engine fingerprinting) mapped directly from each path’stechfield. - Automated Playbook Sanitizer: Strips or blocks target IPs, hostnames, internal emails, and credential literals before anything enters shared
playbook/knowledge.
7. Taking It Further: Six Architectural Upgrades (v1 to v2)
Building and running this harness quickly exposes where prompt-level discipline ends and harder systems engineering needs to begin. These six upgrades turn a good orchestration harness into a production-grade security platform:
1. Runtime Execution Firewall & Agent Containment
Late-2026 security research (including ArtexPot honeypot experiments) proved a harsh truth: autonomous pentesting agents can themselves be compromised by the targets they inspect. If a defended target returns crafted HTML, poisoned repository files, or malicious headers, an uncontained worker running locally with the operator’s shell can suffer RCE or leak .ssh and cloud keys.
- The Upgrade: Run every Worker inside an ephemeral, rootless container or microVM with zero access to host credentials, routing outbound traffic through a deterministic proxy enforcing target CIDR allowlists, request-rate limits, and banned dangerous flags—regardless of what the LLM tries to execute.
2. Bayesian / Evidence-Driven EV Propagation
Right now, ev scores mostly update manually or via coarse phase rules.
- The Upgrade: Automatically propagate structural proof across sibling nodes. If an enumeration worker confirms strict typed integer parsing (
strconv.Atoi) and parameterized SQL queries on search endpoints, dynamically decayevon speculative injection siblings while boosting business-logic and authorization-flow paths.
3. Schema-Enforced Negative Proofs & Auto-Reopen Triggers
Relying on free-text reason strings lets rushed workers close paths too loosely.
- The Upgrade: Require structured YAML negative-proof fields (
tested_params,baseline_hash,oob_verified,canary_count) beforestatus: deadpasses validation. Pair this with declarative reopen triggers (reopen_on: signing_key) so that the instant a key or config file lands inloot/, blocked cryptographic paths wake up automatically.
4. Shared OOB Listener & Auth-Session Broker
Two parallel workers spinning up conflicting callback listeners or logging out shared test accounts create subtle false negatives.
- The Upgrade: Add sub-leases for ephemeral callback tokens (mapping unique correlation IDs per path over a single multiplexed listener) and managed session jars that isolate or refresh per-principal cookies cleanly.
5. Context-Budgeted Worker Compilation
Dumping whole scan outputs or large HTML captures into every worker wastes tokens and triggers early context rot.
- The Upgrade: Have
harness claim --briefcompile a minimal, deterministic context packet for the worker: onlySTATUS.yamlsummaries, the claimed node’s parentreason, exact matchingplaybook/snippets, and bounded pointers to relevantloot/excerpts.
6. Cryptographically Signed Audit Replay (harness replay)
In enterprise consulting and compliance-driven red teaming, knowing how an agent reached a finding matters as much as the finding itself.
- The Upgrade: Record every
claim, command hash, state diff, and output digest into an append-only engagement ledger so human leads can audit scope compliance and reproduce every verified issue cleanly.
8. Honest Tradeoffs & Closing
A strict state-graph harness is not frictionless:
- Maintaining clean
PATHS.yamldiscipline takes upfront schema design and deliberate pruning so graphs don’t bloat. - Strict module boundaries and negative-proof requirements can feel slower in the first five minutes than letting an unconstrained agent fire scanners blindly.
- Guardrails never replace human judgment on nuanced business logic or complex multi-step authorization bugs.
Yet the lesson remains clear whether you are running ARTEX, building internal AppSec agents, or designing custom offensive workflows: intelligence without a control plane just produces faster chaos. Give your agents typed YAML graphs, exclusive leases, deterministic boundaries, and sandboxed execution—and let them research the technology cleanly.
Building AI security tooling or hardening agent control planes? Follow me on X/Twitter and LinkedIn, or read How Your AI Gets Compromised Through MCP.