@highflame/overwatch 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 (156) hide show
  1. package/README.md +337 -0
  2. package/bin/overwatch +12 -0
  3. package/dist/auth/cli-oauth.d.ts +13 -0
  4. package/dist/auth/cli-oauth.d.ts.map +1 -0
  5. package/dist/auth/html-utils.d.ts +20 -0
  6. package/dist/auth/html-utils.d.ts.map +1 -0
  7. package/dist/auth/index.d.ts +10 -0
  8. package/dist/auth/index.d.ts.map +1 -0
  9. package/dist/auth/oauth.d.ts +81 -0
  10. package/dist/auth/oauth.d.ts.map +1 -0
  11. package/dist/auth/pkce.d.ts +26 -0
  12. package/dist/auth/pkce.d.ts.map +1 -0
  13. package/dist/auth/token-store.d.ts +44 -0
  14. package/dist/auth/token-store.d.ts.map +1 -0
  15. package/dist/bin/overwatch +12 -0
  16. package/dist/cli.d.ts +6 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +5449 -0
  19. package/dist/cli.js.map +7 -0
  20. package/dist/config/index.d.ts +5 -0
  21. package/dist/config/index.d.ts.map +1 -0
  22. package/dist/config/manager.d.ts +54 -0
  23. package/dist/config/manager.d.ts.map +1 -0
  24. package/dist/daemon.d.ts +11 -0
  25. package/dist/daemon.d.ts.map +1 -0
  26. package/dist/daemon.js +6004 -0
  27. package/dist/daemon.js.map +7 -0
  28. package/dist/data/ingestor.d.ts +31 -0
  29. package/dist/data/ingestor.d.ts.map +1 -0
  30. package/dist/data/processor.d.ts +96 -0
  31. package/dist/data/processor.d.ts.map +1 -0
  32. package/dist/data/reader.d.ts +24 -0
  33. package/dist/data/reader.d.ts.map +1 -0
  34. package/dist/data/recorder.d.ts +12 -0
  35. package/dist/data/recorder.d.ts.map +1 -0
  36. package/dist/engines/cedar.d.ts +41 -0
  37. package/dist/engines/cedar.d.ts.map +1 -0
  38. package/dist/engines/remote.d.ts +21 -0
  39. package/dist/engines/remote.d.ts.map +1 -0
  40. package/dist/engines/yara.d.ts +12 -0
  41. package/dist/engines/yara.d.ts.map +1 -0
  42. package/dist/handlers/dashboard-handler.d.ts +7 -0
  43. package/dist/handlers/dashboard-handler.d.ts.map +1 -0
  44. package/dist/handlers/hook-handler.d.ts +23 -0
  45. package/dist/handlers/hook-handler.d.ts.map +1 -0
  46. package/dist/handlers/oauth-handler.d.ts +12 -0
  47. package/dist/handlers/oauth-handler.d.ts.map +1 -0
  48. package/dist/handlers/scan-handler.d.ts +13 -0
  49. package/dist/handlers/scan-handler.d.ts.map +1 -0
  50. package/dist/handlers/utils.d.ts +11 -0
  51. package/dist/handlers/utils.d.ts.map +1 -0
  52. package/dist/hooks/claudecode/hooks.json.template +20 -0
  53. package/dist/hooks/cursor/hooks.json.template +74 -0
  54. package/dist/hooks/universal-hook.sh +36 -0
  55. package/dist/http/server.d.ts +38 -0
  56. package/dist/http/server.d.ts.map +1 -0
  57. package/dist/index.d.ts +8 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +5941 -0
  60. package/dist/index.js.map +7 -0
  61. package/dist/installer.d.ts +25 -0
  62. package/dist/installer.d.ts.map +1 -0
  63. package/dist/javelin/admin-client.d.ts +75 -0
  64. package/dist/javelin/admin-client.d.ts.map +1 -0
  65. package/dist/javelin/client.d.ts +30 -0
  66. package/dist/javelin/client.d.ts.map +1 -0
  67. package/dist/javelin/config-reader.d.ts +70 -0
  68. package/dist/javelin/config-reader.d.ts.map +1 -0
  69. package/dist/javelin/index.d.ts +5 -0
  70. package/dist/javelin/index.d.ts.map +1 -0
  71. package/dist/javelin/types.d.ts +81 -0
  72. package/dist/javelin/types.d.ts.map +1 -0
  73. package/dist/lib/policy-engine.d.ts +34 -0
  74. package/dist/lib/policy-engine.d.ts.map +1 -0
  75. package/dist/lib/policy-manager.d.ts +86 -0
  76. package/dist/lib/policy-manager.d.ts.map +1 -0
  77. package/dist/module.d.ts +52 -0
  78. package/dist/module.d.ts.map +1 -0
  79. package/dist/pipeline/context-mapper.d.ts +16 -0
  80. package/dist/pipeline/context-mapper.d.ts.map +1 -0
  81. package/dist/pipeline/extractors/claude-extractor.d.ts +48 -0
  82. package/dist/pipeline/extractors/claude-extractor.d.ts.map +1 -0
  83. package/dist/pipeline/extractors/cursor-extractor.d.ts +44 -0
  84. package/dist/pipeline/extractors/cursor-extractor.d.ts.map +1 -0
  85. package/dist/pipeline/extractors/github-copilot-extractor.d.ts +49 -0
  86. package/dist/pipeline/extractors/github-copilot-extractor.d.ts.map +1 -0
  87. package/dist/pipeline/extractors/index.d.ts +47 -0
  88. package/dist/pipeline/extractors/index.d.ts.map +1 -0
  89. package/dist/pipeline/extractors/registry.d.ts +38 -0
  90. package/dist/pipeline/extractors/registry.d.ts.map +1 -0
  91. package/dist/pipeline/hook-pipeline.d.ts +25 -0
  92. package/dist/pipeline/hook-pipeline.d.ts.map +1 -0
  93. package/dist/policy.cedar +783 -0
  94. package/dist/rules/pre/command_injection.yar +60 -0
  95. package/dist/rules/pre/cross_origin_escalation.yar +106 -0
  96. package/dist/rules/pre/mcp_config_risk.yar +35 -0
  97. package/dist/rules/pre/path_traversal.yar +50 -0
  98. package/dist/rules/pre/prompt_injection.yar +101 -0
  99. package/dist/rules/pre/secrets_leakage.yar +100 -0
  100. package/dist/rules/pre/sql_injection.yar +65 -0
  101. package/dist/scanner.d.ts +80 -0
  102. package/dist/scanner.d.ts.map +1 -0
  103. package/dist/service.d.ts +18 -0
  104. package/dist/service.d.ts.map +1 -0
  105. package/dist/services/interface.d.ts +11 -0
  106. package/dist/services/interface.d.ts.map +1 -0
  107. package/dist/services/launchd.d.ts +12 -0
  108. package/dist/services/launchd.d.ts.map +1 -0
  109. package/dist/services/systemd.d.ts +12 -0
  110. package/dist/services/systemd.d.ts.map +1 -0
  111. package/dist/services/windows.d.ts +7 -0
  112. package/dist/services/windows.d.ts.map +1 -0
  113. package/dist/skills/index.d.ts +7 -0
  114. package/dist/skills/index.d.ts.map +1 -0
  115. package/dist/skills/scanner.d.ts +44 -0
  116. package/dist/skills/scanner.d.ts.map +1 -0
  117. package/dist/skills/types.d.ts +29 -0
  118. package/dist/skills/types.d.ts.map +1 -0
  119. package/dist/types/config.d.ts +165 -0
  120. package/dist/types/config.d.ts.map +1 -0
  121. package/dist/types/events.d.ts +225 -0
  122. package/dist/types/events.d.ts.map +1 -0
  123. package/dist/types/index.d.ts +6 -0
  124. package/dist/types/index.d.ts.map +1 -0
  125. package/dist/types/remote-policy.d.ts +129 -0
  126. package/dist/types/remote-policy.d.ts.map +1 -0
  127. package/dist/types/requests.d.ts +45 -0
  128. package/dist/types/requests.d.ts.map +1 -0
  129. package/dist/types/responses.d.ts +60 -0
  130. package/dist/types/responses.d.ts.map +1 -0
  131. package/dist/ui/images/highflame-mono.png +0 -0
  132. package/dist/ui/views/dashboard.ejs +301 -0
  133. package/dist/ui/views/dashboard.js +785 -0
  134. package/dist/ui/views/partials/commands-table.ejs +54 -0
  135. package/dist/ui/views/partials/events-table.ejs +36 -0
  136. package/dist/ui/views/partials/filter-dropdown.ejs +12 -0
  137. package/dist/ui/views/partials/overview-charts.ejs +149 -0
  138. package/dist/ui/views/partials/scans-table.ejs +136 -0
  139. package/dist/ui/views/partials/sessions-table.ejs +50 -0
  140. package/dist/ui/views/partials/stats-grid.ejs +23 -0
  141. package/dist/ui/views/partials/threats-table.ejs +60 -0
  142. package/dist/utils/index.d.ts +3 -0
  143. package/dist/utils/index.d.ts.map +1 -0
  144. package/dist/utils/logger.d.ts +28 -0
  145. package/dist/utils/logger.d.ts.map +1 -0
  146. package/dist/utils/performance.d.ts +26 -0
  147. package/dist/utils/performance.d.ts.map +1 -0
  148. package/dist/utils/port-manager.d.ts +6 -0
  149. package/dist/utils/port-manager.d.ts.map +1 -0
  150. package/dist/yara/engine.d.ts +58 -0
  151. package/dist/yara/engine.d.ts.map +1 -0
  152. package/dist/yara/index.d.ts +5 -0
  153. package/dist/yara/index.d.ts.map +1 -0
  154. package/lib/platform-loader.js +210 -0
  155. package/package.json +63 -0
  156. package/scripts/postinstall.js +121 -0
@@ -0,0 +1,783 @@
1
+ // ============================================================================
2
+ // OVERWATCH SECURITY POLICIES - MULTI-FRAMEWORK COMPLIANCE
3
+ // ============================================================================
4
+ // This Cedar policy file implements security controls that map to multiple
5
+ // compliance frameworks including NIST 800-53, OWASP, and MITRE ATT&CK.
6
+ //
7
+ // Framework Coverage:
8
+ // • NIST 800-53 Rev 5: Access Control, System Integrity, Configuration Management
9
+ // • OWASP Top 10 2021: Injection, Access Control, Security Misconfiguration
10
+ // • MITRE ATT&CK v14: Execution, Defense Evasion, Credential Access techniques
11
+ // • CIS Controls v8: Inventory, Access Control, Malware Defenses
12
+ // ============================================================================
13
+
14
+ // === DEFAULT ACTION ===
15
+ // @compliance_id: "DEFAULT_001"
16
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
17
+ // @nist: AC-2 (Account Management), AC-3 (Access Enforcement)
18
+ // @owasp: V4.1.1 (General Access Control Design)
19
+ // @cis: 5.1 (Account Management)
20
+ // @description: "Default permit policy with least privilege enforcement"
21
+ // @severity: MEDIUM
22
+ permit (principal, action, resource);
23
+
24
+ // ============================================================================
25
+ // COMMAND EXECUTION PREVENTION - CRITICAL SECURITY CONTROL
26
+ // ============================================================================
27
+ // @compliance_id: "CMD_EXEC_001"
28
+ // @frameworks: ["NIST-800-53", "OWASP-Top10", "MITRE-ATT&CK", "CIS-Controls"]
29
+ // @nist: AC-3 (Access Enforcement), SI-3 (Malicious Code Protection), CM-7 (Least Functionality)
30
+ // @owasp: A01 (Broken Access Control), A03 (Injection)
31
+ // @mitre: T1059 (Command and Scripting Interpreter), T1059.004 (Unix Shell)
32
+ // @cis: 5.1 (Secure System Boot Settings), 16.1 (Network Monitoring and Defense)
33
+ // @description: "Prevents execution of dangerous system commands and shell access"
34
+ // @severity: CRITICAL
35
+ // @category: "Command Injection Prevention"
36
+
37
+ // Block shell command execution
38
+ forbid (
39
+ principal == User::"mcp_client",
40
+ action == Action::"call_tool",
41
+ resource == Tool::"shell"
42
+ );
43
+
44
+ // Block bash command execution
45
+ forbid (
46
+ principal == User::"mcp_client",
47
+ action == Action::"call_tool",
48
+ resource == Tool::"bash"
49
+ );
50
+
51
+ // Block sh command execution
52
+ forbid (
53
+ principal == User::"mcp_client",
54
+ action == Action::"call_tool",
55
+ resource == Tool::"sh"
56
+ );
57
+
58
+ // Block system.exec calls
59
+ forbid (
60
+ principal == User::"mcp_client",
61
+ action == Action::"call_tool",
62
+ resource == Tool::"system.exec"
63
+ );
64
+
65
+ // Block process spawning
66
+ forbid (
67
+ principal == User::"mcp_client",
68
+ action == Action::"call_tool",
69
+ resource == Tool::"process.spawn"
70
+ );
71
+
72
+ // Block dangerous file operations
73
+ forbid (
74
+ principal == User::"mcp_client",
75
+ action == Action::"call_tool",
76
+ resource == Tool::"fs.delete"
77
+ );
78
+
79
+ // ============================================================================
80
+ // PROMPT INJECTION PROTECTION - COMPREHENSIVE AI SECURITY CONTROL
81
+ // ============================================================================
82
+ // @compliance_id: "PROMPT_INJ_001"
83
+ // @frameworks: ["NIST-800-53", "OWASP-Top10", "MITRE-ATT&CK", "OWASP-ASVS"]
84
+ // @nist: SI-3 (Malicious Code Protection), SI-4 (Information System Monitoring), AC-3 (Access Enforcement)
85
+ // @owasp: A03 (Injection), A04 (Insecure Design)
86
+ // @owasp_asvs: V5.1.1 (Input Validation), V5.3.4 (Output Encoding and Injection Prevention)
87
+ // @mitre: T1566 (Phishing), T1027 (Obfuscated Files or Information), T1204 (User Execution)
88
+ // @description: "Prevents prompt injection, jailbreak attempts, and AI manipulation techniques"
89
+ // @severity: HIGH
90
+ // @category: "AI Security / Prompt Injection Prevention"
91
+
92
+ // Allow legitimate system-related queries (whitelist approach)
93
+ permit (
94
+ principal == User::"mcp_client",
95
+ action == Action::"process_prompt",
96
+ resource
97
+ ) when {
98
+ context has prompt_text &&
99
+ (context.prompt_text like "*how to ignore errors in python*" ||
100
+ context.prompt_text like "*git ignore file*" ||
101
+ context.prompt_text like "*docker ignore*" ||
102
+ context.prompt_text like "*ignore whitespace*" ||
103
+ context.prompt_text like "*ignore case*" ||
104
+ context.prompt_text like "*system requirements*" ||
105
+ context.prompt_text like "*system design*" ||
106
+ context.prompt_text like "*system architecture*")
107
+ };
108
+
109
+ // Block malicious prompt injection patterns
110
+ forbid (
111
+ principal == User::"mcp_client",
112
+ action == Action::"process_prompt",
113
+ resource
114
+ ) when {
115
+ context has prompt_text &&
116
+ (// Instruction override attempts (MITRE T1204: User Execution)
117
+ context.prompt_text like "*ignore all*" ||
118
+ context.prompt_text like "*ignore previous*" ||
119
+ context.prompt_text like "*ignore instructions*" ||
120
+ context.prompt_text like "*ignore the*" ||
121
+ context.prompt_text like "*forget all*" ||
122
+ context.prompt_text like "*forget previous*" ||
123
+ context.prompt_text like "*forget instructions*" ||
124
+ context.prompt_text like "*forget what*" ||
125
+ context.prompt_text like "*forget that*" ||
126
+ context.prompt_text like "*forget everything*" ||
127
+ context.prompt_text like "*disregard all*" ||
128
+ context.prompt_text like "*disregard previous*" ||
129
+ context.prompt_text like "*disregard instructions*" ||
130
+ context.prompt_text like "*override*" ||
131
+ context.prompt_text like "*bypass*" ||
132
+ context.prompt_text like "*jailbreak*" ||
133
+ // Mode manipulation attempts (MITRE T1027: Obfuscated Files or Information)
134
+ context.prompt_text like "*developer mode*" ||
135
+ context.prompt_text like "*god mode*" ||
136
+ context.prompt_text like "*admin mode*" ||
137
+ context.prompt_text like "*disable all filters*" ||
138
+ context.prompt_text like "*remove all limitations*" ||
139
+ // System prompt extraction attempts (MITRE T1566: Phishing)
140
+ context.prompt_text like "*show me your system prompt*" ||
141
+ context.prompt_text like "*what are your instructions*" ||
142
+ context.prompt_text like "*reveal your instructions*" ||
143
+ context.prompt_text like "*print your system prompt*" ||
144
+ // Role manipulation attempts
145
+ context.prompt_text like "*you are now a different ai*" ||
146
+ context.prompt_text like "*pretend you are*" ||
147
+ context.prompt_text like "*act as if you are*" ||
148
+ // Role/conversation markers that indicate injection (OWASP A03: Injection)
149
+ context.prompt_text like "*system:*" ||
150
+ context.prompt_text like "*assistant:*" ||
151
+ context.prompt_text like "*user:*" ||
152
+ context.prompt_text like "*human:*" ||
153
+ context.prompt_text like "*ai:*" ||
154
+ context.prompt_text like "*chatgpt:*" ||
155
+ // Code injection patterns (OWASP A03: Injection)
156
+ context.prompt_text like "*exec *" ||
157
+ context.prompt_text like "*eval *" ||
158
+ context.prompt_text like "*execute *" ||
159
+ context.prompt_text like "*run code*" ||
160
+ context.prompt_text like "*<script*" ||
161
+ context.prompt_text like "*javascript:*" ||
162
+ // Prompt structure manipulation
163
+ context.prompt_text like "*\\n\\n*" ||
164
+ context.prompt_text like "*---*" ||
165
+ context.prompt_text like "*###*" ||
166
+ context.prompt_text like "*```*")
167
+ };
168
+
169
+ // ============================================================================
170
+ // SECRETS DETECTION - DATA PROTECTION CONTROL
171
+ // ============================================================================
172
+ // @compliance_id: "SECRET_DETECT_001"
173
+ // @frameworks: ["NIST-800-53", "OWASP-Top10", "MITRE-ATT&CK", "CIS-Controls"]
174
+ // @nist: SC-28 (Protection of Information at Rest), IA-5 (Authenticator Management)
175
+ // @owasp: A02 (Cryptographic Failures), V2.1.1 (Password Security)
176
+ // @mitre: T1552 (Unsecured Credentials), T1555 (Credentials from Password Stores)
177
+ // @cis: 16.1 (Network Monitoring and Defense), 18.1 (Application Software Security)
178
+ // @description: "Prevents exposure of secrets, credentials, and sensitive data in prompts"
179
+ // @severity: HIGH
180
+ // @category: "Data Protection / Secrets Management"
181
+
182
+ // Block prompts containing secrets
183
+ forbid (
184
+ principal == User::"mcp_client",
185
+ action == Action::"process_prompt",
186
+ resource
187
+ ) when {
188
+ context has contains_secrets && context.contains_secrets == true
189
+ };
190
+
191
+ // ============================================================================
192
+ // MCP SERVER ACCESS CONTROL - NETWORK BOUNDARY PROTECTION
193
+ // ============================================================================
194
+ // @compliance_id: "MCP_ACCESS_001"
195
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
196
+ // @nist: AC-3 (Access Enforcement), SC-7 (Boundary Protection), AC-4 (Information Flow Enforcement)
197
+ // @owasp: V4.1.1 (General Access Control Design), V4.2.1 (Operation Level Access Control)
198
+ // @cis: 5.1 (Account Management), 12.1 (Network Infrastructure Management)
199
+ // @description: "Controls access to specific MCP servers based on authorization policies"
200
+ // @severity: MEDIUM
201
+ // @category: "Access Control / Server Authorization"
202
+
203
+ // === PLAYWRIGHT SERVER RESTRICTIONS ===
204
+ forbid (
205
+ principal == User::"mcp_client",
206
+ action == Action::"call_tool",
207
+ resource
208
+ ) when {
209
+ context has server_name && context.server_name == "playwright"
210
+ };
211
+
212
+ // === FILESYSTEM SERVER RESTRICTIONS ===
213
+ // Allow filesystem tools for specific operations
214
+ permit (
215
+ principal == User::"mcp_client",
216
+ action == Action::"call_tool",
217
+ resource
218
+ ) when {
219
+ context has server_name && context.server_name == "filesystem" &&
220
+ (resource == Tool::"read_file" ||
221
+ resource == Tool::"write_file" ||
222
+ resource == Tool::"list_directory" ||
223
+ resource == Tool::"create_directory")
224
+ };
225
+
226
+ // Block dangerous filesystem operations
227
+ forbid (
228
+ principal == User::"mcp_client",
229
+ action == Action::"call_tool",
230
+ resource
231
+ ) when {
232
+ context has server_name && context.server_name == "filesystem" &&
233
+ (resource == Tool::"delete_file" ||
234
+ resource == Tool::"execute_file" ||
235
+ resource == Tool::"move_file")
236
+ };
237
+
238
+ // ============================================================================
239
+ // FILE SYSTEM ACCESS CONTROL - SENSITIVE DATA PROTECTION
240
+ // ============================================================================
241
+ // @compliance_id: "FS_ACCESS_001"
242
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls", "MITRE-ATT&CK"]
243
+ // @nist: AC-3 (Access Enforcement), SC-28 (Protection of Information at Rest), AC-6 (Least Privilege)
244
+ // @owasp: V4.1.1 (General Access Control Design), V14.2.1 (File Upload Requirements)
245
+ // @cis: 5.1 (Secure System Boot Settings), 13.1 (Network Ports, Protocols and Services)
246
+ // @mitre: T1005 (Data from Local System), T1552.001 (Credentials In Files)
247
+ // @description: "Blocks access to sensitive system directories and credential files"
248
+ // @severity: HIGH
249
+ // @category: "Data Protection / File System Security"
250
+
251
+ // Block access to sensitive system directories
252
+ forbid (
253
+ principal == User::"mcp_client",
254
+ action in [Action::"read_file", Action::"write_file"],
255
+ resource
256
+ ) when {
257
+ context has path &&
258
+ (context.path like "/etc/*" ||
259
+ context.path like "/var/*" ||
260
+ context.path like "/proc/*" ||
261
+ context.path like "/sys/*" ||
262
+ context.path like "/root/*" ||
263
+ context.path like "*/.env" ||
264
+ context.path like "*.pem" ||
265
+ context.path like "*/id_*" ||
266
+ context.path like "*/.ssh/*" ||
267
+ context.path like "*/.aws/*")
268
+ };
269
+
270
+ // @compliance_id: "FS_ALLOW_001"
271
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
272
+ // @nist: AC-3 (Access Enforcement), AC-6 (Least Privilege)
273
+ // @owasp: V4.1.1 (General Access Control Design)
274
+ // @cis: 5.1 (Account Management)
275
+ // @description: "Allows controlled access to workspace and temporary file locations"
276
+ // @severity: MEDIUM
277
+ // @category: "Access Control / Workspace Management"
278
+
279
+ // Allow workspace and temp file access
280
+ permit (
281
+ principal == User::"mcp_client",
282
+ action in [Action::"read_file", Action::"write_file"],
283
+ resource
284
+ ) when {
285
+ context has path &&
286
+ ((context has is_within_workspace &&
287
+ context.is_within_workspace == true) ||
288
+ context.path like "/tmp/*" ||
289
+ context.path like "/var/tmp/*" ||
290
+ context.path like "./tmp/*" ||
291
+ context.path like "*/tmp/*" ||
292
+ context.path like "~/tmp/*")
293
+ };
294
+
295
+ // ============================================================================
296
+ // HTTP REQUEST CONTROL - SSRF PROTECTION
297
+ // ============================================================================
298
+ // @compliance_id: "HTTP_SSRF_001"
299
+ // @frameworks: ["NIST-800-53", "OWASP-Top10", "MITRE-ATT&CK", "CIS-Controls"]
300
+ // @nist: SC-7 (Boundary Protection), SI-3 (Malicious Code Protection), AC-4 (Information Flow Enforcement)
301
+ // @owasp: A10 (Server-Side Request Forgery), V5.2.5 (Sanitization and Sandboxing Requirements)
302
+ // @mitre: T1071.001 (Web Protocols), T1190 (Exploit Public-Facing Application)
303
+ // @cis: 12.1 (Network Infrastructure Management), 13.1 (Network Ports, Protocols and Services)
304
+ // @description: "Prevents Server-Side Request Forgery (SSRF) attacks by blocking requests to private networks"
305
+ // @severity: HIGH
306
+ // @category: "Network Security / SSRF Prevention"
307
+
308
+ // Block requests to private/internal networks (SSRF protection)
309
+ forbid (
310
+ principal == User::"mcp_client",
311
+ action == Action::"http_request",
312
+ resource
313
+ ) when {
314
+ context has ip_address &&
315
+ (context.ip_address like "127.*" || // IPv4 loopback
316
+ context.ip_address like "10.*" || // RFC1918
317
+ context.ip_address like "172.16.*" || // RFC1918 subset
318
+ context.ip_address like "172.17.*" ||
319
+ context.ip_address like "172.18.*" ||
320
+ context.ip_address like "172.19.*" ||
321
+ context.ip_address like "172.2?.*" ||
322
+ context.ip_address like "172.3?.*" ||
323
+ context.ip_address like "192.168.*" || // RFC1918
324
+ context.ip_address like "169.254.*" || // IPv4 link-local
325
+ context.ip_address like "100.64.*" || // Carrier-grade NAT subset
326
+ context.ip_address like "224.*" || // Multicast subset
327
+ context.ip_address == "::1" || // IPv6 loopback
328
+ context.ip_address like "fc*" || // IPv6 unique local
329
+ context.ip_address like "fd*" ||
330
+ context.ip_address like "fe8*") // IPv6 link-local
331
+ };
332
+
333
+ // HTTP response size limits are handled by the general response size policies below
334
+
335
+
336
+ // ============================================================================
337
+ // SECRET DETECTION - AWS ACCESS KEY PROTECTION
338
+ // ============================================================================
339
+ // @compliance_id: "SECRET_AWS_001"
340
+ // @frameworks: ["NIST-800-53", "OWASP-Top10", "MITRE-ATT&CK", "CIS-Controls"]
341
+ // @nist: IA-5 (Authenticator Management), SC-28 (Protection of Information at Rest)
342
+ // @owasp: A02 (Cryptographic Failures), V2.1.1 (Password Security)
343
+ // @mitre: T1552.001 (Credentials In Files), T1555 (Credentials from Password Stores)
344
+ // @cis: 16.1 (Network Monitoring and Defense), 18.1 (Application Software Security)
345
+ // @description: "Detects and blocks AWS access keys from being exposed in responses"
346
+ // @severity: CRITICAL
347
+ // @category: "Credential Protection / AWS Security"
348
+
349
+ // Block responses containing AWS access keys
350
+ forbid (
351
+ principal,
352
+ action,
353
+ resource
354
+ ) when {
355
+ context has response_content &&
356
+ context.response_content like "*AKIA*"
357
+ };
358
+
359
+ // Block responses containing AWS secret keys
360
+ forbid (
361
+ principal,
362
+ action,
363
+ resource
364
+ ) when {
365
+ context has response_content &&
366
+ (context.response_content like "*AWS_SECRET_ACCESS_KEY*" ||
367
+ context.response_content like "*aws_secret_access_key*")
368
+ };
369
+
370
+ // Block responses containing GitHub tokens
371
+ forbid (
372
+ principal,
373
+ action,
374
+ resource
375
+ ) when {
376
+ context has response_content &&
377
+ (context.response_content like "*ghp_*" ||
378
+ context.response_content like "*github_pat_*" ||
379
+ context.response_content like "*ghs_*")
380
+ };
381
+
382
+ // Block responses containing AI API keys - use YARA threat analysis
383
+ forbid (
384
+ principal,
385
+ action,
386
+ resource
387
+ ) when {
388
+ context has yara_threats &&
389
+ (context.yara_threats.contains("openai_api_key") ||
390
+ context.yara_threats.contains("anthropic_api_key") ||
391
+ context.yara_threats.contains("ai_service_key"))
392
+ };
393
+
394
+ // Block responses containing SSH private keys
395
+ forbid (
396
+ principal,
397
+ action,
398
+ resource
399
+ ) when {
400
+ context has response_content &&
401
+ (context.response_content like "*-----BEGIN PRIVATE KEY-----*" ||
402
+ context.response_content like "*-----BEGIN RSA PRIVATE KEY-----*" ||
403
+ context.response_content like "*-----BEGIN OPENSSH PRIVATE KEY-----*")
404
+ };
405
+
406
+ // Block responses containing JWTs - use YARA threat analysis for sophisticated detection
407
+ forbid (
408
+ principal,
409
+ action,
410
+ resource
411
+ ) when {
412
+ context has yara_threats &&
413
+ context.yara_threats.contains("jwt_token_exposure") ||
414
+ context has yara_threats &&
415
+ context.yara_threats.contains("bearer_token_leak")
416
+ };
417
+
418
+ // Block responses containing common secret patterns - use YARA threat analysis
419
+ forbid (
420
+ principal,
421
+ action,
422
+ resource
423
+ ) when {
424
+ context has yara_threats &&
425
+ (context.yara_threats.contains("secret_exposure") ||
426
+ context.yara_threats.contains("credential_leak") ||
427
+ context.yara_threats.contains("api_key_exposure"))
428
+ };
429
+
430
+ // === RESPONSE SIZE LIMITS ===
431
+ // Response size limits are handled by specific Enhanced Response Size Policies below
432
+ // This allows for different limits for different types of responses
433
+
434
+ // ============================================================================
435
+ // CONCURRENCY AND RATE LIMITS - RESOURCE PROTECTION
436
+ // ============================================================================
437
+ // @compliance_id: "RATE_LIMIT_001"
438
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
439
+ // @nist: SC-5 (Denial of Service Protection), AC-7 (Unsuccessful Logon Attempts)
440
+ // @owasp: V4.2.1 (Operation Level Access Control), V11.1.1 (Business Logic Security Requirements)
441
+ // @cis: 13.1 (Network Ports, Protocols and Services)
442
+ // @description: "Prevents resource exhaustion by limiting concurrent operations"
443
+ // @severity: MEDIUM
444
+ // @category: "Resource Management / DoS Prevention"
445
+
446
+ // Block requests exceeding concurrent tool call limits
447
+ forbid (
448
+ principal == User::"mcp_client",
449
+ action == Action::"call_tool",
450
+ resource
451
+ ) when {
452
+ context has concurrent_calls && context.concurrent_calls > 4
453
+ };
454
+
455
+ // @compliance_id: "RATE_LIMIT_002"
456
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
457
+ // @nist: SC-5 (Denial of Service Protection), AC-7 (Unsuccessful Logon Attempts)
458
+ // @owasp: V4.2.1 (Operation Level Access Control), V11.1.1 (Business Logic Security Requirements)
459
+ // @cis: 13.1 (Network Ports, Protocols and Services)
460
+ // @description: "Prevents abuse by enforcing per-minute request rate limits"
461
+ // @severity: MEDIUM
462
+ // @category: "Resource Management / Rate Limiting"
463
+
464
+ // Block requests exceeding rate limits
465
+ forbid (
466
+ principal == User::"mcp_client",
467
+ action,
468
+ resource
469
+ ) when {
470
+ context has requests_per_minute && context.requests_per_minute > 100
471
+ };
472
+
473
+ // ============================================================================
474
+ // SECURITY SCANNING AUTHORIZATION - VULNERABILITY MANAGEMENT
475
+ // ============================================================================
476
+ // @compliance_id: "SCAN_AUTH_001"
477
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
478
+ // @nist: RA-5 (Vulnerability Scanning), SI-2 (Flaw Remediation), CA-2 (Security Assessments)
479
+ // @owasp: V14.1.1 (Build and Deploy Requirements), V14.2.1 (Dependency Requirements)
480
+ // @cis: 7.1 (Malware Defenses), 18.1 (Application Software Security)
481
+ // @description: "Authorizes legitimate security scanning operations for vulnerability assessment"
482
+ // @severity: LOW
483
+ // @category: "Security Operations / Vulnerability Management"
484
+
485
+ // Allow security scanner to scan targets
486
+ permit (
487
+ principal == User::"security_scanner",
488
+ action == Action::"scan_target",
489
+ resource
490
+ ) when {
491
+ context has scan_type &&
492
+ (context.scan_type == "vulnerability_scan" ||
493
+ context.scan_type == "security_audit" ||
494
+ context.scan_type == "compliance_check")
495
+ };
496
+
497
+ // @compliance_id: "VULN_FLAG_001"
498
+ // @frameworks: ["NIST-800-53", "CIS-Controls"]
499
+ // @nist: RA-5 (Vulnerability Scanning), SI-2 (Flaw Remediation), IR-4 (Incident Handling)
500
+ // @cis: 7.1 (Malware Defenses), 18.1 (Application Software Security)
501
+ // @description: "Allows flagging of discovered vulnerabilities with appropriate severity classification"
502
+ // @severity: LOW
503
+ // @category: "Vulnerability Management / Incident Response"
504
+
505
+ // Allow flagging vulnerabilities found during scans
506
+ permit (
507
+ principal == User::"security_scanner",
508
+ action == Action::"flag_vulnerability",
509
+ resource
510
+ ) when {
511
+ context has severity &&
512
+ context.severity in ["low", "medium", "high", "critical"]
513
+ };
514
+
515
+ // ============================================================================
516
+ // YARA THREAT-BASED SECURITY POLICIES - ADVANCED THREAT DETECTION
517
+ // ============================================================================
518
+ // @compliance_id: "YARA_THREAT_001"
519
+ // @frameworks: ["NIST-800-53", "MITRE-ATT&CK", "CIS-Controls"]
520
+ // @nist: SI-3 (Malicious Code Protection), SI-4 (Information System Monitoring)
521
+ // @mitre: T1027 (Obfuscated Files or Information), T1204 (User Execution)
522
+ // @cis: 8.1 (Malware Defenses), 16.1 (Network Monitoring and Defense)
523
+ // @description: "Uses YARA rules for advanced threat detection and automatic blocking of critical threats"
524
+ // @severity: CRITICAL
525
+ // @category: "Threat Detection / Malware Protection"
526
+
527
+ // CRITICAL threats: Always reject
528
+ forbid (
529
+ principal == User::"threat_processor",
530
+ action == Action::"process_prompt",
531
+ resource == Resource::"threat_analysis"
532
+ ) when {
533
+ context has max_threat_severity && context.max_threat_severity >= 4
534
+ };
535
+
536
+ // HIGH severity threats: Reject by default, allow only for trusted users
537
+ forbid (
538
+ principal == User::"threat_processor",
539
+ action == Action::"process_prompt",
540
+ resource == Resource::"threat_analysis"
541
+ ) when {
542
+ context has max_threat_severity && context.max_threat_severity >= 3 &&
543
+ context has user_trust_level && context.user_trust_level != "high"
544
+ };
545
+
546
+ // Command injection: Always reject
547
+ // YARA rule name is "command_injection" - check both yara_threats and threat_types for compatibility
548
+ forbid (
549
+ principal == User::"threat_processor",
550
+ action == Action::"process_prompt",
551
+ resource == Resource::"threat_analysis"
552
+ ) when {
553
+ context has yara_threats && context.yara_threats.contains("command_injection")
554
+ };
555
+
556
+ // Prompt injection: Always reject
557
+ // YARA rule name is "prompt_injection" - blocks jailbreak attempts, DAN mode, etc.
558
+ forbid (
559
+ principal == User::"threat_processor",
560
+ action == Action::"process_prompt",
561
+ resource == Resource::"threat_analysis"
562
+ ) when {
563
+ context has yara_threats && context.yara_threats.contains("prompt_injection")
564
+ };
565
+
566
+ // Secrets leakage: Alert but allow for internal users
567
+ // YARA rule name is "secrets_leakage"
568
+ permit (
569
+ principal == User::"threat_processor",
570
+ action == Action::"process_prompt",
571
+ resource == Resource::"threat_analysis"
572
+ ) when {
573
+ context has yara_threats && context.yara_threats.contains("secrets_leakage") &&
574
+ context has user_type && context.user_type == "internal" &&
575
+ context has alert_enabled && context.alert_enabled == true
576
+ };
577
+
578
+ // Cross-origin escalation: Monitor and warn
579
+ // YARA rule name is "cross_origin_escalation"
580
+ permit (
581
+ principal == User::"threat_processor",
582
+ action == Action::"process_prompt",
583
+ resource == Resource::"threat_analysis"
584
+ ) when {
585
+ context has yara_threats && context.yara_threats.contains("cross_origin_escalation") &&
586
+ context has monitoring_enabled && context.monitoring_enabled == true
587
+ };
588
+
589
+ // Path traversal: Block external users, warn internal users
590
+ // YARA rule name is "path_traversal"
591
+ forbid (
592
+ principal == User::"threat_processor",
593
+ action == Action::"process_prompt",
594
+ resource == Resource::"threat_analysis"
595
+ ) when {
596
+ context has yara_threats && context.yara_threats.contains("path_traversal") &&
597
+ context has user_type && context.user_type == "external"
598
+ };
599
+
600
+ // No threats detected: Always allow
601
+ permit (
602
+ principal == User::"threat_processor",
603
+ action == Action::"process_prompt",
604
+ resource == Resource::"threat_analysis"
605
+ ) when {
606
+ context has threat_count && context.threat_count == 0
607
+ };
608
+
609
+ // Low severity threats: Always allow with monitoring
610
+ permit (
611
+ principal == User::"threat_processor",
612
+ action == Action::"process_prompt",
613
+ resource == Resource::"threat_analysis"
614
+ ) when {
615
+ context has max_threat_severity && context.max_threat_severity <= 1
616
+ };
617
+
618
+ // ============================================================================
619
+ // ENHANCED RESPONSE SIZE POLICIES - RESOURCE MANAGEMENT
620
+ // ============================================================================
621
+ // @compliance_id: "RESP_SIZE_001"
622
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
623
+ // @nist: SC-5 (Denial of Service Protection), SC-6 (Resource Availability)
624
+ // @owasp: V11.1.1 (Business Logic Security Requirements), V4.2.1 (Operation Level Access Control)
625
+ // @cis: 13.1 (Network Ports, Protocols and Services)
626
+ // @description: "Controls response sizes to prevent resource exhaustion and ensure system stability"
627
+ // @severity: MEDIUM
628
+ // @category: "Resource Management / DoS Prevention"
629
+
630
+ // Allow responses up to 50MB
631
+ permit (
632
+ principal == User::"mcp_client",
633
+ action == Action::"process_response",
634
+ resource == ResponseData::"response_data"
635
+ ) when {
636
+ context has response_size_mb && context.response_size_mb <= 50
637
+ };
638
+
639
+ // @compliance_id: "RESP_SIZE_002"
640
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
641
+ // @nist: SC-5 (Denial of Service Protection), SC-6 (Resource Availability)
642
+ // @owasp: V11.1.1 (Business Logic Security Requirements)
643
+ // @cis: 13.1 (Network Ports, Protocols and Services)
644
+ // @description: "Hard limit on response sizes to prevent system overload and memory exhaustion"
645
+ // @severity: HIGH
646
+ // @category: "Resource Management / System Protection"
647
+
648
+ // Block responses over 100MB
649
+ forbid (
650
+ principal == User::"mcp_client",
651
+ action == Action::"process_response",
652
+ resource == ResponseData::"response_data"
653
+ ) when {
654
+ context has response_size_mb && context.response_size_mb > 100
655
+ };
656
+
657
+ // ============================================================================
658
+ // GUARDRAIL SKIP POLICIES - SELECTIVE BYPASS CONTROL
659
+ // ============================================================================
660
+ // @compliance_id: "GUARDRAIL_001"
661
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS"]
662
+ // @nist: AC-3 (Access Enforcement), AC-6 (Least Privilege)
663
+ // @owasp: V4.1.1 (General Access Control Design), V4.2.1 (Operation Level Access Control)
664
+ // @description: "Allows selective bypass of guardrails for safe, read-only operations while maintaining security"
665
+ // @severity: LOW
666
+ // @category: "Access Control / Performance Optimization"
667
+
668
+ // Allow skipping guardrails for safe read-only methods
669
+ permit (
670
+ principal == User::"mcp_client",
671
+ action == Action::"skip_guardrails",
672
+ resource == Resource::"tools/list"
673
+ );
674
+
675
+ permit (
676
+ principal == User::"mcp_client",
677
+ action == Action::"skip_guardrails",
678
+ resource == Resource::"resources/list"
679
+ );
680
+
681
+ permit (
682
+ principal == User::"mcp_client",
683
+ action == Action::"skip_guardrails",
684
+ resource == Resource::"prompts/list"
685
+ );
686
+
687
+ // @compliance_id: "GUARDRAIL_002"
688
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
689
+ // @nist: AC-3 (Access Enforcement), SI-3 (Malicious Code Protection)
690
+ // @owasp: V4.1.1 (General Access Control Design)
691
+ // @cis: 5.1 (Account Management)
692
+ // @description: "Prevents bypass of security guardrails for potentially dangerous operations"
693
+ // @severity: HIGH
694
+ // @category: "Security Enforcement / Guardrail Protection"
695
+
696
+ // Block skipping guardrails for potentially dangerous methods
697
+ forbid (
698
+ principal == User::"mcp_client",
699
+ action == Action::"skip_guardrails",
700
+ resource == Resource::"tools/call"
701
+ );
702
+
703
+ forbid (
704
+ principal == User::"mcp_client",
705
+ action == Action::"skip_guardrails",
706
+ resource == Resource::"resources/read"
707
+ );
708
+
709
+ // Block skipping guardrails for unknown methods (regular LLM chat requests)
710
+ // These should always go through Javelin Guardrails validation
711
+ forbid (
712
+ principal == User::"mcp_client",
713
+ action == Action::"skip_guardrails",
714
+ resource == Resource::"unknown"
715
+ );
716
+
717
+ // ============================================================================
718
+ // ENHANCED SERVER-SPECIFIC ACCESS POLICIES - LEAST PRIVILEGE ACCESS
719
+ // ============================================================================
720
+ // @compliance_id: "SERVER_ACCESS_001"
721
+ // @frameworks: ["NIST-800-53", "OWASP-ASVS", "CIS-Controls"]
722
+ // @nist: AC-3 (Access Enforcement), AC-6 (Least Privilege), AC-4 (Information Flow Enforcement)
723
+ // @owasp: V4.1.1 (General Access Control Design), V4.2.1 (Operation Level Access Control)
724
+ // @cis: 5.1 (Account Management), 12.1 (Network Infrastructure Management)
725
+ // @description: "Default-allow policy for server resources with explicit security restrictions"
726
+ // @severity: MEDIUM
727
+ // @category: "Access Control / Server Authorization"
728
+
729
+ // Default allow for server-specific access unless explicitly forbidden
730
+ permit (
731
+ principal == User::"mcp_client",
732
+ action == Action::"access_server_resource",
733
+ resource
734
+ );
735
+
736
+ // @compliance_id: "SERVER_BLOCK_001"
737
+ // @frameworks: ["NIST-800-53", "OWASP-Top10", "MITRE-ATT&CK", "CIS-Controls"]
738
+ // @nist: AC-3 (Access Enforcement), SI-3 (Malicious Code Protection), CM-7 (Least Functionality)
739
+ // @owasp: A01 (Broken Access Control), A03 (Injection)
740
+ // @mitre: T1059 (Command and Scripting Interpreter), T1059.004 (Unix Shell)
741
+ // @cis: 5.1 (Secure System Boot Settings)
742
+ // @description: "Blocks dangerous command execution tools across all server contexts"
743
+ // @severity: CRITICAL
744
+ // @category: "Command Injection Prevention / Server Security"
745
+
746
+ // Block dangerous tools on any server
747
+ forbid (
748
+ principal == User::"mcp_client",
749
+ action == Action::"access_server_resource",
750
+ resource
751
+ ) when {
752
+ context has tool_name &&
753
+ (context.tool_name == "shell" ||
754
+ context.tool_name == "bash" ||
755
+ context.tool_name == "system.exec" ||
756
+ context.tool_name == "process.spawn")
757
+ };
758
+
759
+ // Block access to sensitive resources
760
+ forbid (
761
+ principal == User::"mcp_client",
762
+ action == Action::"access_server_resource",
763
+ resource
764
+ ) when {
765
+ context has resource_name &&
766
+ (context.resource_name.contains("/etc/") ||
767
+ context.resource_name.contains("passwd") ||
768
+ context.resource_name.contains("shadow") ||
769
+ context.resource_name.contains(".ssh/"))
770
+ };
771
+
772
+ // Block dangerous prompts that might leak system information
773
+ forbid (
774
+ principal == User::"mcp_client",
775
+ action == Action::"access_server_resource",
776
+ resource
777
+ ) when {
778
+ context has prompt_name &&
779
+ (context.prompt_name.contains("system") ||
780
+ context.prompt_name.contains("admin") ||
781
+ context.prompt_name.contains("root"))
782
+ };
783
+