@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.
- package/_schemas/ai_gateway/context.json +703 -0
- package/_schemas/ai_gateway/schema.cedarschema +286 -0
- package/_schemas/ai_gateway/templates/defaults/agent_security.cedar +140 -0
- package/_schemas/ai_gateway/templates/defaults/baseline.cedar +23 -0
- package/_schemas/ai_gateway/templates/defaults/semantic.cedar +105 -0
- package/_schemas/ai_gateway/templates/defaults/tools.cedar +92 -0
- package/_schemas/ai_gateway/templates/llm_default_allow.cedar +22 -0
- package/_schemas/ai_gateway/templates/mcp_server_allowlist.cedar +33 -0
- package/_schemas/ai_gateway/templates/mcp_tool_permissions.cedar +77 -0
- package/_schemas/ai_gateway/templates/pii_redaction.cedar +89 -0
- package/_schemas/ai_gateway/templates/templates.json +117 -0
- package/dist/ai_gateway-context.gen.d.ts +53 -0
- package/dist/ai_gateway-context.gen.js +54 -0
- package/dist/ai_gateway-defaults.gen.d.ts +61 -0
- package/dist/ai_gateway-defaults.gen.js +829 -0
- package/dist/ai_gateway-entities.gen.d.ts +11 -0
- package/dist/ai_gateway-entities.gen.js +37 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/service-schemas.gen.d.ts +10 -10
- package/dist/service-schemas.gen.js +667 -645
- package/dist/types.d.ts +5 -5
- package/dist/types.js +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,829 @@
|
|
|
1
|
+
// Code generated by highflame-policy-codegen. DO NOT EDIT.
|
|
2
|
+
// Source: schemas/ai_gateway/templates/templates.json
|
|
3
|
+
//
|
|
4
|
+
// AiGateway default policies and templates.
|
|
5
|
+
// Cedar text is embedded at build time. PolicyRule[] can be parsed at runtime
|
|
6
|
+
// using parseCedarToRules().
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// EMBEDDED CEDAR POLICY TEXT
|
|
9
|
+
// =============================================================================
|
|
10
|
+
const AI_GATEWAY_BASELINE_DEFAULT_CEDAR = `// =============================================================================
|
|
11
|
+
// Baseline Permit Policy (Default)
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Permits all actions by default. Threat-specific forbid policies override
|
|
14
|
+
// this to block when detection engines identify issues.
|
|
15
|
+
//
|
|
16
|
+
// Cedar is default-deny: without at least one permit rule, every request
|
|
17
|
+
// is denied regardless of forbid rules.
|
|
18
|
+
//
|
|
19
|
+
// Category: organization
|
|
20
|
+
// Namespace: AIGateway
|
|
21
|
+
// =============================================================================
|
|
22
|
+
|
|
23
|
+
@id("baseline-permit-all")
|
|
24
|
+
@name("Permit all actions by default")
|
|
25
|
+
@description("Baseline permit for all actions -- threat-specific forbid policies override this when threats are detected")
|
|
26
|
+
@severity("low")
|
|
27
|
+
@tags("baseline,permit-default,organization")
|
|
28
|
+
permit (
|
|
29
|
+
principal,
|
|
30
|
+
action,
|
|
31
|
+
resource
|
|
32
|
+
);
|
|
33
|
+
`;
|
|
34
|
+
const AI_GATEWAY_SEMANTIC_DEFAULT_CEDAR = `// =============================================================================
|
|
35
|
+
// Semantic Threat Detection Policy (Default)
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// Detects and blocks prompt injection, jailbreak attempts, and high-severity
|
|
38
|
+
// threats in MCP tool calls and server connections.
|
|
39
|
+
//
|
|
40
|
+
// Category: semantic
|
|
41
|
+
// Namespace: AIGateway
|
|
42
|
+
// =============================================================================
|
|
43
|
+
|
|
44
|
+
// Block content with prompt injection patterns detected by rules
|
|
45
|
+
@id("semantic-block-injection")
|
|
46
|
+
@name("Block prompt injection")
|
|
47
|
+
@description("Block tool calls when detection engine rules identify prompt injection patterns in tool arguments or content")
|
|
48
|
+
@severity("critical")
|
|
49
|
+
@tags("injection,security,owasp-llm01,baseline")
|
|
50
|
+
@reject_message("Tool call was blocked because prompt injection patterns were detected in the content (OWASP LLM01).")
|
|
51
|
+
forbid (
|
|
52
|
+
principal,
|
|
53
|
+
action == AIGateway::Action::"call_tool",
|
|
54
|
+
resource
|
|
55
|
+
)
|
|
56
|
+
when {
|
|
57
|
+
context has detected_threats && context.detected_threats.contains("prompt_injection")
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Block content with high ML injection confidence
|
|
61
|
+
@id("semantic-block-injection-score")
|
|
62
|
+
@name("Block high-confidence injection")
|
|
63
|
+
@description("Block tool calls when the ML injection classifier confidence exceeds 75/100")
|
|
64
|
+
@severity("critical")
|
|
65
|
+
@tags("injection,ml-classifier,security,owasp-llm01")
|
|
66
|
+
@reject_message("Tool call was blocked because the ML classifier detected prompt injection with high confidence.")
|
|
67
|
+
forbid (
|
|
68
|
+
principal,
|
|
69
|
+
action == AIGateway::Action::"call_tool",
|
|
70
|
+
resource
|
|
71
|
+
)
|
|
72
|
+
when {
|
|
73
|
+
context has injection_confidence && context.injection_confidence >= 75
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Block content with jailbreak patterns
|
|
77
|
+
@id("semantic-block-jailbreak")
|
|
78
|
+
@name("Block jailbreak attempts")
|
|
79
|
+
@description("Block tool calls when jailbreak patterns are detected in content")
|
|
80
|
+
@severity("critical")
|
|
81
|
+
@tags("jailbreak,security,owasp-llm02,baseline")
|
|
82
|
+
@reject_message("Tool call was blocked because jailbreak patterns were detected.")
|
|
83
|
+
forbid (
|
|
84
|
+
principal,
|
|
85
|
+
action == AIGateway::Action::"call_tool",
|
|
86
|
+
resource
|
|
87
|
+
)
|
|
88
|
+
when {
|
|
89
|
+
context has detected_threats && context.detected_threats.contains("jailbreak")
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Block content with high ML jailbreak confidence
|
|
93
|
+
@id("semantic-block-jailbreak-score")
|
|
94
|
+
@name("Block high-confidence jailbreak")
|
|
95
|
+
@description("Block tool calls when the ML jailbreak classifier confidence exceeds 75/100")
|
|
96
|
+
@severity("critical")
|
|
97
|
+
@tags("jailbreak,ml-classifier,security,owasp-llm02")
|
|
98
|
+
@reject_message("Tool call was blocked because the ML classifier detected a jailbreak attempt with high confidence.")
|
|
99
|
+
forbid (
|
|
100
|
+
principal,
|
|
101
|
+
action == AIGateway::Action::"call_tool",
|
|
102
|
+
resource
|
|
103
|
+
)
|
|
104
|
+
when {
|
|
105
|
+
context has jailbreak_confidence && context.jailbreak_confidence >= 75
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Block any content with critical severity threats
|
|
109
|
+
@id("semantic-block-critical")
|
|
110
|
+
@name("Block critical threats")
|
|
111
|
+
@description("Block all MCP operations when any detection engine reports critical severity")
|
|
112
|
+
@severity("critical")
|
|
113
|
+
@tags("critical,baseline,security,catch-all")
|
|
114
|
+
@reject_message("MCP operation was blocked because security scanners detected a critical-severity threat.")
|
|
115
|
+
forbid (
|
|
116
|
+
principal,
|
|
117
|
+
action,
|
|
118
|
+
resource
|
|
119
|
+
)
|
|
120
|
+
when {
|
|
121
|
+
context has highest_severity && context.highest_severity == "critical"
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Block tool calls with multiple concurrent threats
|
|
125
|
+
@id("semantic-block-multi-threat-tools")
|
|
126
|
+
@name("Block multi-threat tool calls")
|
|
127
|
+
@description("Block tool execution when 3+ distinct threats are detected simultaneously")
|
|
128
|
+
@severity("high")
|
|
129
|
+
@tags("multi-threat,tools,security,defense-in-depth")
|
|
130
|
+
@reject_message("Tool execution was blocked because multiple security threats were detected simultaneously.")
|
|
131
|
+
forbid (
|
|
132
|
+
principal,
|
|
133
|
+
action == AIGateway::Action::"call_tool",
|
|
134
|
+
resource
|
|
135
|
+
)
|
|
136
|
+
when {
|
|
137
|
+
context has threat_count && context.threat_count >= 3
|
|
138
|
+
};
|
|
139
|
+
`;
|
|
140
|
+
const AI_GATEWAY_TOOLS_DEFAULT_CEDAR = `// =============================================================================
|
|
141
|
+
// Tool Permissioning Policy (Default)
|
|
142
|
+
// =============================================================================
|
|
143
|
+
// Controls access to MCP tools based on risk scoring, threat detection,
|
|
144
|
+
// and tool classification.
|
|
145
|
+
//
|
|
146
|
+
// Category: tools
|
|
147
|
+
// Namespace: AIGateway
|
|
148
|
+
// =============================================================================
|
|
149
|
+
|
|
150
|
+
// Block tools with very high computed risk
|
|
151
|
+
@id("tools-block-high-risk-score")
|
|
152
|
+
@name("Block high-risk tool operations")
|
|
153
|
+
@description("Block tool operations when the computed risk score exceeds 90/100")
|
|
154
|
+
@severity("critical")
|
|
155
|
+
@tags("tool-risk,security,owasp-llm06,owasp-asi02")
|
|
156
|
+
@reject_message("Tool execution blocked: this operation scored 90+ on the risk assessment.")
|
|
157
|
+
forbid (
|
|
158
|
+
principal,
|
|
159
|
+
action == AIGateway::Action::"call_tool",
|
|
160
|
+
resource
|
|
161
|
+
)
|
|
162
|
+
when {
|
|
163
|
+
context has tool_risk_score && context.tool_risk_score >= 90
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// Block tools classified as dangerous
|
|
167
|
+
@id("tools-block-dangerous-category")
|
|
168
|
+
@name("Block dangerous tool category")
|
|
169
|
+
@description("Block all tools classified as dangerous by the detection engine")
|
|
170
|
+
@severity("critical")
|
|
171
|
+
@tags("tool-category,dangerous,security,owasp-llm06")
|
|
172
|
+
@reject_message("Tool execution blocked: this tool is classified as dangerous.")
|
|
173
|
+
forbid (
|
|
174
|
+
principal,
|
|
175
|
+
action == AIGateway::Action::"call_tool",
|
|
176
|
+
resource
|
|
177
|
+
)
|
|
178
|
+
when {
|
|
179
|
+
context has tool_category && context.tool_category == "dangerous"
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Block sensitive tools when threats are detected
|
|
183
|
+
@id("tools-block-sensitive-with-threats")
|
|
184
|
+
@name("Block sensitive tools with threats")
|
|
185
|
+
@description("Block sensitive tools when any threats are detected concurrently")
|
|
186
|
+
@severity("high")
|
|
187
|
+
@tags("tool-category,sensitive,security,defense-in-depth")
|
|
188
|
+
@reject_message("Sensitive tool execution blocked: threats were detected alongside a sensitive tool operation.")
|
|
189
|
+
forbid (
|
|
190
|
+
principal,
|
|
191
|
+
action == AIGateway::Action::"call_tool",
|
|
192
|
+
resource
|
|
193
|
+
)
|
|
194
|
+
when {
|
|
195
|
+
context has tool_is_sensitive && context.tool_is_sensitive &&
|
|
196
|
+
context has threat_count && context.threat_count > 0
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Block tool calls with high severity threats
|
|
200
|
+
@id("tools-block-high-severity-threats")
|
|
201
|
+
@name("Block tool calls with high severity threats")
|
|
202
|
+
@description("Prevent tool execution when high or critical severity threats are detected")
|
|
203
|
+
@severity("high")
|
|
204
|
+
@tags("tools,threats,severity,security")
|
|
205
|
+
@reject_message("Tool execution was blocked because high or critical severity threats were detected.")
|
|
206
|
+
forbid (
|
|
207
|
+
principal,
|
|
208
|
+
action == AIGateway::Action::"call_tool",
|
|
209
|
+
resource
|
|
210
|
+
)
|
|
211
|
+
when {
|
|
212
|
+
context has threat_count && context has max_threat_severity &&
|
|
213
|
+
context.threat_count > 0 && context.max_threat_severity >= 3
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// Block detected command injection patterns
|
|
217
|
+
@id("tools-block-command-injection")
|
|
218
|
+
@name("Block command injection in tool calls")
|
|
219
|
+
@description("Block tool calls when command injection patterns are detected in arguments")
|
|
220
|
+
@severity("critical")
|
|
221
|
+
@tags("command-injection,security,mitre-t1059,owasp-asi02")
|
|
222
|
+
@reject_message("Tool execution blocked: command injection pattern detected in tool arguments.")
|
|
223
|
+
forbid (
|
|
224
|
+
principal,
|
|
225
|
+
action == AIGateway::Action::"call_tool",
|
|
226
|
+
resource
|
|
227
|
+
)
|
|
228
|
+
when {
|
|
229
|
+
context has detected_threats &&
|
|
230
|
+
context.detected_threats.contains("command_injection")
|
|
231
|
+
};
|
|
232
|
+
`;
|
|
233
|
+
const AI_GATEWAY_AGENT_SECURITY_DEFAULT_CEDAR = `// =============================================================================
|
|
234
|
+
// Agent Security Policy (Default)
|
|
235
|
+
// =============================================================================
|
|
236
|
+
// Detects and blocks tool poisoning, rug pull attacks, indirect prompt injection,
|
|
237
|
+
// and MCP supply chain threats.
|
|
238
|
+
//
|
|
239
|
+
// Category: agent_security
|
|
240
|
+
// Namespace: AIGateway
|
|
241
|
+
// =============================================================================
|
|
242
|
+
|
|
243
|
+
// Block tool calls with tool poisoning risk
|
|
244
|
+
@id("as-block-tool-poisoning")
|
|
245
|
+
@name("Block tool poisoning")
|
|
246
|
+
@description("Block tool execution when hidden instructions are detected in tool descriptions or arguments (score >= 70)")
|
|
247
|
+
@severity("critical")
|
|
248
|
+
@tags("tool-poisoning,agent-security,owasp-asi01")
|
|
249
|
+
@reject_message("Tool execution blocked: hidden manipulation instructions detected in tool description or arguments (OWASP ASI01).")
|
|
250
|
+
forbid (
|
|
251
|
+
principal,
|
|
252
|
+
action == AIGateway::Action::"call_tool",
|
|
253
|
+
resource
|
|
254
|
+
)
|
|
255
|
+
when {
|
|
256
|
+
context has tool_poisoning_score && context.tool_poisoning_score >= 70
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// Block MCP server connections with poisoning risk
|
|
260
|
+
@id("as-block-server-poisoning")
|
|
261
|
+
@name("Block poisoned MCP servers")
|
|
262
|
+
@description("Block connections to MCP servers when tool poisoning patterns are detected (score >= 60)")
|
|
263
|
+
@severity("critical")
|
|
264
|
+
@tags("tool-poisoning,mcp-security,owasp-asi04,owasp-mcp02")
|
|
265
|
+
@reject_message("MCP server connection blocked: tool poisoning patterns detected in server tool descriptions.")
|
|
266
|
+
forbid (
|
|
267
|
+
principal,
|
|
268
|
+
action == AIGateway::Action::"connect_server",
|
|
269
|
+
resource
|
|
270
|
+
)
|
|
271
|
+
when {
|
|
272
|
+
context has tool_poisoning_score && context.tool_poisoning_score >= 60
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// Block tool calls with behavioral drift (rug pull)
|
|
276
|
+
@id("as-block-rug-pull")
|
|
277
|
+
@name("Block rug pull attacks")
|
|
278
|
+
@description("Block tool execution when behavioral drift is detected (score >= 70)")
|
|
279
|
+
@severity("critical")
|
|
280
|
+
@tags("rug-pull,agent-security,owasp-asi04")
|
|
281
|
+
@reject_message("Tool execution blocked: tool behavior has changed significantly from its established pattern.")
|
|
282
|
+
forbid (
|
|
283
|
+
principal,
|
|
284
|
+
action in [AIGateway::Action::"call_tool", AIGateway::Action::"connect_server"],
|
|
285
|
+
resource
|
|
286
|
+
)
|
|
287
|
+
when {
|
|
288
|
+
context has rug_pull_score && context.rug_pull_score >= 70
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// Block with indirect injection from tool outputs
|
|
292
|
+
@id("as-block-indirect-injection")
|
|
293
|
+
@name("Block indirect prompt injection")
|
|
294
|
+
@description("Block when indirect prompt injection is detected in tool outputs (score >= 70)")
|
|
295
|
+
@severity("critical")
|
|
296
|
+
@tags("indirect-injection,owasp-llm01,owasp-asi01")
|
|
297
|
+
@reject_message("Content blocked: indirect prompt injection detected in tool output or retrieved content.")
|
|
298
|
+
forbid (
|
|
299
|
+
principal,
|
|
300
|
+
action in [AIGateway::Action::"call_tool", AIGateway::Action::"connect_server"],
|
|
301
|
+
resource
|
|
302
|
+
)
|
|
303
|
+
when {
|
|
304
|
+
context has indirect_injection_score && context.indirect_injection_score >= 70
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// Strict indirect injection for sensitive tool calls
|
|
308
|
+
@id("as-block-indirect-injection-sensitive-tools")
|
|
309
|
+
@name("Block indirect injection on sensitive tools")
|
|
310
|
+
@description("Lower threshold (>= 50) for indirect injection when the tool is classified as sensitive")
|
|
311
|
+
@severity("critical")
|
|
312
|
+
@tags("indirect-injection,sensitive-tools,owasp-asi02")
|
|
313
|
+
@reject_message("Sensitive tool execution blocked: moderate indirect injection risk detected.")
|
|
314
|
+
forbid (
|
|
315
|
+
principal,
|
|
316
|
+
action == AIGateway::Action::"call_tool",
|
|
317
|
+
resource
|
|
318
|
+
)
|
|
319
|
+
when {
|
|
320
|
+
context has indirect_injection_score && context.indirect_injection_score >= 50 &&
|
|
321
|
+
context has tool_is_sensitive && context.tool_is_sensitive
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// Block unverified MCP server tool calls with detected threats
|
|
325
|
+
@id("as-block-unverified-threats")
|
|
326
|
+
@name("Block unverified server threats")
|
|
327
|
+
@description("Block tool calls from unverified MCP servers when any threat is detected")
|
|
328
|
+
@severity("high")
|
|
329
|
+
@tags("mcp-trust,owasp-asi04,supply-chain")
|
|
330
|
+
@reject_message("Tool execution blocked: the MCP server is unverified and security threats were detected.")
|
|
331
|
+
forbid (
|
|
332
|
+
principal,
|
|
333
|
+
action == AIGateway::Action::"call_tool",
|
|
334
|
+
resource
|
|
335
|
+
)
|
|
336
|
+
when {
|
|
337
|
+
context has mcp_server_verified && context.mcp_server_verified == false &&
|
|
338
|
+
context has threat_count && context.threat_count > 0
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// Block connections to MCP servers with risky configurations
|
|
342
|
+
@id("as-block-mcp-config-risk")
|
|
343
|
+
@name("Block risky MCP server configs")
|
|
344
|
+
@description("Block MCP server connections when risky configuration patterns are detected (score >= 70)")
|
|
345
|
+
@severity("high")
|
|
346
|
+
@tags("mcp-config,owasp-mcp03,supply-chain")
|
|
347
|
+
@reject_message("MCP server connection blocked: risky server configuration detected.")
|
|
348
|
+
forbid (
|
|
349
|
+
principal,
|
|
350
|
+
action == AIGateway::Action::"connect_server",
|
|
351
|
+
resource
|
|
352
|
+
)
|
|
353
|
+
when {
|
|
354
|
+
context has mcp_config_risk && context.mcp_config_risk &&
|
|
355
|
+
context has mcp_risk_score && context.mcp_risk_score >= 70
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
// Block connections to unverified MCP servers
|
|
359
|
+
@id("as-block-unverified-server-connect")
|
|
360
|
+
@name("Block unverified MCP server connections")
|
|
361
|
+
@description("Block connections to MCP servers that are not from a verified registry")
|
|
362
|
+
@severity("high")
|
|
363
|
+
@tags("mcp-trust,owasp-asi04,owasp-mcp05,supply-chain")
|
|
364
|
+
@reject_message("MCP server connection blocked: server is not from a verified registry.")
|
|
365
|
+
forbid (
|
|
366
|
+
principal,
|
|
367
|
+
action == AIGateway::Action::"connect_server",
|
|
368
|
+
resource
|
|
369
|
+
)
|
|
370
|
+
when {
|
|
371
|
+
context has mcp_server_verified && context.mcp_server_verified == false
|
|
372
|
+
};
|
|
373
|
+
`;
|
|
374
|
+
const AI_GATEWAY_TOOLS_MCP_ALLOWLIST_CEDAR = `// MCP Server Allowlist Template
|
|
375
|
+
// Only allow specific MCP servers to be used
|
|
376
|
+
// Category: tools
|
|
377
|
+
//
|
|
378
|
+
// NOTE: Users should customize the mcp_server values in the permit rule
|
|
379
|
+
// to match their allowed servers before deploying this template.
|
|
380
|
+
|
|
381
|
+
@id("mcp-allowlist-permit")
|
|
382
|
+
@name("Allow specific MCP servers")
|
|
383
|
+
@description("Only allow connections to pre-approved MCP servers (customize the list)")
|
|
384
|
+
@severity("medium")
|
|
385
|
+
@tags("mcp,allowlist,server,governance")
|
|
386
|
+
permit (
|
|
387
|
+
principal,
|
|
388
|
+
action == AIGateway::Action::"connect_server",
|
|
389
|
+
resource
|
|
390
|
+
)
|
|
391
|
+
when {
|
|
392
|
+
context has mcp_server &&
|
|
393
|
+
(context.mcp_server == "filesystem" ||
|
|
394
|
+
context.mcp_server == "playwright")
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
@id("mcp-allowlist-deny")
|
|
398
|
+
@name("Deny unallowed MCP servers")
|
|
399
|
+
@description("Block all MCP server connections not in the allowlist")
|
|
400
|
+
@severity("medium")
|
|
401
|
+
@tags("mcp,deny-default,server")
|
|
402
|
+
forbid (
|
|
403
|
+
principal,
|
|
404
|
+
action == AIGateway::Action::"connect_server",
|
|
405
|
+
resource
|
|
406
|
+
);
|
|
407
|
+
`;
|
|
408
|
+
const AI_GATEWAY_TOOLS_MCP_TOOL_PERMISSIONS_CEDAR = `// =============================================================================
|
|
409
|
+
// MCP Tool Permissions Template (AIGateway)
|
|
410
|
+
// =============================================================================
|
|
411
|
+
// Per-tool access control for MCP servers.
|
|
412
|
+
// Complements the MCP Server Allowlist (connect_server action)
|
|
413
|
+
// with fine-grained per-tool control on call_tool action.
|
|
414
|
+
//
|
|
415
|
+
// Category: tools
|
|
416
|
+
// Namespace: AIGateway
|
|
417
|
+
// =============================================================================
|
|
418
|
+
|
|
419
|
+
// -- GitHub MCP: Read-only access -------------------------------------------
|
|
420
|
+
|
|
421
|
+
@id("mcp-tool-allow-read-github")
|
|
422
|
+
@name("Allow read-only GitHub tools")
|
|
423
|
+
@description("Permit read operations from GitHub MCP server")
|
|
424
|
+
@severity("medium")
|
|
425
|
+
@tags("mcp,github,read-only,least-privilege")
|
|
426
|
+
permit (
|
|
427
|
+
principal,
|
|
428
|
+
action == AIGateway::Action::"call_tool",
|
|
429
|
+
resource
|
|
430
|
+
) when {
|
|
431
|
+
context has mcp_server && context.mcp_server == "github" &&
|
|
432
|
+
context has tool_name &&
|
|
433
|
+
(context.tool_name == "read_issues" ||
|
|
434
|
+
context.tool_name == "get_issue" ||
|
|
435
|
+
context.tool_name == "list_repos" ||
|
|
436
|
+
context.tool_name == "get_pull_request" ||
|
|
437
|
+
context.tool_name == "search_code" ||
|
|
438
|
+
context.tool_name == "get_file_contents")
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
@id("mcp-tool-deny-write-github")
|
|
442
|
+
@name("Deny write GitHub tools")
|
|
443
|
+
@description("Block create/update/delete operations on GitHub MCP server")
|
|
444
|
+
@severity("high")
|
|
445
|
+
@tags("mcp,github,write-block,least-privilege")
|
|
446
|
+
forbid (
|
|
447
|
+
principal,
|
|
448
|
+
action == AIGateway::Action::"call_tool",
|
|
449
|
+
resource
|
|
450
|
+
) when {
|
|
451
|
+
context has mcp_server && context.mcp_server == "github"
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// -- Organization-wide MCP server exclusions --------------------------------
|
|
455
|
+
|
|
456
|
+
@id("mcp-tool-exclude-server")
|
|
457
|
+
@name("Exclude specific MCP servers")
|
|
458
|
+
@description("Block all tool calls from excluded MCP servers (org-wide exclusion list)")
|
|
459
|
+
@severity("critical")
|
|
460
|
+
@tags("mcp,exclusion,org-wide,block")
|
|
461
|
+
forbid (
|
|
462
|
+
principal,
|
|
463
|
+
action == AIGateway::Action::"call_tool",
|
|
464
|
+
resource
|
|
465
|
+
) when {
|
|
466
|
+
context has mcp_server &&
|
|
467
|
+
(context.mcp_server == "untrusted-server" ||
|
|
468
|
+
context.mcp_server == "deprecated-server")
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
// -- Block unverified MCP servers -------------------------------------------
|
|
472
|
+
|
|
473
|
+
@id("mcp-tool-block-unverified")
|
|
474
|
+
@name("Block tools from unverified MCP servers")
|
|
475
|
+
@description("Deny tool calls from MCP servers not in the verified registry")
|
|
476
|
+
@severity("high")
|
|
477
|
+
@tags("mcp,trust,verification")
|
|
478
|
+
forbid (
|
|
479
|
+
principal,
|
|
480
|
+
action == AIGateway::Action::"call_tool",
|
|
481
|
+
resource
|
|
482
|
+
) when {
|
|
483
|
+
context has mcp_server_verified && context.mcp_server_verified == false
|
|
484
|
+
};
|
|
485
|
+
`;
|
|
486
|
+
const AI_GATEWAY_DATA_PII_REDACTION_CEDAR = `// =============================================================================
|
|
487
|
+
// PII Redaction Policy
|
|
488
|
+
// =============================================================================
|
|
489
|
+
// Block or redact requests containing personally identifiable information.
|
|
490
|
+
// Covers all AI Gateway actions (MCP tool calls, LLM prompts, file ops).
|
|
491
|
+
//
|
|
492
|
+
// Category: data_protection
|
|
493
|
+
// Namespace: AIGateway
|
|
494
|
+
// =============================================================================
|
|
495
|
+
|
|
496
|
+
// Block requests with PII detected
|
|
497
|
+
@id("data-block-pii")
|
|
498
|
+
@name("Block PII in requests")
|
|
499
|
+
@description("Block any AI Gateway operation when PII is detected in the content")
|
|
500
|
+
@severity("high")
|
|
501
|
+
@tags("pii,data-protection,owasp-llm06,dlp")
|
|
502
|
+
@reject_message("Request was blocked because personally identifiable information (PII) was detected. Remove sensitive data before retrying.")
|
|
503
|
+
forbid (
|
|
504
|
+
principal,
|
|
505
|
+
action == AIGateway::Action::"process_prompt",
|
|
506
|
+
resource
|
|
507
|
+
)
|
|
508
|
+
when {
|
|
509
|
+
context has pii_detected && context.pii_detected == true
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
// Block requests with secrets/credentials
|
|
513
|
+
@id("data-block-secrets")
|
|
514
|
+
@name("Block secrets in requests")
|
|
515
|
+
@description("Block any AI Gateway operation when secrets or credentials are detected")
|
|
516
|
+
@severity("critical")
|
|
517
|
+
@tags("secrets,data-protection,credentials,dlp")
|
|
518
|
+
@reject_message("Request was blocked because secrets or credentials were detected in the content. Remove sensitive credentials before retrying.")
|
|
519
|
+
forbid (
|
|
520
|
+
principal,
|
|
521
|
+
action == AIGateway::Action::"process_prompt",
|
|
522
|
+
resource
|
|
523
|
+
)
|
|
524
|
+
when {
|
|
525
|
+
context has contains_secrets && context.contains_secrets == true
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// Block MCP tool calls with PII
|
|
529
|
+
@id("data-block-pii-tools")
|
|
530
|
+
@name("Block PII in tool calls")
|
|
531
|
+
@description("Block MCP tool execution when PII is detected in tool arguments")
|
|
532
|
+
@severity("high")
|
|
533
|
+
@tags("pii,tools,data-protection,dlp")
|
|
534
|
+
@reject_message("Tool call was blocked because PII was detected in the arguments.")
|
|
535
|
+
forbid (
|
|
536
|
+
principal,
|
|
537
|
+
action == AIGateway::Action::"call_tool",
|
|
538
|
+
resource
|
|
539
|
+
)
|
|
540
|
+
when {
|
|
541
|
+
context has pii_detected && context.pii_detected == true
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
// Block MCP tool calls with secrets
|
|
545
|
+
@id("data-block-secrets-tools")
|
|
546
|
+
@name("Block secrets in tool calls")
|
|
547
|
+
@description("Block MCP tool execution when secrets or credentials are detected")
|
|
548
|
+
@severity("critical")
|
|
549
|
+
@tags("secrets,tools,data-protection,dlp")
|
|
550
|
+
@reject_message("Tool call was blocked because secrets were detected in the arguments.")
|
|
551
|
+
forbid (
|
|
552
|
+
principal,
|
|
553
|
+
action == AIGateway::Action::"call_tool",
|
|
554
|
+
resource
|
|
555
|
+
)
|
|
556
|
+
when {
|
|
557
|
+
context has contains_secrets && context.contains_secrets == true
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
// Block bulk PII exposure (3+ PII matches)
|
|
561
|
+
@id("data-block-bulk-pii")
|
|
562
|
+
@name("Block bulk PII exposure")
|
|
563
|
+
@description("Block operations with 3 or more PII matches -- indicates data dump or exfiltration attempt")
|
|
564
|
+
@severity("critical")
|
|
565
|
+
@tags("pii,bulk,data-protection,exfiltration")
|
|
566
|
+
@reject_message("Request was blocked because multiple PII matches were detected, indicating potential data exfiltration.")
|
|
567
|
+
forbid (
|
|
568
|
+
principal,
|
|
569
|
+
action,
|
|
570
|
+
resource
|
|
571
|
+
)
|
|
572
|
+
when {
|
|
573
|
+
context has pii_count && context.pii_count >= 3
|
|
574
|
+
};
|
|
575
|
+
`;
|
|
576
|
+
const AI_GATEWAY_LLM_DEFAULT_ALLOW_CEDAR = `// =============================================================================
|
|
577
|
+
// Default Allow LLM Proxy Calls
|
|
578
|
+
// =============================================================================
|
|
579
|
+
// Permits all LLM prompt processing by default. Deploy this alongside
|
|
580
|
+
// threat-specific forbid policies to create a "default allow, block on threat"
|
|
581
|
+
// posture for LLM chat completions.
|
|
582
|
+
//
|
|
583
|
+
// Category: organization
|
|
584
|
+
// Namespace: AIGateway
|
|
585
|
+
// =============================================================================
|
|
586
|
+
|
|
587
|
+
// Allow all LLM prompt processing by default
|
|
588
|
+
@id("llm-permit-all-prompts")
|
|
589
|
+
@name("Allow all LLM proxy calls")
|
|
590
|
+
@description("Permits all LLM chat completion requests by default -- threat-specific forbid policies override this when threats are detected")
|
|
591
|
+
@severity("low")
|
|
592
|
+
@tags("llm,permit-default,organization,proxy")
|
|
593
|
+
permit (
|
|
594
|
+
principal,
|
|
595
|
+
action == AIGateway::Action::"process_prompt",
|
|
596
|
+
resource
|
|
597
|
+
);
|
|
598
|
+
`;
|
|
599
|
+
// =============================================================================
|
|
600
|
+
// CATEGORIES
|
|
601
|
+
// =============================================================================
|
|
602
|
+
export const AI_GATEWAY_CATEGORIES = [
|
|
603
|
+
{ id: 'semantic', name: 'Semantic Threat Detection', description: 'Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats' },
|
|
604
|
+
{ id: 'tools', name: 'Tool Permissioning', description: 'Control access to MCP tools, enforce risk scoring, and manage per-tool permissions' },
|
|
605
|
+
{ id: 'agent_security', name: 'Agent Security', description: 'Detect and block tool poisoning, rug pull attacks, indirect prompt injection, and MCP supply chain threats' },
|
|
606
|
+
{ id: 'data_protection', name: 'Data Protection', description: 'Prevent secrets and PII leakage in LLM chat completions and MCP operations' },
|
|
607
|
+
{ id: 'content_safety', name: 'Content Safety', description: 'Enforce content moderation score thresholds on LLM prompts and MCP content' },
|
|
608
|
+
{ id: 'organization', name: 'Organization Rules', description: 'Apply organization-wide policy baselines for AI gateway operations' },
|
|
609
|
+
];
|
|
610
|
+
// =============================================================================
|
|
611
|
+
// DEFAULT POLICIES
|
|
612
|
+
// =============================================================================
|
|
613
|
+
export const AI_GATEWAY_DEFAULTS = [
|
|
614
|
+
{
|
|
615
|
+
id: 'baseline-default',
|
|
616
|
+
name: 'Baseline Permit',
|
|
617
|
+
description: 'Permits all actions by default -- threat-specific forbid policies override this when threats are detected',
|
|
618
|
+
category: 'organization',
|
|
619
|
+
cedarText: AI_GATEWAY_BASELINE_DEFAULT_CEDAR,
|
|
620
|
+
severity: 'low',
|
|
621
|
+
tags: ['baseline', 'permit-default', 'organization'],
|
|
622
|
+
isActive: true,
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
id: 'semantic-default',
|
|
626
|
+
name: 'Semantic Threat Detection',
|
|
627
|
+
description: 'Detect and block prompt injection, jailbreak attempts, and high-severity threats in MCP tool calls and LLM prompts',
|
|
628
|
+
category: 'semantic',
|
|
629
|
+
cedarText: AI_GATEWAY_SEMANTIC_DEFAULT_CEDAR,
|
|
630
|
+
severity: 'critical',
|
|
631
|
+
tags: ['prompt-injection', 'jailbreak', 'owasp-llm01', 'owasp-llm02', 'security', 'baseline'],
|
|
632
|
+
isActive: true,
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
id: 'tools-default',
|
|
636
|
+
name: 'Tool Permissioning',
|
|
637
|
+
description: 'Enforce tool risk scoring, block dangerous tools, and detect command injection in MCP tool arguments',
|
|
638
|
+
category: 'tools',
|
|
639
|
+
cedarText: AI_GATEWAY_TOOLS_DEFAULT_CEDAR,
|
|
640
|
+
severity: 'critical',
|
|
641
|
+
tags: ['tool-risk', 'command-injection', 'owasp-llm06', 'owasp-asi02', 'baseline'],
|
|
642
|
+
isActive: true,
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
id: 'agent-security-default',
|
|
646
|
+
name: 'Agent Security',
|
|
647
|
+
description: 'Detect and block tool poisoning, rug pull attacks, indirect prompt injection, and MCP supply chain threats',
|
|
648
|
+
category: 'agent_security',
|
|
649
|
+
cedarText: AI_GATEWAY_AGENT_SECURITY_DEFAULT_CEDAR,
|
|
650
|
+
severity: 'critical',
|
|
651
|
+
tags: ['tool-poisoning', 'rug-pull', 'indirect-injection', 'mcp-security', 'owasp-asi01', 'owasp-asi04', 'baseline'],
|
|
652
|
+
isActive: true,
|
|
653
|
+
},
|
|
654
|
+
];
|
|
655
|
+
// =============================================================================
|
|
656
|
+
// ALL TEMPLATES
|
|
657
|
+
// =============================================================================
|
|
658
|
+
export const AI_GATEWAY_TEMPLATES = [
|
|
659
|
+
{
|
|
660
|
+
id: 'tools-mcp-allowlist',
|
|
661
|
+
name: 'MCP Server Allowlist',
|
|
662
|
+
description: 'Only allow specific MCP servers to be used',
|
|
663
|
+
category: 'tools',
|
|
664
|
+
cedarText: AI_GATEWAY_TOOLS_MCP_ALLOWLIST_CEDAR,
|
|
665
|
+
severity: 'medium',
|
|
666
|
+
tags: ['mcp', 'allowlist', 'whitelist'],
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
id: 'tools-mcp-tool-permissions',
|
|
670
|
+
name: 'MCP Tool Permissions',
|
|
671
|
+
description: 'Per-tool access control for MCP servers -- allow specific tools while denying others, exclude servers org-wide, block unverified sources',
|
|
672
|
+
category: 'tools',
|
|
673
|
+
cedarText: AI_GATEWAY_TOOLS_MCP_TOOL_PERMISSIONS_CEDAR,
|
|
674
|
+
severity: 'high',
|
|
675
|
+
tags: ['mcp', 'tools', 'least-privilege', 'per-server', 'exclusion'],
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
id: 'data-pii-redaction',
|
|
679
|
+
name: 'PII & Secrets Redaction',
|
|
680
|
+
description: 'Block requests containing PII or secrets across LLM prompts and MCP tool calls -- prevents data leakage and credential exposure',
|
|
681
|
+
category: 'data_protection',
|
|
682
|
+
cedarText: AI_GATEWAY_DATA_PII_REDACTION_CEDAR,
|
|
683
|
+
severity: 'high',
|
|
684
|
+
tags: ['pii', 'secrets', 'data-protection', 'dlp', 'owasp-llm06'],
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
id: 'llm-default-allow',
|
|
688
|
+
name: 'Default Allow LLM Proxy',
|
|
689
|
+
description: 'Permit all LLM chat completion requests by default -- deploy alongside threat-specific forbid policies for a default-allow posture',
|
|
690
|
+
category: 'organization',
|
|
691
|
+
cedarText: AI_GATEWAY_LLM_DEFAULT_ALLOW_CEDAR,
|
|
692
|
+
severity: 'low',
|
|
693
|
+
tags: ['llm', 'permit-default', 'proxy', 'organization'],
|
|
694
|
+
},
|
|
695
|
+
];
|
|
696
|
+
// =============================================================================
|
|
697
|
+
// TEMPLATES METADATA
|
|
698
|
+
// =============================================================================
|
|
699
|
+
/** Raw templates.json metadata for the AiGateway service. */
|
|
700
|
+
export const AI_GATEWAY_TEMPLATES_JSON = `{
|
|
701
|
+
"service": "ai_gateway",
|
|
702
|
+
"version": "2.0.0",
|
|
703
|
+
"description": "AIGateway policy templates for MCP + LLM gateway security",
|
|
704
|
+
"categories": [
|
|
705
|
+
{
|
|
706
|
+
"id": "semantic",
|
|
707
|
+
"name": "Semantic Threat Detection",
|
|
708
|
+
"description": "Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"id": "tools",
|
|
712
|
+
"name": "Tool Permissioning",
|
|
713
|
+
"description": "Control access to MCP tools, enforce risk scoring, and manage per-tool permissions"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"id": "agent_security",
|
|
717
|
+
"name": "Agent Security",
|
|
718
|
+
"description": "Detect and block tool poisoning, rug pull attacks, indirect prompt injection, and MCP supply chain threats"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
"id": "data_protection",
|
|
722
|
+
"name": "Data Protection",
|
|
723
|
+
"description": "Prevent secrets and PII leakage in LLM chat completions and MCP operations"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
"id": "content_safety",
|
|
727
|
+
"name": "Content Safety",
|
|
728
|
+
"description": "Enforce content moderation score thresholds on LLM prompts and MCP content"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"id": "organization",
|
|
732
|
+
"name": "Organization Rules",
|
|
733
|
+
"description": "Apply organization-wide policy baselines for AI gateway operations"
|
|
734
|
+
}
|
|
735
|
+
],
|
|
736
|
+
"defaults": [
|
|
737
|
+
{
|
|
738
|
+
"id": "baseline-default",
|
|
739
|
+
"name": "Baseline Permit",
|
|
740
|
+
"description": "Permits all actions by default -- threat-specific forbid policies override this when threats are detected",
|
|
741
|
+
"category": "organization",
|
|
742
|
+
"file": "defaults/baseline.cedar",
|
|
743
|
+
"severity": "low",
|
|
744
|
+
"tags": ["baseline", "permit-default", "organization"],
|
|
745
|
+
"is_active": true
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
"id": "semantic-default",
|
|
749
|
+
"name": "Semantic Threat Detection",
|
|
750
|
+
"description": "Detect and block prompt injection, jailbreak attempts, and high-severity threats in MCP tool calls and LLM prompts",
|
|
751
|
+
"category": "semantic",
|
|
752
|
+
"file": "defaults/semantic.cedar",
|
|
753
|
+
"severity": "critical",
|
|
754
|
+
"tags": ["prompt-injection", "jailbreak", "owasp-llm01", "owasp-llm02", "security", "baseline"],
|
|
755
|
+
"is_active": true
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"id": "tools-default",
|
|
759
|
+
"name": "Tool Permissioning",
|
|
760
|
+
"description": "Enforce tool risk scoring, block dangerous tools, and detect command injection in MCP tool arguments",
|
|
761
|
+
"category": "tools",
|
|
762
|
+
"file": "defaults/tools.cedar",
|
|
763
|
+
"severity": "critical",
|
|
764
|
+
"tags": ["tool-risk", "command-injection", "owasp-llm06", "owasp-asi02", "baseline"],
|
|
765
|
+
"is_active": true
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"id": "agent-security-default",
|
|
769
|
+
"name": "Agent Security",
|
|
770
|
+
"description": "Detect and block tool poisoning, rug pull attacks, indirect prompt injection, and MCP supply chain threats",
|
|
771
|
+
"category": "agent_security",
|
|
772
|
+
"file": "defaults/agent_security.cedar",
|
|
773
|
+
"severity": "critical",
|
|
774
|
+
"tags": ["tool-poisoning", "rug-pull", "indirect-injection", "mcp-security", "owasp-asi01", "owasp-asi04", "baseline"],
|
|
775
|
+
"is_active": true
|
|
776
|
+
}
|
|
777
|
+
],
|
|
778
|
+
"templates": [
|
|
779
|
+
{
|
|
780
|
+
"id": "tools-mcp-allowlist",
|
|
781
|
+
"name": "MCP Server Allowlist",
|
|
782
|
+
"description": "Only allow specific MCP servers to be used",
|
|
783
|
+
"category": "tools",
|
|
784
|
+
"file": "mcp_server_allowlist.cedar",
|
|
785
|
+
"severity": "medium",
|
|
786
|
+
"tags": ["mcp", "allowlist", "whitelist"]
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
"id": "tools-mcp-tool-permissions",
|
|
790
|
+
"name": "MCP Tool Permissions",
|
|
791
|
+
"description": "Per-tool access control for MCP servers -- allow specific tools while denying others, exclude servers org-wide, block unverified sources",
|
|
792
|
+
"category": "tools",
|
|
793
|
+
"file": "mcp_tool_permissions.cedar",
|
|
794
|
+
"severity": "high",
|
|
795
|
+
"tags": ["mcp", "tools", "least-privilege", "per-server", "exclusion"]
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
"id": "data-pii-redaction",
|
|
799
|
+
"name": "PII & Secrets Redaction",
|
|
800
|
+
"description": "Block requests containing PII or secrets across LLM prompts and MCP tool calls -- prevents data leakage and credential exposure",
|
|
801
|
+
"category": "data_protection",
|
|
802
|
+
"file": "pii_redaction.cedar",
|
|
803
|
+
"severity": "high",
|
|
804
|
+
"tags": ["pii", "secrets", "data-protection", "dlp", "owasp-llm06"]
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"id": "llm-default-allow",
|
|
808
|
+
"name": "Default Allow LLM Proxy",
|
|
809
|
+
"description": "Permit all LLM chat completion requests by default -- deploy alongside threat-specific forbid policies for a default-allow posture",
|
|
810
|
+
"category": "organization",
|
|
811
|
+
"file": "llm_default_allow.cedar",
|
|
812
|
+
"severity": "low",
|
|
813
|
+
"tags": ["llm", "permit-default", "proxy", "organization"]
|
|
814
|
+
}
|
|
815
|
+
]
|
|
816
|
+
}
|
|
817
|
+
`;
|
|
818
|
+
// =============================================================================
|
|
819
|
+
// HELPER FUNCTIONS
|
|
820
|
+
// =============================================================================
|
|
821
|
+
export function getAiGatewayDefaultsByCategory(category) {
|
|
822
|
+
return AI_GATEWAY_DEFAULTS.filter(d => d.category === category);
|
|
823
|
+
}
|
|
824
|
+
export function getAiGatewayTemplatesByCategory(category) {
|
|
825
|
+
return AI_GATEWAY_TEMPLATES.filter(t => t.category === category);
|
|
826
|
+
}
|
|
827
|
+
export function getAiGatewayTemplateById(id) {
|
|
828
|
+
return AI_GATEWAY_TEMPLATES.find(t => t.id === id);
|
|
829
|
+
}
|