@highflame/policy 2.1.15 → 2.1.16

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.
@@ -1,15 +1,307 @@
1
1
  // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
- // Source: schemas/guardrails/schema.cedarschema, schemas/mcp_gateway/schema.cedarschema, schemas/overwatch/schema.cedarschema, schemas/palisade/schema.cedarschema, schemas/sentry/schema.cedarschema
2
+ // Source: schemas/ai_gateway/schema.cedarschema, schemas/guardrails/schema.cedarschema, schemas/overwatch/schema.cedarschema, schemas/palisade/schema.cedarschema, schemas/sentry/schema.cedarschema
3
3
  //
4
4
  // Service-specific Cedar schemas and context metadata.
5
5
  // Works in both browser and Node.js environments.
6
6
  //
7
7
  // Usage:
8
+ // import { AI_GATEWAY_SCHEMA, AI_GATEWAY_CONTEXT } from '@highflame/policy/types';
8
9
  // import { GUARDRAILS_SCHEMA, GUARDRAILS_CONTEXT } from '@highflame/policy/types';
9
- // import { MCP_GATEWAY_SCHEMA, MCP_GATEWAY_CONTEXT } from '@highflame/policy/types';
10
10
  // import { OVERWATCH_SCHEMA, OVERWATCH_CONTEXT } from '@highflame/policy/types';
11
11
  // import { PALISADE_SCHEMA, PALISADE_CONTEXT } from '@highflame/policy/types';
12
12
  // import { SENTRY_SCHEMA, SENTRY_CONTEXT } from '@highflame/policy/types';
13
+ /**
14
+ * AiGateway Cedar schema
15
+ *
16
+ * Full Cedar schema for ai_gateway, embedded at codegen time.
17
+ */
18
+ export const AI_GATEWAY_SCHEMA = `// AIGateway Cedar Schema
19
+ // ===================================
20
+ // AI Gateway Security & Policy Enforcement
21
+ //
22
+ // AIGateway protects both MCP proxy operations (tool calls, server connections)
23
+ // and LLM chat completions (prompt processing) by evaluating threats detected
24
+ // by the Shield detection engine pipeline against Cedar policies.
25
+ //
26
+ // Architecture:
27
+ // MCP/LLM Client -> Firehog Proxy -> Shield (detection + Cedar) -> Allow/Deny
28
+ //
29
+ // Threat Coverage:
30
+ // - OWASP Top 10 for LLM Applications 2025 (LLM01, LLM06)
31
+ // - OWASP Top 10 for Agentic Applications (ASI01, ASI02, ASI04)
32
+ // - OWASP MCP Top 10 (MCP01-MCP05)
33
+
34
+ namespace AIGateway {
35
+
36
+ // =============================================================================
37
+ // ENTITIES - Tenant Hierarchy (ReBAC)
38
+ // =============================================================================
39
+ // AIGateway does not use App/Session hierarchy.
40
+ //
41
+ // Entity hierarchy:
42
+ // Account (org root)
43
+ // -> Project in [Account]
44
+ // -> Tool/Server in [Project]
45
+ //
46
+ // Policy scoping examples:
47
+ // resource == AIGateway::Tool::"get_me" -> specific tool
48
+ // resource in AIGateway::Project::"<uuid>" -> project-wide
49
+ // resource in AIGateway::Account::"<uuid>" -> org-wide
50
+
51
+ /// Account represents an organization (top-level tenant)
52
+ entity Account;
53
+
54
+ /// Project represents a project within an account
55
+ entity Project in [Account];
56
+
57
+ // =============================================================================
58
+ // ENTITIES - Principals
59
+ // =============================================================================
60
+
61
+ /// Human user authenticated via JWT or API key
62
+ entity User;
63
+
64
+ /// MCP client (default principal for unauthenticated requests)
65
+ entity MCP_Client;
66
+
67
+ // =============================================================================
68
+ // ENTITIES - Resources (scoped under Project)
69
+ // =============================================================================
70
+
71
+ /// MCP tool -- resource for call_tool action
72
+ entity Tool in [Project];
73
+
74
+ /// MCP server -- resource for connect_server action
75
+ entity Server in [Project];
76
+
77
+ /// MCP prompt -- resource for process_prompt action
78
+ entity LlmPrompt in [Project];
79
+
80
+ /// File/resource path -- resource for read_file/write_file actions
81
+ entity FilePath in [Project];
82
+
83
+ // =============================================================================
84
+ // ACTIONS
85
+ // =============================================================================
86
+
87
+ // Call an MCP tool
88
+ // Threat focus: command injection, tool poisoning, rug pull, secrets, PII
89
+ action call_tool appliesTo {
90
+ principal: [User, MCP_Client],
91
+ resource: [Tool],
92
+ context: {
93
+ // --- Content ---
94
+ content: String, // Raw content being scanned
95
+
96
+ // --- Tool & MCP ---
97
+ tool_name?: String, // Tool name
98
+ mcp_server?: String, // MCP server name
99
+ mcp_tool?: String, // MCP tool name
100
+
101
+ // --- Threat Detection (from Shield detection pipeline) ---
102
+ threat_count?: Long, // Total threats detected
103
+ highest_severity?: String, // "critical", "high", "medium", "low", "none"
104
+ threat_categories?: Set<String>, // Threat category names
105
+ detected_threats?: Set<String>, // Detection rule names that matched
106
+ max_threat_severity?: Long, // Numeric severity (0=none, 1=low, 2=medium, 3=high, 4=critical)
107
+ contains_secrets?: Bool, // Whether secrets/credentials detected
108
+
109
+ // --- Secrets (granular) ---
110
+ secret_types?: Set<String>,
111
+ secret_count?: Long,
112
+
113
+ // --- PII Detection ---
114
+ pii_detected?: Bool,
115
+ pii_types?: Set<String>,
116
+ pii_count?: Long,
117
+
118
+ // --- ML Detector Confidence Scores (0-100) ---
119
+ injection_confidence?: Long, // Prompt injection classifier confidence
120
+ jailbreak_confidence?: Long, // Jailbreak detection classifier confidence
121
+
122
+ // --- Agent Security (0-100) ---
123
+ tool_poisoning_score?: Long, // Hidden instructions in tool description/args
124
+ tool_poisoning_detected?: Bool,
125
+ rug_pull_score?: Long, // Tool behavior drift after trust establishment
126
+ rug_pull_detected?: Bool,
127
+ indirect_injection_score?: Long, // Indirect injection via tool output
128
+
129
+ // --- Tool Risk Assessment ---
130
+ tool_risk_score?: Long, // Computed tool risk (0-100)
131
+ tool_category?: String, // "safe", "sensitive", "dangerous"
132
+ tool_is_sensitive?: Bool,
133
+ tool_is_builtin?: Bool,
134
+
135
+ // --- MCP Trust ---
136
+ mcp_server_verified?: Bool, // Whether server is from verified registry
137
+
138
+ // --- Content Safety Scores (0-100) ---
139
+ violence_score?: Long,
140
+ weapons_score?: Long,
141
+ hate_speech_score?: Long,
142
+ crime_score?: Long,
143
+ sexual_score?: Long,
144
+ profanity_score?: Long,
145
+
146
+ // --- Encoding & Unicode Attacks ---
147
+ contains_invisible_chars?: Bool,
148
+ invisible_chars_score?: Long,
149
+
150
+ // --- Behavioral Analysis ---
151
+ loop_detected?: Bool,
152
+ loop_count?: Long,
153
+ loop_tool?: String,
154
+ suspicious_pattern?: Bool,
155
+ pattern_type?: String,
156
+ sequence_risk?: Long,
157
+ },
158
+ };
159
+
160
+ // Connect to an MCP server
161
+ // Threat focus: supply chain, tool poisoning, rug pull, config risk
162
+ action connect_server appliesTo {
163
+ principal: [User, MCP_Client],
164
+ resource: [Server],
165
+ context: {
166
+ content?: String, // Server config content (if available)
167
+ mcp_server?: String,
168
+
169
+ // --- Threat Detection ---
170
+ threat_count?: Long,
171
+ highest_severity?: String,
172
+ threat_categories?: Set<String>,
173
+ max_threat_severity?: Long,
174
+
175
+ // --- Agent Security (0-100) ---
176
+ tool_poisoning_score?: Long,
177
+ tool_poisoning_detected?: Bool,
178
+ rug_pull_score?: Long,
179
+ rug_pull_detected?: Bool,
180
+ indirect_injection_score?: Long,
181
+
182
+ // --- Secrets ---
183
+ contains_secrets?: Bool,
184
+ secret_types?: Set<String>,
185
+ secret_count?: Long,
186
+
187
+ // --- PII Detection ---
188
+ pii_detected?: Bool,
189
+ pii_types?: Set<String>,
190
+ pii_count?: Long,
191
+
192
+ // --- MCP Trust & Config Risk ---
193
+ mcp_server_verified?: Bool,
194
+ mcp_config_risk?: Bool,
195
+ mcp_risk_score?: Long,
196
+ },
197
+ };
198
+
199
+ // Process a prompt (MCP prompts/get or LLM chat completions)
200
+ // Threat focus: injection, jailbreak, secrets, PII, content safety
201
+ action process_prompt appliesTo {
202
+ principal: [User, MCP_Client],
203
+ resource: [LlmPrompt],
204
+ context: {
205
+ content: String,
206
+ mcp_server?: String,
207
+
208
+ // --- Threat Detection ---
209
+ threat_count?: Long,
210
+ highest_severity?: String,
211
+ threat_categories?: Set<String>,
212
+ detected_threats?: Set<String>,
213
+ max_threat_severity?: Long,
214
+ contains_secrets?: Bool,
215
+
216
+ // --- Secrets ---
217
+ secret_types?: Set<String>,
218
+ secret_count?: Long,
219
+
220
+ // --- PII Detection ---
221
+ pii_detected?: Bool,
222
+ pii_types?: Set<String>,
223
+ pii_count?: Long,
224
+
225
+ // --- ML Detector Confidence Scores (0-100) ---
226
+ injection_confidence?: Long,
227
+ jailbreak_confidence?: Long,
228
+
229
+ // --- Content Safety Scores (0-100) ---
230
+ violence_score?: Long,
231
+ weapons_score?: Long,
232
+ hate_speech_score?: Long,
233
+ crime_score?: Long,
234
+ sexual_score?: Long,
235
+ profanity_score?: Long,
236
+
237
+ // --- Encoding ---
238
+ contains_invisible_chars?: Bool,
239
+ invisible_chars_score?: Long,
240
+
241
+ // --- LLM-specific ---
242
+ model_name?: String, // Target model name (e.g., "gpt-4", "claude-3-opus")
243
+ model_provider?: String, // Provider name (e.g., "openai", "anthropic", "bedrock")
244
+ },
245
+ };
246
+
247
+ // Read an MCP resource (resources/read, resources/list)
248
+ // Threat focus: secrets exposure, PII exposure, sensitive paths
249
+ action read_file appliesTo {
250
+ principal: [User, MCP_Client],
251
+ resource: [FilePath],
252
+ context: {
253
+ content: String,
254
+ mcp_server?: String,
255
+
256
+ // --- Threat Detection ---
257
+ threat_count?: Long,
258
+ highest_severity?: String,
259
+ threat_categories?: Set<String>,
260
+ detected_threats?: Set<String>,
261
+ max_threat_severity?: Long,
262
+ contains_secrets?: Bool,
263
+
264
+ // --- Secrets ---
265
+ secret_types?: Set<String>,
266
+ secret_count?: Long,
267
+
268
+ // --- PII Detection ---
269
+ pii_detected?: Bool,
270
+ pii_types?: Set<String>,
271
+ pii_count?: Long,
272
+ },
273
+ };
274
+
275
+ // Write an MCP resource (resources/write)
276
+ // Threat focus: secrets in output, PII in output
277
+ action write_file appliesTo {
278
+ principal: [User, MCP_Client],
279
+ resource: [FilePath],
280
+ context: {
281
+ content: String,
282
+ mcp_server?: String,
283
+
284
+ // --- Threat Detection ---
285
+ threat_count?: Long,
286
+ highest_severity?: String,
287
+ threat_categories?: Set<String>,
288
+ detected_threats?: Set<String>,
289
+ max_threat_severity?: Long,
290
+ contains_secrets?: Bool,
291
+
292
+ // --- Secrets ---
293
+ secret_types?: Set<String>,
294
+ secret_count?: Long,
295
+
296
+ // --- PII Detection ---
297
+ pii_detected?: Bool,
298
+ pii_types?: Set<String>,
299
+ pii_count?: Long,
300
+ },
301
+ };
302
+
303
+ }
304
+ `;
13
305
  /**
14
306
  * Guardrails Cedar schema
15
307
  *
@@ -200,231 +492,13 @@ namespace Guardrails {
200
492
  "keyword_categories"?: Set<String>,
201
493
  "keyword_count"?: Long,
202
494
  "contains_non_ascii"?: Bool,
203
- "phishing_detected"?: Bool,
204
- "content_safety_score"?: Long, // 0-100
205
- "content_safety_blocked"?: Bool,
206
-
207
- // Agentic - Multi-Turn Context (optional)
208
- "conversation_turn"?: Long,
209
- "multi_turn_detection"?: Bool,
210
-
211
- // Session Detection History — cross-turn sticky flags (optional)
212
- "session_pii_detected"?: Bool,
213
- "session_pii_types"?: Set<String>,
214
- "session_secrets_detected"?: Bool,
215
- "session_secret_types"?: Set<String>,
216
- "session_injection_detected"?: Bool,
217
- "session_command_injection"?: Bool,
218
- "session_threat_turns"?: Long,
219
- "session_max_injection_score"?: Long,
220
- "session_max_jailbreak_score"?: Long,
221
- "session_max_command_injection_score"?: Long,
222
- "session_max_pii_score"?: Long,
223
- "session_max_secret_score"?: Long,
224
- "session_cumulative_risk_score"?: Long,
225
-
226
- // Agent Identity — authenticated agent principal metadata (optional)
227
- // Present when the request is made by an AI agent (API key or JWT with agent claims).
228
- // Empty strings for human user requests. Use these to write agent-specific policies.
229
- "agent_id"?: String, // Unique agent identifier (e.g., "agent_research_v3")
230
- "agent_type"?: String, // "orchestrator" | "autonomous" | "tool_agent" | "human_proxy"
231
- "agent_trust_level"?: String, // "first_party" | "verified_third_party" | "unverified"
232
- "agent_framework"?: String, // Agent framework (e.g., "claude-code", "langchain", "crewai")
233
- "agent_publisher"?: String, // Organization that published the agent
234
-
235
- };
236
-
237
- /// Context for call_tool action (agentic tool execution)
238
- type CallToolContext = {
239
- // Core metadata (required)
240
- "request_id": String,
241
- "timestamp": Long,
242
-
243
- // Tool Risk (optional)
244
- "tool_name"?: String, // "shell", "write_file", "http_post", etc.
245
- "tool_risk_score"?: Long, // 0-100
246
- "tool_is_sensitive"?: Bool,
247
- "tool_category"?: String, // "safe" | "sensitive" | "dangerous"
248
- "tool_is_builtin"?: Bool,
249
-
250
- // MCP context (optional — only present for MCP tool calls)
251
- "mcp_server"?: String, // MCP server name (e.g., "github", "filesystem")
252
- "mcp_tool"?: String, // MCP tool name within the server
253
- "mcp_server_verified"?: Bool, // Whether server is from verified registry
254
-
255
- // Agentic - Behavioral Patterns (optional)
256
- "suspicious_pattern"?: Bool,
257
- "pattern_type"?: String, // "data_exfiltration" | "secret_exfiltration" | "db_exfiltration" | "credential_theft" | "destructive_sequence" | "none"
258
- "sequence_risk"?: Long, // 0-100
259
-
260
- // Agentic - Loop Detection (optional)
261
- "loop_detected"?: Bool,
262
- "loop_count"?: Long,
263
- "loop_tool"?: String,
264
-
265
- // Agentic - Budget Control (optional)
266
- "budget_remaining_pct"?: Long, // 0-100
267
- "budget_exceeded"?: Bool,
268
-
269
- // Semantic - Topic Classification (optional)
270
- "content_topics"?: Set<String>, // ["controlled_substances", "weapons_manufacturing", ...]
271
- "topic_confidence"?: Long, // 0-100
272
-
273
- // Security checks on tool arguments (optional)
274
- "contains_secrets"?: Bool,
275
- "secret_count"?: Long,
276
- "secret_types"?: Set<String>,
277
- "pii_detected"?: Bool,
278
- "pii_types"?: Set<String>,
279
- "pii_count"?: Long, // Number of PII pattern matches in tool content
280
- "pii_confidence"?: Long, // PII ML classifier confidence (0-100)
281
- "injection_confidence"?: Long,
282
- "injection_pulse_score"?: Long, // 0-100 Pulse single-turn classifier
283
- "injection_deep_context_score"?: Long, // 0-100 DeepContext multi-turn
284
-
285
- // Security - Pattern Detection (optional)
286
- "command_injection_detected"?: Bool,
287
- "command_injection_type"?: String,
288
- "command_injection_score"?: Long, // 0-100
289
- "path_traversal_detected"?: Bool,
290
- "path_traversal_severity"?: String,
291
- "path_traversal_type"?: String,
292
- "sql_injection_detected"?: Bool,
293
- "sql_injection_type"?: String,
294
- "sql_injection_score"?: Long, // 0-100
295
-
296
- // Security - Cross-Origin Escalation (optional)
297
- "cross_origin_detected"?: Bool,
298
- "cross_origin_type"?: String,
299
- "cross_origin_score"?: Long, // 0-100
300
-
301
- // File & Path (optional — for path-based access control policies)
302
- "path"?: String, // File path when tool operates on files
303
-
304
- // Security - Invisible Character Detection in tool args (optional)
305
- "contains_invisible_chars"?: Bool, // Whether invisible Unicode chars detected in tool args
306
- "invisible_chars_score"?: Long, // Invisible character attack severity (0-100)
307
-
308
- // Security - Encoded Injection (optional)
309
- "encoded_content_detected"?: Bool,
310
- "encoded_types"?: Set<String>,
311
- "encoded_count"?: Long,
312
- "encoded_score"?: Long, // 0-100
313
-
314
- // Agentic - Agent Security (optional)
315
- "tool_poisoning_detected"?: Bool,
316
- "tool_poisoning_score"?: Long, // 0-100
317
- "tool_poisoning_type"?: String, // "hidden_instructions" | "system_prompt_injection" | "authority_hijack"
318
- "rug_pull_detected"?: Bool,
319
- "rug_pull_score"?: Long, // 0-100
320
- "rug_pull_type"?: String, // "risk_spike" | "pattern_change" | "combined" | "none"
321
-
322
- // Agentic - Indirect Prompt Injection (optional — injection via tool outputs/retrieved content)
323
- "indirect_injection_score"?: Long, // Indirect injection risk score (0-100)
324
- "indirect_injection_type"?: String, // Type of indirect injection detected
325
-
326
- // Agentic - MCP Risk (optional)
327
- "mcp_config_risk"?: Bool,
328
- "mcp_risk_type"?: String, // "inline_execution" | "suspicious_url" | "cross_origin"
329
- "mcp_risk_score"?: Long, // 0-100
330
-
331
- // Agentic - Multi-Turn Context (optional)
332
- "conversation_turn"?: Long,
333
- "multi_turn_detection"?: Bool,
334
-
335
- // Session Detection History — cross-turn sticky flags (optional)
336
- "session_pii_detected"?: Bool,
337
- "session_pii_types"?: Set<String>,
338
- "session_secrets_detected"?: Bool,
339
- "session_secret_types"?: Set<String>,
340
- "session_injection_detected"?: Bool,
341
- "session_command_injection"?: Bool,
342
- "session_threat_turns"?: Long,
343
- "session_max_injection_score"?: Long,
344
- "session_max_jailbreak_score"?: Long,
345
- "session_max_command_injection_score"?: Long,
346
- "session_max_pii_score"?: Long,
347
- "session_max_secret_score"?: Long,
348
- "session_cumulative_risk_score"?: Long,
349
-
350
- // Agent Identity — authenticated agent principal metadata (optional)
351
- "agent_id"?: String,
352
- "agent_type"?: String,
353
- "agent_trust_level"?: String,
354
- "agent_framework"?: String,
355
- "agent_publisher"?: String,
356
-
357
- };
358
-
359
- /// Context for read_file action
360
- type FileReadContext = {
361
- // Core metadata (required)
362
- "request_id": String,
363
- "timestamp": Long,
364
-
365
- // File path (optional — for path-based access control policies)
366
- "path"?: String, // File path being read
367
-
368
- // Security checks on file content (optional)
369
- "contains_secrets"?: Bool,
370
- "secret_count"?: Long,
371
- "secret_types"?: Set<String>,
372
- "pii_detected"?: Bool,
373
- "pii_types"?: Set<String>,
374
-
375
- // Security - Path Traversal (optional)
376
- "path_traversal_detected"?: Bool,
377
- "path_traversal_severity"?: String,
378
- "path_traversal_type"?: String,
379
-
380
- // Session Detection History — cross-turn sticky flags (optional)
381
- "session_pii_detected"?: Bool,
382
- "session_pii_types"?: Set<String>,
383
- "session_secrets_detected"?: Bool,
384
- "session_secret_types"?: Set<String>,
385
- "session_injection_detected"?: Bool,
386
- "session_command_injection"?: Bool,
387
- "session_threat_turns"?: Long,
388
- "session_max_injection_score"?: Long,
389
- "session_max_jailbreak_score"?: Long,
390
- "session_max_command_injection_score"?: Long,
391
- "session_max_pii_score"?: Long,
392
- "session_max_secret_score"?: Long,
393
- "session_cumulative_risk_score"?: Long,
394
-
395
- // Agent Identity — authenticated agent principal metadata (optional)
396
- "agent_id"?: String,
397
- "agent_type"?: String,
398
- "agent_trust_level"?: String,
399
- "agent_framework"?: String,
400
- "agent_publisher"?: String,
401
-
402
- };
403
-
404
- /// Context for write_file action
405
- type FileWriteContext = {
406
- // Core metadata (required)
407
- "request_id": String,
408
- "timestamp": Long,
409
-
410
- // File path (optional — for path-based access control policies)
411
- "path"?: String, // File path being written
412
-
413
- // Security - Invisible Character Detection in write content (optional)
414
- "contains_invisible_chars"?: Bool, // Whether invisible Unicode chars detected in write content
415
- "invisible_chars_score"?: Long, // Invisible character attack severity (0-100)
416
-
417
- // Security checks on content being written (optional)
418
- "contains_secrets"?: Bool,
419
- "secret_count"?: Long,
420
- "secret_types"?: Set<String>,
421
- "pii_detected"?: Bool,
422
- "pii_types"?: Set<String>,
495
+ "phishing_detected"?: Bool,
496
+ "content_safety_score"?: Long, // 0-100
497
+ "content_safety_blocked"?: Bool,
423
498
 
424
- // Security - Path Traversal (optional)
425
- "path_traversal_detected"?: Bool,
426
- "path_traversal_severity"?: String,
427
- "path_traversal_type"?: String,
499
+ // Agentic - Multi-Turn Context (optional)
500
+ "conversation_turn"?: Long,
501
+ "multi_turn_detection"?: Bool,
428
502
 
429
503
  // Session Detection History — cross-turn sticky flags (optional)
430
504
  "session_pii_detected"?: Bool,
@@ -442,38 +516,113 @@ namespace Guardrails {
442
516
  "session_cumulative_risk_score"?: Long,
443
517
 
444
518
  // Agent Identity — authenticated agent principal metadata (optional)
445
- "agent_id"?: String,
446
- "agent_type"?: String,
447
- "agent_trust_level"?: String,
448
- "agent_framework"?: String,
449
- "agent_publisher"?: String,
519
+ // Present when the request is made by an AI agent (API key or JWT with agent claims).
520
+ // Empty strings for human user requests. Use these to write agent-specific policies.
521
+ "agent_id"?: String, // Unique agent identifier (e.g., "agent_research_v3")
522
+ "agent_type"?: String, // "orchestrator" | "autonomous" | "tool_agent" | "human_proxy"
523
+ "agent_trust_level"?: String, // "first_party" | "verified_third_party" | "unverified"
524
+ "agent_framework"?: String, // Agent framework (e.g., "claude-code", "langchain", "crewai")
525
+ "agent_publisher"?: String, // Organization that published the agent
450
526
 
451
527
  };
452
528
 
453
- /// Context for connect_server action (MCP server connections)
454
- type ConnectServerContext = {
529
+ /// Context for call_tool action (agentic tool execution)
530
+ type CallToolContext = {
455
531
  // Core metadata (required)
456
532
  "request_id": String,
457
533
  "timestamp": Long,
458
534
 
459
- // MCP context (optional)
535
+ // Tool Risk (optional)
536
+ "tool_name"?: String, // "shell", "write_file", "http_post", etc.
537
+ "tool_risk_score"?: Long, // 0-100
538
+ "tool_is_sensitive"?: Bool,
539
+ "tool_category"?: String, // "safe" | "sensitive" | "dangerous"
540
+ "tool_is_builtin"?: Bool,
541
+
542
+ // MCP context (optional — only present for MCP tool calls)
460
543
  "mcp_server"?: String, // MCP server name (e.g., "github", "filesystem")
544
+ "mcp_tool"?: String, // MCP tool name within the server
461
545
  "mcp_server_verified"?: Bool, // Whether server is from verified registry
462
546
 
547
+ // Agentic - Behavioral Patterns (optional)
548
+ "suspicious_pattern"?: Bool,
549
+ "pattern_type"?: String, // "data_exfiltration" | "secret_exfiltration" | "db_exfiltration" | "credential_theft" | "destructive_sequence" | "none"
550
+ "sequence_risk"?: Long, // 0-100
551
+
552
+ // Agentic - Loop Detection (optional)
553
+ "loop_detected"?: Bool,
554
+ "loop_count"?: Long,
555
+ "loop_tool"?: String,
556
+
557
+ // Agentic - Budget Control (optional)
558
+ "budget_remaining_pct"?: Long, // 0-100
559
+ "budget_exceeded"?: Bool,
560
+
561
+ // Semantic - Topic Classification (optional)
562
+ "content_topics"?: Set<String>, // ["controlled_substances", "weapons_manufacturing", ...]
563
+ "topic_confidence"?: Long, // 0-100
564
+
565
+ // Security checks on tool arguments (optional)
566
+ "contains_secrets"?: Bool,
567
+ "secret_count"?: Long,
568
+ "secret_types"?: Set<String>,
569
+ "pii_detected"?: Bool,
570
+ "pii_types"?: Set<String>,
571
+ "pii_count"?: Long, // Number of PII pattern matches in tool content
572
+ "pii_confidence"?: Long, // PII ML classifier confidence (0-100)
573
+ "injection_confidence"?: Long,
574
+ "injection_pulse_score"?: Long, // 0-100 Pulse single-turn classifier
575
+ "injection_deep_context_score"?: Long, // 0-100 DeepContext multi-turn
576
+
577
+ // Security - Pattern Detection (optional)
578
+ "command_injection_detected"?: Bool,
579
+ "command_injection_type"?: String,
580
+ "command_injection_score"?: Long, // 0-100
581
+ "path_traversal_detected"?: Bool,
582
+ "path_traversal_severity"?: String,
583
+ "path_traversal_type"?: String,
584
+ "sql_injection_detected"?: Bool,
585
+ "sql_injection_type"?: String,
586
+ "sql_injection_score"?: Long, // 0-100
587
+
588
+ // Security - Cross-Origin Escalation (optional)
589
+ "cross_origin_detected"?: Bool,
590
+ "cross_origin_type"?: String,
591
+ "cross_origin_score"?: Long, // 0-100
592
+
593
+ // File & Path (optional — for path-based access control policies)
594
+ "path"?: String, // File path when tool operates on files
595
+
596
+ // Security - Invisible Character Detection in tool args (optional)
597
+ "contains_invisible_chars"?: Bool, // Whether invisible Unicode chars detected in tool args
598
+ "invisible_chars_score"?: Long, // Invisible character attack severity (0-100)
599
+
600
+ // Security - Encoded Injection (optional)
601
+ "encoded_content_detected"?: Bool,
602
+ "encoded_types"?: Set<String>,
603
+ "encoded_count"?: Long,
604
+ "encoded_score"?: Long, // 0-100
605
+
463
606
  // Agentic - Agent Security (optional)
464
607
  "tool_poisoning_detected"?: Bool,
465
- "tool_poisoning_score"?: Long,
466
- "tool_poisoning_type"?: String,
608
+ "tool_poisoning_score"?: Long, // 0-100
609
+ "tool_poisoning_type"?: String, // "hidden_instructions" | "system_prompt_injection" | "authority_hijack"
610
+ "rug_pull_detected"?: Bool,
611
+ "rug_pull_score"?: Long, // 0-100
612
+ "rug_pull_type"?: String, // "risk_spike" | "pattern_change" | "combined" | "none"
613
+
614
+ // Agentic - Indirect Prompt Injection (optional — injection via tool outputs/retrieved content)
615
+ "indirect_injection_score"?: Long, // Indirect injection risk score (0-100)
616
+ "indirect_injection_type"?: String, // Type of indirect injection detected
467
617
 
468
618
  // Agentic - MCP Risk (optional)
469
619
  "mcp_config_risk"?: Bool,
470
- "mcp_risk_type"?: String,
471
- "mcp_risk_score"?: Long,
620
+ "mcp_risk_type"?: String, // "inline_execution" | "suspicious_url" | "cross_origin"
621
+ "mcp_risk_score"?: Long, // 0-100
472
622
 
473
- // Security - Cross-Origin Escalation (optional)
474
- "cross_origin_detected"?: Bool,
475
- "cross_origin_type"?: String,
476
- "cross_origin_score"?: Long,
623
+ // Agentic - Multi-Turn Context (optional)
624
+ "conversation_turn"?: Long,
625
+ "multi_turn_detection"?: Bool,
477
626
 
478
627
  // Session Detection History — cross-turn sticky flags (optional)
479
628
  "session_pii_detected"?: Bool,
@@ -498,284 +647,149 @@ namespace Guardrails {
498
647
  "agent_publisher"?: String,
499
648
 
500
649
  };
501
- }
502
- `;
503
- /**
504
- * McpGateway Cedar schema
505
- *
506
- * Full Cedar schema for mcp_gateway, embedded at codegen time.
507
- */
508
- export const MCP_GATEWAY_SCHEMA = `// MCPGateway Cedar Schema
509
- // ===================================
510
- // MCP Gateway Security & Policy Enforcement
511
- //
512
- // MCPGateway protects MCP proxy operations (tool calls, server connections)
513
- // by evaluating threats detected by the Shield detection engine pipeline
514
- // against Cedar policies.
515
- //
516
- // Architecture:
517
- // MCP Client -> Firehog Proxy -> Shield (detection + Cedar) -> Allow/Deny
518
- //
519
- // Threat Coverage:
520
- // - OWASP Top 10 for LLM Applications 2025 (LLM01, LLM06)
521
- // - OWASP Top 10 for Agentic Applications (ASI01, ASI02, ASI04)
522
- // - OWASP MCP Top 10 (MCP01-MCP05)
523
-
524
- namespace MCPGateway {
525
-
526
- // =============================================================================
527
- // ENTITIES - Tenant Hierarchy (ReBAC)
528
- // =============================================================================
529
- // MCPGateway does not use App/Session hierarchy.
530
- //
531
- // Entity hierarchy:
532
- // Account (org root)
533
- // -> Project in [Account]
534
- // -> Tool/Server in [Project]
535
- //
536
- // Policy scoping examples:
537
- // resource == MCPGateway::Tool::"get_me" -> specific tool
538
- // resource in MCPGateway::Project::"<uuid>" -> project-wide
539
- // resource in MCPGateway::Account::"<uuid>" -> org-wide
540
-
541
- /// Account represents an organization (top-level tenant)
542
- entity Account;
543
-
544
- /// Project represents a project within an account
545
- entity Project in [Account];
546
-
547
- // =============================================================================
548
- // ENTITIES - Principals
549
- // =============================================================================
550
-
551
- /// Human user authenticated via JWT or API key
552
- entity User;
553
-
554
- /// MCP client (default principal for unauthenticated requests)
555
- entity MCP_Client;
556
-
557
- // =============================================================================
558
- // ENTITIES - Resources (scoped under Project)
559
- // =============================================================================
560
-
561
- /// MCP tool -- resource for call_tool action
562
- entity Tool in [Project];
563
-
564
- /// MCP server -- resource for connect_server action
565
- entity Server in [Project];
566
-
567
- /// MCP prompt -- resource for process_prompt action
568
- entity LlmPrompt in [Project];
569
-
570
- /// File/resource path -- resource for read_file/write_file actions
571
- entity FilePath in [Project];
572
-
573
- // =============================================================================
574
- // ACTIONS
575
- // =============================================================================
576
-
577
- // Call an MCP tool
578
- // Threat focus: command injection, tool poisoning, rug pull, secrets, PII
579
- action call_tool appliesTo {
580
- principal: [User, MCP_Client],
581
- resource: [Tool],
582
- context: {
583
- // --- Content ---
584
- content: String, // Raw content being scanned
585
-
586
- // --- Tool & MCP ---
587
- tool_name?: String, // Tool name
588
- mcp_server?: String, // MCP server name
589
- mcp_tool?: String, // MCP tool name
590
-
591
- // --- Threat Detection (from Shield detection pipeline) ---
592
- threat_count?: Long, // Total threats detected
593
- highest_severity?: String, // "critical", "high", "medium", "low", "none"
594
- threat_categories?: Set<String>, // Threat category names
595
- detected_threats?: Set<String>, // Detection rule names that matched
596
- max_threat_severity?: Long, // Numeric severity (0=none, 1=low, 2=medium, 3=high, 4=critical)
597
- contains_secrets?: Bool, // Whether secrets/credentials detected
598
-
599
- // --- Secrets (granular) ---
600
- secret_types?: Set<String>,
601
- secret_count?: Long,
602
-
603
- // --- PII Detection ---
604
- pii_detected?: Bool,
605
- pii_types?: Set<String>,
606
- pii_count?: Long,
607
-
608
- // --- ML Detector Confidence Scores (0-100) ---
609
- injection_confidence?: Long, // Prompt injection classifier confidence
610
- jailbreak_confidence?: Long, // Jailbreak detection classifier confidence
611
-
612
- // --- Agent Security (0-100) ---
613
- tool_poisoning_score?: Long, // Hidden instructions in tool description/args
614
- tool_poisoning_detected?: Bool,
615
- rug_pull_score?: Long, // Tool behavior drift after trust establishment
616
- rug_pull_detected?: Bool,
617
- indirect_injection_score?: Long, // Indirect injection via tool output
618
-
619
- // --- Tool Risk Assessment ---
620
- tool_risk_score?: Long, // Computed tool risk (0-100)
621
- tool_category?: String, // "safe", "sensitive", "dangerous"
622
- tool_is_sensitive?: Bool,
623
- tool_is_builtin?: Bool,
624
-
625
- // --- MCP Trust ---
626
- mcp_server_verified?: Bool, // Whether server is from verified registry
627
-
628
- // --- Content Safety Scores (0-100) ---
629
- violence_score?: Long,
630
- weapons_score?: Long,
631
- hate_speech_score?: Long,
632
- crime_score?: Long,
633
- sexual_score?: Long,
634
- profanity_score?: Long,
635
-
636
- // --- Encoding & Unicode Attacks ---
637
- contains_invisible_chars?: Bool,
638
- invisible_chars_score?: Long,
639
650
 
640
- // --- Behavioral Analysis ---
641
- loop_detected?: Bool,
642
- loop_count?: Long,
643
- loop_tool?: String,
644
- suspicious_pattern?: Bool,
645
- pattern_type?: String,
646
- sequence_risk?: Long,
647
- },
648
- };
651
+ /// Context for read_file action
652
+ type FileReadContext = {
653
+ // Core metadata (required)
654
+ "request_id": String,
655
+ "timestamp": Long,
649
656
 
650
- // Connect to an MCP server
651
- // Threat focus: supply chain, tool poisoning, rug pull, config risk
652
- action connect_server appliesTo {
653
- principal: [User, MCP_Client],
654
- resource: [Server],
655
- context: {
656
- content?: String, // Server config content (if available)
657
- mcp_server?: String,
657
+ // File path (optional for path-based access control policies)
658
+ "path"?: String, // File path being read
658
659
 
659
- // --- Threat Detection ---
660
- threat_count?: Long,
661
- highest_severity?: String,
662
- threat_categories?: Set<String>,
663
- max_threat_severity?: Long,
660
+ // Security checks on file content (optional)
661
+ "contains_secrets"?: Bool,
662
+ "secret_count"?: Long,
663
+ "secret_types"?: Set<String>,
664
+ "pii_detected"?: Bool,
665
+ "pii_types"?: Set<String>,
664
666
 
665
- // --- Agent Security (0-100) ---
666
- tool_poisoning_score?: Long,
667
- tool_poisoning_detected?: Bool,
668
- rug_pull_score?: Long,
669
- rug_pull_detected?: Bool,
670
- indirect_injection_score?: Long,
667
+ // Security - Path Traversal (optional)
668
+ "path_traversal_detected"?: Bool,
669
+ "path_traversal_severity"?: String,
670
+ "path_traversal_type"?: String,
671
671
 
672
- // --- MCP Trust & Config Risk ---
673
- mcp_server_verified?: Bool,
674
- mcp_config_risk?: Bool,
675
- mcp_risk_score?: Long,
676
- },
677
- };
672
+ // Session Detection History cross-turn sticky flags (optional)
673
+ "session_pii_detected"?: Bool,
674
+ "session_pii_types"?: Set<String>,
675
+ "session_secrets_detected"?: Bool,
676
+ "session_secret_types"?: Set<String>,
677
+ "session_injection_detected"?: Bool,
678
+ "session_command_injection"?: Bool,
679
+ "session_threat_turns"?: Long,
680
+ "session_max_injection_score"?: Long,
681
+ "session_max_jailbreak_score"?: Long,
682
+ "session_max_command_injection_score"?: Long,
683
+ "session_max_pii_score"?: Long,
684
+ "session_max_secret_score"?: Long,
685
+ "session_cumulative_risk_score"?: Long,
678
686
 
679
- // Process an MCP prompt (prompts/get, prompts/list)
680
- // Threat focus: injection, jailbreak, secrets, PII, content safety
681
- action process_prompt appliesTo {
682
- principal: [User, MCP_Client],
683
- resource: [LlmPrompt],
684
- context: {
685
- content: String,
686
- mcp_server?: String,
687
+ // Agent Identity authenticated agent principal metadata (optional)
688
+ "agent_id"?: String,
689
+ "agent_type"?: String,
690
+ "agent_trust_level"?: String,
691
+ "agent_framework"?: String,
692
+ "agent_publisher"?: String,
687
693
 
688
- // --- Threat Detection ---
689
- threat_count?: Long,
690
- highest_severity?: String,
691
- threat_categories?: Set<String>,
692
- detected_threats?: Set<String>,
693
- max_threat_severity?: Long,
694
- contains_secrets?: Bool,
694
+ };
695
695
 
696
- // --- Secrets ---
697
- secret_types?: Set<String>,
698
- secret_count?: Long,
696
+ /// Context for write_file action
697
+ type FileWriteContext = {
698
+ // Core metadata (required)
699
+ "request_id": String,
700
+ "timestamp": Long,
699
701
 
700
- // --- PII Detection ---
701
- pii_detected?: Bool,
702
- pii_types?: Set<String>,
703
- pii_count?: Long,
702
+ // File path (optional — for path-based access control policies)
703
+ "path"?: String, // File path being written
704
704
 
705
- // --- ML Detector Confidence Scores (0-100) ---
706
- injection_confidence?: Long,
707
- jailbreak_confidence?: Long,
705
+ // Security - Invisible Character Detection in write content (optional)
706
+ "contains_invisible_chars"?: Bool, // Whether invisible Unicode chars detected in write content
707
+ "invisible_chars_score"?: Long, // Invisible character attack severity (0-100)
708
708
 
709
- // --- Content Safety Scores (0-100) ---
710
- violence_score?: Long,
711
- weapons_score?: Long,
712
- hate_speech_score?: Long,
713
- crime_score?: Long,
714
- sexual_score?: Long,
715
- profanity_score?: Long,
709
+ // Security checks on content being written (optional)
710
+ "contains_secrets"?: Bool,
711
+ "secret_count"?: Long,
712
+ "secret_types"?: Set<String>,
713
+ "pii_detected"?: Bool,
714
+ "pii_types"?: Set<String>,
716
715
 
717
- // --- Encoding ---
718
- contains_invisible_chars?: Bool,
719
- invisible_chars_score?: Long,
720
- },
721
- };
716
+ // Security - Path Traversal (optional)
717
+ "path_traversal_detected"?: Bool,
718
+ "path_traversal_severity"?: String,
719
+ "path_traversal_type"?: String,
722
720
 
723
- // Read an MCP resource (resources/read, resources/list)
724
- // Threat focus: secrets exposure, PII exposure, sensitive paths
725
- action read_file appliesTo {
726
- principal: [User, MCP_Client],
727
- resource: [FilePath],
728
- context: {
729
- content: String,
730
- mcp_server?: String,
721
+ // Session Detection History cross-turn sticky flags (optional)
722
+ "session_pii_detected"?: Bool,
723
+ "session_pii_types"?: Set<String>,
724
+ "session_secrets_detected"?: Bool,
725
+ "session_secret_types"?: Set<String>,
726
+ "session_injection_detected"?: Bool,
727
+ "session_command_injection"?: Bool,
728
+ "session_threat_turns"?: Long,
729
+ "session_max_injection_score"?: Long,
730
+ "session_max_jailbreak_score"?: Long,
731
+ "session_max_command_injection_score"?: Long,
732
+ "session_max_pii_score"?: Long,
733
+ "session_max_secret_score"?: Long,
734
+ "session_cumulative_risk_score"?: Long,
731
735
 
732
- // --- Threat Detection ---
733
- threat_count?: Long,
734
- highest_severity?: String,
735
- threat_categories?: Set<String>,
736
- detected_threats?: Set<String>,
737
- max_threat_severity?: Long,
738
- contains_secrets?: Bool,
736
+ // Agent Identity authenticated agent principal metadata (optional)
737
+ "agent_id"?: String,
738
+ "agent_type"?: String,
739
+ "agent_trust_level"?: String,
740
+ "agent_framework"?: String,
741
+ "agent_publisher"?: String,
739
742
 
740
- // --- Secrets ---
741
- secret_types?: Set<String>,
742
- secret_count?: Long,
743
+ };
743
744
 
744
- // --- PII Detection ---
745
- pii_detected?: Bool,
746
- pii_types?: Set<String>,
747
- pii_count?: Long,
748
- },
749
- };
745
+ /// Context for connect_server action (MCP server connections)
746
+ type ConnectServerContext = {
747
+ // Core metadata (required)
748
+ "request_id": String,
749
+ "timestamp": Long,
750
750
 
751
- // Write an MCP resource (resources/write)
752
- // Threat focus: secrets in output, PII in output
753
- action write_file appliesTo {
754
- principal: [User, MCP_Client],
755
- resource: [FilePath],
756
- context: {
757
- content: String,
758
- mcp_server?: String,
751
+ // MCP context (optional)
752
+ "mcp_server"?: String, // MCP server name (e.g., "github", "filesystem")
753
+ "mcp_server_verified"?: Bool, // Whether server is from verified registry
759
754
 
760
- // --- Threat Detection ---
761
- threat_count?: Long,
762
- highest_severity?: String,
763
- threat_categories?: Set<String>,
764
- detected_threats?: Set<String>,
765
- max_threat_severity?: Long,
766
- contains_secrets?: Bool,
755
+ // Agentic - Agent Security (optional)
756
+ "tool_poisoning_detected"?: Bool,
757
+ "tool_poisoning_score"?: Long,
758
+ "tool_poisoning_type"?: String,
767
759
 
768
- // --- Secrets ---
769
- secret_types?: Set<String>,
770
- secret_count?: Long,
760
+ // Agentic - MCP Risk (optional)
761
+ "mcp_config_risk"?: Bool,
762
+ "mcp_risk_type"?: String,
763
+ "mcp_risk_score"?: Long,
771
764
 
772
- // --- PII Detection ---
773
- pii_detected?: Bool,
774
- pii_types?: Set<String>,
775
- pii_count?: Long,
776
- },
777
- };
765
+ // Security - Cross-Origin Escalation (optional)
766
+ "cross_origin_detected"?: Bool,
767
+ "cross_origin_type"?: String,
768
+ "cross_origin_score"?: Long,
769
+
770
+ // Session Detection History — cross-turn sticky flags (optional)
771
+ "session_pii_detected"?: Bool,
772
+ "session_pii_types"?: Set<String>,
773
+ "session_secrets_detected"?: Bool,
774
+ "session_secret_types"?: Set<String>,
775
+ "session_injection_detected"?: Bool,
776
+ "session_command_injection"?: Bool,
777
+ "session_threat_turns"?: Long,
778
+ "session_max_injection_score"?: Long,
779
+ "session_max_jailbreak_score"?: Long,
780
+ "session_max_command_injection_score"?: Long,
781
+ "session_max_pii_score"?: Long,
782
+ "session_max_secret_score"?: Long,
783
+ "session_cumulative_risk_score"?: Long,
784
+
785
+ // Agent Identity — authenticated agent principal metadata (optional)
786
+ "agent_id"?: String,
787
+ "agent_type"?: String,
788
+ "agent_trust_level"?: String,
789
+ "agent_framework"?: String,
790
+ "agent_publisher"?: String,
778
791
 
792
+ };
779
793
  }
780
794
  `;
781
795
  /**
@@ -1758,9 +1772,160 @@ action upload_file appliesTo {
1758
1772
  session_threat_turns?: Long,
1759
1773
  },
1760
1774
  };
1761
-
1762
- }
1763
- `;
1775
+
1776
+ }
1777
+ `;
1778
+ /**
1779
+ * AiGateway context metadata (parsed JSON)
1780
+ */
1781
+ export const AI_GATEWAY_CONTEXT = {
1782
+ "service": "ai_gateway",
1783
+ "version": "2.0.0",
1784
+ "description": "Context attributes for AIGateway Cedar policies (MCP + LLM)",
1785
+ "actions": [
1786
+ {
1787
+ "name": "call_tool",
1788
+ "description": "Call an MCP tool — threat focus: command injection, tool poisoning, rug pull, secrets, PII",
1789
+ "context_attributes": [
1790
+ { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
1791
+ { "key": "tool_name", "type": "string", "required": false, "description": "Tool name" },
1792
+ { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
1793
+ { "key": "mcp_tool", "type": "string", "required": false, "description": "MCP tool name" },
1794
+ { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
1795
+ { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
1796
+ { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
1797
+ { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
1798
+ { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
1799
+ { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
1800
+ { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
1801
+ { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
1802
+ { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
1803
+ { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
1804
+ { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" },
1805
+ { "key": "injection_confidence", "type": "number", "required": false, "description": "Injection classifier confidence (0-100)" },
1806
+ { "key": "jailbreak_confidence", "type": "number", "required": false, "description": "Jailbreak classifier confidence (0-100)" },
1807
+ { "key": "tool_poisoning_score", "type": "number", "required": false, "description": "Tool poisoning risk score (0-100)" },
1808
+ { "key": "tool_poisoning_detected", "type": "boolean", "required": false, "description": "Tool poisoning detected flag" },
1809
+ { "key": "rug_pull_score", "type": "number", "required": false, "description": "Rug pull risk score (0-100)" },
1810
+ { "key": "rug_pull_detected", "type": "boolean", "required": false, "description": "Rug pull detected flag" },
1811
+ { "key": "indirect_injection_score", "type": "number", "required": false, "description": "Indirect injection score (0-100)" },
1812
+ { "key": "tool_risk_score", "type": "number", "required": false, "description": "Computed tool risk (0-100)" },
1813
+ { "key": "tool_category", "type": "string", "required": false, "description": "Tool category: safe/sensitive/dangerous" },
1814
+ { "key": "tool_is_sensitive", "type": "boolean", "required": false, "description": "Tool sensitivity flag" },
1815
+ { "key": "tool_is_builtin", "type": "boolean", "required": false, "description": "Built-in tool flag" },
1816
+ { "key": "mcp_server_verified", "type": "boolean", "required": false, "description": "Whether server is from verified registry" },
1817
+ { "key": "violence_score", "type": "number", "required": false, "description": "Violence content score (0-100)" },
1818
+ { "key": "weapons_score", "type": "number", "required": false, "description": "Weapons content score (0-100)" },
1819
+ { "key": "hate_speech_score", "type": "number", "required": false, "description": "Hate speech score (0-100)" },
1820
+ { "key": "crime_score", "type": "number", "required": false, "description": "Crime content score (0-100)" },
1821
+ { "key": "sexual_score", "type": "number", "required": false, "description": "Sexual content score (0-100)" },
1822
+ { "key": "profanity_score", "type": "number", "required": false, "description": "Profanity score (0-100)" },
1823
+ { "key": "contains_invisible_chars", "type": "boolean", "required": false, "description": "Invisible Unicode chars detected" },
1824
+ { "key": "invisible_chars_score", "type": "number", "required": false, "description": "Unicode attack severity (0-100)" },
1825
+ { "key": "loop_detected", "type": "boolean", "required": false, "description": "Tool call loop detected" },
1826
+ { "key": "loop_count", "type": "number", "required": false, "description": "Consecutive repeat calls" },
1827
+ { "key": "suspicious_pattern", "type": "boolean", "required": false, "description": "Data exfiltration or attack sequence detected" },
1828
+ { "key": "pattern_type", "type": "string", "required": false, "description": "Pattern type" },
1829
+ { "key": "sequence_risk", "type": "number", "required": false, "description": "Sequence risk score (0-100)" }
1830
+ ]
1831
+ },
1832
+ {
1833
+ "name": "connect_server",
1834
+ "description": "Connect to an MCP server — threat focus: supply chain, tool poisoning, config risk",
1835
+ "context_attributes": [
1836
+ { "key": "content", "type": "string", "required": false, "description": "Server config content" },
1837
+ { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
1838
+ { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
1839
+ { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
1840
+ { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
1841
+ { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
1842
+ { "key": "tool_poisoning_score", "type": "number", "required": false, "description": "Tool poisoning risk (0-100)" },
1843
+ { "key": "tool_poisoning_detected", "type": "boolean", "required": false, "description": "Tool poisoning detected" },
1844
+ { "key": "rug_pull_score", "type": "number", "required": false, "description": "Rug pull risk (0-100)" },
1845
+ { "key": "rug_pull_detected", "type": "boolean", "required": false, "description": "Rug pull detected" },
1846
+ { "key": "indirect_injection_score", "type": "number", "required": false, "description": "Indirect injection score (0-100)" },
1847
+ { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
1848
+ { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
1849
+ { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
1850
+ { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
1851
+ { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
1852
+ { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" },
1853
+ { "key": "mcp_server_verified", "type": "boolean", "required": false, "description": "Verified registry status" },
1854
+ { "key": "mcp_config_risk", "type": "boolean", "required": false, "description": "Risky server config detected" },
1855
+ { "key": "mcp_risk_score", "type": "number", "required": false, "description": "Config risk severity (0-100)" }
1856
+ ]
1857
+ },
1858
+ {
1859
+ "name": "process_prompt",
1860
+ "description": "Process a prompt (MCP or LLM chat completion) — threat focus: injection, jailbreak, secrets, PII, content safety",
1861
+ "context_attributes": [
1862
+ { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
1863
+ { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
1864
+ { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
1865
+ { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
1866
+ { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
1867
+ { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
1868
+ { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
1869
+ { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
1870
+ { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
1871
+ { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
1872
+ { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
1873
+ { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
1874
+ { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" },
1875
+ { "key": "injection_confidence", "type": "number", "required": false, "description": "Injection classifier confidence (0-100)" },
1876
+ { "key": "jailbreak_confidence", "type": "number", "required": false, "description": "Jailbreak classifier confidence (0-100)" },
1877
+ { "key": "violence_score", "type": "number", "required": false, "description": "Violence content score (0-100)" },
1878
+ { "key": "weapons_score", "type": "number", "required": false, "description": "Weapons content score (0-100)" },
1879
+ { "key": "hate_speech_score", "type": "number", "required": false, "description": "Hate speech score (0-100)" },
1880
+ { "key": "crime_score", "type": "number", "required": false, "description": "Crime content score (0-100)" },
1881
+ { "key": "sexual_score", "type": "number", "required": false, "description": "Sexual content score (0-100)" },
1882
+ { "key": "profanity_score", "type": "number", "required": false, "description": "Profanity score (0-100)" },
1883
+ { "key": "contains_invisible_chars", "type": "boolean", "required": false, "description": "Invisible Unicode chars detected" },
1884
+ { "key": "invisible_chars_score", "type": "number", "required": false, "description": "Unicode attack severity (0-100)" },
1885
+ { "key": "model_name", "type": "string", "required": false, "description": "Target model name (e.g., gpt-4, claude-3-opus)" },
1886
+ { "key": "model_provider", "type": "string", "required": false, "description": "Provider name (e.g., openai, anthropic, bedrock)" }
1887
+ ]
1888
+ },
1889
+ {
1890
+ "name": "read_file",
1891
+ "description": "Read an MCP resource — threat focus: secrets exposure, PII exposure",
1892
+ "context_attributes": [
1893
+ { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
1894
+ { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
1895
+ { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
1896
+ { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
1897
+ { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
1898
+ { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
1899
+ { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
1900
+ { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
1901
+ { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
1902
+ { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
1903
+ { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
1904
+ { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
1905
+ { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" }
1906
+ ]
1907
+ },
1908
+ {
1909
+ "name": "write_file",
1910
+ "description": "Write an MCP resource — threat focus: secrets in output, PII in output",
1911
+ "context_attributes": [
1912
+ { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
1913
+ { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
1914
+ { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
1915
+ { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
1916
+ { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
1917
+ { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
1918
+ { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
1919
+ { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
1920
+ { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
1921
+ { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
1922
+ { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
1923
+ { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
1924
+ { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" }
1925
+ ]
1926
+ }
1927
+ ]
1928
+ };
1764
1929
  /**
1765
1930
  * Guardrails context metadata (parsed JSON)
1766
1931
  */
@@ -2057,149 +2222,6 @@ export const GUARDRAILS_CONTEXT = {
2057
2222
  }
2058
2223
  ]
2059
2224
  };
2060
- /**
2061
- * McpGateway context metadata (parsed JSON)
2062
- */
2063
- export const MCP_GATEWAY_CONTEXT = {
2064
- "service": "mcp_gateway",
2065
- "version": "1.0.0",
2066
- "description": "Context attributes for MCPGateway Cedar policies",
2067
- "actions": [
2068
- {
2069
- "name": "call_tool",
2070
- "description": "Call an MCP tool — threat focus: command injection, tool poisoning, rug pull, secrets, PII",
2071
- "context_attributes": [
2072
- { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
2073
- { "key": "tool_name", "type": "string", "required": false, "description": "Tool name" },
2074
- { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
2075
- { "key": "mcp_tool", "type": "string", "required": false, "description": "MCP tool name" },
2076
- { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
2077
- { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
2078
- { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
2079
- { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
2080
- { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
2081
- { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
2082
- { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
2083
- { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
2084
- { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
2085
- { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
2086
- { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" },
2087
- { "key": "injection_confidence", "type": "number", "required": false, "description": "Injection classifier confidence (0-100)" },
2088
- { "key": "jailbreak_confidence", "type": "number", "required": false, "description": "Jailbreak classifier confidence (0-100)" },
2089
- { "key": "tool_poisoning_score", "type": "number", "required": false, "description": "Tool poisoning risk score (0-100)" },
2090
- { "key": "tool_poisoning_detected", "type": "boolean", "required": false, "description": "Tool poisoning detected flag" },
2091
- { "key": "rug_pull_score", "type": "number", "required": false, "description": "Rug pull risk score (0-100)" },
2092
- { "key": "rug_pull_detected", "type": "boolean", "required": false, "description": "Rug pull detected flag" },
2093
- { "key": "indirect_injection_score", "type": "number", "required": false, "description": "Indirect injection score (0-100)" },
2094
- { "key": "tool_risk_score", "type": "number", "required": false, "description": "Computed tool risk (0-100)" },
2095
- { "key": "tool_category", "type": "string", "required": false, "description": "Tool category: safe/sensitive/dangerous" },
2096
- { "key": "tool_is_sensitive", "type": "boolean", "required": false, "description": "Tool sensitivity flag" },
2097
- { "key": "tool_is_builtin", "type": "boolean", "required": false, "description": "Built-in tool flag" },
2098
- { "key": "mcp_server_verified", "type": "boolean", "required": false, "description": "Whether server is from verified registry" },
2099
- { "key": "violence_score", "type": "number", "required": false, "description": "Violence content score (0-100)" },
2100
- { "key": "weapons_score", "type": "number", "required": false, "description": "Weapons content score (0-100)" },
2101
- { "key": "hate_speech_score", "type": "number", "required": false, "description": "Hate speech score (0-100)" },
2102
- { "key": "crime_score", "type": "number", "required": false, "description": "Crime content score (0-100)" },
2103
- { "key": "sexual_score", "type": "number", "required": false, "description": "Sexual content score (0-100)" },
2104
- { "key": "profanity_score", "type": "number", "required": false, "description": "Profanity score (0-100)" },
2105
- { "key": "contains_invisible_chars", "type": "boolean", "required": false, "description": "Invisible Unicode chars detected" },
2106
- { "key": "invisible_chars_score", "type": "number", "required": false, "description": "Unicode attack severity (0-100)" },
2107
- { "key": "loop_detected", "type": "boolean", "required": false, "description": "Tool call loop detected" },
2108
- { "key": "loop_count", "type": "number", "required": false, "description": "Consecutive repeat calls" },
2109
- { "key": "suspicious_pattern", "type": "boolean", "required": false, "description": "Data exfiltration or attack sequence detected" },
2110
- { "key": "pattern_type", "type": "string", "required": false, "description": "Pattern type" },
2111
- { "key": "sequence_risk", "type": "number", "required": false, "description": "Sequence risk score (0-100)" }
2112
- ]
2113
- },
2114
- {
2115
- "name": "connect_server",
2116
- "description": "Connect to an MCP server — threat focus: supply chain, tool poisoning, config risk",
2117
- "context_attributes": [
2118
- { "key": "content", "type": "string", "required": false, "description": "Server config content" },
2119
- { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
2120
- { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
2121
- { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
2122
- { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
2123
- { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
2124
- { "key": "tool_poisoning_score", "type": "number", "required": false, "description": "Tool poisoning risk (0-100)" },
2125
- { "key": "tool_poisoning_detected", "type": "boolean", "required": false, "description": "Tool poisoning detected" },
2126
- { "key": "rug_pull_score", "type": "number", "required": false, "description": "Rug pull risk (0-100)" },
2127
- { "key": "rug_pull_detected", "type": "boolean", "required": false, "description": "Rug pull detected" },
2128
- { "key": "indirect_injection_score", "type": "number", "required": false, "description": "Indirect injection score (0-100)" },
2129
- { "key": "mcp_server_verified", "type": "boolean", "required": false, "description": "Verified registry status" },
2130
- { "key": "mcp_config_risk", "type": "boolean", "required": false, "description": "Risky server config detected" },
2131
- { "key": "mcp_risk_score", "type": "number", "required": false, "description": "Config risk severity (0-100)" }
2132
- ]
2133
- },
2134
- {
2135
- "name": "process_prompt",
2136
- "description": "Process an MCP prompt — threat focus: injection, jailbreak, secrets, PII, content safety",
2137
- "context_attributes": [
2138
- { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
2139
- { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
2140
- { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
2141
- { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
2142
- { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
2143
- { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
2144
- { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
2145
- { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
2146
- { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
2147
- { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
2148
- { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
2149
- { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
2150
- { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" },
2151
- { "key": "injection_confidence", "type": "number", "required": false, "description": "Injection classifier confidence (0-100)" },
2152
- { "key": "jailbreak_confidence", "type": "number", "required": false, "description": "Jailbreak classifier confidence (0-100)" },
2153
- { "key": "violence_score", "type": "number", "required": false, "description": "Violence content score (0-100)" },
2154
- { "key": "weapons_score", "type": "number", "required": false, "description": "Weapons content score (0-100)" },
2155
- { "key": "hate_speech_score", "type": "number", "required": false, "description": "Hate speech score (0-100)" },
2156
- { "key": "crime_score", "type": "number", "required": false, "description": "Crime content score (0-100)" },
2157
- { "key": "sexual_score", "type": "number", "required": false, "description": "Sexual content score (0-100)" },
2158
- { "key": "profanity_score", "type": "number", "required": false, "description": "Profanity score (0-100)" },
2159
- { "key": "contains_invisible_chars", "type": "boolean", "required": false, "description": "Invisible Unicode chars detected" },
2160
- { "key": "invisible_chars_score", "type": "number", "required": false, "description": "Unicode attack severity (0-100)" }
2161
- ]
2162
- },
2163
- {
2164
- "name": "read_file",
2165
- "description": "Read an MCP resource — threat focus: secrets exposure, PII exposure",
2166
- "context_attributes": [
2167
- { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
2168
- { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
2169
- { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
2170
- { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
2171
- { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
2172
- { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
2173
- { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
2174
- { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
2175
- { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
2176
- { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
2177
- { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
2178
- { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
2179
- { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" }
2180
- ]
2181
- },
2182
- {
2183
- "name": "write_file",
2184
- "description": "Write an MCP resource — threat focus: secrets in output, PII in output",
2185
- "context_attributes": [
2186
- { "key": "content", "type": "string", "required": true, "description": "Raw content being scanned" },
2187
- { "key": "mcp_server", "type": "string", "required": false, "description": "MCP server name" },
2188
- { "key": "threat_count", "type": "number", "required": false, "description": "Total threats detected" },
2189
- { "key": "highest_severity", "type": "string", "required": false, "description": "Highest threat severity" },
2190
- { "key": "threat_categories", "type": "array", "required": false, "description": "Threat category names" },
2191
- { "key": "detected_threats", "type": "array", "required": false, "description": "Detection rule names that matched" },
2192
- { "key": "max_threat_severity", "type": "number", "required": false, "description": "Numeric severity (0-4)" },
2193
- { "key": "contains_secrets", "type": "boolean", "required": false, "description": "Whether secrets/credentials detected" },
2194
- { "key": "secret_types", "type": "array", "required": false, "description": "Types of secrets found" },
2195
- { "key": "secret_count", "type": "number", "required": false, "description": "Number of distinct secrets" },
2196
- { "key": "pii_detected", "type": "boolean", "required": false, "description": "Whether PII detected" },
2197
- { "key": "pii_types", "type": "array", "required": false, "description": "Types of PII detected" },
2198
- { "key": "pii_count", "type": "number", "required": false, "description": "Number of PII matches" }
2199
- ]
2200
- }
2201
- ]
2202
- };
2203
2225
  /**
2204
2226
  * Overwatch context metadata (parsed JSON)
2205
2227
  */