@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,90 @@
1
+ // =============================================================================
2
+ // Contextual PII (Tier 2)
3
+ // =============================================================================
4
+ // Blocks the same high-sensitivity identifier groups inferred from surrounding context by the ML PII model — catches unstructured or novel PII the structural patterns miss (higher recall). Requires the pii_model detector.
5
+ //
6
+ // Sensitivity tiers and the structural (regex) / contextual (model) type
7
+ // vocabulary are defined canonically in schemas/_shared/pii_taxonomy.json and
8
+ // enforced by tools/lint-templates.
9
+ //
10
+ // Context keys consumed:
11
+ // - pii_types: Set<String> (union of structural lowercase + contextual uppercase types)
12
+ //
13
+ // Category: privacy
14
+ // Namespace: AgentOps
15
+ // =============================================================================
16
+
17
+ @id("privacy.block-pii-national-id-model")
18
+ @name("Block national ID numbers (contextual)")
19
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a national ID (SSN, passport, or driver's license).")
20
+ @severity("high")
21
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
22
+ @reject_message("Content blocked: national identifier (SSN, passport, or driver's license) patterns detected.")
23
+ forbid (
24
+ principal,
25
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool", AgentOps::Action::"read_file", AgentOps::Action::"write_file"],
26
+ resource
27
+ )
28
+ when {
29
+ context has pii_types && context.pii_types.contains("NATIONAL_ID")
30
+ };
31
+
32
+ @id("privacy.block-pii-credit-card-model")
33
+ @name("Block credit card numbers (contextual)")
34
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credit card number.")
35
+ @severity("critical")
36
+ @tags("category:privacy,threat:pii,detection:ml,compliance:pci-dss,owasp:llm06")
37
+ @reject_message("Content blocked: credit card number patterns detected.")
38
+ forbid (
39
+ principal,
40
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool", AgentOps::Action::"read_file", AgentOps::Action::"write_file"],
41
+ resource
42
+ )
43
+ when {
44
+ context has pii_types && context.pii_types.contains("CREDIT_CARD")
45
+ };
46
+
47
+ @id("privacy.block-pii-bank-account-model")
48
+ @name("Block bank account numbers (contextual)")
49
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a bank account number (IBAN, SWIFT/BIC, or routing number).")
50
+ @severity("critical")
51
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
52
+ @reject_message("Content blocked: bank account (IBAN) number patterns detected.")
53
+ forbid (
54
+ principal,
55
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool", AgentOps::Action::"read_file", AgentOps::Action::"write_file"],
56
+ resource
57
+ )
58
+ when {
59
+ context has pii_types && context.pii_types.contains("ACCOUNT_NUMBER")
60
+ };
61
+
62
+ @id("privacy.block-pii-medical-model")
63
+ @name("Block medical identifiers (contextual)")
64
+ @description("Blocks prompts, tool calls, and file reads/writes that contain medical data (record number, MBI, NPI, or blood type).")
65
+ @severity("medium")
66
+ @tags("category:privacy,threat:pii,detection:ml,compliance:hipaa,owasp:llm06")
67
+ @reject_message("Content blocked: medical record identifier patterns detected.")
68
+ forbid (
69
+ principal,
70
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool", AgentOps::Action::"read_file", AgentOps::Action::"write_file"],
71
+ resource
72
+ )
73
+ when {
74
+ context has pii_types && context.pii_types.contains("MEDICAL")
75
+ };
76
+
77
+ @id("privacy.block-pii-credential-model")
78
+ @name("Block credentials (contextual)")
79
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credential or secret (API key, token, password hash, or private key).")
80
+ @severity("critical")
81
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
82
+ @reject_message("Content blocked: credential or API key patterns detected.")
83
+ forbid (
84
+ principal,
85
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool", AgentOps::Action::"read_file", AgentOps::Action::"write_file"],
86
+ resource
87
+ )
88
+ when {
89
+ context has pii_types && context.pii_types.contains("CREDENTIAL")
90
+ };
@@ -0,0 +1,22 @@
1
+ // =============================================================================
2
+ // Default Deny All
3
+ // =============================================================================
4
+ // Org-wide baseline that blocks everything unless explicitly permitted by
5
+ // other policies. Pair with scoped permit rules (e.g. team_permissions) for
6
+ // a deny-by-default posture.
7
+ //
8
+ // Category: organization
9
+ // Namespace: AgentOps
10
+ // =============================================================================
11
+
12
+ @id("organization.deny-baseline")
13
+ @name("Block all actions (deny baseline)")
14
+ @description("Blocks all actions; pair with scoped permit rules for a deny-by-default posture.")
15
+ @severity("high")
16
+ @tags("category:organization,posture:deny-default,scope:org-wide")
17
+ @reject_message("Request blocked: this organization uses a deny-by-default baseline — only explicitly permitted actions are allowed.")
18
+ forbid (
19
+ principal,
20
+ action,
21
+ resource
22
+ );
@@ -0,0 +1,38 @@
1
+ // =============================================================================
2
+ // Project-Based Permissions (ReBAC)
3
+ // =============================================================================
4
+ // Grants IDE access based on project membership using Cedar's entity
5
+ // hierarchy. Resources (Tool, Server, FilePath, etc.) are parented under
6
+ // Project, so `resource in Project::"..."` matches all resources scoped
7
+ // to that project.
8
+ //
9
+ // Entity hierarchy required:
10
+ // Account::"acme-corp"
11
+ // ├── Project::"dev-project"
12
+ // └── Project::"support-project"
13
+ //
14
+ // Category: organization
15
+ // Namespace: AgentOps
16
+ // =============================================================================
17
+
18
+ @id("organization.allow-dev-project")
19
+ @name("Permit dev project full access")
20
+ @description("Permits all actions on resources scoped to Project::\"dev-project\".")
21
+ @severity("medium")
22
+ @tags("category:organization,scope:per-tool,posture:deny-default")
23
+ permit (
24
+ principal,
25
+ action,
26
+ resource in AgentOps::Project::"dev-project"
27
+ );
28
+
29
+ @id("organization.allow-support-project-read")
30
+ @name("Permit support project read-only access")
31
+ @description("Permits process_prompt and read_file actions on resources scoped to Project::\"support-project\".")
32
+ @severity("medium")
33
+ @tags("category:organization,scope:per-tool,posture:deny-default")
34
+ permit (
35
+ principal,
36
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"read_file"],
37
+ resource in AgentOps::Project::"support-project"
38
+ );
@@ -0,0 +1,30 @@
1
+ // =============================================================================
2
+ // Advanced Detection — Threat Severity
3
+ // =============================================================================
4
+ // Catch-all that blocks any content flagged as critical severity by any
5
+ // detector. Acts as a safety net behind all other policies.
6
+ //
7
+ // Context keys consumed:
8
+ // - highest_severity: String
9
+ //
10
+ // Compliance:
11
+ // - NIST 800-53 SI-3, SI-4
12
+ //
13
+ // Category: security
14
+ // Namespace: AgentOps
15
+ // =============================================================================
16
+
17
+ @id("security.advanced-block-critical-severity")
18
+ @name("Block critical-severity threats")
19
+ @description("Blocks process_prompt when highest_severity equals \"critical\".")
20
+ @severity("critical")
21
+ @tags("category:security,detection:aggregate,surface:process-prompt,posture:catch-all,compliance:nist-si-3")
22
+ @reject_message("Prompt blocked: a critical-severity threat was reported by at least one detector.")
23
+ forbid (
24
+ principal,
25
+ action == AgentOps::Action::"process_prompt",
26
+ resource
27
+ )
28
+ when {
29
+ context has highest_severity && context.highest_severity == "critical"
30
+ };
@@ -0,0 +1,47 @@
1
+ // =============================================================================
2
+ // Chat Assistant — Security
3
+ // =============================================================================
4
+ // Aggressive injection and jailbreak defence for customer-facing chatbots.
5
+ // Lower thresholds than the org-wide defaults — public-facing chat has the
6
+ // highest adversarial surface.
7
+ //
8
+ // Context keys consumed:
9
+ // - injection_score: Long (0-100)
10
+ // - jailbreak_score: Long (0-100)
11
+ //
12
+ // Compliance:
13
+ // - OWASP LLM01, OWASP LLM02
14
+ //
15
+ // Category: security
16
+ // Namespace: AgentOps
17
+ // =============================================================================
18
+
19
+ @id("security.chat-block-injection")
20
+ @name("Block injection (chat profile)")
21
+ @description("Blocks process_prompt and call_tool when injection_score >= 71 (lower threshold for public chat).")
22
+ @severity("high")
23
+ @tags("category:security,threat:injection,detection:ml,owasp:llm01")
24
+ @reject_message("Prompt blocked: prompt injection detected with high confidence (chat profile).")
25
+ forbid (
26
+ principal,
27
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
28
+ resource
29
+ )
30
+ when {
31
+ context has injection_score && context.injection_score >= 71
32
+ };
33
+
34
+ @id("security.chat-block-jailbreak")
35
+ @name("Block jailbreak (chat profile)")
36
+ @description("Blocks process_prompt when jailbreak_score >= 66 (lower threshold for public chat).")
37
+ @severity("high")
38
+ @tags("category:security,threat:jailbreak,detection:ml,owasp:llm02")
39
+ @reject_message("Prompt blocked: jailbreak attempt detected with high confidence (chat profile).")
40
+ forbid (
41
+ principal,
42
+ action == AgentOps::Action::"process_prompt",
43
+ resource
44
+ )
45
+ when {
46
+ context has jailbreak_score && context.jailbreak_score >= 66
47
+ };
@@ -0,0 +1,31 @@
1
+ // =============================================================================
2
+ // Data Pipeline — Security
3
+ // =============================================================================
4
+ // Aggressive injection defence for RAG inputs and data processing — these
5
+ // pipelines consume external content as trusted input and have the highest
6
+ // adversarial surface for indirect injection.
7
+ //
8
+ // Context keys consumed:
9
+ // - injection_score: Long (0-100)
10
+ //
11
+ // Compliance:
12
+ // - OWASP LLM01
13
+ //
14
+ // Category: security
15
+ // Namespace: AgentOps
16
+ // =============================================================================
17
+
18
+ @id("security.data-pipeline-block-injection")
19
+ @name("Block pipeline injection (data-pipeline profile)")
20
+ @description("Blocks process_prompt and call_tool when injection_score >= 66 (lower threshold for data pipelines).")
21
+ @severity("high")
22
+ @tags("category:security,threat:injection,detection:ml,owasp:llm01")
23
+ @reject_message("Request blocked: prompt injection detected at the data-pipeline threshold — RAG inputs are high-risk for indirect injection.")
24
+ forbid (
25
+ principal,
26
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
27
+ resource
28
+ )
29
+ when {
30
+ context has injection_score && context.injection_score >= 66
31
+ };
@@ -0,0 +1,82 @@
1
+ // =============================================================================
2
+ // Injection & Jailbreak Detection (Default)
3
+ // =============================================================================
4
+ // Blocks prompt injection and jailbreak attempts using ML classifier
5
+ // confidence scores plus an invisible-character defence for encoded
6
+ // injection payloads.
7
+ //
8
+ // Context keys consumed:
9
+ // - injection_score: Long (0-100)
10
+ // - jailbreak_score: Long (0-100)
11
+ // - invisible_chars_detected: Bool
12
+ // - invisible_chars_score: Long (0-100)
13
+ //
14
+ // Compliance:
15
+ // - OWASP LLM01, OWASP LLM02
16
+ // - MITRE ATLAS AML.T0051, AML.T0054
17
+ //
18
+ // Category: security
19
+ // Namespace: AgentOps
20
+ // =============================================================================
21
+
22
+ @id("security.block-injection-ml")
23
+ @name("Block injection (ML)")
24
+ @description("Blocks process_prompt and call_tool when injection_score >= 86.")
25
+ @severity("high")
26
+ @tags("category:security,threat:injection,detection:ml,owasp:llm01,mitre:atlas-t0051")
27
+ @reject_message("Prompt blocked: the ML classifier detected prompt injection with high confidence.")
28
+ forbid (
29
+ principal,
30
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
31
+ resource
32
+ )
33
+ when {
34
+ context has injection_score && context.injection_score >= 86
35
+ };
36
+
37
+ @id("security.block-jailbreak-ml")
38
+ @name("Block jailbreak (ML)")
39
+ @description("Blocks process_prompt when jailbreak_score >= 81.")
40
+ @severity("high")
41
+ @tags("category:security,threat:jailbreak,detection:ml,owasp:llm02,mitre:atlas-t0054")
42
+ @reject_message("Prompt blocked: the ML classifier detected a jailbreak attempt with high confidence.")
43
+ forbid (
44
+ principal,
45
+ action == AgentOps::Action::"process_prompt",
46
+ resource
47
+ )
48
+ when {
49
+ context has jailbreak_score && context.jailbreak_score >= 81
50
+ };
51
+
52
+ @id("security.block-injection-combined")
53
+ @name("Block injection + jailbreak (combined)")
54
+ @description("Blocks process_prompt when injection_score >= 61 and jailbreak_score >= 61.")
55
+ @severity("high")
56
+ @tags("category:security,threat:injection,threat:jailbreak,detection:ml")
57
+ @reject_message("Prompt blocked: moderate injection and jailbreak signals were detected together.")
58
+ forbid (
59
+ principal,
60
+ action == AgentOps::Action::"process_prompt",
61
+ resource
62
+ )
63
+ when {
64
+ context has injection_score && context has jailbreak_score &&
65
+ context.injection_score >= 61 && context.jailbreak_score >= 61
66
+ };
67
+
68
+ @id("security.block-invisible-chars")
69
+ @name("Block invisible-character injection")
70
+ @description("Blocks process_prompt when invisible_chars_detected is true and invisible_chars_score >= 51.")
71
+ @severity("high")
72
+ @tags("category:security,threat:invisible-chars,threat:injection,detection:pattern")
73
+ @reject_message("Prompt blocked: invisible Unicode characters often used for injection were detected.")
74
+ forbid (
75
+ principal,
76
+ action == AgentOps::Action::"process_prompt",
77
+ resource
78
+ )
79
+ when {
80
+ context has invisible_chars_detected && context.invisible_chars_detected == true &&
81
+ context has invisible_chars_score && context.invisible_chars_score >= 51
82
+ };
@@ -0,0 +1,72 @@
1
+ // =============================================================================
2
+ // Security Pattern Detection (Default)
3
+ // =============================================================================
4
+ // Blocks command injection, path traversal, and SQL injection using
5
+ // regex-based pattern detection from Shield's security detectors.
6
+ //
7
+ // Context keys consumed:
8
+ // - command_injection_detected: Bool
9
+ // - path_traversal_detected: Bool
10
+ // - path_traversal_severity: String
11
+ // - sql_injection_detected: Bool
12
+ // - sql_injection_score: Long (0-100)
13
+ //
14
+ // Compliance:
15
+ // - MITRE T1059 (Command Injection), T1005 (Data from Local System)
16
+ //
17
+ // Category: security
18
+ // Namespace: AgentOps
19
+ // =============================================================================
20
+
21
+ @id("security.block-command-injection")
22
+ @name("Block command injection")
23
+ @description("Blocks process_prompt and call_tool when command_injection_detected is true.")
24
+ @severity("critical")
25
+ @tags("category:security,threat:command-injection,detection:pattern,mitre:t1059")
26
+ @reject_message("Request blocked: command injection pattern detected — reverse shell, destructive command, or privilege escalation.")
27
+ forbid (
28
+ principal,
29
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
30
+ resource
31
+ )
32
+ when {
33
+ context has command_injection_detected && context.command_injection_detected == true
34
+ };
35
+
36
+ @id("security.block-path-traversal")
37
+ @name("Block path traversal")
38
+ @description("Blocks process_prompt, call_tool, read_file, and write_file when path_traversal_detected is true and severity is high or critical.")
39
+ @severity("high")
40
+ @tags("category:security,threat:path-traversal,detection:pattern,mitre:t1005")
41
+ @reject_message("Request blocked: path traversal pattern detected — sensitive system files or deep directory traversal.")
42
+ forbid (
43
+ principal,
44
+ action in [
45
+ AgentOps::Action::"process_prompt",
46
+ AgentOps::Action::"call_tool",
47
+ AgentOps::Action::"read_file",
48
+ AgentOps::Action::"write_file"
49
+ ],
50
+ resource
51
+ )
52
+ when {
53
+ context has path_traversal_detected && context.path_traversal_detected == true &&
54
+ context has path_traversal_severity &&
55
+ (context.path_traversal_severity == "critical" || context.path_traversal_severity == "high")
56
+ };
57
+
58
+ @id("security.block-sql-injection")
59
+ @name("Block SQL injection")
60
+ @description("Blocks process_prompt and call_tool when sql_injection_detected is true and sql_injection_score >= 75.")
61
+ @severity("high")
62
+ @tags("category:security,threat:sql-injection,detection:pattern")
63
+ @reject_message("Request blocked: SQL injection pattern detected — tautology, UNION attack, or destructive query.")
64
+ forbid (
65
+ principal,
66
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
67
+ resource
68
+ )
69
+ when {
70
+ context has sql_injection_detected && context.sql_injection_detected == true &&
71
+ context has sql_injection_score && context.sql_injection_score >= 75
72
+ };
@@ -0,0 +1,155 @@
1
+ // =============================================================================
2
+ // Semantic Threat Detection (Default)
3
+ // =============================================================================
4
+ // Blocks injection attacks (command, SQL, path traversal), prompt injection,
5
+ // jailbreak attempts, and encoded payloads using two detection tiers:
6
+ //
7
+ // Tier 1 — Pattern-based (always available, no external dependency)
8
+ // command_injection, sql_injection, path_traversal, detect_encoded
9
+ //
10
+ // Tier 2 — ML classifiers (require Highflame API token)
11
+ // injection_score, jailbreak_score
12
+ //
13
+ // Content-safety rules (violence, hate, sexual, etc.) live in content_safety.cedar.
14
+ //
15
+ // Context keys consumed:
16
+ // - detected_threats: Set<String>
17
+ // - injection_score: Long (0-100)
18
+ // - jailbreak_score: Long (0-100)
19
+ //
20
+ // Compliance:
21
+ // - OWASP LLM01, LLM02; OWASP ASI01, ASI02
22
+ // - MITRE ATLAS AML.T0051, AML.T0054; MITRE ATT&CK T1059, T1005
23
+ // - NIST 800-53 SI-3, SI-4
24
+ //
25
+ // Category: semantic
26
+ // Namespace: AgentOps
27
+ // =============================================================================
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // Tier 1: Pattern-based injection detection
31
+ // ---------------------------------------------------------------------------
32
+
33
+ @id("semantic.block-command-injection-tool")
34
+ @name("Block command injection in tool calls")
35
+ @description("Blocks call_tool when detected_threats contains \"command_injection\".")
36
+ @severity("critical")
37
+ @tags("category:semantic,threat:command-injection,detection:pattern,surface:call-tool,mitre:t1059,owasp:asi02")
38
+ @reject_message("Tool execution blocked: command injection pattern detected — reverse shell, destructive command, or privilege escalation.")
39
+ forbid (
40
+ principal,
41
+ action == AgentOps::Action::"call_tool",
42
+ resource
43
+ )
44
+ when {
45
+ context has detected_threats && context.detected_threats.contains("command_injection")
46
+ };
47
+
48
+ @id("semantic.block-command-injection-prompt")
49
+ @name("Block command injection in prompts")
50
+ @description("Blocks process_prompt when detected_threats contains \"command_injection\".")
51
+ @severity("critical")
52
+ @tags("category:semantic,threat:command-injection,detection:pattern,surface:process-prompt,mitre:t1059")
53
+ @reject_message("Prompt blocked: command injection pattern detected.")
54
+ forbid (
55
+ principal,
56
+ action == AgentOps::Action::"process_prompt",
57
+ resource
58
+ )
59
+ when {
60
+ context has detected_threats && context.detected_threats.contains("command_injection")
61
+ };
62
+
63
+ @id("semantic.block-sql-injection-tool")
64
+ @name("Block SQL injection in tool calls")
65
+ @description("Blocks call_tool when detected_threats contains \"sql_injection\".")
66
+ @severity("high")
67
+ @tags("category:semantic,threat:sql-injection,detection:pattern,surface:call-tool")
68
+ @reject_message("Tool execution blocked: SQL injection pattern detected — tautology, UNION attack, or destructive query.")
69
+ forbid (
70
+ principal,
71
+ action == AgentOps::Action::"call_tool",
72
+ resource
73
+ )
74
+ when {
75
+ context has detected_threats && context.detected_threats.contains("sql_injection")
76
+ };
77
+
78
+ @id("semantic.block-sql-injection-prompt")
79
+ @name("Block SQL injection in prompts")
80
+ @description("Blocks process_prompt when detected_threats contains \"sql_injection\".")
81
+ @severity("high")
82
+ @tags("category:semantic,threat:sql-injection,detection:pattern,surface:process-prompt")
83
+ @reject_message("Prompt blocked: SQL injection pattern detected.")
84
+ forbid (
85
+ principal,
86
+ action == AgentOps::Action::"process_prompt",
87
+ resource
88
+ )
89
+ when {
90
+ context has detected_threats && context.detected_threats.contains("sql_injection")
91
+ };
92
+
93
+ @id("semantic.block-path-traversal")
94
+ @name("Block path traversal")
95
+ @description("Blocks call_tool, read_file, and write_file when detected_threats contains \"path_traversal\".")
96
+ @severity("high")
97
+ @tags("category:semantic,threat:path-traversal,detection:pattern,mitre:t1005")
98
+ @reject_message("Request blocked: path traversal pattern detected — sensitive system files or deep directory traversal.")
99
+ forbid (
100
+ principal,
101
+ action in [AgentOps::Action::"call_tool", AgentOps::Action::"read_file", AgentOps::Action::"write_file"],
102
+ resource
103
+ )
104
+ when {
105
+ context has detected_threats && context.detected_threats.contains("path_traversal")
106
+ };
107
+
108
+ @id("semantic.block-encoded")
109
+ @name("Block encoded payloads in tool calls")
110
+ @description("Blocks call_tool when detected_threats contains \"detect_encoded\".")
111
+ @severity("medium")
112
+ @tags("category:semantic,threat:encoded-payload,detection:pattern,surface:call-tool")
113
+ @reject_message("Tool execution blocked: encoded or obfuscated payload detected (base64 or hash IOCs in tool arguments).")
114
+ forbid (
115
+ principal,
116
+ action == AgentOps::Action::"call_tool",
117
+ resource
118
+ )
119
+ when {
120
+ context has detected_threats && context.detected_threats.contains("detect_encoded")
121
+ };
122
+
123
+ // ---------------------------------------------------------------------------
124
+ // Tier 2: ML classifier detection
125
+ // ---------------------------------------------------------------------------
126
+
127
+ @id("semantic.block-injection-ml")
128
+ @name("Block injection (ML)")
129
+ @description("Blocks process_prompt and call_tool when injection_score >= 75.")
130
+ @severity("critical")
131
+ @tags("category:semantic,threat:injection,detection:ml,owasp:llm01,mitre:atlas-t0051")
132
+ @reject_message("Request blocked: prompt injection detected by ML classifier with high confidence.")
133
+ forbid (
134
+ principal,
135
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
136
+ resource
137
+ )
138
+ when {
139
+ context has injection_score && context.injection_score >= 75
140
+ };
141
+
142
+ @id("semantic.block-jailbreak-ml")
143
+ @name("Block jailbreak (ML)")
144
+ @description("Blocks process_prompt and call_tool when jailbreak_score >= 75.")
145
+ @severity("critical")
146
+ @tags("category:semantic,threat:jailbreak,detection:ml,owasp:llm02,mitre:atlas-t0054")
147
+ @reject_message("Request blocked: jailbreak attempt detected by ML classifier with high confidence.")
148
+ forbid (
149
+ principal,
150
+ action in [AgentOps::Action::"process_prompt", AgentOps::Action::"call_tool"],
151
+ resource
152
+ )
153
+ when {
154
+ context has jailbreak_score && context.jailbreak_score >= 75
155
+ };