Pen Test Agent Design
Design blueprint for a custom autonomous penetration testing agent targeting a Next.js + ECS Fargate + ALB + Neon stack. Synthesized from AWS Security Agent patterns and PentAGI architecture. Implemented in repo:~/repos/pentest-agent.
Target Stack
Notable gap: no CloudFront/WAF — highest-priority finding before agent runs.
Agent Architecture
Loop: Plan → Probe → Report Supervisor + Specialists:reports/), not agent memory. Each specialist writes findings to reports/findings-<phase>.json. Supervisor synthesizes.
Domain Scope Model (from AWS Security Agent)
Three categories — never conflate:
This is a hard constraint in
config/config.yaml. Any tool call targeting outside the target allowlist is rejected before execution.
Safety Constraints (Always-On)
- Scope lock: allowlist enforced per tool call
- Rate cap: 10 rps default; agent cannot override
- Read-only by default:
POST/PUT/DELETEto data-mutating endpoints requires explicitdestructive: trueflag in tool schema - Test account only: dedicated
TEST_USERNAME+TEST_PASSWORDenv vars; real account never used
Two Phases
Phase 1 — Black-Box (HTTP surface)
No AWS credentials required. Simulates external attacker. Tools:nmap: port/service scan of ALBtestssl.sh: TLS config, cipher suite, HSTSnuclei: template-based web vuln scan (CVEs, misconfigs, exposures)- Custom HTTP probes: security headers, Next.js-specific paths (
/_next/static,/api/*enumeration), CORS config sqlmap: SQL injection against discovered form/API endpoints
Phase 2 — Gray-Box (AWS config inspection)
Requires read-only AWS credentials. Inspects infrastructure layer. Tools:Prowler: IAM misconfig, security group open ports, CloudTrail gaps, S3 public accessTrivy: ECR image CVE scanboto3: ECS task definition env vars (secrets in plaintext?), security group rules
Auth Flow
Agent authenticates with test account at session start:- POST to login endpoint with
TEST_USERNAME/TEST_PASSWORD - Extract session cookie or JWT from response
- Inject into all subsequent requests via
Authorization/Cookieheader - Test account has real-user permissions, isolated data
Tool Implementation Pattern
Each CLI wrapper follows this interface:Output
reports/findings.json: structured{vuln, severity, endpoint, evidence, remediation}reports/report.md: human-readable, generated from findings.jsonreport.mdingested into wiki aswiki/summaries/pentest-YYYY-MM-DD.md- Diff against previous
findings.jsonon subsequent runs
Progressive Deployment
Key Patterns Borrowed
- Scope split (target/accessible/out-of-scope): from Aws Security Agent
- Flow → Task → SubTask hierarchy: from PentAGI
- Chain summarization for long scans: from PentAGI — implement if web-agent context fills during nuclei scan
- Shared filesystem state: from Agent Harness
Related Pages
- Aws Security Agent — managed AWS pen test service; scope control reference
- PentAGI — OSS autonomous pen test system; architecture reference
- Agent Harness — supervisor pattern used here
- OWASP Security Checklist — vuln categories the agent tests against
- Tool Design for Agents — error message design for CLI wrappers