@highflame/policy 2.2.31 → 2.2.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/_schemas/agent_ops/context.json +1274 -441
  2. package/_schemas/agent_ops/schema.cedarschema +24 -0
  3. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_a2a_cross_origin.cedar +92 -0
  4. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_a2a_escalation.cedar +99 -0
  5. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_a2a_identity_enforcement.cedar +101 -0
  6. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_a2a_inter_agent_injection.cedar +120 -0
  7. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_claude_block_injection.cedar +30 -0
  8. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_defaults.cedar +122 -0
  9. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_multi_agent_safety.cedar +164 -0
  10. package/_schemas/agent_ops/templates/ported/agent-security/agent_identity_multi_agent_trust.cedar +143 -0
  11. package/_schemas/agent_ops/templates/ported/agent-security/agent_security_data_pipeline.cedar +45 -0
  12. package/_schemas/agent_ops/templates/ported/agent-security/agent_security_defaults.cedar +164 -0
  13. package/_schemas/agent_ops/templates/ported/agent-security/agent_security_malicious_package.cedar +59 -0
  14. package/_schemas/agent_ops/templates/ported/agent-security/agent_security_param_validation.cedar +119 -0
  15. package/_schemas/agent_ops/templates/ported/agent-security/agent_security_tool_risk.cedar +66 -0
  16. package/_schemas/agent_ops/templates/ported/code-security/agent_identity_a2a_supply_chain.cedar +101 -0
  17. package/_schemas/agent_ops/templates/ported/code-security/agent_security_code_agent.cedar +130 -0
  18. package/_schemas/agent_ops/templates/ported/code-security/agent_security_code_agent_supply_chain.cedar +116 -0
  19. package/_schemas/agent_ops/templates/ported/code-security/security_code_agent_encoding.cedar +51 -0
  20. package/_schemas/agent_ops/templates/ported/code-security/security_code_agent_path_security.cedar +149 -0
  21. package/_schemas/agent_ops/templates/ported/content-safety/trust_safety_chat_assistant.cedar +58 -0
  22. package/_schemas/agent_ops/templates/ported/content-safety/trust_safety_defaults.cedar +111 -0
  23. package/_schemas/agent_ops/templates/ported/content-safety/trust_safety_semantic.cedar +78 -0
  24. package/_schemas/agent_ops/templates/ported/content-safety/trust_safety_toxicity.cedar +71 -0
  25. package/_schemas/agent_ops/templates/ported/data-protection/data_protection_advanced_secrets.cedar +74 -0
  26. package/_schemas/agent_ops/templates/ported/data-protection/data_protection_code_block_write_secrets.cedar +26 -0
  27. package/_schemas/agent_ops/templates/ported/data-protection/data_protection_data_pipeline.cedar +52 -0
  28. package/_schemas/agent_ops/templates/ported/data-protection/data_protection_defaults.cedar +57 -0
  29. package/_schemas/agent_ops/templates/ported/data-protection/privacy_advanced_pii.cedar +465 -0
  30. package/_schemas/agent_ops/templates/ported/data-protection/privacy_defaults.cedar +164 -0
  31. package/_schemas/agent_ops/templates/ported/data-protection/privacy_pii_model.cedar +90 -0
  32. package/_schemas/agent_ops/templates/ported/organization/organization_deny_baseline.cedar +22 -0
  33. package/_schemas/agent_ops/templates/ported/organization/organization_team_permissions.cedar +38 -0
  34. package/_schemas/agent_ops/templates/ported/threat-detection/security_advanced_block_critical_severity.cedar +30 -0
  35. package/_schemas/agent_ops/templates/ported/threat-detection/security_chat_assistant.cedar +47 -0
  36. package/_schemas/agent_ops/templates/ported/threat-detection/security_data_pipeline_block_injection.cedar +31 -0
  37. package/_schemas/agent_ops/templates/ported/threat-detection/security_injection.cedar +82 -0
  38. package/_schemas/agent_ops/templates/ported/threat-detection/security_patterns.cedar +72 -0
  39. package/_schemas/agent_ops/templates/ported/threat-detection/semantic_defaults.cedar +155 -0
  40. package/_schemas/agent_ops/templates/ported/tool-permissioning/tools_bash_operation_classes.cedar +142 -0
  41. package/_schemas/agent_ops/templates/ported/tool-permissioning/tools_block_shell.cedar +40 -0
  42. package/_schemas/agent_ops/templates/ported/tool-permissioning/tools_defaults.cedar +76 -0
  43. package/_schemas/agent_ops/templates/ported/tool-permissioning/tools_mcp_server_allowlist.cedar +41 -0
  44. package/_schemas/agent_ops/templates/ported/tool-permissioning/tools_mcp_tool_permissions.cedar +103 -0
  45. package/_schemas/agent_ops/templates/templates.json +752 -8
  46. package/_schemas/ai_gateway/context.json +2 -2
  47. package/_schemas/guardrails/context.json +27 -2
  48. package/_schemas/guardrails/schema.cedarschema +13 -0
  49. package/_schemas/guardrails/templates/templates.json +6 -1
  50. package/_schemas/overwatch/context.json +3 -3
  51. package/dist/aarm-annotations.gen.js +1 -1
  52. package/dist/agent_ops-context.gen.d.ts +5 -1
  53. package/dist/agent_ops-context.gen.js +8 -0
  54. package/dist/agent_ops-defaults.gen.js +5168 -8
  55. package/dist/guardrails-context.gen.d.ts +5 -1
  56. package/dist/guardrails-context.gen.js +8 -0
  57. package/dist/guardrails-defaults.gen.js +6 -1
  58. package/dist/guardrails-detectors.gen.d.ts +1 -1
  59. package/dist/guardrails-detectors.gen.js +19 -1
  60. package/dist/overwatch-defaults.gen.js +109 -0
  61. package/dist/service-schemas.gen.d.ts +2 -2
  62. package/dist/service-schemas.gen.js +65 -12
  63. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ // =============================================================================
2
+ // Action Parameter Validation (AARM R3 / CAP-ENF-007)
3
+ // =============================================================================
4
+ // Validates the structured arguments of a tool call. Shield projects well-known,
5
+ // safety-relevant tool-call arguments into `context.action_params` (each value
6
+ // coerced to its declared type), so policies can enforce parameter constraints by
7
+ // - type: deny when an argument failed type coercion (param_type_violation)
8
+ // - range: numeric bounds on a parameter (e.g. amount, count)
9
+ // - pattern: Cedar `like` glob on a string parameter (e.g. path, url)
10
+ // - allowlist: permit only an approved set of values
11
+ // - blocklist: deny a set of dangerous values
12
+ //
13
+ // These are EXAMPLES — customize the thresholds, patterns, and allow/block lists
14
+ // for your tenant. Not auto-deployed.
15
+ //
16
+ // Context keys consumed:
17
+ // - action_params: { amount, count, command, path, url, recipient, target, query }
18
+ // - param_type_violation: Bool
19
+ //
20
+ // Category: agent-security
21
+ // Namespace: AgentOps
22
+ // =============================================================================
23
+
24
+ // ---------------------------------------------------------------------------
25
+ // type — deny when any projected argument failed type coercion
26
+ // ---------------------------------------------------------------------------
27
+ @id("agent-security.param-type-violation")
28
+ @name("Deny tool calls with mistyped parameters")
29
+ @description("Denies call_tool when any projected argument was present but failed type coercion (e.g. a non-numeric amount).")
30
+ @severity("high")
31
+ @tags("category:agent-security,surface:call-tool,aarm:r3,check:type,posture:deny-default")
32
+ forbid (
33
+ principal,
34
+ action == AgentOps::Action::"call_tool",
35
+ resource
36
+ )
37
+ when {
38
+ context has param_type_violation && context.param_type_violation
39
+ };
40
+
41
+ // ---------------------------------------------------------------------------
42
+ // range — numeric bound on a parameter
43
+ // ---------------------------------------------------------------------------
44
+ @id("agent-security.param-amount-range")
45
+ @name("Deny tool calls exceeding the amount limit")
46
+ @description("Range check: denies call_tool when action_params.amount exceeds 10000.")
47
+ @severity("high")
48
+ @tags("category:agent-security,surface:call-tool,aarm:r3,check:range,posture:deny-default")
49
+ forbid (
50
+ principal,
51
+ action == AgentOps::Action::"call_tool",
52
+ resource
53
+ )
54
+ when {
55
+ context has action_params &&
56
+ context.action_params has amount &&
57
+ context.action_params.amount > 10000
58
+ };
59
+
60
+ // ---------------------------------------------------------------------------
61
+ // blocklist — deny a set of dangerous command values
62
+ // ---------------------------------------------------------------------------
63
+ @id("agent-security.param-command-blocklist")
64
+ @name("Block dangerous shell commands by parameter")
65
+ @description("Blocklist check: denies call_tool when action_params.command is a destructive command.")
66
+ @severity("critical")
67
+ @tags("category:agent-security,surface:call-tool,aarm:r3,check:blocklist,posture:deny-default")
68
+ forbid (
69
+ principal,
70
+ action == AgentOps::Action::"call_tool",
71
+ resource
72
+ )
73
+ when {
74
+ context has action_params &&
75
+ context.action_params has command &&
76
+ (
77
+ context.action_params.command like "*rm -rf*" ||
78
+ context.action_params.command like "*shutdown*" ||
79
+ context.action_params.command like "*mkfs*"
80
+ )
81
+ };
82
+
83
+ // ---------------------------------------------------------------------------
84
+ // pattern — Cedar `like` glob on a string parameter
85
+ // ---------------------------------------------------------------------------
86
+ @id("agent-security.param-path-pattern")
87
+ @name("Restrict file paths by pattern")
88
+ @description("Pattern check: denies call_tool when action_params.path is outside the /workspace/ tree.")
89
+ @severity("high")
90
+ @tags("category:agent-security,surface:call-tool,aarm:r3,check:pattern,posture:deny-default")
91
+ forbid (
92
+ principal,
93
+ action == AgentOps::Action::"call_tool",
94
+ resource
95
+ )
96
+ when {
97
+ context has action_params &&
98
+ context.action_params has path &&
99
+ !(context.action_params.path like "/workspace/*")
100
+ };
101
+
102
+ // ---------------------------------------------------------------------------
103
+ // allowlist — permit only an approved set of recipient values
104
+ // ---------------------------------------------------------------------------
105
+ @id("agent-security.param-recipient-allowlist")
106
+ @name("Allow payouts only to approved recipients")
107
+ @description("Allowlist check: denies call_tool when action_params.recipient is not in the approved set.")
108
+ @severity("high")
109
+ @tags("category:agent-security,surface:call-tool,aarm:r3,check:allowlist,posture:deny-default")
110
+ forbid (
111
+ principal,
112
+ action == AgentOps::Action::"call_tool",
113
+ resource
114
+ )
115
+ when {
116
+ context has action_params &&
117
+ context.action_params has recipient &&
118
+ !(["treasury@example.com", "payroll@example.com"].contains(context.action_params.recipient))
119
+ };
@@ -0,0 +1,66 @@
1
+ // =============================================================================
2
+ // Tool Risk (Default)
3
+ // =============================================================================
4
+ // Blocks dangerous tool calls based on risk scoring, tool classification,
5
+ // and well-known dangerous tool names (shell, execute_command).
6
+ //
7
+ // Context keys consumed:
8
+ // - tool_name: String
9
+ // - tool_risk_score: Long (0-100)
10
+ // - tool_is_sensitive: Bool
11
+ // - tool_category: String ("safe" | "sensitive" | "dangerous")
12
+ //
13
+ // Compliance:
14
+ // - OWASP LLM06, OWASP ASI02
15
+ //
16
+ // Category: agent-security
17
+ // Namespace: AgentOps
18
+ // =============================================================================
19
+
20
+ @id("agent-security.block-dangerous-tool")
21
+ @name("Block dangerous tools")
22
+ @description("Blocks call_tool when tool_risk_score >= 86 or tool_category equals \"dangerous\".")
23
+ @severity("critical")
24
+ @tags("category:agent-security,detection:aggregate,surface:call-tool,owasp:llm06,owasp:asi02")
25
+ @reject_message("Tool execution blocked: tool is classified as dangerous or scored a high risk.")
26
+ forbid (
27
+ principal,
28
+ action == AgentOps::Action::"call_tool",
29
+ resource
30
+ )
31
+ when {
32
+ (context has tool_risk_score && context.tool_risk_score >= 86) ||
33
+ (context has tool_category && context.tool_category == "dangerous")
34
+ };
35
+
36
+ @id("agent-security.block-shell-commands")
37
+ @name("Block shell command execution")
38
+ @description("Blocks call_tool when tool_name equals \"shell\" or \"execute_command\".")
39
+ @severity("high")
40
+ @tags("category:agent-security,threat:command-injection,detection:rule,surface:call-tool,mitre:t1059")
41
+ @reject_message("Tool execution blocked: direct shell or command execution is not permitted.")
42
+ forbid (
43
+ principal,
44
+ action == AgentOps::Action::"call_tool",
45
+ resource
46
+ )
47
+ when {
48
+ context has tool_name &&
49
+ (context.tool_name == "shell" || context.tool_name == "execute_command")
50
+ };
51
+
52
+ @id("agent-security.block-sensitive-high-risk")
53
+ @name("Block sensitive high-risk tools")
54
+ @description("Blocks call_tool when tool_is_sensitive is true and tool_risk_score >= 71.")
55
+ @severity("high")
56
+ @tags("category:agent-security,detection:aggregate,surface:call-tool,owasp:llm06")
57
+ @reject_message("Tool execution blocked: a sensitive tool was called with elevated risk score.")
58
+ forbid (
59
+ principal,
60
+ action == AgentOps::Action::"call_tool",
61
+ resource
62
+ )
63
+ when {
64
+ context has tool_is_sensitive && context.tool_is_sensitive == true &&
65
+ context has tool_risk_score && context.tool_risk_score >= 71
66
+ };
@@ -0,0 +1,101 @@
1
+ // =============================================================================
2
+ // A2A Security — Supply Chain & Behavioural Drift
3
+ // =============================================================================
4
+ // Blocks supply-chain attacks specific to agent-to-agent ecosystems: tool
5
+ // poisoning from external agent tool chains, rug pull behavioural drift,
6
+ // and multi-step credential theft.
7
+ //
8
+ // Context keys consumed:
9
+ // - agent_id, agent_trust_level
10
+ // - tool_poisoning_detected, tool_poisoning_score
11
+ // - rug_pull_detected, rug_pull_score
12
+ // - suspicious_pattern, pattern_type
13
+ //
14
+ // Compliance:
15
+ // - OWASP ASI04, OWASP MCP01/MCP03
16
+ // - MITRE ATT&CK T1552; MITRE ATLAS AML.T0049
17
+ // - NIST 800-53 SI-7
18
+ //
19
+ // Category: agent-identity
20
+ // Namespace: AgentOps
21
+ // =============================================================================
22
+
23
+ // ---------------------------------------------------------------------------
24
+ // Section 1: Tool poisoning
25
+ // ---------------------------------------------------------------------------
26
+
27
+ @id("agent-identity.a2a-block-tool-poisoning")
28
+ @name("Block tool poisoning from non-first-party agents")
29
+ @description("Blocks call_tool when agent_trust_level is not \"first_party\", tool_poisoning_detected is true, and tool_poisoning_score >= 60.")
30
+ @severity("critical")
31
+ @tags("category:agent-identity,threat:tool-poisoning,scope:per-agent,detection:ml,surface:call-tool,owasp:asi04")
32
+ @reject_message("Tool execution blocked: tool poisoning detected in content from a non-first-party agent — supply-chain risk.")
33
+ forbid (
34
+ principal is AgentOps::Agent,
35
+ action == AgentOps::Action::"call_tool",
36
+ resource
37
+ )
38
+ when {
39
+ context has agent_trust_level && context.agent_trust_level != "first_party" &&
40
+ context has tool_poisoning_detected && context.tool_poisoning_detected == true &&
41
+ context has tool_poisoning_score && context.tool_poisoning_score >= 60
42
+ };
43
+
44
+ @id("agent-identity.a2a-block-server-poisoning")
45
+ @name("Block poisoned server connections from agents")
46
+ @description("Blocks connect_server when agent_id is non-empty, tool_poisoning_detected is true, and tool_poisoning_score >= 55.")
47
+ @severity("critical")
48
+ @tags("category:agent-identity,threat:tool-poisoning,scope:per-agent,detection:ml,surface:connect-server,owasp:asi04")
49
+ @reject_message("MCP server connection blocked: tool poisoning detected from agent request — server-level poisoning affects all tools.")
50
+ forbid (
51
+ principal is AgentOps::Agent,
52
+ action == AgentOps::Action::"connect_server",
53
+ resource
54
+ )
55
+ when {
56
+ context has agent_id && context.agent_id != "" &&
57
+ context has tool_poisoning_detected && context.tool_poisoning_detected == true &&
58
+ context has tool_poisoning_score && context.tool_poisoning_score >= 55
59
+ };
60
+
61
+ // ---------------------------------------------------------------------------
62
+ // Section 2: Rug pull behavioural drift
63
+ // ---------------------------------------------------------------------------
64
+
65
+ @id("agent-identity.a2a-block-rug-pull")
66
+ @name("Block rug pull behavioural drift from agents")
67
+ @description("Blocks call_tool when agent_id is non-empty, rug_pull_detected is true, and rug_pull_score >= 70.")
68
+ @severity("critical")
69
+ @tags("category:agent-identity,threat:rug-pull,scope:per-agent,detection:ml,surface:call-tool,owasp:asi04")
70
+ @reject_message("Tool execution blocked: behavioural drift detected — tool behaviour has deviated from established patterns.")
71
+ forbid (
72
+ principal is AgentOps::Agent,
73
+ action == AgentOps::Action::"call_tool",
74
+ resource
75
+ )
76
+ when {
77
+ context has agent_id && context.agent_id != "" &&
78
+ context has rug_pull_detected && context.rug_pull_detected == true &&
79
+ context has rug_pull_score && context.rug_pull_score >= 70
80
+ };
81
+
82
+ // ---------------------------------------------------------------------------
83
+ // Section 3: Credential theft chains
84
+ // ---------------------------------------------------------------------------
85
+
86
+ @id("agent-identity.a2a-block-credential-theft")
87
+ @name("Block credential theft chains from agents")
88
+ @description("Blocks call_tool when agent_trust_level is not \"first_party\", suspicious_pattern is true, and pattern_type equals \"credential_theft\".")
89
+ @severity("critical")
90
+ @tags("category:agent-identity,threat:exfiltration,scope:per-agent,detection:rule,surface:call-tool")
91
+ @reject_message("Tool execution blocked: credential theft chain detected from a non-first-party agent — multi-step credential harvesting.")
92
+ forbid (
93
+ principal is AgentOps::Agent,
94
+ action == AgentOps::Action::"call_tool",
95
+ resource
96
+ )
97
+ when {
98
+ context has agent_trust_level && context.agent_trust_level != "first_party" &&
99
+ context has suspicious_pattern && context.suspicious_pattern == true &&
100
+ context has pattern_type && context.pattern_type == "credential_theft"
101
+ };
@@ -0,0 +1,130 @@
1
+ // =============================================================================
2
+ // Code Agent — Agentic Security
3
+ // =============================================================================
4
+ // Tool risk controls, shell execution blocking, loop detection, exfiltration
5
+ // prevention, and budget enforcement for coding assistants.
6
+ //
7
+ // Context keys consumed:
8
+ // - tool_risk_score, tool_category, tool_is_sensitive, tool_name
9
+ // - loop_detected, loop_count
10
+ // - suspicious_pattern, pattern_type
11
+ // - sequence_risk: Long (0-100)
12
+ // - budget_exceeded: Bool
13
+ //
14
+ // Compliance:
15
+ // - OWASP LLM06, OWASP ASI02, MITRE T1059
16
+ //
17
+ // Category: agent-security
18
+ // Namespace: AgentOps
19
+ // =============================================================================
20
+
21
+ @id("agent-security.code-block-dangerous-tools")
22
+ @name("Block dangerous tools (code profile)")
23
+ @description("Blocks call_tool when tool_risk_score >= 86 or tool_category equals \"dangerous\".")
24
+ @severity("critical")
25
+ @tags("category:agent-security,detection:aggregate,surface:call-tool,owasp:llm06")
26
+ @reject_message("Tool execution blocked: tool is classified as dangerous or scored high risk (code profile).")
27
+ forbid (
28
+ principal,
29
+ action == AgentOps::Action::"call_tool",
30
+ resource
31
+ )
32
+ when {
33
+ (context has tool_risk_score && context.tool_risk_score >= 86) ||
34
+ (context has tool_category && context.tool_category == "dangerous")
35
+ };
36
+
37
+ @id("agent-security.code-block-shell-execution")
38
+ @name("Block shell commands (code profile)")
39
+ @description("Blocks call_tool when tool_name is a shell tool.")
40
+ @severity("high")
41
+ @tags("category:agent-security,threat:command-injection,detection:rule,surface:call-tool,mitre:t1059")
42
+ @reject_message("Tool execution blocked: direct shell or command execution is not permitted for the code profile.")
43
+ forbid (
44
+ principal,
45
+ action == AgentOps::Action::"call_tool",
46
+ resource
47
+ )
48
+ when {
49
+ context has tool_name &&
50
+ (context.tool_name == "shell" || context.tool_name == "execute_command" || context.tool_name == "bash")
51
+ };
52
+
53
+ @id("agent-security.code-block-sensitive-tools")
54
+ @name("Block sensitive tools with elevated risk (code profile)")
55
+ @description("Blocks call_tool when tool_is_sensitive is true and tool_risk_score >= 71.")
56
+ @severity("high")
57
+ @tags("category:agent-security,detection:aggregate,surface:call-tool,owasp:llm06")
58
+ @reject_message("Tool execution blocked: sensitive tool with elevated risk (code profile).")
59
+ forbid (
60
+ principal,
61
+ action == AgentOps::Action::"call_tool",
62
+ resource
63
+ )
64
+ when {
65
+ context has tool_is_sensitive && context.tool_is_sensitive == true &&
66
+ context has tool_risk_score && context.tool_risk_score >= 71
67
+ };
68
+
69
+ @id("agent-security.code-block-loops")
70
+ @name("Block tool call loops (code profile)")
71
+ @description("Blocks call_tool when loop_detected is true and loop_count >= 6.")
72
+ @severity("high")
73
+ @tags("category:agent-security,threat:loop,detection:aggregate,surface:call-tool")
74
+ @reject_message("Tool execution blocked: infinite tool-call loop detected (code profile).")
75
+ forbid (
76
+ principal,
77
+ action == AgentOps::Action::"call_tool",
78
+ resource
79
+ )
80
+ when {
81
+ context has loop_detected && context.loop_detected == true &&
82
+ context has loop_count && context.loop_count >= 6
83
+ };
84
+
85
+ @id("agent-security.code-block-exfiltration")
86
+ @name("Block data exfiltration patterns (code profile)")
87
+ @description("Blocks call_tool when suspicious_pattern is true and pattern_type matches an exfiltration class.")
88
+ @severity("critical")
89
+ @tags("category:agent-security,threat:exfiltration,detection:rule,surface:call-tool")
90
+ @reject_message("Tool execution blocked: data exfiltration pattern detected (code profile).")
91
+ forbid (
92
+ principal,
93
+ action == AgentOps::Action::"call_tool",
94
+ resource
95
+ )
96
+ when {
97
+ context has suspicious_pattern && context.suspicious_pattern == true &&
98
+ context has pattern_type &&
99
+ (context.pattern_type == "data_exfiltration" || context.pattern_type == "secret_exfiltration")
100
+ };
101
+
102
+ @id("agent-security.code-block-sequence-risk")
103
+ @name("Block high-risk action sequences (code profile)")
104
+ @description("Blocks call_tool when sequence_risk >= 76.")
105
+ @severity("high")
106
+ @tags("category:agent-security,detection:aggregate,surface:call-tool")
107
+ @reject_message("Tool execution blocked: action sequence scored a high cumulative risk (code profile).")
108
+ forbid (
109
+ principal,
110
+ action == AgentOps::Action::"call_tool",
111
+ resource
112
+ )
113
+ when {
114
+ context has sequence_risk && context.sequence_risk >= 76
115
+ };
116
+
117
+ @id("agent-security.code-block-budget-exceeded")
118
+ @name("Block when budget exceeded (code profile)")
119
+ @description("Blocks call_tool when budget_exceeded is true.")
120
+ @severity("medium")
121
+ @tags("category:agent-security,threat:budget-violation,detection:rule,surface:call-tool")
122
+ @reject_message("Tool execution blocked: agent has exhausted its token or cost budget (code profile).")
123
+ forbid (
124
+ principal,
125
+ action == AgentOps::Action::"call_tool",
126
+ resource
127
+ )
128
+ when {
129
+ context has budget_exceeded && context.budget_exceeded == true
130
+ };
@@ -0,0 +1,116 @@
1
+ // =============================================================================
2
+ // Code Agent — Supply Chain Security
3
+ // =============================================================================
4
+ // Detects and blocks MCP server poisoning, indirect prompt injection from
5
+ // tool outputs, credential theft chains, destructive operation sequences,
6
+ // and installs of packages with known-malicious (MAL-) osv.dev advisories.
7
+ //
8
+ // Context keys consumed:
9
+ // - tool_poisoning_score: Long (0-100)
10
+ // - indirect_injection_score: Long (0-100)
11
+ // - tool_is_sensitive: Bool
12
+ // - suspicious_pattern: Bool
13
+ // - pattern_type: String
14
+ // - malicious_package_detected: Bool
15
+ //
16
+ // Compliance:
17
+ // - OWASP ASI01, ASI02, ASI04, LLM01 (indirect), MCP01–05
18
+ // - MITRE ATLAS AML.T0051, MITRE ATT&CK T1552
19
+ //
20
+ // Category: agent-security
21
+ // Namespace: AgentOps
22
+ // =============================================================================
23
+
24
+ @id("agent-security.code-block-server-poisoning")
25
+ @name("Block poisoned MCP servers (code profile)")
26
+ @description("Blocks connect_server when tool_poisoning_score >= 60.")
27
+ @severity("critical")
28
+ @tags("category:agent-security,threat:tool-poisoning,detection:ml,surface:connect-server,owasp:asi04")
29
+ @reject_message("MCP server connection blocked: tool poisoning patterns detected in server tool descriptions.")
30
+ forbid (
31
+ principal,
32
+ action == AgentOps::Action::"connect_server",
33
+ resource
34
+ )
35
+ when {
36
+ context has tool_poisoning_score && context.tool_poisoning_score >= 60
37
+ };
38
+
39
+ @id("agent-security.code-block-indirect-injection")
40
+ @name("Block indirect injection (code profile)")
41
+ @description("Blocks call_tool when indirect_injection_score >= 70.")
42
+ @severity("critical")
43
+ @tags("category:agent-security,threat:indirect-injection,detection:ml,surface:call-tool,owasp:llm01,owasp:asi01")
44
+ @reject_message("Content blocked: indirect prompt injection detected in tool output or retrieved content.")
45
+ forbid (
46
+ principal,
47
+ action == AgentOps::Action::"call_tool",
48
+ resource
49
+ )
50
+ when {
51
+ context has indirect_injection_score && context.indirect_injection_score >= 70
52
+ };
53
+
54
+ @id("agent-security.code-block-indirect-injection-sensitive")
55
+ @name("Block indirect injection on sensitive tools (code profile)")
56
+ @description("Blocks call_tool when indirect_injection_score >= 50 and tool_is_sensitive is true.")
57
+ @severity("critical")
58
+ @tags("category:agent-security,threat:indirect-injection,detection:ml,surface:call-tool,owasp:asi02")
59
+ @reject_message("Sensitive tool execution blocked: moderate indirect-injection risk detected (code profile).")
60
+ forbid (
61
+ principal,
62
+ action == AgentOps::Action::"call_tool",
63
+ resource
64
+ )
65
+ when {
66
+ context has indirect_injection_score && context.indirect_injection_score >= 50 &&
67
+ context has tool_is_sensitive && context.tool_is_sensitive == true
68
+ };
69
+
70
+ @id("agent-security.code-block-credential-theft")
71
+ @name("Block credential theft chains (code profile)")
72
+ @description("Blocks call_tool when suspicious_pattern is true and pattern_type equals \"credential_theft\".")
73
+ @severity("critical")
74
+ @tags("category:agent-security,threat:exfiltration,detection:rule,surface:call-tool,mitre:t1059")
75
+ @reject_message("Tool execution blocked: credential theft chain detected — multi-step credential harvesting pattern.")
76
+ forbid (
77
+ principal,
78
+ action == AgentOps::Action::"call_tool",
79
+ resource
80
+ )
81
+ when {
82
+ context has suspicious_pattern && context.suspicious_pattern == true &&
83
+ context has pattern_type && context.pattern_type == "credential_theft"
84
+ };
85
+
86
+ @id("agent-security.code-block-destructive-sequence")
87
+ @name("Block destructive operation sequences (code profile)")
88
+ @description("Blocks call_tool when suspicious_pattern is true and pattern_type equals \"destructive_sequence\".")
89
+ @severity("critical")
90
+ @tags("category:agent-security,detection:rule,surface:call-tool,owasp:asi02")
91
+ @reject_message("Tool execution blocked: destructive operation sequence detected — bulk deletions, config overwrites, or repo manipulation.")
92
+ forbid (
93
+ principal,
94
+ action == AgentOps::Action::"call_tool",
95
+ resource
96
+ )
97
+ when {
98
+ context has suspicious_pattern && context.suspicious_pattern == true &&
99
+ context has pattern_type && context.pattern_type == "destructive_sequence"
100
+ };
101
+
102
+ @id("agent-security.code-block-malicious-package")
103
+ @name("Block malicious package installs (code profile)")
104
+ @description("Blocks call_tool when a referenced package carries a known-malicious osv.dev (MAL-) advisory.")
105
+ @severity("critical")
106
+ @tags("category:agent-security,threat:supply-chain,detection:aggregate,surface:call-tool,owasp:llm03,owasp:asi02")
107
+ @reject_message("Package install blocked: the requested package is flagged as malicious in the osv.dev database.")
108
+ forbid (
109
+ principal,
110
+ action == AgentOps::Action::"call_tool",
111
+ resource
112
+ )
113
+ when {
114
+ context has malicious_package_detected &&
115
+ context.malicious_package_detected == true
116
+ };
@@ -0,0 +1,51 @@
1
+ // =============================================================================
2
+ // Code Agent — Encoding & Unicode Attack Protection
3
+ // =============================================================================
4
+ // Blocks invisible Unicode characters in tool arguments and file writes to
5
+ // prevent encoding-based prompt injection and persistent invisible payloads.
6
+ //
7
+ // Tool arguments and file content should be plain text — invisible characters
8
+ // (zero-width joiners, bidirectional overrides, tag characters) indicate
9
+ // payload injection or encoding evasion attempts.
10
+ //
11
+ // Ref: EchoLeak CVE-2025-32711, Rules File Backdoor (Pillar Security)
12
+ //
13
+ // Context keys consumed:
14
+ // - invisible_chars_detected: Bool
15
+ //
16
+ // Compliance:
17
+ // - OWASP LLM01 (encoding evasion), OWASP ASI01, NIST 800-53 SI-10
18
+ //
19
+ // Category: security
20
+ // Namespace: AgentOps
21
+ // =============================================================================
22
+
23
+ @id("security.code-block-invisible-tool-args")
24
+ @name("Block invisible characters in tool calls (code profile)")
25
+ @description("Blocks call_tool when invisible_chars_detected is true.")
26
+ @severity("critical")
27
+ @tags("category:security,threat:invisible-chars,threat:injection,detection:pattern,surface:call-tool,owasp:asi01")
28
+ @reject_message("Tool execution blocked: invisible Unicode characters detected in tool arguments — encoding evasion or payload injection.")
29
+ forbid (
30
+ principal,
31
+ action == AgentOps::Action::"call_tool",
32
+ resource
33
+ )
34
+ when {
35
+ context has invisible_chars_detected && context.invisible_chars_detected == true
36
+ };
37
+
38
+ @id("security.code-block-invisible-file-write")
39
+ @name("Block invisible characters in file writes (code profile)")
40
+ @description("Blocks write_file when invisible_chars_detected is true.")
41
+ @severity("high")
42
+ @tags("category:security,threat:invisible-chars,detection:pattern,surface:write-file,owasp:asi01")
43
+ @reject_message("File write blocked: invisible Unicode characters detected — persistent invisible payloads can backdoor downstream agents.")
44
+ forbid (
45
+ principal,
46
+ action == AgentOps::Action::"write_file",
47
+ resource
48
+ )
49
+ when {
50
+ context has invisible_chars_detected && context.invisible_chars_detected == true
51
+ };