Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Agentic Pentesting — How I Built an AI System That Attacks Its Own Infrastructure

Most penetration testing today is still fundamentally manual. A skilled human runs a tool, reads the output, decides what to try next, and repeats. That loop works — but it doesn't scale, it doesn't run at 3am, and it ca

Most penetration testing today is still fundamentally manual. A skilled human runs a tool, reads the output, decides what to try next, and repeats. That loop works — but it doesn't scale, it doesn't run at 3am, and it can't simultaneously cover 400 attack surfaces across a distributed enterprise.
I built AI-enabled agentic cybersecurity and penetration testing platform to change that. Here's what I learned building an agentic AI system that autonomously plans, executes, and reports on offensive security operations — and why the hardest problem wasn't the AI.
The Architecture
Application runs on three layers:

  1. Reconnaissance Agent — handles asset discovery and attack surface mapping. It runs structured queries, parses results into a knowledge graph, and surfaces the highest-value targets: open ports, exposed services, misconfigured APIs, unpatched CVEs. Standard pentesting work, done continuously and without human initiation.
  2. RAG-Powered Exploit Planning — uses a retrieval-augmented generation pipeline built on a curated corpus of offensive security knowledge: CVE details, proof-of-concept references, attack chain patterns, MITRE ATT&CK techniques. When the recon agent surfaces a target, the planning agent retrieves the most relevant offensive context and constructs a proposed attack chain. The prompt engineering here matters enormously. You're asking an LLM to reason about how to compromise a system — which means guardrails, scope constraints, and audit trails aren't optional features. They're the architecture.
  3. Human-in-the-Loop Approval Gate — before any exploit fires, a human must approve it. The agent proposes; a person decides. This isn't a limitation — it's deliberate design. Autonomous execution of offensive security actions without human oversight is not responsible AI. The Stack • Python for all agent logic • LangChain for orchestration • pgvector for the RAG knowledge base • Docker + Kubernetes for containerised deployment • GitHub Actions for CI/CD • Cursor for AI-native development What Actually Surprised Me The LLM reasoning quality on attack chain construction was better than expected. What was harder was context management — keeping the agent's understanding of the target environment consistent across a long, multi-step assessment without hallucination. The solution: aggressive grounding. Every agent action is anchored to retrieved evidence from the RAG corpus, and the planning agent is explicitly instructed to cite its reasoning. Uncited assertions trigger a re-retrieval loop before proceeding. The Bigger Picture Enterprise security teams are overwhelmed. Threat surfaces are expanding faster than headcount can scale. Agentic AI for offensive security isn't a replacement for human expertise — it's a force multiplier that lets one skilled security engineer do the work of ten, while maintaining the judgment that only humans should exercise. About the author: Technology executive and hands-on engineer with 20+ years across enterprise IT, digital transformation, and AI delivery. Founder of an AI-enabled agentic cybersecurity and penetration testing platform. — Srinivasa Sitapavani Srikanth Mulakaluri
📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.