@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.
@@ -0,0 +1,286 @@
1
+ // AIGateway Cedar Schema
2
+ // ===================================
3
+ // AI Gateway Security & Policy Enforcement
4
+ //
5
+ // AIGateway protects both MCP proxy operations (tool calls, server connections)
6
+ // and LLM chat completions (prompt processing) by evaluating threats detected
7
+ // by the Shield detection engine pipeline against Cedar policies.
8
+ //
9
+ // Architecture:
10
+ // MCP/LLM Client -> Firehog Proxy -> Shield (detection + Cedar) -> Allow/Deny
11
+ //
12
+ // Threat Coverage:
13
+ // - OWASP Top 10 for LLM Applications 2025 (LLM01, LLM06)
14
+ // - OWASP Top 10 for Agentic Applications (ASI01, ASI02, ASI04)
15
+ // - OWASP MCP Top 10 (MCP01-MCP05)
16
+
17
+ namespace AIGateway {
18
+
19
+ // =============================================================================
20
+ // ENTITIES - Tenant Hierarchy (ReBAC)
21
+ // =============================================================================
22
+ // AIGateway does not use App/Session hierarchy.
23
+ //
24
+ // Entity hierarchy:
25
+ // Account (org root)
26
+ // -> Project in [Account]
27
+ // -> Tool/Server in [Project]
28
+ //
29
+ // Policy scoping examples:
30
+ // resource == AIGateway::Tool::"get_me" -> specific tool
31
+ // resource in AIGateway::Project::"<uuid>" -> project-wide
32
+ // resource in AIGateway::Account::"<uuid>" -> org-wide
33
+
34
+ /// Account represents an organization (top-level tenant)
35
+ entity Account;
36
+
37
+ /// Project represents a project within an account
38
+ entity Project in [Account];
39
+
40
+ // =============================================================================
41
+ // ENTITIES - Principals
42
+ // =============================================================================
43
+
44
+ /// Human user authenticated via JWT or API key
45
+ entity User;
46
+
47
+ /// MCP client (default principal for unauthenticated requests)
48
+ entity MCP_Client;
49
+
50
+ // =============================================================================
51
+ // ENTITIES - Resources (scoped under Project)
52
+ // =============================================================================
53
+
54
+ /// MCP tool -- resource for call_tool action
55
+ entity Tool in [Project];
56
+
57
+ /// MCP server -- resource for connect_server action
58
+ entity Server in [Project];
59
+
60
+ /// MCP prompt -- resource for process_prompt action
61
+ entity LlmPrompt in [Project];
62
+
63
+ /// File/resource path -- resource for read_file/write_file actions
64
+ entity FilePath in [Project];
65
+
66
+ // =============================================================================
67
+ // ACTIONS
68
+ // =============================================================================
69
+
70
+ // Call an MCP tool
71
+ // Threat focus: command injection, tool poisoning, rug pull, secrets, PII
72
+ action call_tool appliesTo {
73
+ principal: [User, MCP_Client],
74
+ resource: [Tool],
75
+ context: {
76
+ // --- Content ---
77
+ content: String, // Raw content being scanned
78
+
79
+ // --- Tool & MCP ---
80
+ tool_name?: String, // Tool name
81
+ mcp_server?: String, // MCP server name
82
+ mcp_tool?: String, // MCP tool name
83
+
84
+ // --- Threat Detection (from Shield detection pipeline) ---
85
+ threat_count?: Long, // Total threats detected
86
+ highest_severity?: String, // "critical", "high", "medium", "low", "none"
87
+ threat_categories?: Set<String>, // Threat category names
88
+ detected_threats?: Set<String>, // Detection rule names that matched
89
+ max_threat_severity?: Long, // Numeric severity (0=none, 1=low, 2=medium, 3=high, 4=critical)
90
+ contains_secrets?: Bool, // Whether secrets/credentials detected
91
+
92
+ // --- Secrets (granular) ---
93
+ secret_types?: Set<String>,
94
+ secret_count?: Long,
95
+
96
+ // --- PII Detection ---
97
+ pii_detected?: Bool,
98
+ pii_types?: Set<String>,
99
+ pii_count?: Long,
100
+
101
+ // --- ML Detector Confidence Scores (0-100) ---
102
+ injection_confidence?: Long, // Prompt injection classifier confidence
103
+ jailbreak_confidence?: Long, // Jailbreak detection classifier confidence
104
+
105
+ // --- Agent Security (0-100) ---
106
+ tool_poisoning_score?: Long, // Hidden instructions in tool description/args
107
+ tool_poisoning_detected?: Bool,
108
+ rug_pull_score?: Long, // Tool behavior drift after trust establishment
109
+ rug_pull_detected?: Bool,
110
+ indirect_injection_score?: Long, // Indirect injection via tool output
111
+
112
+ // --- Tool Risk Assessment ---
113
+ tool_risk_score?: Long, // Computed tool risk (0-100)
114
+ tool_category?: String, // "safe", "sensitive", "dangerous"
115
+ tool_is_sensitive?: Bool,
116
+ tool_is_builtin?: Bool,
117
+
118
+ // --- MCP Trust ---
119
+ mcp_server_verified?: Bool, // Whether server is from verified registry
120
+
121
+ // --- Content Safety Scores (0-100) ---
122
+ violence_score?: Long,
123
+ weapons_score?: Long,
124
+ hate_speech_score?: Long,
125
+ crime_score?: Long,
126
+ sexual_score?: Long,
127
+ profanity_score?: Long,
128
+
129
+ // --- Encoding & Unicode Attacks ---
130
+ contains_invisible_chars?: Bool,
131
+ invisible_chars_score?: Long,
132
+
133
+ // --- Behavioral Analysis ---
134
+ loop_detected?: Bool,
135
+ loop_count?: Long,
136
+ loop_tool?: String,
137
+ suspicious_pattern?: Bool,
138
+ pattern_type?: String,
139
+ sequence_risk?: Long,
140
+ },
141
+ };
142
+
143
+ // Connect to an MCP server
144
+ // Threat focus: supply chain, tool poisoning, rug pull, config risk
145
+ action connect_server appliesTo {
146
+ principal: [User, MCP_Client],
147
+ resource: [Server],
148
+ context: {
149
+ content?: String, // Server config content (if available)
150
+ mcp_server?: String,
151
+
152
+ // --- Threat Detection ---
153
+ threat_count?: Long,
154
+ highest_severity?: String,
155
+ threat_categories?: Set<String>,
156
+ max_threat_severity?: Long,
157
+
158
+ // --- Agent Security (0-100) ---
159
+ tool_poisoning_score?: Long,
160
+ tool_poisoning_detected?: Bool,
161
+ rug_pull_score?: Long,
162
+ rug_pull_detected?: Bool,
163
+ indirect_injection_score?: Long,
164
+
165
+ // --- Secrets ---
166
+ contains_secrets?: Bool,
167
+ secret_types?: Set<String>,
168
+ secret_count?: Long,
169
+
170
+ // --- PII Detection ---
171
+ pii_detected?: Bool,
172
+ pii_types?: Set<String>,
173
+ pii_count?: Long,
174
+
175
+ // --- MCP Trust & Config Risk ---
176
+ mcp_server_verified?: Bool,
177
+ mcp_config_risk?: Bool,
178
+ mcp_risk_score?: Long,
179
+ },
180
+ };
181
+
182
+ // Process a prompt (MCP prompts/get or LLM chat completions)
183
+ // Threat focus: injection, jailbreak, secrets, PII, content safety
184
+ action process_prompt appliesTo {
185
+ principal: [User, MCP_Client],
186
+ resource: [LlmPrompt],
187
+ context: {
188
+ content: String,
189
+ mcp_server?: String,
190
+
191
+ // --- Threat Detection ---
192
+ threat_count?: Long,
193
+ highest_severity?: String,
194
+ threat_categories?: Set<String>,
195
+ detected_threats?: Set<String>,
196
+ max_threat_severity?: Long,
197
+ contains_secrets?: Bool,
198
+
199
+ // --- Secrets ---
200
+ secret_types?: Set<String>,
201
+ secret_count?: Long,
202
+
203
+ // --- PII Detection ---
204
+ pii_detected?: Bool,
205
+ pii_types?: Set<String>,
206
+ pii_count?: Long,
207
+
208
+ // --- ML Detector Confidence Scores (0-100) ---
209
+ injection_confidence?: Long,
210
+ jailbreak_confidence?: Long,
211
+
212
+ // --- Content Safety Scores (0-100) ---
213
+ violence_score?: Long,
214
+ weapons_score?: Long,
215
+ hate_speech_score?: Long,
216
+ crime_score?: Long,
217
+ sexual_score?: Long,
218
+ profanity_score?: Long,
219
+
220
+ // --- Encoding ---
221
+ contains_invisible_chars?: Bool,
222
+ invisible_chars_score?: Long,
223
+
224
+ // --- LLM-specific ---
225
+ model_name?: String, // Target model name (e.g., "gpt-4", "claude-3-opus")
226
+ model_provider?: String, // Provider name (e.g., "openai", "anthropic", "bedrock")
227
+ },
228
+ };
229
+
230
+ // Read an MCP resource (resources/read, resources/list)
231
+ // Threat focus: secrets exposure, PII exposure, sensitive paths
232
+ action read_file appliesTo {
233
+ principal: [User, MCP_Client],
234
+ resource: [FilePath],
235
+ context: {
236
+ content: String,
237
+ mcp_server?: String,
238
+
239
+ // --- Threat Detection ---
240
+ threat_count?: Long,
241
+ highest_severity?: String,
242
+ threat_categories?: Set<String>,
243
+ detected_threats?: Set<String>,
244
+ max_threat_severity?: Long,
245
+ contains_secrets?: Bool,
246
+
247
+ // --- Secrets ---
248
+ secret_types?: Set<String>,
249
+ secret_count?: Long,
250
+
251
+ // --- PII Detection ---
252
+ pii_detected?: Bool,
253
+ pii_types?: Set<String>,
254
+ pii_count?: Long,
255
+ },
256
+ };
257
+
258
+ // Write an MCP resource (resources/write)
259
+ // Threat focus: secrets in output, PII in output
260
+ action write_file appliesTo {
261
+ principal: [User, MCP_Client],
262
+ resource: [FilePath],
263
+ context: {
264
+ content: String,
265
+ mcp_server?: String,
266
+
267
+ // --- Threat Detection ---
268
+ threat_count?: Long,
269
+ highest_severity?: String,
270
+ threat_categories?: Set<String>,
271
+ detected_threats?: Set<String>,
272
+ max_threat_severity?: Long,
273
+ contains_secrets?: Bool,
274
+
275
+ // --- Secrets ---
276
+ secret_types?: Set<String>,
277
+ secret_count?: Long,
278
+
279
+ // --- PII Detection ---
280
+ pii_detected?: Bool,
281
+ pii_types?: Set<String>,
282
+ pii_count?: Long,
283
+ },
284
+ };
285
+
286
+ }
@@ -0,0 +1,140 @@
1
+ // =============================================================================
2
+ // Agent Security Policy (Default)
3
+ // =============================================================================
4
+ // Detects and blocks tool poisoning, rug pull attacks, indirect prompt injection,
5
+ // and MCP supply chain threats.
6
+ //
7
+ // Category: agent_security
8
+ // Namespace: AIGateway
9
+ // =============================================================================
10
+
11
+ // Block tool calls with tool poisoning risk
12
+ @id("as-block-tool-poisoning")
13
+ @name("Block tool poisoning")
14
+ @description("Block tool execution when hidden instructions are detected in tool descriptions or arguments (score >= 70)")
15
+ @severity("critical")
16
+ @tags("tool-poisoning,agent-security,owasp-asi01")
17
+ @reject_message("Tool execution blocked: hidden manipulation instructions detected in tool description or arguments (OWASP ASI01).")
18
+ forbid (
19
+ principal,
20
+ action == AIGateway::Action::"call_tool",
21
+ resource
22
+ )
23
+ when {
24
+ context has tool_poisoning_score && context.tool_poisoning_score >= 70
25
+ };
26
+
27
+ // Block MCP server connections with poisoning risk
28
+ @id("as-block-server-poisoning")
29
+ @name("Block poisoned MCP servers")
30
+ @description("Block connections to MCP servers when tool poisoning patterns are detected (score >= 60)")
31
+ @severity("critical")
32
+ @tags("tool-poisoning,mcp-security,owasp-asi04,owasp-mcp02")
33
+ @reject_message("MCP server connection blocked: tool poisoning patterns detected in server tool descriptions.")
34
+ forbid (
35
+ principal,
36
+ action == AIGateway::Action::"connect_server",
37
+ resource
38
+ )
39
+ when {
40
+ context has tool_poisoning_score && context.tool_poisoning_score >= 60
41
+ };
42
+
43
+ // Block tool calls with behavioral drift (rug pull)
44
+ @id("as-block-rug-pull")
45
+ @name("Block rug pull attacks")
46
+ @description("Block tool execution when behavioral drift is detected (score >= 70)")
47
+ @severity("critical")
48
+ @tags("rug-pull,agent-security,owasp-asi04")
49
+ @reject_message("Tool execution blocked: tool behavior has changed significantly from its established pattern.")
50
+ forbid (
51
+ principal,
52
+ action in [AIGateway::Action::"call_tool", AIGateway::Action::"connect_server"],
53
+ resource
54
+ )
55
+ when {
56
+ context has rug_pull_score && context.rug_pull_score >= 70
57
+ };
58
+
59
+ // Block with indirect injection from tool outputs
60
+ @id("as-block-indirect-injection")
61
+ @name("Block indirect prompt injection")
62
+ @description("Block when indirect prompt injection is detected in tool outputs (score >= 70)")
63
+ @severity("critical")
64
+ @tags("indirect-injection,owasp-llm01,owasp-asi01")
65
+ @reject_message("Content blocked: indirect prompt injection detected in tool output or retrieved content.")
66
+ forbid (
67
+ principal,
68
+ action in [AIGateway::Action::"call_tool", AIGateway::Action::"connect_server"],
69
+ resource
70
+ )
71
+ when {
72
+ context has indirect_injection_score && context.indirect_injection_score >= 70
73
+ };
74
+
75
+ // Strict indirect injection for sensitive tool calls
76
+ @id("as-block-indirect-injection-sensitive-tools")
77
+ @name("Block indirect injection on sensitive tools")
78
+ @description("Lower threshold (>= 50) for indirect injection when the tool is classified as sensitive")
79
+ @severity("critical")
80
+ @tags("indirect-injection,sensitive-tools,owasp-asi02")
81
+ @reject_message("Sensitive tool execution blocked: moderate indirect injection risk detected.")
82
+ forbid (
83
+ principal,
84
+ action == AIGateway::Action::"call_tool",
85
+ resource
86
+ )
87
+ when {
88
+ context has indirect_injection_score && context.indirect_injection_score >= 50 &&
89
+ context has tool_is_sensitive && context.tool_is_sensitive
90
+ };
91
+
92
+ // Block unverified MCP server tool calls with detected threats
93
+ @id("as-block-unverified-threats")
94
+ @name("Block unverified server threats")
95
+ @description("Block tool calls from unverified MCP servers when any threat is detected")
96
+ @severity("high")
97
+ @tags("mcp-trust,owasp-asi04,supply-chain")
98
+ @reject_message("Tool execution blocked: the MCP server is unverified and security threats were detected.")
99
+ forbid (
100
+ principal,
101
+ action == AIGateway::Action::"call_tool",
102
+ resource
103
+ )
104
+ when {
105
+ context has mcp_server_verified && context.mcp_server_verified == false &&
106
+ context has threat_count && context.threat_count > 0
107
+ };
108
+
109
+ // Block connections to MCP servers with risky configurations
110
+ @id("as-block-mcp-config-risk")
111
+ @name("Block risky MCP server configs")
112
+ @description("Block MCP server connections when risky configuration patterns are detected (score >= 70)")
113
+ @severity("high")
114
+ @tags("mcp-config,owasp-mcp03,supply-chain")
115
+ @reject_message("MCP server connection blocked: risky server configuration detected.")
116
+ forbid (
117
+ principal,
118
+ action == AIGateway::Action::"connect_server",
119
+ resource
120
+ )
121
+ when {
122
+ context has mcp_config_risk && context.mcp_config_risk &&
123
+ context has mcp_risk_score && context.mcp_risk_score >= 70
124
+ };
125
+
126
+ // Block connections to unverified MCP servers
127
+ @id("as-block-unverified-server-connect")
128
+ @name("Block unverified MCP server connections")
129
+ @description("Block connections to MCP servers that are not from a verified registry")
130
+ @severity("high")
131
+ @tags("mcp-trust,owasp-asi04,owasp-mcp05,supply-chain")
132
+ @reject_message("MCP server connection blocked: server is not from a verified registry.")
133
+ forbid (
134
+ principal,
135
+ action == AIGateway::Action::"connect_server",
136
+ resource
137
+ )
138
+ when {
139
+ context has mcp_server_verified && context.mcp_server_verified == false
140
+ };
@@ -0,0 +1,23 @@
1
+ // =============================================================================
2
+ // Baseline Permit Policy (Default)
3
+ // =============================================================================
4
+ // Permits all actions by default. Threat-specific forbid policies override
5
+ // this to block when detection engines identify issues.
6
+ //
7
+ // Cedar is default-deny: without at least one permit rule, every request
8
+ // is denied regardless of forbid rules.
9
+ //
10
+ // Category: organization
11
+ // Namespace: AIGateway
12
+ // =============================================================================
13
+
14
+ @id("baseline-permit-all")
15
+ @name("Permit all actions by default")
16
+ @description("Baseline permit for all actions -- threat-specific forbid policies override this when threats are detected")
17
+ @severity("low")
18
+ @tags("baseline,permit-default,organization")
19
+ permit (
20
+ principal,
21
+ action,
22
+ resource
23
+ );
@@ -0,0 +1,105 @@
1
+ // =============================================================================
2
+ // Semantic Threat Detection Policy (Default)
3
+ // =============================================================================
4
+ // Detects and blocks prompt injection, jailbreak attempts, and high-severity
5
+ // threats in MCP tool calls and server connections.
6
+ //
7
+ // Category: semantic
8
+ // Namespace: AIGateway
9
+ // =============================================================================
10
+
11
+ // Block content with prompt injection patterns detected by rules
12
+ @id("semantic-block-injection")
13
+ @name("Block prompt injection")
14
+ @description("Block tool calls when detection engine rules identify prompt injection patterns in tool arguments or content")
15
+ @severity("critical")
16
+ @tags("injection,security,owasp-llm01,baseline")
17
+ @reject_message("Tool call was blocked because prompt injection patterns were detected in the content (OWASP LLM01).")
18
+ forbid (
19
+ principal,
20
+ action == AIGateway::Action::"call_tool",
21
+ resource
22
+ )
23
+ when {
24
+ context has detected_threats && context.detected_threats.contains("prompt_injection")
25
+ };
26
+
27
+ // Block content with high ML injection confidence
28
+ @id("semantic-block-injection-score")
29
+ @name("Block high-confidence injection")
30
+ @description("Block tool calls when the ML injection classifier confidence exceeds 75/100")
31
+ @severity("critical")
32
+ @tags("injection,ml-classifier,security,owasp-llm01")
33
+ @reject_message("Tool call was blocked because the ML classifier detected prompt injection with high confidence.")
34
+ forbid (
35
+ principal,
36
+ action == AIGateway::Action::"call_tool",
37
+ resource
38
+ )
39
+ when {
40
+ context has injection_confidence && context.injection_confidence >= 75
41
+ };
42
+
43
+ // Block content with jailbreak patterns
44
+ @id("semantic-block-jailbreak")
45
+ @name("Block jailbreak attempts")
46
+ @description("Block tool calls when jailbreak patterns are detected in content")
47
+ @severity("critical")
48
+ @tags("jailbreak,security,owasp-llm02,baseline")
49
+ @reject_message("Tool call was blocked because jailbreak patterns were detected.")
50
+ forbid (
51
+ principal,
52
+ action == AIGateway::Action::"call_tool",
53
+ resource
54
+ )
55
+ when {
56
+ context has detected_threats && context.detected_threats.contains("jailbreak")
57
+ };
58
+
59
+ // Block content with high ML jailbreak confidence
60
+ @id("semantic-block-jailbreak-score")
61
+ @name("Block high-confidence jailbreak")
62
+ @description("Block tool calls when the ML jailbreak classifier confidence exceeds 75/100")
63
+ @severity("critical")
64
+ @tags("jailbreak,ml-classifier,security,owasp-llm02")
65
+ @reject_message("Tool call was blocked because the ML classifier detected a jailbreak attempt with high confidence.")
66
+ forbid (
67
+ principal,
68
+ action == AIGateway::Action::"call_tool",
69
+ resource
70
+ )
71
+ when {
72
+ context has jailbreak_confidence && context.jailbreak_confidence >= 75
73
+ };
74
+
75
+ // Block any content with critical severity threats
76
+ @id("semantic-block-critical")
77
+ @name("Block critical threats")
78
+ @description("Block all MCP operations when any detection engine reports critical severity")
79
+ @severity("critical")
80
+ @tags("critical,baseline,security,catch-all")
81
+ @reject_message("MCP operation was blocked because security scanners detected a critical-severity threat.")
82
+ forbid (
83
+ principal,
84
+ action,
85
+ resource
86
+ )
87
+ when {
88
+ context has highest_severity && context.highest_severity == "critical"
89
+ };
90
+
91
+ // Block tool calls with multiple concurrent threats
92
+ @id("semantic-block-multi-threat-tools")
93
+ @name("Block multi-threat tool calls")
94
+ @description("Block tool execution when 3+ distinct threats are detected simultaneously")
95
+ @severity("high")
96
+ @tags("multi-threat,tools,security,defense-in-depth")
97
+ @reject_message("Tool execution was blocked because multiple security threats were detected simultaneously.")
98
+ forbid (
99
+ principal,
100
+ action == AIGateway::Action::"call_tool",
101
+ resource
102
+ )
103
+ when {
104
+ context has threat_count && context.threat_count >= 3
105
+ };
@@ -0,0 +1,92 @@
1
+ // =============================================================================
2
+ // Tool Permissioning Policy (Default)
3
+ // =============================================================================
4
+ // Controls access to MCP tools based on risk scoring, threat detection,
5
+ // and tool classification.
6
+ //
7
+ // Category: tools
8
+ // Namespace: AIGateway
9
+ // =============================================================================
10
+
11
+ // Block tools with very high computed risk
12
+ @id("tools-block-high-risk-score")
13
+ @name("Block high-risk tool operations")
14
+ @description("Block tool operations when the computed risk score exceeds 90/100")
15
+ @severity("critical")
16
+ @tags("tool-risk,security,owasp-llm06,owasp-asi02")
17
+ @reject_message("Tool execution blocked: this operation scored 90+ on the risk assessment.")
18
+ forbid (
19
+ principal,
20
+ action == AIGateway::Action::"call_tool",
21
+ resource
22
+ )
23
+ when {
24
+ context has tool_risk_score && context.tool_risk_score >= 90
25
+ };
26
+
27
+ // Block tools classified as dangerous
28
+ @id("tools-block-dangerous-category")
29
+ @name("Block dangerous tool category")
30
+ @description("Block all tools classified as dangerous by the detection engine")
31
+ @severity("critical")
32
+ @tags("tool-category,dangerous,security,owasp-llm06")
33
+ @reject_message("Tool execution blocked: this tool is classified as dangerous.")
34
+ forbid (
35
+ principal,
36
+ action == AIGateway::Action::"call_tool",
37
+ resource
38
+ )
39
+ when {
40
+ context has tool_category && context.tool_category == "dangerous"
41
+ };
42
+
43
+ // Block sensitive tools when threats are detected
44
+ @id("tools-block-sensitive-with-threats")
45
+ @name("Block sensitive tools with threats")
46
+ @description("Block sensitive tools when any threats are detected concurrently")
47
+ @severity("high")
48
+ @tags("tool-category,sensitive,security,defense-in-depth")
49
+ @reject_message("Sensitive tool execution blocked: threats were detected alongside a sensitive tool operation.")
50
+ forbid (
51
+ principal,
52
+ action == AIGateway::Action::"call_tool",
53
+ resource
54
+ )
55
+ when {
56
+ context has tool_is_sensitive && context.tool_is_sensitive &&
57
+ context has threat_count && context.threat_count > 0
58
+ };
59
+
60
+ // Block tool calls with high severity threats
61
+ @id("tools-block-high-severity-threats")
62
+ @name("Block tool calls with high severity threats")
63
+ @description("Prevent tool execution when high or critical severity threats are detected")
64
+ @severity("high")
65
+ @tags("tools,threats,severity,security")
66
+ @reject_message("Tool execution was blocked because high or critical severity threats were detected.")
67
+ forbid (
68
+ principal,
69
+ action == AIGateway::Action::"call_tool",
70
+ resource
71
+ )
72
+ when {
73
+ context has threat_count && context has max_threat_severity &&
74
+ context.threat_count > 0 && context.max_threat_severity >= 3
75
+ };
76
+
77
+ // Block detected command injection patterns
78
+ @id("tools-block-command-injection")
79
+ @name("Block command injection in tool calls")
80
+ @description("Block tool calls when command injection patterns are detected in arguments")
81
+ @severity("critical")
82
+ @tags("command-injection,security,mitre-t1059,owasp-asi02")
83
+ @reject_message("Tool execution blocked: command injection pattern detected in tool arguments.")
84
+ forbid (
85
+ principal,
86
+ action == AIGateway::Action::"call_tool",
87
+ resource
88
+ )
89
+ when {
90
+ context has detected_threats &&
91
+ context.detected_threats.contains("command_injection")
92
+ };
@@ -0,0 +1,22 @@
1
+ // =============================================================================
2
+ // Default Allow LLM Proxy Calls
3
+ // =============================================================================
4
+ // Permits all LLM prompt processing by default. Deploy this alongside
5
+ // threat-specific forbid policies to create a "default allow, block on threat"
6
+ // posture for LLM chat completions.
7
+ //
8
+ // Category: organization
9
+ // Namespace: AIGateway
10
+ // =============================================================================
11
+
12
+ // Allow all LLM prompt processing by default
13
+ @id("llm-permit-all-prompts")
14
+ @name("Allow all LLM proxy calls")
15
+ @description("Permits all LLM chat completion requests by default -- threat-specific forbid policies override this when threats are detected")
16
+ @severity("low")
17
+ @tags("llm,permit-default,organization,proxy")
18
+ permit (
19
+ principal,
20
+ action == AIGateway::Action::"process_prompt",
21
+ resource
22
+ );