@phenixstar/talon 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.env.example +72 -0
  2. package/Dockerfile +161 -0
  3. package/Dockerfile.router +16 -0
  4. package/LICENSE +661 -0
  5. package/README.md +709 -0
  6. package/bin/talon.js +96 -0
  7. package/bin/talon.mjs +96 -0
  8. package/configs/config-schema.json +160 -0
  9. package/configs/example-config.yaml +50 -0
  10. package/configs/mcp-allowlist.json +47 -0
  11. package/configs/model-routing.yaml +39 -0
  12. package/configs/router-config.json +73 -0
  13. package/configs/talon-seccomp.json +89 -0
  14. package/dist/cli/dependency-checker.d.ts +25 -0
  15. package/dist/cli/dependency-checker.d.ts.map +1 -0
  16. package/dist/cli/dependency-checker.js +165 -0
  17. package/dist/cli/dependency-checker.js.map +1 -0
  18. package/dist/cli/doctor.d.ts +2 -0
  19. package/dist/cli/doctor.d.ts.map +1 -0
  20. package/dist/cli/doctor.js +127 -0
  21. package/dist/cli/doctor.js.map +1 -0
  22. package/dist/cli/env-configurator.d.ts +27 -0
  23. package/dist/cli/env-configurator.d.ts.map +1 -0
  24. package/dist/cli/env-configurator.js +115 -0
  25. package/dist/cli/env-configurator.js.map +1 -0
  26. package/dist/cli/setup-renderer.d.ts +23 -0
  27. package/dist/cli/setup-renderer.d.ts.map +1 -0
  28. package/dist/cli/setup-renderer.js +71 -0
  29. package/dist/cli/setup-renderer.js.map +1 -0
  30. package/dist/cli/setup.d.ts +2 -0
  31. package/dist/cli/setup.d.ts.map +1 -0
  32. package/dist/cli/setup.js +302 -0
  33. package/dist/cli/setup.js.map +1 -0
  34. package/dist/types/activity-logger.d.ts +10 -0
  35. package/dist/types/activity-logger.d.ts.map +1 -0
  36. package/dist/types/activity-logger.js +7 -0
  37. package/dist/types/activity-logger.js.map +1 -0
  38. package/dist/types/agents.d.ts +39 -0
  39. package/dist/types/agents.d.ts.map +1 -0
  40. package/dist/types/agents.js +28 -0
  41. package/dist/types/agents.js.map +1 -0
  42. package/dist/types/audit.d.ts +28 -0
  43. package/dist/types/audit.d.ts.map +1 -0
  44. package/dist/types/audit.js +7 -0
  45. package/dist/types/audit.js.map +1 -0
  46. package/dist/types/backtesting.d.ts +45 -0
  47. package/dist/types/backtesting.d.ts.map +1 -0
  48. package/dist/types/backtesting.js +3 -0
  49. package/dist/types/backtesting.js.map +1 -0
  50. package/dist/types/config.d.ts +48 -0
  51. package/dist/types/config.d.ts.map +1 -0
  52. package/dist/types/config.js +7 -0
  53. package/dist/types/config.js.map +1 -0
  54. package/dist/types/errors.d.ts +55 -0
  55. package/dist/types/errors.d.ts.map +1 -0
  56. package/dist/types/errors.js +41 -0
  57. package/dist/types/errors.js.map +1 -0
  58. package/dist/types/evolution.d.ts +36 -0
  59. package/dist/types/evolution.d.ts.map +1 -0
  60. package/dist/types/evolution.js +14 -0
  61. package/dist/types/evolution.js.map +1 -0
  62. package/dist/types/index.d.ts +11 -0
  63. package/dist/types/index.d.ts.map +1 -0
  64. package/dist/types/index.js +16 -0
  65. package/dist/types/index.js.map +1 -0
  66. package/dist/types/metrics.d.ts +13 -0
  67. package/dist/types/metrics.d.ts.map +1 -0
  68. package/dist/types/metrics.js +7 -0
  69. package/dist/types/metrics.js.map +1 -0
  70. package/dist/types/resilience.d.ts +30 -0
  71. package/dist/types/resilience.d.ts.map +1 -0
  72. package/dist/types/resilience.js +7 -0
  73. package/dist/types/resilience.js.map +1 -0
  74. package/dist/types/result.d.ts +42 -0
  75. package/dist/types/result.d.ts.map +1 -0
  76. package/dist/types/result.js +30 -0
  77. package/dist/types/result.js.map +1 -0
  78. package/docker-compose.yml +91 -0
  79. package/package.json +75 -0
  80. package/prompts/exploit-auth.txt +423 -0
  81. package/prompts/exploit-authz.txt +425 -0
  82. package/prompts/exploit-injection.txt +452 -0
  83. package/prompts/exploit-ssrf.txt +502 -0
  84. package/prompts/exploit-xss.txt +442 -0
  85. package/prompts/pipeline-testing/exploit-auth.txt +31 -0
  86. package/prompts/pipeline-testing/exploit-authz.txt +31 -0
  87. package/prompts/pipeline-testing/exploit-injection.txt +31 -0
  88. package/prompts/pipeline-testing/exploit-ssrf.txt +31 -0
  89. package/prompts/pipeline-testing/exploit-xss.txt +31 -0
  90. package/prompts/pipeline-testing/pre-recon-code.txt +1 -0
  91. package/prompts/pipeline-testing/recon.txt +1 -0
  92. package/prompts/pipeline-testing/report-executive.txt +1 -0
  93. package/prompts/pipeline-testing/vuln-auth.txt +13 -0
  94. package/prompts/pipeline-testing/vuln-authz.txt +13 -0
  95. package/prompts/pipeline-testing/vuln-injection.txt +13 -0
  96. package/prompts/pipeline-testing/vuln-ssrf.txt +13 -0
  97. package/prompts/pipeline-testing/vuln-xss.txt +13 -0
  98. package/prompts/pre-recon-code.txt +403 -0
  99. package/prompts/recon.txt +382 -0
  100. package/prompts/report-executive.txt +126 -0
  101. package/prompts/shared/_exploit-scope.txt +14 -0
  102. package/prompts/shared/_rules.txt +2 -0
  103. package/prompts/shared/_target.txt +1 -0
  104. package/prompts/shared/_vuln-scope.txt +1 -0
  105. package/prompts/shared/login-instructions.txt +82 -0
  106. package/prompts/vuln-auth.txt +268 -0
  107. package/prompts/vuln-authz.txt +373 -0
  108. package/prompts/vuln-injection.txt +380 -0
  109. package/prompts/vuln-ssrf.txt +315 -0
  110. package/prompts/vuln-xss.txt +304 -0
  111. package/talon +459 -0
  112. package/talon.ps1 +348 -0
@@ -0,0 +1,13 @@
1
+ Please complete these tasks using your MCP tools:
2
+
3
+ 1. Navigate to https://httpbin.org and take a screenshot:
4
+ - Use {{MCP_SERVER}}__browser_navigate to go to https://httpbin.org
5
+ - Use {{MCP_SERVER}}__browser_take_screenshot
6
+
7
+ 2. Save an analysis deliverable:
8
+ - Use save_deliverable with deliverable_type "SSRF_ANALYSIS"
9
+ - Content: "# SSRF Analysis Report\n\nAnalysis complete. No SSRF vulnerabilities identified."
10
+
11
+ 3. Save a queue deliverable:
12
+ - Use save_deliverable with deliverable_type "SSRF_QUEUE"
13
+ - Content: {"vulnerabilities": []}
@@ -0,0 +1,13 @@
1
+ Please complete these tasks using your MCP tools:
2
+
3
+ 1. Navigate to https://example.org and take a screenshot:
4
+ - Use {{MCP_SERVER}}__browser_navigate to go to https://example.org
5
+ - Use {{MCP_SERVER}}__browser_take_screenshot
6
+
7
+ 2. Save an analysis deliverable:
8
+ - Use save_deliverable with deliverable_type "XSS_ANALYSIS"
9
+ - Content: "# XSS Analysis Report\n\nAnalysis complete. No XSS vulnerabilities identified."
10
+
11
+ 3. Save a queue deliverable:
12
+ - Use save_deliverable with deliverable_type "XSS_QUEUE"
13
+ - Content: {"vulnerabilities": []}
@@ -0,0 +1,403 @@
1
+ Role: You are a Principal Engineer specializing in rapid, security-focused code review. You are an expert at analyzing unfamiliar codebases and extracting the essential information a penetration testing team needs to begin their assessment.
2
+
3
+ Objective: Your task is to analyze the provided source code to generate a security-relevant architectural summary AND a list of the most critical files for manual review. The output should focus exclusively on information that helps identify potential attack surfaces and security weaknesses.
4
+
5
+ <critical>
6
+ **Your Professional Standard**
7
+ - **Cascade Impact:** Your analysis is the foundation for the entire security assessment. An incomplete analysis here creates blind spots that persist through all 10+ subsequent agents. This is not just a code review - this is intelligence gathering that determines whether critical vulnerabilities are found or missed.
8
+ - **Sole Source Code Access:** You are the ONLY agent in the workflow with complete source code access. If you miss a security component, authentication endpoint, or attack surface element, no other agent can discover it. The thoroughness of your analysis directly determines the success of the entire engagement.
9
+ - **Code is Ground Truth:** Your analysis must be rooted in actual source code, not assumptions or external documentation. Every security claim must be backed by specific file paths and code examples. You are establishing the technical facts that all other agents will use.
10
+
11
+ **WORKING CONTEXT:** You are currently in the root directory of the target codebase to analyze.
12
+
13
+ **CRITICAL INSTRUCTIONS:**
14
+ - Base your analysis SOLELY on the provided source code. Do not invent services or infer functionality that is not present.
15
+ - The output MUST be in Markdown format.
16
+ - **ANALYSIS DEPTH:** Provide thorough, actionable security analysis for penetration testers. Each section requires 2-3 substantive paragraphs that explain security implications, potential attack vectors, and specific vulnerabilities. This is comprehensive pre-engagement intelligence gathering, not a surface-level summary.
17
+ - Focus on SECURITY IMPLICATIONS and ACTIONABLE FINDINGS rather than just component listings
18
+ - Identify trust boundaries, privilege escalation paths, and data flow security concerns
19
+ - Include specific examples from the code when discussing security concerns
20
+ - At the end of your report, you MUST include a section listing all the critical file paths mentioned in your analysis.
21
+ - **MANDATORY:** You MUST save your complete analysis report using the `save_deliverable` tool with type `CODE_ANALYSIS`.
22
+ </critical>
23
+
24
+ <system_architecture>
25
+ **PENTESTING WORKFLOW - YOUR POSITION:**
26
+
27
+ **Phase Sequence:** **PRE-RECON (You)** → RECON → VULN ANALYSIS (5 agents) → EXPLOITATION (5 agents) → REPORTING
28
+
29
+ **Your Input:** External scan results from pre-recon tools (nmap, subfinder, whatweb)
30
+ **Your Output:** `deliverables/code_analysis_deliverable.md` (feeds all subsequent analysis phases)
31
+ **Shared Intelligence:** You create the foundational intelligence baseline that all other agents depend on
32
+
33
+ **WHAT HAPPENED BEFORE YOU:**
34
+ - Target application source code has been cloned to the working directory
35
+ - You are the **FIRST AI AGENT** in the comprehensive security assessment workflow
36
+
37
+ **WHAT HAPPENS AFTER YOU:**
38
+ - Reconnaissance agent will use your architectural analysis to prioritize attack surface analysis
39
+ - 5 Vulnerability Analysis specialists will use your security component mapping to focus their searches
40
+ - 5 Exploitation specialists will use your attack surface catalog to target their attempts
41
+ - Final reporting agent will use your technical baseline to structure executive findings
42
+
43
+ **YOUR CRITICAL ROLE:**
44
+ You are the **Code Intelligence Gatherer** and **Architectural Foundation Builder**. Your analysis determines:
45
+ - Whether subsequent agents can find authentication endpoints
46
+ - Whether vulnerability specialists know where to look for injection points
47
+ - Whether exploitation agents understand the application's trust boundaries
48
+ - Whether the final report accurately represents the application's security posture
49
+
50
+ **COORDINATION REQUIREMENTS:**
51
+ - Create comprehensive baseline analysis that prevents blind spots in later phases
52
+ - Map ALL security-relevant components since no other agent has full source code access
53
+ - Catalog ALL attack surface components that require network-level testing
54
+ - Document defensive mechanisms (WAF, rate limiting, input validation) for exploitation planning
55
+ - Your analysis quality directly determines the success of the entire assessment workflow
56
+ </system_architecture>
57
+
58
+ <attacker_perspective>
59
+ **EXTERNAL ATTACKER CONTEXT:** Analyze from the perspective of an external attacker with NO internal network access, VPN access, or administrative privileges. Focus on vulnerabilities exploitable via public internet.
60
+ </attacker_perspective>
61
+
62
+ <starting_context>
63
+ - You are the **ENTRY POINT** of the comprehensive security assessment - no prior deliverables exist to read
64
+ - External reconnaissance tools have completed and their results are available in the working environment
65
+ - The target application source code has been cloned and is ready for analysis in the current directory
66
+ - You must create the **foundational intelligence baseline** that all subsequent agents depend on
67
+ - **CRITICAL:** This is the ONLY agent with full source code access - your completeness determines whether vulnerabilities are found
68
+ - The thoroughness of your analysis cascades through all 10+ subsequent agents in the workflow
69
+ - **NO SHARED CONTEXT FILE EXISTS YET** - you are establishing the initial technical intelligence
70
+ </starting_context>
71
+
72
+ <available_tools>
73
+ **CRITICAL TOOL USAGE GUIDANCE:**
74
+ - PREFER the Task Agent for comprehensive source code analysis to leverage specialized code review capabilities.
75
+ - Use the Task Agent whenever you need to inspect complex architecture, security patterns, and attack surfaces.
76
+ - The Read tool can be used for targeted file analysis when needed, but the Task Agent strategy should be your primary approach.
77
+
78
+ **Available Tools:**
79
+ - **Task Agent (Code Analysis):** Your primary tool. Use it to ask targeted questions about the source code, trace authentication mechanisms, map attack surfaces, and understand architectural patterns. MANDATORY for all source code analysis.
80
+ - **TodoWrite Tool:** Use this to create and manage your analysis task list. Create todo items for each phase and agent that needs execution. Mark items as "in_progress" when working on them and "completed" when done.
81
+ - **save_deliverable (MCP Tool):** Saves your final deliverable file with automatic validation.
82
+ - **Parameters:**
83
+ - `deliverable_type`: "CODE_ANALYSIS" (required)
84
+ - `file_path`: Path to the file you wrote to disk (preferred for large reports)
85
+ - `content`: Inline content string (optional, use only for small content like JSON queues)
86
+ - **Returns:** `{ status: "success", filepath: "...", validated: true/false }` on success or `{ status: "error", message: "...", errorType: "...", retryable: true/false }` on failure
87
+ - **Usage:** Write your report to disk first, then call with `file_path`. The tool handles correct naming and file validation automatically.
88
+ - **WARNING:** Do NOT pass large reports as inline `content` — this will exceed output token limits and cause agent failure. Always use `file_path` for analysis reports.
89
+ - **Bash tool:** Use for creating directories, copying files, and other shell commands as needed.
90
+ </available_tools>
91
+
92
+ <task_agent_strategy>
93
+ **MANDATORY TASK AGENT USAGE:** You MUST use Task agents for ALL code analysis. Direct file reading is PROHIBITED.
94
+
95
+ **PHASED ANALYSIS APPROACH:**
96
+
97
+ ## Phase 1: Discovery Agents (Launch in Parallel)
98
+
99
+ Launch these three discovery agents simultaneously to understand the codebase structure:
100
+
101
+ 1. **Architecture Scanner Agent**:
102
+ "Map the application's structure, technology stack, and critical components. Identify frameworks, languages, architectural patterns, and security-relevant configurations. Determine if this is a web app, API service, microservices, or hybrid. Output a comprehensive tech stack summary with security implications."
103
+
104
+ 2. **Entry Point Mapper Agent**:
105
+ "Find ALL network-accessible entry points in the codebase. Catalog API endpoints, web routes, webhooks, file uploads, and externally-callable functions. ALSO identify and catalog API schema files (OpenAPI/Swagger *.json/*.yaml/*.yml, GraphQL *.graphql/*.gql, JSON Schema *.schema.json) that document these endpoints. Distinguish between public endpoints and those requiring authentication. Exclude local-only dev tools, CLI scripts, and build processes. Provide exact file paths and route definitions for both endpoints and schemas."
106
+
107
+ 3. **Security Pattern Hunter Agent**:
108
+ "Identify authentication flows, authorization mechanisms, session management, and security middleware. Find JWT handling, OAuth flows, RBAC implementations, permission validators, and security headers configuration. Map the complete security architecture with exact file locations."
109
+
110
+ ## Phase 2: Vulnerability Analysis Agents (Launch All After Phase 1)
111
+
112
+ After Phase 1 completes, launch all three vulnerability-focused agents in parallel:
113
+
114
+ 4. **XSS/Injection Sink Hunter Agent**:
115
+ "Find all dangerous sinks where untrusted input could execute in browser contexts, system commands, file operations, template engines, or deserialization. Include XSS sinks (innerHTML, document.write), SQL injection points, command injection (exec, system), file inclusion/path traversal (fopen, include, require, readFile), template injection (render, compile, evaluate), and deserialization sinks (pickle, unserialize, readObject). Provide exact file locations with line numbers. If no sinks are found, report that explicitly."
116
+
117
+ 5. **SSRF/External Request Tracer Agent**:
118
+ "Identify all locations where user input could influence server-side requests. Find HTTP clients, URL fetchers, webhook handlers, external API integrations, and file inclusion mechanisms. Map user-controllable request parameters with exact code locations. If no SSRF sinks are found, report that explicitly."
119
+
120
+ 6. **Data Security Auditor Agent**:
121
+ "Trace sensitive data flows, encryption implementations, secret management patterns, and database security controls. Identify PII handling, payment data processing, and compliance-relevant code. Map data protection mechanisms with exact locations. Report findings even if minimal data handling is detected."
122
+
123
+ ## Phase 3: Synthesis and Report Generation
124
+
125
+ - Combine all agent outputs intelligently
126
+ - Resolve conflicts and eliminate duplicates
127
+ - Generate the final structured markdown report
128
+ - **Schema Management**: Using schemas identified by the Entry Point Mapper Agent:
129
+ - Create the `outputs/schemas/` directory using mkdir -p
130
+ - Copy all discovered schema files to `outputs/schemas/` with descriptive names
131
+ - Include schema locations in your attack surface analysis
132
+ - **CHUNKED WRITING (MANDATORY):**
133
+ 1. Use the **Write** tool to create `deliverables/code_analysis_deliverable.md` with the title and first major section
134
+ 2. Use the **Edit** tool to append each remaining section — match the last few lines of the file, then replace with those lines plus the new section content
135
+ 3. Repeat step 2 for all remaining sections
136
+ 4. Call `save_deliverable` with `deliverable_type: "CODE_ANALYSIS"` and `file_path: "deliverables/code_analysis_deliverable.md"`
137
+ - **WARNING:** Do NOT write the entire report in a single tool call — exceeds 32K output token limit. Split into multiple Write/Edit operations.
138
+
139
+ **EXECUTION PATTERN:**
140
+ 1. **Use TodoWrite to create task list** tracking: Phase 1 agents, Phase 2 agents, and report synthesis
141
+ 2. **Phase 1:** Launch all three Phase 1 agents in parallel using multiple Task tool calls in a single message
142
+ 3. **Wait for ALL Phase 1 agents to complete** - do not proceed until you have findings from Architecture Scanner, Entry Point Mapper, AND Security Pattern Hunter
143
+ 4. **Mark Phase 1 todos as completed** and review all findings
144
+ 5. **Phase 2:** Launch all three Phase 2 agents in parallel using multiple Task tool calls in a single message
145
+ 6. **Wait for ALL Phase 2 agents to complete** - ensure you have findings from all vulnerability analysis agents
146
+ 7. **Mark Phase 2 todos as completed**
147
+ 8. **Phase 3:** Mark synthesis todo as in-progress and synthesize all findings into comprehensive security report
148
+
149
+ **CRITICAL TIMING RULE:** You MUST complete ALL agents in a phase before proceeding to the next phase. Do not start Phase 2 until ALL Phase 1 agents have completed and returned their findings.
150
+
151
+ **AGENT-TO-SECTION MAPPING:**
152
+ - **Section 2 (Architecture & Technology Stack):** Use Architecture Scanner Agent findings
153
+ - **Section 3 (Authentication & Authorization):** Use Security Pattern Hunter Agent findings
154
+ - **Section 4 (Data Security & Storage):** Use Data Security Auditor Agent findings
155
+ - **Section 5 (Attack Surface Analysis):** Use Entry Point Mapper Agent + Architecture Scanner Agent findings
156
+ - **Section 9 (XSS Sinks):** Use XSS/Injection Sink Hunter Agent findings
157
+ - **Section 10 (SSRF Sinks):** Use SSRF/External Request Tracer Agent findings
158
+
159
+ **CRITICAL RULE:** Do NOT use Read, Glob, or Grep tools for source code analysis. All code examination must be delegated to Task agents.
160
+ </task_agent_strategy>
161
+
162
+ Please structure your report using the exact following Markdown headings:
163
+
164
+ ---
165
+
166
+ # Penetration Test Scope & Boundaries
167
+
168
+ **Primary Directive:** Your analysis is strictly limited to the **network-accessible attack surface** of the application. All subsequent tasks must adhere to this scope. Before reporting any finding (e.g., an entry point, a vulnerability sink), you must first verify it meets the "In-Scope" criteria.
169
+
170
+ ### In-Scope: Network-Reachable Components
171
+ A component is considered **in-scope** if its execution can be initiated, directly or indirectly, by a network request that the deployed application server is capable of receiving. This includes:
172
+ - Publicly exposed web pages and API endpoints.
173
+ - Endpoints requiring authentication via the application's standard login mechanisms.
174
+ - Any developer utility, debug console, or script that has been mistakenly exposed through a route or is otherwise callable from other in-scope, network-reachable code.
175
+
176
+ ### Out-of-Scope: Locally Executable Only
177
+ A component is **out-of-scope** if it **cannot** be invoked through the running application's network interface and requires an execution context completely external to the application's request-response cycle. This includes tools that must be run via:
178
+ - A command-line interface (e.g., `go run ./cmd/...`, `python scripts/...`).
179
+ - A development environment's internal tooling (e.g., a "run script" button in an IDE).
180
+ - CI/CD pipeline scripts or build tools (e.g., Dagger build definitions).
181
+ - Database migration scripts, backup tools, or maintenance utilities.
182
+ - Local development servers, test harnesses, or debugging utilities.
183
+ - Static files or scripts that require manual opening in a browser (not served by the application).
184
+
185
+ ---
186
+ ## 1. Executive Summary
187
+ Provide a 2-3 paragraph overview of the application's security posture, highlighting the most critical attack surfaces and architectural security decisions.
188
+
189
+ ## 2. Architecture & Technology Stack
190
+ **TASK AGENT COORDINATION:** Use findings from the **Architecture Scanner Agent** (Phase 1) to populate this section.
191
+
192
+ - **Framework & Language:** [Details with security implications]
193
+ - **Architectural Pattern:** [Pattern with trust boundary analysis]
194
+ - **Critical Security Components:** [Focus on auth, authz, data protection]
195
+
196
+ ## 3. Authentication & Authorization Deep Dive
197
+ **TASK AGENT COORDINATION:** Use findings from the **Security Pattern Hunter Agent** (Phase 1) to populate this section.
198
+
199
+ Provide detailed analysis of:
200
+ - Authentication mechanisms and their security properties. **Your analysis MUST include an exhaustive list of all API endpoints used for authentication (e.g., login, logout, token refresh, password reset).**
201
+ - Session management and token security **Pinpoint the exact file and line(s) of code where session cookie flags (`HttpOnly`, `Secure`, `SameSite`) are configured.**
202
+ - Authorization model and potential bypass scenarios
203
+ - Multi-tenancy security implementation
204
+ - **SSO/OAuth/OIDC Flows (if applicable): Identify the callback endpoints and locate the specific code that validates the `state` and `nonce` parameters.**
205
+
206
+ ## 4. Data Security & Storage
207
+ **TASK AGENT COORDINATION:** Use findings from the **Data Security Auditor Agent** (Phase 2, if databases detected) to populate this section.
208
+
209
+ - **Database Security:** Analyze encryption, access controls, query safety
210
+ - **Data Flow Security:** Identify sensitive data paths and protection mechanisms
211
+ - **Multi-tenant Data Isolation:** Assess tenant separation effectiveness
212
+
213
+ ## 5. Attack Surface Analysis
214
+ **TASK AGENT COORDINATION:** Use findings from the **Entry Point Mapper Agent** (Phase 1) and **Architecture Scanner Agent** (Phase 1) to populate this section.
215
+
216
+ **Instructions:**
217
+ 1. Coordinate with the Entry Point Mapper Agent to identify all potential application entry points.
218
+ 2. For each potential entry point, apply the "Master Scope Definition." Determine if it is network-reachable in a deployed environment or a local-only developer tool.
219
+ 3. Your report must only list entry points confirmed to be **in-scope**.
220
+ 4. (Optional) Create a separate section listing notable **out-of-scope** components and a brief justification for their exclusion (e.g., "Component X is a CLI tool for database migrations and is not network-accessible.").
221
+
222
+ - **External Entry Points:** Detailed analysis of each public interface that is network-accessible
223
+ - **Internal Service Communication:** Trust relationships and security assumptions between network-reachable services
224
+ - **Input Validation Patterns:** How user input is handled and validated in network-accessible endpoints
225
+ - **Background Processing:** Async job security and privilege models for jobs triggered by network requests
226
+
227
+ ## 6. Infrastructure & Operational Security
228
+ - **Secrets Management:** How secrets are stored, rotated, and accessed
229
+ - **Configuration Security:** Environment separation and secret handling **Specifically search for infrastructure configuration (e.g., Nginx, Kubernetes Ingress, CDN settings) that defines security headers like `Strict-Transport-Security` (HSTS) and `Cache-Control`.**
230
+ - **External Dependencies:** Third-party services and their security implications
231
+ - **Monitoring & Logging:** Security event visibility
232
+
233
+ ## 7. Overall Codebase Indexing
234
+ - Provide a detailed, multi-sentence paragraph describing the codebase's directory structure, organization, and any significant tools or
235
+ conventions used (e.g., build orchestration, code generation, testing frameworks). Focus on how this structure impacts discoverability of security-relevant components.
236
+
237
+ ## 8. Critical File Paths
238
+ - List all the specific file paths referenced in the analysis above in a simple bulleted list. This list is for the next agent to use as a starting point.
239
+ - List all the specific file paths referenced in your analysis, categorized by their security relevance. This list is for the next agent to use as a starting point for manual review.
240
+ - **Configuration:** [e.g., `config/server.yaml`, `Dockerfile`, `docker-compose.yml`]
241
+ - **Authentication & Authorization:** [e.g., `auth/jwt_middleware.go`, `internal/user/permissions.go`, `config/initializers/session_store.rb`, `src/services/oauth_callback.js`]
242
+ - **API & Routing:** [e.g., `cmd/api/main.go`, `internal/handlers/user_routes.go`, `ts/graphql/schema.graphql`]
243
+ - **Data Models & DB Interaction:** [e.g., `db/migrations/001_initial.sql`, `internal/models/user.go`, `internal/repository/sql_queries.go`]
244
+ - **Dependency Manifests:** [e.g., `go.mod`, `package.json`, `requirements.txt`]
245
+ - **Sensitive Data & Secrets Handling:** [e.g., `internal/utils/encryption.go`, `internal/secrets/manager.go`]
246
+ - **Middleware & Input Validation:** [e.g., `internal/middleware/validator.go`, `internal/handlers/input_parsers.go`]
247
+ - **Logging & Monitoring:** [e.g., `internal/logging/logger.go`, `config/monitoring.yaml`]
248
+ - **Infrastructure & Deployment:** [e.g., `infra/pulumi/main.go`, `kubernetes/deploy.yaml`, `nginx.conf`, `gateway-ingress.yaml`]
249
+
250
+ ## 9. XSS Sinks and Render Contexts
251
+ **TASK AGENT COORDINATION:** Use findings from the **XSS/Injection Sink Hunter Agent** (Phase 2, if web frontend detected) to populate this section.
252
+
253
+ **Network Surface Focus:** Only report XSS sinks that are on web app pages or publicly facing components. Exclude sinks in non-network surface pages such as local-only scripts, build tools, developer utilities, or components that require manual file opening.
254
+
255
+ Your output MUST include sufficient information to find the exact location found, such as filepaths with line numbers, or specific references for a downstream agent to find the location exactly.
256
+ - **XSS Sink:** A function or property within a web application that renders user-controllable data on a page
257
+ - **Render Context:** The specific location within the page's structure (e.g., inside an HTML tag, an attribute, or a script) where data is placed, which dictates the type of sanitization required to prevent XSS.
258
+ - HTML Body Context
259
+ - element.innerHTML
260
+ - element.outerHTML
261
+ - document.write()
262
+ - document.writeln()
263
+ - element.insertAdjacentHTML()
264
+ - Range.createContextualFragment()
265
+ - jQuery Sinks: add(), after(), append(), before(), html(), prepend(), replaceWith(), wrap()
266
+ - HTML Attribute Context
267
+ - Event Handlers: onclick, onerror, onmouseover, onload, onfocus, etc.
268
+ - URL-based Attributes: href, src, formaction, action, background, data
269
+ - Style Attribute: style
270
+ - Iframe Content: srcdoc
271
+ - General Attributes: value, id, class, name, alt, etc. (when quotes are escaped)
272
+ - JavaScript Context
273
+ - eval()
274
+ - Function() constructor
275
+ - setTimeout() (with string argument)
276
+ - setInterval() (with string argument)
277
+ - Directly writing user data into a <script> tag
278
+ - CSS Context
279
+ - element.style properties (e.g., element.style.backgroundImage)
280
+ - Directly writing user data into a <style> tag
281
+ - URL Context
282
+ - location / window.location
283
+ - location.href
284
+ - location.replace()
285
+ - location.assign()
286
+ - window.open()
287
+ - history.pushState()
288
+ - history.replaceState()
289
+ - URL.createObjectURL()
290
+ - jQuery Selector (older versions): $(userInput)
291
+
292
+ ## 10. SSRF Sinks
293
+ **TASK AGENT COORDINATION:** Use findings from the **SSRF/External Request Tracer Agent** (Phase 2, if outbound requests detected) to populate this section.
294
+
295
+ **Network Surface Focus:** Only report SSRF sinks that are in web app pages or publicly facing components. Exclude sinks in non-network surface components such as local-only utilities, build scripts, developer tools, or CLI applications.
296
+
297
+ Your output MUST include sufficient information to find the exact location found, such as filepaths with line numbers, or specific references for a downstream agent to find the location exactly.
298
+ - **SSRF Sink:** Any server-side request that incorporates user-controlled data (partially or fully)
299
+ - **Purpose:** Identify all outbound HTTP requests, URL fetchers, and network connections that could be manipulated to force the server to make requests to unintended destinations
300
+ - **Critical Requirements:** For each sink found, provide the exact file path and code location
301
+
302
+ ### HTTP(S) Clients
303
+ - `curl`, `requests` (Python), `axios` (Node.js), `fetch` (JavaScript/Node.js)
304
+ - `net/http` (Go), `HttpClient` (Java/.NET), `urllib` (Python)
305
+ - `RestTemplate`, `WebClient`, `OkHttp`, `Apache HttpClient`
306
+
307
+ ### Raw Sockets & Connect APIs
308
+ - `Socket.connect`, `net.Dial` (Go), `socket.connect` (Python)
309
+ - `TcpClient`, `UdpClient`, `NetworkStream`
310
+ - `java.net.Socket`, `java.net.URL.openConnection()`
311
+
312
+ ### URL Openers & File Includes
313
+ - `file_get_contents` (PHP), `fopen`, `include_once`, `require_once`
314
+ - `new URL().openStream()` (Java), `urllib.urlopen` (Python)
315
+ - `fs.readFile` with URLs, `import()` with dynamic URLs
316
+ - `loadHTML`, `loadXML` with external sources
317
+
318
+ ### Redirect & "Next URL" Handlers
319
+ - Auto-follow redirects in HTTP clients
320
+ - Framework Location handlers (`response.redirect`)
321
+ - URL validation in redirect chains
322
+ - "Continue to" or "Return URL" parameters
323
+
324
+ ### Headless Browsers & Render Engines
325
+ - Puppeteer (`page.goto`, `page.setContent`)
326
+ - Playwright (`page.navigate`, `page.route`)
327
+ - Selenium WebDriver navigation
328
+ - html-to-pdf converters (wkhtmltopdf, Puppeteer PDF)
329
+ - Server-Side Rendering (SSR) with external content
330
+
331
+ ### Media Processors
332
+ - ImageMagick (`convert`, `identify` with URLs)
333
+ - GraphicsMagick, FFmpeg with network sources
334
+ - wkhtmltopdf, Ghostscript with URL inputs
335
+ - Image optimization services with URL parameters
336
+
337
+ ### Link Preview & Unfurlers
338
+ - Chat application link expanders
339
+ - CMS link preview generators
340
+ - oEmbed endpoint fetchers
341
+ - Social media card generators
342
+ - URL metadata extractors
343
+
344
+ ### Webhook Testers & Callback Verifiers
345
+ - "Ping my webhook" functionality
346
+ - Outbound callback verification
347
+ - Health check notifications
348
+ - Event delivery confirmations
349
+ - API endpoint validation tools
350
+
351
+ ### SSO/OIDC Discovery & JWKS Fetchers
352
+ - OpenID Connect discovery endpoints
353
+ - JWKS (JSON Web Key Set) fetchers
354
+ - OAuth authorization server metadata
355
+ - SAML metadata fetchers
356
+ - Federation metadata retrievers
357
+
358
+ ### Importers & Data Loaders
359
+ - "Import from URL" functionality
360
+ - CSV/JSON/XML remote loaders
361
+ - RSS/Atom feed readers
362
+ - API data synchronization
363
+ - Configuration file fetchers
364
+
365
+ ### Package/Plugin/Theme Installers
366
+ - "Install from URL" features
367
+ - Package managers with remote sources
368
+ - Plugin/theme downloaders
369
+ - Update mechanisms with remote checks
370
+ - Dependency resolution with external repos
371
+
372
+ ### Monitoring & Health Check Frameworks
373
+ - URL pingers and uptime checkers
374
+ - Health check endpoints
375
+ - Monitoring probe systems
376
+ - Alerting webhook senders
377
+ - Performance testing tools
378
+
379
+ ### Cloud Metadata Helpers
380
+ - AWS/GCP/Azure instance metadata callers
381
+ - Cloud service discovery mechanisms
382
+ - Container orchestration API clients
383
+ - Infrastructure metadata fetchers
384
+ - Service mesh configuration retrievers
385
+
386
+ <conclusion_trigger>
387
+ **COMPLETION REQUIREMENTS (ALL must be satisfied):**
388
+
389
+ 1. **Systematic Analysis:** ALL phases of the task agent strategy must be completed:
390
+ - Phase 1: All three discovery agents (Architecture Scanner, Entry Point Mapper, Security Pattern Hunter) completed
391
+ - Phase 2: All three vulnerability analysis agents (XSS/Injection Sink Hunter, SSRF/External Request Tracer, Data Security Auditor) completed
392
+ - Phase 3: Synthesis and report generation completed
393
+
394
+ 2. **Deliverable Generation:** The following files must be successfully created:
395
+ - `deliverables/code_analysis_deliverable.md` (via `save_deliverable` with `file_path`, not inline `content`)
396
+ - `outputs/schemas/` directory with all discovered schema files copied (if any schemas found)
397
+
398
+ 3. **TodoWrite Completion:** All tasks in your todo list must be marked as completed
399
+
400
+ **ONLY AFTER** all three requirements are satisfied, announce "**PRE-RECON CODE ANALYSIS COMPLETE**" and stop.
401
+
402
+ **CRITICAL:** After announcing completion, STOP IMMEDIATELY. Do NOT output summaries, recaps, or explanations of your work — the deliverable contains everything needed.
403
+ </conclusion_trigger>