ARTEX: How Dual Graphs Make LLM Penetration Testing Actually Work
Hook
Most LLM pentesting tools fail because they can't answer "did we already test this endpoint?" or "how did we discover this vulnerability?" ARTEX solves both with a single architectural choice: splitting what exists from what we tried.
Context
The promise of LLM-powered penetration testing has been obvious since GPT-4's launch: autonomous agents that chain tools like subfinder, httpx, and sqlmap to discover vulnerabilities without human guidance. The reality has been messier. Existing tools wrap ChatGPT around Metasploit or build AutoGPT clones that invoke nmap, but they all hit the same problems: agents test the same endpoints repeatedly because they forget what they've scanned, you can't visualize coverage to know which attack surfaces remain unexplored, and when a critical finding appears, there's no trace of how the agent reasoned from initial recon to exploitation.
ARTEX takes a database-first approach to autonomous pentesting. Instead of treating the LLM as a stateful reasoner with memory, it externalizes all state into two PostgreSQL graphs: an Asset Graph that models your company's attack surface (domains, subdomains, services, endpoints in a strict hierarchy) and an Exploration Graph that captures per-task reasoning chains (intents spawn facts, facts spawn findings, with parent-child lineage preserved). The graphs connect through bidirectional anchors, so every intent like "scan example.com for subdomains" links to specific asset nodes, and every discovered fact updates both its exploration chain and the global asset registry. This separation means coverage queries become graph traversals, deduplication becomes asset lookups, and bloodline visualization becomes ancestor walks—no prompt engineering required.
Technical Insight
The architecture runs an event-driven loop where graph mutations wake the planning system. When you create a task with a goal like "find SQLi in api.example.com", the planner singleton wakes, queries the asset and exploration graphs to identify gaps (endpoints without associated security intents, subdomains lacking port scans), then generates intent nodes representing atomic work units. These intents land in a frontier queue implemented as a PostgreSQL table with row-level locking.
Workers are stateless processes that claim exactly one intent via SELECT FOR UPDATE SKIP LOCKED, execute real tools through the norma SDK (which wraps httpx, sqlmap, nuclei as LLM-callable functions), then write discoveries back to both graphs before dying. Here's the intent execution flow:
// Worker claims an intent atomically
var intent Intent
err := db.QueryRow(`
UPDATE intents
SET status = 'running', worker_id = $1, claimed_at = NOW()
WHERE id = (
SELECT id FROM intents
WHERE status = 'pending' AND task_id = $2
ORDER BY priority DESC, created_at ASC
FOR UPDATE SKIP LOCKED
LIMIT 1
)
RETURNING id, task_id, tool_name, parameters, anchor_ids
`).Scan(&intent.ID, &intent.TaskID, &intent.Tool, &intent.Params, &intent.Anchors)
// Execute via norma SDK
result := norma.ExecuteTool(intent.Tool, intent.Params)
// Write facts to exploration graph AND update asset graph
tx.Exec(`
INSERT INTO facts (exploration_id, parent_intent_id, data, fact_type)
VALUES ($1, $2, $3, $4)
`, exploration.ID, intent.ID, result.Data, result.Type)
// Create anchors linking this fact to discovered assets
for _, asset := range result.DiscoveredAssets {
tx.Exec(`
INSERT INTO anchors (fact_id, asset_id) VALUES ($1, $2)
`, fact.ID, asset.ID)
}
The magic is that workers never coordinate directly. If Worker A discovers 15 new subdomains, it writes them to the asset graph and creates fact nodes anchored to those assets. This graph mutation triggers the planner to wake and generate new "port scan subdomain X" intents. Worker B claims one of those intents without knowing Worker A exists—the shared exploration graph IS the coordination mechanism. This eliminates message passing overhead but creates PostgreSQL transaction contention: 10+ concurrent workers spend more time waiting on locks than executing tools.
The dual-graph design solves the coverage problem elegantly. To visualize which endpoints haven't been tested for XSS, you query assets without anchors to XSS-related intents:
SELECT e.url, e.method, e.params
FROM endpoints e
WHERE e.company_id = $1
AND NOT EXISTS (
SELECT 1 FROM anchors a
JOIN intents i ON a.intent_id = i.id
WHERE a.asset_id = e.id
AND i.tool_name IN ('xsstrike', 'dalfox')
AND i.status = 'completed'
)
Bloodline tracking works similarly—every finding node has a parent fact, which has a parent intent, forming a chain back to the original goal. The frontend renders this as a dependency graph showing exactly how recon led to exploitation.
The human-in-the-loop approval system intercepts dangerous tool calls before execution. When a worker invokes sqlmap with --risk=3, the guard layer pauses the worker, streams an approval request via Server-Sent Events to the frontend, and blocks until a human clicks approve. The implementation uses Go channels and SSE:
func (g *Guard) RequestApproval(tool string, params map[string]any) error {
request := ApprovalRequest{
ID: uuid.New(),
Tool: tool,
Params: params,
Timestamp: time.Now(),
}
// Broadcast to all connected SSE clients
g.sseHub.Broadcast(request)
// Block on channel until approval received
select {
case decision := <-g.approvalChans[request.ID]:
if !decision.Approved {
return fmt.Errorf("tool execution denied: %s", decision.Reason)
}
return nil
case <-time.After(5 * time.Minute):
return fmt.Errorf("approval timeout")
}
}
This lets you run overnight scans with auto-approved reconnaissance but pause at exploitation boundaries—practical for compliance scenarios where you need audit trails of human authorization before touching production systems.
The Reporter agent handles finding deduplication using LLM-based semantic clustering rather than string matching. When workers discover potential SQLi in /api/users?id=1 and /api/posts?id=5, the Reporter analyzes both (same root cause, different endpoints, same privilege boundary) and groups them into a unified report. The grouping logic uses an LLM call to determine attack surface equivalence:
type FindingGroup struct {
RootCause string // "SQL injection via unparameterized query"
AffectedAssets []AssetID // All endpoints sharing the vulnerability class
UnifiedReport string // LLM-generated consolidated writeup
Evidence []Evidence // Aggregated HTTP requests, stack traces, etc.
}
func (r *Reporter) ClusterFindings(findings []Finding) []FindingGroup {
prompt := fmt.Sprintf(
"Group these findings by attack surface equivalence. "+
"Consider: same endpoint+param, same auth boundary, same root cause. "+
"Findings: %s",
json.Marshal(findings),
)
response := r.llm.Call(prompt)
return parseGroupsFromLLM(response)
}
When evidence changes (a worker confirms SQLi is exploitable, not just detected), the Reporter regenerates the unified report incorporating new proof-of-concept code. This prevents the "500 duplicate XSS findings" problem that plagues traditional scanners while maintaining full evidence chains.
Planner handoff persistence checkpoints the planner's multi-round todolist into PostgreSQL with version control. The todolist is a stable structure (item IDs survive reordering/renaming) that the planner maintains across planning rounds to remember attack chains:
CREATE TABLE planner_handoffs (
id SERIAL PRIMARY KEY,
task_id UUID NOT NULL,
version INT NOT NULL,
todolist JSONB NOT NULL, -- max 64 items
context TEXT, -- max 64KB
reference_ids UUID[], -- max 256 refs to intents/facts
created_at TIMESTAMP DEFAULT NOW(),
CONSTRAINT handoff_size_limit CHECK (octet_length(context) <= 65536)
);
Recovery injects the last successful snapshot when both save and restore toggles are enabled. The system retains only the last 20 versions per task to prevent unbounded growth, and enforces hard caps: 64KiB context, 64 todo items, 256 reference IDs. Exceeding limits rejects the entire handoff rather than truncating, which means complex tasks can fail to checkpoint and lose all planning context on crashes.
Gotcha
PostgreSQL becomes a scaling bottleneck fast. Every worker writes facts and anchors in transactions with row-level locks on the exploration and asset graphs. Around 10 concurrent workers, you'll spend more time waiting on locks than executing tools. The exploration graph isn't partitioned by task despite being conceptually isolated—all tasks contend on the same tables. There's no sharding, eventual consistency, or advisory lock optimization out of the box. If you need to scale beyond a dozen parallel agents, you're rewriting the storage layer.
Execution isolation is minimal to nonexistent. Skills run as shell scripts via bash -c in the backend process's namespace. A compromised LLM output or malicious skill can execute arbitrary commands, access database credentials from environment variables, or pivot into the Docker host. The approval gate helps but only for explicitly dangerous tools—an attacker could chain approved reconnaissance commands (curl, dig, nmap) into exfiltration or RCE without triggering review. The Docker deployment doesn't use rootless containers, seccomp profiles, or capability dropping by default. This is acceptable for internal authorized testing where you control the environment, but absolutely not for multi-tenant platforms or untrusted scopes.
Finding deduplication depends entirely on the Reporter agent and LLM availability. If Claude rate-limits you or the Reporter configuration breaks, new findings pile up as independent reports indefinitely. The batch "organize selected" job doesn't auto-retry on transient failures—you manually requeue work. Unified reports go stale when new evidence arrives but regeneration requires explicit user action, not automatic invalidation. And if you exceed planner handoff limits (64KiB context, 64 todos, 256 refs), the system rejects the checkpoint and you lose all planning state on the next crash. No graceful degradation, no automatic compression, no repair tooling.
Verdict
Use if: You're running authorized penetration tests against internal infrastructure and want autonomous LLM agents that track coverage, maintain attack bloodlines, and deduplicate findings semantically rather than by CVE string. The dual-graph architecture is genuinely novel—if you're building security automation workflows, study how ARTEX separates asset truth from exploration derivation. The Reporter's semantic clustering and retester's decoupled fix validation are production-worthy features missing from other LLM pentest tools. Perfect for red teams integrating with existing asset databases (ScopeSentry support is built-in) who can tolerate PostgreSQL contention limits and manual recovery on complex task failures.
Skip if: You need multi-tenant isolation, horizontal scaling beyond ~10 concurrent agents, or exactly-once execution guarantees for long-running campaigns. The shell-based skill execution is a security liability for untrusted scopes—an attacker compromising the LLM can trivially escape to the host. PostgreSQL locking will bottleneck you before you hit double-digit parallelism. Handoff persistence caps force manual intervention when planning context exceeds 64KiB. If you want battle-tested exploit modules and stable APIs, use Metasploit Framework. If you need deterministic vulnerability scanning at scale, combine Nuclei with ProjectDiscovery Cloud. ARTEX shines for exploratory autonomous testing where you own the target and can afford to lose planning state on crashes—not for hardened production deployments.