KeygraphHQ/shannon
TypeScript web-app pentester on Temporal; fixed recon, analysis, exploit and report phases run by LLM agents using source code and a live URL.
Overview
Shannon is a white-box pentester for web applications. It needs two inputs: a running URL and the application’s source repository. One command (npx @keygraph/shannon start -u <url> -r <repo>) starts a local Temporal server and a disposable worker container. Inside it, a fixed sequence of LLM agents reads the code, maps the live app in a browser, hunts for five OWASP-style vulnerability classes, tries to prove each candidate against the running target, and writes a report. The output is a workspace folder holding a Markdown and PDF report, report.json, and SARIF for exploit-mode runs.
Code orchestrates and the model works. The phases, the agents, which ones run in parallel, what each must deliver, retries and resume are all defined in a Temporal workflow. The LLM decides what to read, what to run in the shell and what to submit within each agent session. Agents run on the pi coding-agent harness (@earendil-works/pi-coding-agent) with one model for the whole scan, by default anthropic:claude-sonnet-4-6.
Its findings policy is strict: in exploit mode, a finding reaches the report only if an exploit agent marks it exploited (with impact, steps and evidence) or blocked. Its scope control for network targets, though, is prompt-only.
Architecture
flowchart TD
CLI["shannon CLI"] --> TMP["Temporal server (compose)"]
CLI --> WRK["Worker container (docker run --rm)"]
WRK --> WF["pentestPipeline workflow"]
WF --> PRE["Preflight + auth validation"]
WF --> PR["pre-recon (code)"]
PR --> RC["recon (code + browser)"]
RC --> V["5 vuln agents"]
WF --> CAP["Capella SAST (optional child)"]
V --> REC["Reconciliation per class"]
CAP --> REC
REC --> EX["Exploit agents + misc lane"]
EX --> REP["Report agent -> report.json"]
REP --> OUT["Markdown / PDF / SARIF renderer"]
| Component | Path | Role |
|---|---|---|
| CLI | apps/cli/src/ |
Setup wizard, start/stop, Temporal infra, worker container launch |
| Workflow | apps/worker/src/temporal/workflows.ts |
Phase ordering, parallel class lanes, retries, resume, terminal status |
| Activities | apps/worker/src/temporal/activities.ts |
Temporal activity wrappers for every agent and deterministic step |
| Agent registry | apps/worker/src/session-manager.ts |
Agent names, prompt templates, deliverables, prerequisites, browser sessions |
| Agent execution | apps/worker/src/services/agent-execution.ts |
Config, prompt, git checkpoint, pi session, validate, render, commit |
| pi executor | apps/worker/src/ai/pi/ |
Session creation, tool allowlist, task sub-agents, permission extension |
| Collectors | apps/worker/src/collectors/ |
Typed submit tools for recon, vuln queues, exploit verdicts, report findings |
| Reconciliation | apps/worker/src/ai/reconciliation/ |
Prepare, enrich, form, materialize and publish exploitation tasks per class |
| Capella | apps/worker/src/ai/sast/capella/ |
Optional agentic static analysis that feeds SARIF into reconciliation |
| Prompts | apps/worker/prompts/ |
Per-agent templates plus shared scope, rules and target partials |
How a request flows
- Launch.
spawnWorkerruns the worker image with--rmon theshannon-netnetwork. It mounts the repository read-only, with writable overlays for.shannon/deliverables, the scratchpad and Playwright state, and drops Docker’s seccomp profile so Chromium can sandbox itself (docker.ts). - Preflight. The workflow runs
runPreflightChecks: repository, config schema,code_pathrules, a credential probe and target reachability (preflight.ts). For Anthropic and OpenAI it also checks that the account is cleared for security workloads, so the scan does not fail halfway on a provider refusal (cyber-access-verification.ts). - Auth validation. If the config has an
authenticationblock, avalidate-authenticationagent logs in with the browser to prove that the login flow works before any analysis spend. - Recon.
pre-recon(code analysis) andreconrun in sequence. Agentic SAST (Capella) starts alongside them as a Temporal child workflow when it is enabled (workflows.ts). - Class lanes. Five lanes (injection, XSS, auth, authz, SSRF) run with at most five at once, and a miscellaneous exploit lane runs beside them. Each lane runs its vuln agent, waits for the Capella result, reconciles, checks the exploitation queue, and runs the exploit agent only if the queue is non-empty and exploit mode is on (workflows.ts).
- One agent run.
AgentExecutionService.executeloads the config and prompt, takes a git checkpoint of the deliverables repo, runsrunPiPromptwith a typed submit tool, then validates, renders and commits under a repo lock (agent-execution.ts). - Report. The report agent fills a structured
report.jsonthrough collector tools. A deterministic renderer turns it into Markdown, PDF (Typst) and SARIF. The run endscompleted, orpartialif any degradation reason was recorded.
Key components
Temporal workflow
pentestPipeline is the control plane. Activities get long timeouts and up to 50 attempts with 5- to 30-minute backoff. Configuration, credential, target and provider-refusal errors are marked non-retryable (workflows.ts). Resume reads session.json, restores the git checkpoint and runs only incomplete agents. A cancel from the CLI aborts the in-flight pi session through the activity’s cancellation signal.
Agent harness
Every agent gets pi’s built-in read, bash, edit, write, grep, find and ls. Browser agents also get a playwright-cli skill (pi-executor.ts). Custom tools add todo_write, glob, a task tool for child sessions and the phase’s submit tool. Sessions run in memory with pi’s retry settings and context compaction (pi-executor.ts). Child task sessions get only file tools and bash. They cannot spawn further children or submit structured output (task-tool.ts). Security tooling is whatever the model runs through bash, plus the browser.
Findings: queues, reconciliation, verdicts
Vuln agents must call submit_exploitation_queue, which is validated against per-class TypeBox schemas. Reconciliation then merges producer observations, optional SAST provenance and a model-driven task formation pass that groups observations into exploitation tasks. Task formation runs with read-only tools and is always denied .git, .shannon and .pi (task-formation-executor.ts). When the model’s output is rejected in an accepted way, it falls back to one task per observation. Exploit agents return verdicts through a typed collector: exploited requires severity, impact, ordered reproduction steps and evidence, and blocked requires a confidence rating. The exploit prompt’s rule is “Only EXPLOITED and BLOCKED_BY_SECURITY should be reported as findings” (_exploit-scope.txt). The verdict is still the exploit agent’s own claim. No separate step replays it. With exploit: false, queue entries are rendered straight into findings files, so that mode reports unproven candidates.
Scope and safety controls
- Code scope is enforced.
code_pathavoid rules become deny entries in thepi-permission-systemextension. These block file tools and recognised shell file operations, including in child sessions (permission-system.ts). - Network scope is not. The other rule types (
url_path,subdomain,domain,method,header,parameter; see the example config) and the free-textrules_of_engagementare rendered into prompts only. The exploit prompt confines testing to the target URL, forbids out-of-band callbacks and internal-network pivots, and asks for in-band proof. Nothing in the container or the tool layer blocks other hosts. - Preflight guards are one-shot. The target URL check rejects link-local (cloud metadata) addresses and pins DNS for that check, but loopback and RFC 1918 targets are explicitly allowed (preflight.ts). Agents’ later traffic is not filtered.
- Container posture. The repository is read-only, the container is removed after the run, and provider keys come in as environment variables and are held in an in-memory credential store (models.ts). Against that, the worker runs with
seccomp=unconfinedfor the whole container, and agents have unrestrictedbash. There is no human approval step during a run. - Responsible-use framing. The README warns that Shannon “actively executes exploits” and should run only against systems you own or are authorised to test, never production. That is guidance, not a control.
Extending it
- Prompts. Templates in
apps/worker/prompts/(per agent plusshared/partials) can be live-mounted from a source checkout. - Config. YAML validated by a closed JSON Schema:
authentication(form, SSO, API or basic login, TOTP, mailbox for magic links),rules.avoid/rules.focus,rules_of_engagement,exploit,agentic_sast, and report filters (min_severity,min_confidence,guidance,sarif). - Models.
SHANNON_AI_MODEL=<provider>:<model>. Anthropic, OpenAI, xAI and Bedrock are curated (models.ts). Any other pi-catalogue provider works throughSHANNON_AI_API_KEY, and--models-configdefines custom models or gateways. - New classes. Adding one means a new agent entry, prompt templates, a queue schema, a reconciliation class and a workflow lane. The pipeline is not plugin-shaped.
Running it
- Requirements are Docker, Node 18+ and a provider key.
npx @keygraph/shannon setupstores credentials, andstart -u <url> -r <repo> [--config file]runs a scan.--validate-authand--validate-modelrun only those checks.-w <name>names a workspace and resumes it if it exists.status,logsandstopmanage running scans. - The CLI brings up Temporal through Docker Compose and launches one worker container per scan with its own task queue.
- Use it in CI with SARIF upload. Results stay in a local workspace (
workspaces/<host>_<session>/), with internals under.shannon/.
Strengths and caveats
- Strength: deterministic orchestration. Phase order, parallelism, retries and resume live in Temporal, not in a model’s plan, so runs are reproducible in shape and survive crashes.
- Strength: proof-oriented reporting. In exploit mode, typed verdicts with required evidence and a deterministic renderer keep speculative findings out of the report.
- Strength: source plus runtime. Recon and analysis read the code, and the optional Capella SAST feeds SARIF provenance into exploitation tasks.
- Caveat: network scope is honour-system. URL and host avoid rules, rules of engagement and the in-band-only constraint are prompts. Enforce egress yourself if the target sits near anything sensitive.
- Caveat: narrow coverage by design. Exactly five classes plus a miscellaneous lane, web apps only, and a source repository is required.
- Caveat: one model for everything, no spend cap. Every agent, including task formation and Capella, uses the same model, and there is no budget limit. Long retry windows (up to 50 attempts) can stretch a failing run.
- Caveat: AGPL-3.0. Embedding Shannon in a hosted service carries copyleft obligations.
Sources: code at b9744f6, verified Q&A.
How it answers the Open-source AI pentest and offensive-security agents questions
Each answer was drafted by a code-reading agent at commit b9744f6. Its citations were checked mechanically. Compare with the other open-source ai pentest and offensive-security agents →
How is the agent loop and planning implemented?
answeredShannon uses a multi-agent, single-model, phase-based pipeline orchestrated by Temporal workflows (apps/worker/src/temporal/workflows.ts), not a dynamic model-driven loop. The pentestPipeline function runs five sequential phases: pre-recon, recon, vulnerability analysis (5 parallel agents: injection, xss, auth, authz, ssrf), exploitation (5 parallel agents + 1 miscellaneous), and reporting. Agents are defined declaratively in apps/worker/src/session-manager.ts with prompt templates, deliverables, and prerequisites — the workflow's explicit code structure enforces ordering and concurrency, not a model-authored plan. Each agent runs a single-turn-or-until-complete session via the pi-coding-agent harness (apps/worker/src/ai/pi/pi-executor.ts:runPiPrompt), which uses built-in tools (read, bash, edit, write, grep, find, ls) plus per-phase custom collectors. There is no iterative planning loop: the workflow calls activities (wrappers around AgentExecutionService.execute()) which handle the full lifecycle — load config, load prompt, git checkpoint, pi session, output validation, render deliverable, git commit (apps/worker/src/services/agent-execution.ts:151-401). Retry is owned by Temporal's activity retry policy: up to 50 attempts with exponential backoff (5 min initial, 30 min max) in production, with specific non-retryable error types (apps/worker/src/temporal/workflows.ts:92-106). Cancellation is handled via Temporal's cancellation scope with WAIT_CANCELLATION_COMPLETED for report operations, TRY_CANCEL for agents. Stop conditions: completed (all agents successful), partial (some degradation), failed (hard error), or cancelled (user-initiated). Capella (agentic SAST) runs as a Temporal child workflow overlapping the pentest, and its result is joined per-class before reconciliation. The miscellaneous exploitation lane runs concurrently with the five fixed classes. Resume is supported: detected via session.json, restoring git checkpoints and only running incomplete agents (apps/worker/src/temporal/workflows.ts:1296-1342).
How are security tools integrated and executed?
answeredSecurity tools are integrated through pi's custom tool system and the tool call mechanism from the pi-coding-agent harness. Every agent gets a standard set of built-in pi tools: read, bash, edit, write, grep, find, ls (apps/worker/src/ai/pi/pi-executor.ts:60). Three custom tools are added universally: todo_write (full-state-replace planning scratchpad for agent task tracking), glob (file pattern matching via zx's globby), and task (child-session delegation — spawns an independent sub-agent with its own tools for parallel sub-tasks, constrained to CHILD_TOOLS = ['read', 'grep', 'find', 'ls', 'write', 'bash'] with no recursive task or collector tools) (apps/worker/src/ai/pi/task-tool.ts:47, apps/worker/src/ai/pi/session-tools.ts:25-104). Per-phase collector tools are injected by the activity: vulnerability agents get submit_exploitation_queue which captures structured findings via TypeBox validation (apps/worker/src/ai/queue-schemas.ts:295-348), plus set_findings_summary, set_strategic_intelligence, set_safe_vectors, and set_blind_spots for the analysis deliverable (apps/worker/src/collectors/vuln-collector.ts:365-474). Recon and pre-recon phases have their own collector tools with TypeBox schemas in their respective apps/worker/src/collectors/ files. Browser automation is integrated for auth agents via the playwright-cli Skill (apps/worker/src/ai/pi/pi-executor.ts:62-77), injected only for browser-using agents (determined by apps/worker/src/utils/browser-agents.ts). Each agent is assigned to one of 6 isolated Playwright sessions via PLAYWRIGHT_SESSION_MAPPING to share browser state without interfering (apps/worker/src/session-manager.ts:177-206). Bash commands are bounded via a timeout extension (BASH_TIMEOUT_EXTENSION_DIR). Commands are built within the pi session environment; tools like save-deliverable and generate-totp are exposed as CLI scripts on the PATH. Output is parsed by the model as tool results, and structured payloads (exploitation queues, analysis sections) are captured via the collector tool's in-memory state before being written to disk by AgentExecutionService.
How are scope, authorization and dangerous actions controlled?
answeredScope, authorization, and dangerous actions are controlled through five layers of defense:
1. Preflight Validation (apps/worker/src/services/preflight.ts:534-579): Five sequential checks run before any agent starts: repo path existence and type, config file validation against a closed JSON Schema (additionalProperties: false), code_path rules matching real filesystem entries, credential validation via a minimal pi session probe, and target URL reachability (DNS + HTTP HEAD with pinned lookup to prevent DNS rebinding). The target URL check includes a link-local metadata blocklist (169.254.0.0/16, apps/worker/src/services/preflight.ts:67-79) to prevent scanning cloud metadata services.
2. Config-level Scoping (code_path avoid/focus rules): The YAML config supports rules.avoid and rules.focus with type code_path, which are glob patterns scoped to the target repository. Avoid rules are enforced via the @gotgenes/pi-permission-system extension (apps/worker/src/ai/pi/permission-system.ts): each avoid pattern is translated into a cross-cutting path deny entry that blocks file access (read/edit/write/grep/find/ls) AND recognized bash file operations (cat/grep/sed/…) on matching paths, across every tool and child task session. external_directory: allow keeps legitimate access outside the mounted working directory unblocked (apps/worker/src/ai/pi/permission-system.ts:78-93). Config values are also sanitized against dangerous patterns (path traversal, HTML/JS/data/file URLs, apps/worker/src/config-parser.ts:55-61).
3. Task Formation Boundaries (apps/worker/src/ai/pi/task-formation-executor.ts:43-44): Always-denied paths (.git, .shannon, .pi) block access to git history, scan internals, and credentials. Task formation agents are confined to read, grep, find, ls, glob, submit_result tools only — no bash or write access.
4. Container Isolation: Each scan runs in an ephemeral docker run --rm container with a per-invocation task queue, ensuring repo isolation and preventing cross-scan interference. The target repo is mounted read-only where appropriate.
5. Cancellation Signals: Temporal cancellation signals are threaded through agent sessions (apps/worker/src/ai/pi/pi-executor.ts:322-328), allowing UI/CLI cancel to abort in-flight agent sessions rather than waiting for timeouts.
code_path avoid rules are enforced (via pi-permission-system); URL/subdomain/domain/method/header/parameter rules and rules_of_engagement are prompt text only, the 169.254/16 block applies just to the preflight target check, and the worker runs with seccomp=unconfined on an unfiltered bridge network.How are findings validated and reported?
answeredFindings flow through a deterministic pipeline with no LLM involvement in validation or deduplication.
Capture: Vulnerability agents produce structured exploitation queues via the submit_exploitation_queue custom tool, which validates each entry against a TypeBox schema with per-class fields (injection, xss, auth, authz, ssrf, miscellaneous). The tool rejects out-of-namespace IDs and duplicate producer IDs before the data leaves the agent session (apps/worker/src/ai/queue-schemas.ts:313-348). Per-agent validators in session-manager.ts (createVulnValidator, createExploitValidator) check that the queue JSON file exists on disk.
Reconciliation (apps/worker/src/temporal/workflows.ts:619-702): After vuln analysis, each class undergoes a five-stage reconciliation pipeline: prepare (read durable producer observations), enrich (enrich observations with SAST provenance if available), form (Pass 1 model-based task formation — groups observations into exploitation tasks via a dedicated pi session; falls back to a singleton fallback when the model fails in an accepted way), materialize (merges enrichment into tasks), and publish (writes the reconciled queue as durable state). The form stage applies a FORBIDDEN_MODEL_KEYS blocklist to prevent internal IDs from leaking into published tasks (apps/worker/src/ai/reconciliation/form.ts:46-54).
Confirmation: Shannon does not use a second-agent review for confirmation. Instead, the exploitation phase runs a separate agent that independently attempts to exploit each finding from the reconciled queue. The exploitation agent produces *_exploitation_evidence.md files with proof-of-concept steps. The exploitation decision is based on whether the reconciled queue has vulnerabilities (apps/worker/src/temporal/workflows.ts:776-778).
Report Assembly (apps/worker/src/services/reporting.ts, apps/worker/src/services/report-renderer.ts): The report agent produces a structured report.json, which is then deterministically rendered (no LLM) into: Markdown (Security-Assessment-Report.md), PDF (via Typst from apps/worker/templates/typst/report.typ), and SARIF 2.1.0 (report.sarif, exploit runs only). Degradation is tracked via closed PartialReasonCodes (apps/worker/src/types/run-state.ts:30-39). When exploit=false, the findings renderer (apps/worker/src/services/findings-renderer.ts) deterministically converts each *_exploitation_queue.json into *_findings.md with no LLM in the loop. The final status is partial if any partial reasons were recorded, completed otherwise.
exploited verdict is the exploit agent's own schema-validated claim with no independent replay; only the final report rendering is deterministic.How is engagement state and knowledge kept across a long run?
answeredEngagement state is persisted through a file-based audit and checkpoint system, not an in-memory knowledge graph or database.
Run Directory Structure: Each scan writes to a workspace directory (workspaces/{hostname}_{sessionId}/). The top level holds the customer-facing report (PDF and Markdown); all internals — checkpoints, logs, prompts, agent deliverables, session.json, browser artifacts — live under a hidden .shannon/ subdirectory (apps/worker/src/audit/utils.ts:52-54).
Session State: session.json records the canonical workflow state including completed agents, expected agents, participating classes, report progress (stage, partial reasons, model checkpoint), and the miscellaneous exploitation outcome (apps/worker/src/audit/utils.ts:59-62). This is the file resume reads to determine which agents to skip.
Workflow Logger (apps/worker/src/audit/workflow-logger.ts): A combined workflow.log provides human-readable per-workflow logs backed by LogStream (apps/worker/src/audit/log-stream.ts). Every combined-log line is also projected into per-agent files under .shannon/agents/<slug>.log via actor-projection.ts. Capella stages get their own per-stage trace queues drained before the activity returns.
Git Checkpoints: After each agent completes successfully, its deliverable is git-committed to a deliverables repo within the workspace. On resume, the workflow restores the git checkpoint, removes incomplete agent deliverables, and only re-routes missing agents (apps/worker/src/temporal/workflows.ts:1318-1342). Rollback is handled by rollbackGitWorkspace in apps/worker/src/services/agent-execution.ts:410-415.
Reconciliation Artifact Store (apps/worker/src/ai/reconciliation/artifact-store.ts): A file-based store for reconciliation observations and tasks, referenced by opaque artifact refs passed between reconciliation stages. Each stage (prepare, enrich, form, materialize, publish) writes its output as a durable artifact.
No summarization or compaction of long sessions beyond pi's built-in context compaction (compaction: { enabled: true } in apps/worker/src/ai/pi/pi-executor.ts:344), which compresses the transcript when it approaches the context window. There is no knowledge graph, semantic memory store, or cross-session learning. Each task child session accumulates its usage separately; the parent totals its own plus child spend.
Which models are supported and how are cost and context managed?
answeredOne model runs the entire workflow, set via SHANNON_AI_MODEL=<provider>:<model-id>, defaulting to anthropic:claude-sonnet-4-6 (apps/worker/src/ai/models.ts:84). There is no per-role or per-phase model selection — every agent (pre-recon, recon, 5 vuln agents, 5+1 exploit agents, report agent) and the Capella SAST child workflow use the same model.
Supported Providers: Four curated providers with dedicated credential variables — anthropic (ANTHROPIC_API_KEY), openai (OPENAI_API_KEY), xai (XAI_API_KEY), amazon-bedrock (AWS_BEARER_TOKEN_BEDROCK + AWS_REGION). Any other pi-ai provider ID works via the generic SHANNON_AI_API_KEY env var. Bedrock is the only exception — it authenticates through AWS_ variables, not the generic key (apps/worker/src/ai/models.ts:54-81).
Model Resolution: Resolution happens at scan start via resolveModelSelection() (apps/worker/src/ai/models.ts:285-313), which parses the spec (splitting on the first colon only to preserve Bedrock IDs), collects credentials from env vars, creates a ModelRuntime via pi with network catalogue refresh (10s timeout, falls back to static), and looks up the model. A --models-config file overlays custom model definitions onto pi's catalogue via models.json. Custom definitions and the generic SHANNON_AI_BASE_URL for endpoint overrides are both supported. Credentials stay in an in-memory RuntimeCredentialStore — never written to disk (apps/worker/src/ai/models.ts:163-195). Pi auth.json reuse is supported via SHANNON_USE_PI_AUTH=1.
Thinking Level: Set to 'high' globally (apps/worker/src/ai/pi/thinking-level.ts), passed to every createAgentSession call for deeper analysis than pi's default (medium). The preflight credential probe and structured generation calls run without reasoning.
Cost and Context Management: pi's context compaction is enabled (compaction: { enabled: true }, apps/worker/src/ai/pi/pi-executor.ts:344) to guard against context window overflow on long agent runs. Usage (tokens, cost, cache hits) is tracked per agent and aggregated into OperationalMetrics for the final summary (apps/worker/src/temporal/workflows.ts:313-325). The task child-session tool accumulates its own usage and reports it back to the parent for accurate total spend (apps/worker/src/ai/pi/task-tool.ts:183-191). There is no user-configurable token or cost budget — the only cost control is Temporal's activity retry and the pipeline's stop conditions. pi's retry settings absorb provider-level transport faults (apps/worker/src/ai/pi/retry-settings.ts).