@securityreviewai/security-review-mcp 0.2.9

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.
@@ -0,0 +1,496 @@
1
+ import * as z from "zod/v4";
2
+ export function registerAnalysisPrompts(server) {
3
+ server.registerPrompt("full_security_analysis", {
4
+ description: "Comprehensive end-to-end security analysis of any content. Generates security objectives, components, data dictionary, threat scenarios (with CVSS 4.0 scoring), and countermeasures. Use this when the user asks for a complete security review of a document, architecture, or system description.",
5
+ argsSchema: {
6
+ content: z.string(),
7
+ content_type: z.string().default("document"),
8
+ },
9
+ }, async ({ content, content_type }) => promptText(`You are an expert security architect performing a comprehensive security threat model analysis.
10
+
11
+ Analyze the following ${content_type} and produce a **complete security review** with all five sections below.
12
+
13
+ ## CONTENT TO ANALYZE
14
+ ---
15
+ ${content}
16
+ ---
17
+
18
+ ## INSTRUCTIONS
19
+
20
+ Produce the analysis in the following order. Each section builds on the previous ones.
21
+
22
+ ---
23
+
24
+ ### SECTION 1: SECURITY OBJECTIVES
25
+
26
+ Identify 8-15 security objectives organized into three categories:
27
+
28
+ **Regulatory Requirements**: Objectives derived from applicable regulations (GDPR, HIPAA, PCI-DSS, SOC2, etc.). For each, cite the specific regulation and section.
29
+
30
+ **Internal Security Requirements**: Objectives based on security best practices (authentication, authorization, encryption, input validation, logging, etc.).
31
+
32
+ **Contractual Requirements**: Objectives arising from business agreements, SLAs, or third-party commitments.
33
+
34
+ For each objective provide:
35
+ - **Name**: Concise title
36
+ - **Description**: 2-3 sentence explanation
37
+ - **Type**: Regulatory / Internal / Contractual
38
+ - **Reasoning**: Why this objective is relevant to this system
39
+ - **Evidence**: What in the content led to this objective
40
+
41
+ ---
42
+
43
+ ### SECTION 2: SYSTEM COMPONENTS
44
+
45
+ Identify all distinct system components/entities. For each provide:
46
+ - **Name**: Component name
47
+ - **Description**: What it does
48
+ - **Purpose**: Its role in the overall architecture
49
+ - **Connected To**: List of other components it interacts with
50
+ - **Security Objective IDs**: Which objectives from Section 1 are relevant
51
+
52
+ ---
53
+
54
+ ### SECTION 3: DATA DICTIONARY
55
+
56
+ Identify 8-15 sensitive data assets in two categories:
57
+
58
+ **Direct Sensitive Data**: PII, financial data, health data, authentication credentials, etc.
59
+ **Stepping Stones**: Data that isn't sensitive itself but could be used to access sensitive data (API keys, tokens, session IDs, internal URLs, config files, etc.)
60
+
61
+ For each asset provide:
62
+ - **Name**: Data asset name
63
+ - **Description**: What it contains and where it resides
64
+ - **Type**: Direct Sensitive Data / Stepping Stone
65
+ - **Reasoning**: Why this is security-relevant
66
+
67
+ ---
68
+
69
+ ### SECTION 4: THREAT SCENARIOS
70
+
71
+ Generate 15-40 threat scenarios across the PWN-ISMS categories:
72
+ 1. **Product Security** (application-level vulnerabilities, business logic flaws)
73
+ 2. **Workload Security** (container, runtime, compute vulnerabilities)
74
+ 3. **Network Security** (network-layer attacks, TLS, DNS, firewall issues)
75
+ 4. **Identity & Access Management** (authentication, authorization, privilege escalation)
76
+ 5. **Secrets Management** (credential exposure, key management, rotation)
77
+ 6. **Logging & Monitoring** (detection gaps, audit trail tampering, alert fatigue)
78
+ 7. **Supply Chain** (dependency vulnerabilities, CI/CD attacks, third-party risks)
79
+
80
+ For each threat provide:
81
+ - **Name**: Concise threat title
82
+ - **Description**: Detailed description of the attack scenario (3-5 sentences)
83
+ - **Category**: PWN-ISMS category from above
84
+ - **STRIDE Classification**: Which STRIDE categories apply (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege)
85
+ - **CWE ID**: The most relevant CWE identifier
86
+ - **CVSS 4.0 Score**: Score from 0.0 to 10.0 using CVSS 4.0 methodology
87
+ - **CVSS Vector**: The CVSS 4.0 vector string
88
+ - **Severity**: Critical (9.0-10.0) / High (7.0-8.9) / Medium (4.0-6.9) / Low (0.1-3.9)
89
+ - **Reasoning**: Why this threat is realistic for this system
90
+ - **Affected Components**: Which components from Section 2 are affected
91
+ - **Affected Data**: Which data assets from Section 3 are at risk
92
+
93
+ ---
94
+
95
+ ### SECTION 5: COUNTERMEASURES
96
+
97
+ Generate countermeasures for every threat in Section 4. Each threat must have at least one countermeasure.
98
+
99
+ For each countermeasure provide:
100
+ - **Name**: Concise title
101
+ - **Description**: What the countermeasure does
102
+ - **Implementation Steps**: Numbered list of concrete steps to implement
103
+ - **Threat IDs**: Which threats this mitigates
104
+ - **Category**: The PWN-ISMS category
105
+ - **Framework References**: Relevant compliance framework sections (e.g., "OWASP ASVS V2.1", "NIST SP 800-53 AC-2")
106
+ - **Priority**: High / Medium / Low
107
+
108
+ ---
109
+
110
+ ## OUTPUT FORMAT
111
+
112
+ Present each section with clear markdown headers. Use tables where appropriate.
113
+ Ensure every threat has at least one countermeasure. Cross-reference IDs between sections.`));
114
+ server.registerPrompt("security_objectives_analysis", {
115
+ description: "Generate security objectives for content. Identifies regulatory, internal, and contractual security requirements. Use when the user asks specifically about security objectives or requirements.",
116
+ argsSchema: {
117
+ content: z.string(),
118
+ frameworks: z.string().optional(),
119
+ },
120
+ }, async ({ content, frameworks }) => promptText(`You are an expert security architect specializing in security requirements and compliance.
121
+
122
+ Analyze the following content and identify comprehensive security objectives.${frameworks ? `\n\nPay special attention to these compliance frameworks: ${frameworks}` : ""}
123
+
124
+ ## CONTENT
125
+ ---
126
+ ${content}
127
+ ---
128
+
129
+ ## INSTRUCTIONS
130
+
131
+ Generate 8-15 security objectives organized into three categories:
132
+
133
+ ### Regulatory Requirements
134
+ Objectives derived from applicable regulations and standards (GDPR, HIPAA, PCI-DSS, SOC2, NIST, ISO 27001, DORA, etc.).
135
+ For each, cite the specific regulation and relevant section/clause.
136
+
137
+ ### Internal Security Requirements
138
+ Objectives based on security best practices and industry standards:
139
+ - Authentication and credential management
140
+ - Authorization and access control
141
+ - Data encryption (at rest and in transit)
142
+ - Input validation and output encoding
143
+ - Session management
144
+ - Error handling and logging
145
+ - Secure communications
146
+ - Security configuration
147
+
148
+ ### Contractual Requirements
149
+ Objectives arising from business agreements, SLAs, data processing agreements, or third-party commitments.
150
+
151
+ For **each objective** provide:
152
+ | Field | Description |
153
+ |-------|-------------|
154
+ | Name | Concise, descriptive title |
155
+ | Description | 2-3 sentence detailed explanation |
156
+ | Type | Regulatory / Internal / Contractual |
157
+ | Reasoning | Why this is relevant to the analyzed system |
158
+ | Evidence | Specific text or patterns from the content that justify this |
159
+ | Framework Reference | Applicable standard and section (e.g., "OWASP ASVS V2.1.1") |
160
+
161
+ Present as a structured list with clear categorization.`));
162
+ server.registerPrompt("component_analysis", {
163
+ description: "Extract and analyze system components/entities from content. Identifies all distinct components, their purposes, connections, and security profiles. Use when the user asks about system architecture or component identification.",
164
+ argsSchema: {
165
+ content: z.string(),
166
+ },
167
+ }, async ({ content }) => promptText(`You are an expert software architect analyzing system architecture for security threat modeling.
168
+
169
+ ## CONTENT
170
+ ---
171
+ ${content}
172
+ ---
173
+
174
+ ## TASK
175
+
176
+ Identify and describe ALL distinct system components/entities in the content above.
177
+
178
+ For **each component** provide:
179
+
180
+ 1. **Name**: Exact name as described in the content
181
+ 2. **Description**: Brief functional description (1-2 sentences)
182
+ 3. **Purpose**: Its role within the overall system architecture
183
+ 4. **Technology**: Specific technologies, frameworks, or platforms used (if identifiable)
184
+ 5. **Connected To**: List of other component names it communicates with
185
+ 6. **Data Handled**: What data flows through or is stored by this component
186
+ 7. **Trust Level**: External (untrusted) / Internal (trusted) / Semi-trusted
187
+ 8. **Attack Surface**: What interfaces it exposes (APIs, UI, network ports, file access, etc.)
188
+ 9. **Security Profile**: Key security characteristics (authentication required, encryption used, etc.)
189
+
190
+ ## GUIDELINES
191
+ - Include infrastructure components (databases, message queues, caches, load balancers)
192
+ - Include external services and third-party integrations
193
+ - Include client-side components (browsers, mobile apps, CLI tools)
194
+ - Map the connections between components to identify trust boundaries
195
+ - Identify any component that processes, stores, or transmits sensitive data
196
+
197
+ Present the components in a structured format, followed by a connection/data flow summary.`));
198
+ server.registerPrompt("data_dictionary_analysis", {
199
+ description: "Build a security-focused data dictionary from content. Identifies sensitive data assets and stepping stones. Use when the user asks about data classification, sensitive data, or data security.",
200
+ argsSchema: {
201
+ content: z.string(),
202
+ },
203
+ }, async ({ content }) => promptText(`You are a security expert specializing in data classification and sensitive data identification.
204
+
205
+ ## CONTENT
206
+ ---
207
+ ${content}
208
+ ---
209
+
210
+ ## TASK
211
+
212
+ Identify all sensitive data assets in the system described above. Categorize them into two types:
213
+
214
+ ### Type 1: Direct Sensitive Data
215
+ Data that is inherently sensitive and requires protection:
216
+ - **PII** (Personally Identifiable Information): names, emails, addresses, phone numbers, SSNs, etc.
217
+ - **Financial Data**: credit card numbers, bank accounts, transaction records, billing info
218
+ - **Health Data (PHI)**: medical records, prescriptions, diagnoses, insurance info
219
+ - **Authentication Data**: passwords, password hashes, biometric data
220
+ - **Business Sensitive**: trade secrets, proprietary algorithms, strategic plans, financial reports
221
+
222
+ ### Type 2: Stepping Stones
223
+ Data that could be used as a pathway to access sensitive data:
224
+ - API keys and tokens
225
+ - Session identifiers
226
+ - Internal URLs and endpoints
227
+ - Database connection strings
228
+ - Configuration files with security settings
229
+ - Encryption keys and certificates
230
+ - Service account credentials
231
+ - JWT secrets
232
+ - Webhook URLs
233
+ - Internal IP addresses and network topology
234
+
235
+ For **each data asset** provide:
236
+ | Field | Description |
237
+ |-------|-------------|
238
+ | Name | Descriptive name for the data asset |
239
+ | Type | Direct Sensitive Data / Stepping Stone |
240
+ | Sub-type | PII, Financial, PHI, Auth, Business, API Key, Token, Config, etc. |
241
+ | Description | What the data contains and its purpose |
242
+ | Location | Where it is stored/transmitted (database, file, API, memory, etc.) |
243
+ | Protection Required | Encryption, access control, masking, or other protections needed |
244
+ | Reasoning | Why this data is security-relevant |
245
+
246
+ Generate 8-15 data assets. Ensure both direct sensitive data and stepping stones are represented.`));
247
+ server.registerPrompt("threat_analysis", {
248
+ description: "Generate threat scenarios with CVSS 4.0 scoring. Analyzes content for threats across PWN-ISMS categories (Product, Workload, Network, IAM, Secrets, Logging, Supply Chain). Use when the user asks specifically about threats, vulnerabilities, or attack scenarios.",
249
+ argsSchema: {
250
+ content: z.string(),
251
+ categories: z.string().optional(),
252
+ },
253
+ }, async ({ content, categories }) => promptText(`You are a senior security threat analyst performing threat modeling using the PWN-ISMS methodology.
254
+
255
+ ## CONTENT
256
+ ---
257
+ ${content}
258
+ ---
259
+
260
+ ## TASK
261
+
262
+ Generate detailed threat scenarios for the system described above.${categories ? `\n\nFocus specifically on these PWN-ISMS categories: ${categories}` : ""}
263
+
264
+ ### PWN-ISMS Categories
265
+
266
+ Analyze threats across ALL of these categories (unless specific categories are requested):
267
+
268
+ 1. **Product Security (P)**: Application-level vulnerabilities
269
+ - Injection attacks (SQL, XSS, command, LDAP, template)
270
+ - Business logic flaws
271
+ - Authentication/session bypasses
272
+ - Insecure direct object references
273
+ - File upload vulnerabilities
274
+ - API abuse and rate limiting gaps
275
+
276
+ 2. **Workload Security (W)**: Runtime and compute vulnerabilities
277
+ - Container escape and image vulnerabilities
278
+ - Serverless function abuse
279
+ - Memory corruption and buffer overflows
280
+ - Insecure deserialization
281
+ - Resource exhaustion
282
+
283
+ 3. **Network Security (N)**: Network-layer attacks
284
+ - Man-in-the-middle attacks
285
+ - TLS/SSL misconfigurations
286
+ - DNS attacks
287
+ - Network segmentation failures
288
+ - DDoS vulnerabilities
289
+ - Exposed services and ports
290
+
291
+ 4. **Identity & Access Management (I)**: Auth and access threats
292
+ - Credential stuffing and brute force
293
+ - Privilege escalation
294
+ - Insecure session management
295
+ - OAuth/OIDC misconfigurations
296
+ - Broken access control (IDOR, BOLA)
297
+ - Insufficient MFA
298
+
299
+ 5. **Secrets Management (S)**: Credential and key threats
300
+ - Hardcoded credentials in source code
301
+ - Exposed API keys
302
+ - Insufficient key rotation
303
+ - Insecure credential storage
304
+ - Secrets in logs or error messages
305
+
306
+ 6. **Logging & Monitoring (M)**: Detection and audit threats
307
+ - Insufficient logging
308
+ - Log injection
309
+ - Alert fatigue and missed detections
310
+ - Audit trail tampering
311
+ - Monitoring blind spots
312
+
313
+ 7. **Supply Chain (S)**: Dependency and pipeline threats
314
+ - Vulnerable dependencies
315
+ - Dependency confusion attacks
316
+ - CI/CD pipeline compromises
317
+ - Malicious packages
318
+ - Third-party service compromises
319
+
320
+ ### Output Format
321
+
322
+ For **each threat** provide:
323
+ | Field | Description |
324
+ |-------|-------------|
325
+ | Name | Concise threat title |
326
+ | Description | Detailed attack scenario (3-5 sentences describing the attack vector, preconditions, and impact) |
327
+ | Category | PWN-ISMS category (Product/Workload/Network/IAM/Secrets/Logging/Supply Chain) |
328
+ | STRIDE | Applicable STRIDE categories (Spoofing, Tampering, Repudiation, Information Disclosure, DoS, Elevation of Privilege) |
329
+ | CWE ID | Most relevant CWE identifier (e.g., CWE-79) |
330
+ | CVSS 4.0 Score | Numerical score 0.0-10.0 |
331
+ | CVSS Vector | CVSS 4.0 vector string |
332
+ | Severity | Critical (9.0-10.0) / High (7.0-8.9) / Medium (4.0-6.9) / Low (0.1-3.9) |
333
+ | Reasoning | Why this threat is realistic and relevant |
334
+
335
+ ### CVSS 4.0 Scoring Guidance
336
+
337
+ When scoring, consider these metrics:
338
+ - **Attack Vector (AV)**: Network / Adjacent / Local / Physical
339
+ - **Attack Complexity (AC)**: Low / High
340
+ - **Attack Requirements (AT)**: None / Present
341
+ - **Privileges Required (PR)**: None / Low / High
342
+ - **User Interaction (UI)**: None / Passive / Active
343
+ - **Vulnerable System Impact**: Confidentiality (VC), Integrity (VI), Availability (VA)
344
+ - **Subsequent System Impact**: Confidentiality (SC), Integrity (SI), Availability (SA)
345
+
346
+ Generate 15-40 threats total, aiming for at least 2-3 per category. Focus on realistic, actionable threats specific to the analyzed system -- avoid generic or theoretical scenarios.`));
347
+ server.registerPrompt("countermeasure_analysis", {
348
+ description: "Generate countermeasures/mitigations for identified threats. Maps each countermeasure to specific threats with implementation steps and framework references. Use when the user asks about mitigations, remediation, or security controls.",
349
+ argsSchema: {
350
+ content: z.string(),
351
+ threats_context: z.string().optional(),
352
+ },
353
+ }, async ({ content, threats_context }) => {
354
+ const threatsSection = threats_context
355
+ ? `\n\n## PREVIOUSLY IDENTIFIED THREATS\n---\n${threats_context}\n---\n`
356
+ : "";
357
+ const threatsInstruction = threats_context
358
+ ? "Map countermeasures directly to the threats provided above. Otherwise, first identify the key threats, then provide countermeasures."
359
+ : "First identify the key threats in the system, then provide countermeasures for each.";
360
+ return promptText(`You are a security engineering expert specializing in designing security controls and countermeasures.
361
+
362
+ ## CONTENT
363
+ ---
364
+ ${content}
365
+ ---
366
+ ${threatsSection}
367
+
368
+ ## TASK
369
+
370
+ Generate actionable countermeasures for the security threats in the system described above.
371
+ ${threatsInstruction}
372
+
373
+ ### Requirements
374
+
375
+ 1. **Every identified threat must have at least one countermeasure**
376
+ 2. Countermeasures should be specific and implementable, not generic advice
377
+ 3. Include both preventive and detective controls
378
+ 4. Reference industry standards and frameworks where applicable
379
+
380
+ ### Output Format
381
+
382
+ For **each countermeasure** provide:
383
+ | Field | Description |
384
+ |-------|-------------|
385
+ | Name | Concise countermeasure title |
386
+ | Description | What this countermeasure does and why it is effective (2-3 sentences) |
387
+ | Implementation Steps | Numbered list of concrete steps to implement this control |
388
+ | Threat(s) Mitigated | Which specific threats this addresses |
389
+ | Category | PWN-ISMS category (Product/Workload/Network/IAM/Secrets/Logging/Supply Chain) |
390
+ | Framework References | Relevant standards (e.g., "OWASP ASVS V2.1", "NIST SP 800-53 AC-2", "CIS Control 6.1") |
391
+ | Priority | High (must implement) / Medium (should implement) / Low (nice to have) |
392
+ | Effort | Low (hours-days) / Medium (days-weeks) / High (weeks-months) |
393
+
394
+ ### Countermeasure Categories to Cover
395
+
396
+ Ensure coverage across these control types:
397
+ - **Preventive**: Controls that prevent the threat from occurring
398
+ - **Detective**: Controls that detect when a threat is being exploited
399
+ - **Corrective**: Controls that limit damage after exploitation
400
+ - **Compensating**: Alternative controls when primary controls are not feasible
401
+
402
+ Generate 15-30 countermeasures ensuring complete threat coverage.`);
403
+ });
404
+ server.registerPrompt("code_security_review", {
405
+ description: "Perform a security-focused code review. Analyzes code for vulnerabilities, injection flaws, hardcoded secrets, insecure patterns, and OWASP Top 10 issues. Use when the user provides code or asks for a code security review.",
406
+ argsSchema: {
407
+ code_content: z.string(),
408
+ language: z.string().default("auto-detect"),
409
+ },
410
+ }, async ({ code_content, language }) => promptText(`You are a senior application security engineer performing a security-focused code review.
411
+
412
+ ## CODE (${language})
413
+ \`\`\`
414
+ ${code_content}
415
+ \`\`\`
416
+
417
+ ## TASK
418
+
419
+ Perform a thorough security code review. Analyze for:
420
+
421
+ ### 1. Injection Vulnerabilities
422
+ - SQL injection
423
+ - Cross-site scripting (XSS)
424
+ - Command injection
425
+ - LDAP injection
426
+ - Template injection
427
+ - XML/XXE injection
428
+ - Path traversal
429
+
430
+ ### 2. Authentication & Authorization
431
+ - Hardcoded credentials
432
+ - Weak password handling
433
+ - Missing authentication checks
434
+ - Broken access control
435
+ - Insecure session management
436
+ - Missing CSRF protection
437
+
438
+ ### 3. Data Exposure
439
+ - Sensitive data in logs
440
+ - Unencrypted sensitive data
441
+ - Information disclosure in error messages
442
+ - PII handling violations
443
+ - Insecure data storage
444
+
445
+ ### 4. Cryptographic Issues
446
+ - Weak algorithms (MD5, SHA1, DES)
447
+ - Hardcoded keys/secrets
448
+ - Insecure random number generation
449
+ - Missing encryption
450
+
451
+ ### 5. Configuration & Dependencies
452
+ - Debug mode in production
453
+ - Insecure defaults
454
+ - Missing security headers
455
+ - Vulnerable dependencies
456
+ - Exposed configuration
457
+
458
+ ### 6. Logic Flaws
459
+ - Race conditions
460
+ - Business logic bypasses
461
+ - Integer overflows
462
+ - Null pointer issues
463
+ - Resource exhaustion
464
+
465
+ ## OUTPUT FORMAT
466
+
467
+ For each finding provide:
468
+ | Field | Description |
469
+ |-------|-------------|
470
+ | Finding | Concise title |
471
+ | Severity | Critical / High / Medium / Low / Informational |
472
+ | Location | File/function/line reference |
473
+ | Description | What the vulnerability is and how it could be exploited |
474
+ | CWE | Relevant CWE ID |
475
+ | OWASP | Relevant OWASP Top 10 category |
476
+ | Remediation | Specific code fix or approach to resolve |
477
+ | Code Example | Show the vulnerable code and the fixed version |
478
+
479
+ Also provide a summary with:
480
+ - Total findings by severity
481
+ - Overall risk assessment
482
+ - Top 3 priority fixes`));
483
+ }
484
+ function promptText(text) {
485
+ return {
486
+ messages: [
487
+ {
488
+ role: "user",
489
+ content: {
490
+ type: "text",
491
+ text,
492
+ },
493
+ },
494
+ ],
495
+ };
496
+ }