@highflame/policy 2.1.5 → 2.1.7

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 (29) hide show
  1. package/_schemas/guardrails/context.json +168 -0
  2. package/_schemas/guardrails/schema.cedarschema +40 -0
  3. package/_schemas/guardrails/templates/defaults/agent_identity.cedar +118 -0
  4. package/_schemas/guardrails/templates/defaults/agentic_safety.cedar +4 -4
  5. package/_schemas/guardrails/templates/defaults/injection.cedar +4 -4
  6. package/_schemas/guardrails/templates/defaults/secrets.cedar +2 -2
  7. package/_schemas/guardrails/templates/defaults/security_patterns.cedar +1 -1
  8. package/_schemas/guardrails/templates/defaults/semantic.cedar +10 -7
  9. package/_schemas/guardrails/templates/defaults/toxicity.cedar +3 -3
  10. package/_schemas/guardrails/templates/mcp_tool_permissions.cedar +7 -5
  11. package/_schemas/guardrails/templates/profiles/chat_assistant/privacy.cedar +1 -1
  12. package/_schemas/guardrails/templates/profiles/chat_assistant/security.cedar +2 -2
  13. package/_schemas/guardrails/templates/profiles/chat_assistant/trust_safety.cedar +2 -2
  14. package/_schemas/guardrails/templates/profiles/code_agent/agentic_security.cedar +3 -3
  15. package/_schemas/guardrails/templates/profiles/data_pipeline/agentic_security.cedar +1 -1
  16. package/_schemas/guardrails/templates/profiles/data_pipeline/privacy.cedar +2 -2
  17. package/_schemas/guardrails/templates/profiles/data_pipeline/security.cedar +2 -2
  18. package/_schemas/guardrails/templates/profiles/multi_agent/agent_safety.cedar +157 -0
  19. package/_schemas/guardrails/templates/profiles/multi_agent/agent_trust.cedar +140 -0
  20. package/_schemas/guardrails/templates/templates.json +40 -0
  21. package/dist/engine.d.ts +1 -1
  22. package/dist/engine.js +1 -1
  23. package/dist/guardrails-context.gen.d.ts +5 -0
  24. package/dist/guardrails-context.gen.js +5 -0
  25. package/dist/guardrails-defaults.gen.d.ts +1 -1
  26. package/dist/guardrails-defaults.gen.js +520 -32
  27. package/dist/service-schemas.gen.d.ts +1 -1
  28. package/dist/service-schemas.gen.js +73 -5
  29. package/package.json +1 -1
@@ -54,7 +54,7 @@ const GUARDRAILS_SECRETS_DEFAULT_CEDAR = `// ===================================
54
54
  @tags("secrets,security,data-leak")
55
55
  forbid (
56
56
  principal,
57
- action,
57
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
58
58
  resource
59
59
  ) when {
60
60
  context has contains_secrets && context.contains_secrets == true
@@ -67,7 +67,7 @@ forbid (
67
67
  @tags("secrets,security,data-leak")
68
68
  forbid (
69
69
  principal,
70
- action,
70
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
71
71
  resource
72
72
  ) when {
73
73
  context has secret_count && context.secret_count > 2
@@ -97,7 +97,7 @@ const GUARDRAILS_INJECTION_DEFAULT_CEDAR = `// =================================
97
97
  @tags("injection,jailbreak,security")
98
98
  forbid (
99
99
  principal,
100
- action,
100
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool"],
101
101
  resource
102
102
  ) when {
103
103
  context has injection_confidence && context.injection_confidence > 85
@@ -110,7 +110,7 @@ forbid (
110
110
  @tags("jailbreak,security")
111
111
  forbid (
112
112
  principal,
113
- action,
113
+ action == Guardrails::Action::"process_prompt",
114
114
  resource
115
115
  ) when {
116
116
  context has jailbreak_confidence && context.jailbreak_confidence > 80
@@ -123,7 +123,7 @@ forbid (
123
123
  @tags("injection,jailbreak,security")
124
124
  forbid (
125
125
  principal,
126
- action,
126
+ action == Guardrails::Action::"process_prompt",
127
127
  resource
128
128
  ) when {
129
129
  context has injection_confidence && context has jailbreak_confidence &&
@@ -137,7 +137,7 @@ forbid (
137
137
  @tags("injection,unicode,security")
138
138
  forbid (
139
139
  principal,
140
- action,
140
+ action == Guardrails::Action::"process_prompt",
141
141
  resource
142
142
  ) when {
143
143
  context has contains_invisible_chars && context.contains_invisible_chars == true &&
@@ -218,7 +218,7 @@ const GUARDRAILS_TOXICITY_DEFAULT_CEDAR = `// ==================================
218
218
  @tags("toxicity,trust-safety")
219
219
  forbid (
220
220
  principal,
221
- action,
221
+ action == Guardrails::Action::"process_prompt",
222
222
  resource
223
223
  ) when {
224
224
  (context has violence_score && context.violence_score > 90) ||
@@ -236,7 +236,7 @@ forbid (
236
236
  @tags("hate-speech,trust-safety")
237
237
  forbid (
238
238
  principal,
239
- action,
239
+ action == Guardrails::Action::"process_prompt",
240
240
  resource
241
241
  ) when {
242
242
  context has hate_speech_score && context.hate_speech_score > 75
@@ -249,7 +249,7 @@ forbid (
249
249
  @tags("toxicity,trust-safety")
250
250
  forbid (
251
251
  principal,
252
- action,
252
+ action == Guardrails::Action::"process_prompt",
253
253
  resource
254
254
  ) when {
255
255
  // Any 2 of 6 toxicity scores above 60 triggers a block
@@ -371,7 +371,7 @@ forbid (
371
371
  @tags("agentic,exfiltration,security")
372
372
  forbid (
373
373
  principal,
374
- action,
374
+ action == Guardrails::Action::"call_tool",
375
375
  resource
376
376
  ) when {
377
377
  context has suspicious_pattern && context.suspicious_pattern == true &&
@@ -390,7 +390,7 @@ forbid (
390
390
  @tags("agentic,patterns,security")
391
391
  forbid (
392
392
  principal,
393
- action,
393
+ action == Guardrails::Action::"call_tool",
394
394
  resource
395
395
  ) when {
396
396
  context has sequence_risk && context.sequence_risk > 80
@@ -403,7 +403,7 @@ forbid (
403
403
  @tags("agentic,budget,cost-control")
404
404
  forbid (
405
405
  principal,
406
- action,
406
+ action == Guardrails::Action::"call_tool",
407
407
  resource
408
408
  ) when {
409
409
  context has budget_exceeded && context.budget_exceeded == true
@@ -416,7 +416,7 @@ forbid (
416
416
  @tags("agentic,budget,cost-control")
417
417
  forbid (
418
418
  principal,
419
- action,
419
+ action == Guardrails::Action::"call_tool",
420
420
  resource
421
421
  ) when {
422
422
  context has budget_remaining_pct &&
@@ -507,7 +507,7 @@ forbid (
507
507
  @tags("path-traversal,security")
508
508
  forbid (
509
509
  principal,
510
- action,
510
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
511
511
  resource
512
512
  ) when {
513
513
  context has path_traversal_detected && context.path_traversal_detected == true &&
@@ -529,6 +529,125 @@ forbid (
529
529
  context has sql_injection_score && context.sql_injection_score >= 75
530
530
  };
531
531
  `;
532
+ const GUARDRAILS_AGENT_IDENTITY_TRUST_CEDAR = `// =============================================================================
533
+ // Agent Identity Policy — Agent-to-Agent Security Defaults
534
+ // =============================================================================
535
+ // Enforces trust-based access control for AI agents authenticated via API key
536
+ // or JWT with agent claims. These policies use agent identity context keys
537
+ // populated from Shield's authentication layer.
538
+ //
539
+ // Agent trust levels:
540
+ // - first_party: Your own agents (highest trust)
541
+ // - verified_third_party: Audited external agents (medium trust)
542
+ // - unverified: Unknown/untrusted agents (lowest trust)
543
+ //
544
+ // Agent types:
545
+ // - orchestrator: Coordinates sub-agents
546
+ // - autonomous: Self-directed, no human in the loop
547
+ // - tool_agent: Single-purpose tool execution
548
+ // - human_proxy: Acts on behalf of a human
549
+ //
550
+ // Context keys used:
551
+ // - agent_id: String - Unique agent identifier
552
+ // - agent_type: String - Agent classification
553
+ // - agent_trust_level: String - Trust tier
554
+ // - agent_framework: String - Agent framework/SDK
555
+ // - agent_publisher: String - Publishing organization
556
+ // - tool_name: String - Tool being called
557
+ // - tool_category: String - "safe" | "sensitive" | "dangerous"
558
+ // - tool_risk_score: Long (0-100) - Computed risk score
559
+ // - injection_confidence: Long (0-100) - Injection detection score
560
+ //
561
+ // Category: agent_identity
562
+ // Namespace: Guardrails
563
+ // =============================================================================
564
+
565
+ // -----------------------------------------------------------------------------
566
+ // Trust-Based Tool Access
567
+ // -----------------------------------------------------------------------------
568
+
569
+ @id("agent-block-unverified-dangerous-tools")
570
+ @name("Block unverified agents from dangerous tools")
571
+ @description("Unverified agents cannot execute tools classified as dangerous. Require first_party or verified_third_party trust level for high-risk operations")
572
+ @severity("critical")
573
+ @tags("agent-identity,trust,tools,a2a")
574
+ forbid (
575
+ principal is Guardrails::Agent,
576
+ action == Guardrails::Action::"call_tool",
577
+ resource
578
+ ) when {
579
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
580
+ context has tool_category && context.tool_category == "dangerous"
581
+ };
582
+
583
+ @id("agent-block-unverified-shell")
584
+ @name("Block unverified agents from shell execution")
585
+ @description("Shell and command execution are restricted to first_party and verified_third_party agents")
586
+ @severity("critical")
587
+ @tags("agent-identity,trust,shell,a2a")
588
+ forbid (
589
+ principal is Guardrails::Agent,
590
+ action == Guardrails::Action::"call_tool",
591
+ resource
592
+ ) when {
593
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
594
+ context has tool_name &&
595
+ (context.tool_name == "shell" ||
596
+ context.tool_name == "execute_command" ||
597
+ context.tool_name == "bash")
598
+ };
599
+
600
+ @id("agent-block-unverified-sensitive-tools")
601
+ @name("Block unverified agents from sensitive tools with elevated risk")
602
+ @description("Unverified agents cannot execute sensitive tools with risk score above 60")
603
+ @severity("high")
604
+ @tags("agent-identity,trust,tools,a2a")
605
+ forbid (
606
+ principal is Guardrails::Agent,
607
+ action == Guardrails::Action::"call_tool",
608
+ resource
609
+ ) when {
610
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
611
+ context has tool_is_sensitive && context.tool_is_sensitive == true &&
612
+ context has tool_risk_score && context.tool_risk_score > 60
613
+ };
614
+
615
+ // -----------------------------------------------------------------------------
616
+ // Autonomous Agent Restrictions
617
+ // -----------------------------------------------------------------------------
618
+
619
+ @id("agent-block-autonomous-injection")
620
+ @name("Stricter injection threshold for autonomous agents")
621
+ @description("Autonomous agents operate without human oversight. Apply lower injection confidence threshold (50 vs standard 80) to compensate for lack of human review")
622
+ @severity("high")
623
+ @tags("agent-identity,autonomous,injection,a2a")
624
+ forbid (
625
+ principal is Guardrails::Agent,
626
+ action == Guardrails::Action::"process_prompt",
627
+ resource
628
+ ) when {
629
+ context has agent_type && context.agent_type == "autonomous" &&
630
+ context has injection_confidence && context.injection_confidence > 50
631
+ };
632
+
633
+ // -----------------------------------------------------------------------------
634
+ // Cross-Turn Agent Trust Enforcement
635
+ // -----------------------------------------------------------------------------
636
+
637
+ @id("agent-block-unverified-after-threats")
638
+ @name("Block unverified agents after session threats")
639
+ @description("If any prior turn in the session detected threats, block unverified agents from further tool calls. Prevents compromised sessions from being exploited by untrusted agents")
640
+ @severity("critical")
641
+ @tags("agent-identity,trust,session,cross-turn,a2a")
642
+ forbid (
643
+ principal is Guardrails::Agent,
644
+ action == Guardrails::Action::"call_tool",
645
+ resource
646
+ ) when {
647
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
648
+ context has session_threat_turns && context.session_threat_turns > 0
649
+ };
650
+ `;
532
651
  const GUARDRAILS_MCP_TOOL_PERMISSIONS_CEDAR = `// =============================================================================
533
652
  // MCP Tool Permissions Template
534
653
  // =============================================================================
@@ -559,7 +678,8 @@ permit (
559
678
  action == Guardrails::Action::"call_tool",
560
679
  resource
561
680
  ) when {
562
- context.mcp_server == "github" &&
681
+ context has mcp_server && context.mcp_server == "github" &&
682
+ context has tool_name &&
563
683
  (context.tool_name == "read_issues" ||
564
684
  context.tool_name == "get_issue" ||
565
685
  context.tool_name == "list_repos" ||
@@ -578,7 +698,7 @@ forbid (
578
698
  action == Guardrails::Action::"call_tool",
579
699
  resource
580
700
  ) when {
581
- context.mcp_server == "github"
701
+ context has mcp_server && context.mcp_server == "github"
582
702
  };
583
703
 
584
704
  // -- Organization-wide MCP server exclusions --------------------------------
@@ -595,8 +715,9 @@ forbid (
595
715
  ) when {
596
716
  // Add server names to block across the organization.
597
717
  // Modify this list to match your exclusion requirements.
598
- context.mcp_server == "untrusted-server" ||
599
- context.mcp_server == "deprecated-server"
718
+ context has mcp_server &&
719
+ (context.mcp_server == "untrusted-server" ||
720
+ context.mcp_server == "deprecated-server")
600
721
  };
601
722
 
602
723
  // -- Block unverified MCP servers -------------------------------------------
@@ -611,7 +732,7 @@ forbid (
611
732
  action == Guardrails::Action::"call_tool",
612
733
  resource
613
734
  ) when {
614
- context.mcp_server_verified == false
735
+ context has mcp_server_verified && context.mcp_server_verified == false
615
736
  };
616
737
  `;
617
738
  const GUARDRAILS_CHAT_ASSISTANT_SECURITY_CEDAR = `// =============================================================================
@@ -631,7 +752,7 @@ const GUARDRAILS_CHAT_ASSISTANT_SECURITY_CEDAR = `// ===========================
631
752
  @tags("profile,chat-assistant,injection,security")
632
753
  forbid (
633
754
  principal,
634
- action,
755
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool"],
635
756
  resource
636
757
  ) when {
637
758
  context has injection_confidence && context.injection_confidence > 70
@@ -644,7 +765,7 @@ forbid (
644
765
  @tags("profile,chat-assistant,jailbreak,security")
645
766
  forbid (
646
767
  principal,
647
- action,
768
+ action == Guardrails::Action::"process_prompt",
648
769
  resource
649
770
  ) when {
650
771
  context has jailbreak_confidence && context.jailbreak_confidence > 65
@@ -667,7 +788,7 @@ const GUARDRAILS_CHAT_ASSISTANT_PRIVACY_CEDAR = `// ============================
667
788
  @tags("profile,chat-assistant,pii,privacy")
668
789
  forbid (
669
790
  principal,
670
- action,
791
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
671
792
  resource
672
793
  ) when {
673
794
  context has pii_detected && context.pii_detected == true
@@ -690,7 +811,7 @@ const GUARDRAILS_CHAT_ASSISTANT_TRUST_SAFETY_CEDAR = `// =======================
690
811
  @tags("profile,chat-assistant,toxicity,trust-safety")
691
812
  forbid (
692
813
  principal,
693
- action,
814
+ action == Guardrails::Action::"process_prompt",
694
815
  resource
695
816
  ) when {
696
817
  (context has violence_score && context.violence_score > 70) ||
@@ -706,7 +827,7 @@ forbid (
706
827
  @tags("profile,chat-assistant,semantic,compliance")
707
828
  forbid (
708
829
  principal,
709
- action,
830
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool"],
710
831
  resource
711
832
  ) when {
712
833
  context has topic_confidence && context.topic_confidence > 70 &&
@@ -792,7 +913,7 @@ forbid (
792
913
  @tags("profile,code-agent,agentic,exfiltration")
793
914
  forbid (
794
915
  principal,
795
- action,
916
+ action == Guardrails::Action::"call_tool",
796
917
  resource
797
918
  ) when {
798
919
  context has suspicious_pattern && context.suspicious_pattern == true &&
@@ -808,7 +929,7 @@ forbid (
808
929
  @tags("profile,code-agent,agentic,patterns")
809
930
  forbid (
810
931
  principal,
811
- action,
932
+ action == Guardrails::Action::"call_tool",
812
933
  resource
813
934
  ) when {
814
935
  context has sequence_risk && context.sequence_risk > 75
@@ -821,7 +942,7 @@ forbid (
821
942
  @tags("profile,code-agent,budget,cost-control")
822
943
  forbid (
823
944
  principal,
824
- action,
945
+ action == Guardrails::Action::"call_tool",
825
946
  resource
826
947
  ) when {
827
948
  context has budget_exceeded && context.budget_exceeded == true
@@ -867,7 +988,7 @@ const GUARDRAILS_DATA_PIPELINE_PRIVACY_CEDAR = `// =============================
867
988
  @tags("profile,data-pipeline,pii,privacy")
868
989
  forbid (
869
990
  principal,
870
- action,
991
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
871
992
  resource
872
993
  ) when {
873
994
  context has pii_detected && context.pii_detected == true
@@ -880,7 +1001,7 @@ forbid (
880
1001
  @tags("profile,data-pipeline,pii,compliance")
881
1002
  forbid (
882
1003
  principal,
883
- action,
1004
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
884
1005
  resource
885
1006
  ) when {
886
1007
  context has pii_types &&
@@ -908,7 +1029,7 @@ const GUARDRAILS_DATA_PIPELINE_SECURITY_CEDAR = `// ============================
908
1029
  @tags("profile,data-pipeline,secrets,security")
909
1030
  forbid (
910
1031
  principal,
911
- action,
1032
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
912
1033
  resource
913
1034
  ) when {
914
1035
  context has contains_secrets && context.contains_secrets == true
@@ -935,7 +1056,7 @@ forbid (
935
1056
  @tags("profile,data-pipeline,injection,security")
936
1057
  forbid (
937
1058
  principal,
938
- action,
1059
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool"],
939
1060
  resource
940
1061
  ) when {
941
1062
  context has injection_confidence && context.injection_confidence > 65
@@ -958,7 +1079,7 @@ const GUARDRAILS_DATA_PIPELINE_AGENTIC_SECURITY_CEDAR = `// ====================
958
1079
  @tags("profile,data-pipeline,exfiltration,security")
959
1080
  forbid (
960
1081
  principal,
961
- action,
1082
+ action == Guardrails::Action::"call_tool",
962
1083
  resource
963
1084
  ) when {
964
1085
  context has suspicious_pattern && context.suspicious_pattern == true &&
@@ -980,6 +1101,305 @@ forbid (
980
1101
  context has tool_risk_score && context.tool_risk_score > 60
981
1102
  };
982
1103
  `;
1104
+ const GUARDRAILS_MULTI_AGENT_TRUST_CEDAR = `// =============================================================================
1105
+ // Multi-Agent Orchestration — Agent Trust Policies
1106
+ // =============================================================================
1107
+ // Production-grade trust policies for multi-agent systems where an orchestrator
1108
+ // coordinates sub-agents with varying trust levels. These policies enforce
1109
+ // least-privilege access: each agent gets only the permissions its trust level
1110
+ // and type warrant.
1111
+ //
1112
+ // Architecture supported:
1113
+ // Orchestrator (first_party)
1114
+ // ├── Research Agent (verified_third_party, autonomous)
1115
+ // ├── Code Agent (first_party, tool_agent)
1116
+ // └── External Plugin (unverified, tool_agent)
1117
+ //
1118
+ // Context keys used:
1119
+ // - agent_id: String - Unique agent identifier
1120
+ // - agent_type: String - orchestrator | autonomous | tool_agent | human_proxy
1121
+ // - agent_trust_level: String - first_party | verified_third_party | unverified
1122
+ // - agent_framework: String - Agent framework/SDK
1123
+ // - agent_publisher: String - Publishing organization
1124
+ // - tool_name: String - Tool being called
1125
+ // - tool_category: String - safe | sensitive | dangerous
1126
+ // - tool_risk_score: Long (0-100) - Computed risk score
1127
+ // - tool_is_sensitive: Bool - Whether tool is sensitive
1128
+ // - mcp_server_verified: Bool - Whether MCP server is verified
1129
+ // - injection_confidence: Long (0-100) - Injection detection score
1130
+ // - jailbreak_confidence: Long (0-100) - Jailbreak detection score
1131
+ //
1132
+ // Category: agent_identity
1133
+ // Namespace: Guardrails
1134
+ // =============================================================================
1135
+
1136
+ // -----------------------------------------------------------------------------
1137
+ // Tiered Tool Access — The Core A2A Trust Model
1138
+ // -----------------------------------------------------------------------------
1139
+
1140
+ @id("multi-agent-only-first-party-dangerous")
1141
+ @name("Only first-party agents can use dangerous tools")
1142
+ @description("Dangerous tools (shell, delete_file, run_sql) are restricted to first-party agents only. Third-party and unverified agents are blocked regardless of other signals")
1143
+ @severity("critical")
1144
+ @tags("profile,multi-agent,trust,tools,a2a")
1145
+ forbid (
1146
+ principal is Guardrails::Agent,
1147
+ action == Guardrails::Action::"call_tool",
1148
+ resource
1149
+ ) when {
1150
+ context has agent_trust_level && context.agent_trust_level != "first_party" &&
1151
+ context has tool_category && context.tool_category == "dangerous"
1152
+ };
1153
+
1154
+ @id("multi-agent-block-unverified-sensitive")
1155
+ @name("Block unverified agents from all sensitive tools")
1156
+ @description("Unverified agents can only use tools classified as safe. Sensitive tools (write_file, http_post, send_email) require at least verified_third_party trust")
1157
+ @severity("high")
1158
+ @tags("profile,multi-agent,trust,tools,a2a")
1159
+ forbid (
1160
+ principal is Guardrails::Agent,
1161
+ action == Guardrails::Action::"call_tool",
1162
+ resource
1163
+ ) when {
1164
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
1165
+ context has tool_is_sensitive && context.tool_is_sensitive == true
1166
+ };
1167
+
1168
+ @id("multi-agent-block-unverified-mcp")
1169
+ @name("Block unverified agents from unverified MCP servers")
1170
+ @description("Unverified agents cannot call tools from unverified MCP servers. Double-unverified (agent + server) presents unacceptable supply chain risk")
1171
+ @severity("critical")
1172
+ @tags("profile,multi-agent,trust,mcp,a2a")
1173
+ forbid (
1174
+ principal is Guardrails::Agent,
1175
+ action == Guardrails::Action::"call_tool",
1176
+ resource
1177
+ ) when {
1178
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
1179
+ context has mcp_server_verified && context.mcp_server_verified == false
1180
+ };
1181
+
1182
+ // -----------------------------------------------------------------------------
1183
+ // Autonomous Agent Safeguards
1184
+ // -----------------------------------------------------------------------------
1185
+
1186
+ @id("multi-agent-autonomous-tool-risk-cap")
1187
+ @name("Cap tool risk for autonomous agents")
1188
+ @description("Autonomous agents (no human in the loop) have a lower tool risk ceiling. Tools with risk > 70 require human oversight that autonomous agents lack")
1189
+ @severity("high")
1190
+ @tags("profile,multi-agent,autonomous,tools,a2a")
1191
+ forbid (
1192
+ principal is Guardrails::Agent,
1193
+ action == Guardrails::Action::"call_tool",
1194
+ resource
1195
+ ) when {
1196
+ context has agent_type && context.agent_type == "autonomous" &&
1197
+ context has tool_risk_score && context.tool_risk_score > 70
1198
+ };
1199
+
1200
+ @id("multi-agent-autonomous-injection-defense")
1201
+ @name("Enhanced injection defense for autonomous agents")
1202
+ @description("Autonomous agents are high-value targets for injection. Lower the threshold to 50 (vs 80 standard) since there is no human to catch false negatives")
1203
+ @severity("high")
1204
+ @tags("profile,multi-agent,autonomous,injection,a2a")
1205
+ forbid (
1206
+ principal is Guardrails::Agent,
1207
+ action == Guardrails::Action::"process_prompt",
1208
+ resource
1209
+ ) when {
1210
+ context has agent_type && context.agent_type == "autonomous" &&
1211
+ context has injection_confidence && context.injection_confidence > 50
1212
+ };
1213
+
1214
+ @id("multi-agent-autonomous-jailbreak-defense")
1215
+ @name("Enhanced jailbreak defense for autonomous agents")
1216
+ @description("Lower jailbreak threshold for autonomous agents. Without human review, we must be more conservative")
1217
+ @severity("high")
1218
+ @tags("profile,multi-agent,autonomous,jailbreak,a2a")
1219
+ forbid (
1220
+ principal is Guardrails::Agent,
1221
+ action == Guardrails::Action::"process_prompt",
1222
+ resource
1223
+ ) when {
1224
+ context has agent_type && context.agent_type == "autonomous" &&
1225
+ context has jailbreak_confidence && context.jailbreak_confidence > 50
1226
+ };
1227
+
1228
+ // -----------------------------------------------------------------------------
1229
+ // MCP Server Connection Trust
1230
+ // -----------------------------------------------------------------------------
1231
+
1232
+ @id("multi-agent-block-unverified-server-connect")
1233
+ @name("Block unverified agents from connecting to MCP servers")
1234
+ @description("Unverified agents cannot establish new MCP server connections. Limits blast radius of compromised or rogue agents")
1235
+ @severity("high")
1236
+ @tags("profile,multi-agent,trust,mcp,connect,a2a")
1237
+ forbid (
1238
+ principal is Guardrails::Agent,
1239
+ action == Guardrails::Action::"connect_server",
1240
+ resource
1241
+ ) when {
1242
+ context has agent_trust_level && context.agent_trust_level == "unverified"
1243
+ };
1244
+ `;
1245
+ const GUARDRAILS_MULTI_AGENT_SAFETY_CEDAR = `// =============================================================================
1246
+ // Multi-Agent Orchestration — Cross-Turn Agent Safety
1247
+ // =============================================================================
1248
+ // Session-aware policies that use cross-turn detection history combined with
1249
+ // agent identity for defense-in-depth. These policies handle the scenario
1250
+ // where one agent in a multi-agent session detects a threat, and subsequent
1251
+ // agents in the same session must be restricted accordingly.
1252
+ //
1253
+ // Key insight: In multi-agent orchestration, Agent A may detect PII in turn 3,
1254
+ // and Agent B (a different agent) arrives in turn 5 wanting to call http_post.
1255
+ // Cross-turn session flags + agent trust level enable this policy:
1256
+ // "If PII was seen AND this agent is unverified → block network tools."
1257
+ //
1258
+ // Context keys used:
1259
+ // - agent_trust_level: String - Trust tier of the current agent
1260
+ // - agent_type: String - Agent classification
1261
+ // - session_pii_detected: Bool - PII seen in any prior turn
1262
+ // - session_pii_types: Set<String> - PII types accumulated
1263
+ // - session_secrets_detected: Bool - Secrets seen in any prior turn
1264
+ // - session_injection_detected: Bool - Injection seen in any prior turn
1265
+ // - session_command_injection: Bool - Command injection in any prior turn
1266
+ // - session_threat_turns: Long - Count of turns with threats
1267
+ // - session_cumulative_risk_score: Long - Total accumulated risk
1268
+ // - tool_name: String - Tool being called
1269
+ // - tool_is_sensitive: Bool - Whether tool is sensitive
1270
+ // - suspicious_pattern: Bool - Whether exfiltration pattern detected
1271
+ //
1272
+ // Category: agent_identity
1273
+ // Namespace: Guardrails
1274
+ // =============================================================================
1275
+
1276
+ // -----------------------------------------------------------------------------
1277
+ // PII Containment — Prevent Agent Data Leakage
1278
+ // -----------------------------------------------------------------------------
1279
+
1280
+ @id("multi-agent-pii-block-network-tools")
1281
+ @name("Block network tools after PII detection for non-first-party agents")
1282
+ @description("If PII was detected in any prior turn, block non-first-party agents from calling network-facing tools. Prevents data exfiltration by untrusted agents in sessions containing sensitive data")
1283
+ @severity("critical")
1284
+ @tags("profile,multi-agent,pii,exfiltration,cross-turn,a2a")
1285
+ forbid (
1286
+ principal is Guardrails::Agent,
1287
+ action == Guardrails::Action::"call_tool",
1288
+ resource
1289
+ ) when {
1290
+ context has agent_trust_level && context.agent_trust_level != "first_party" &&
1291
+ context has session_pii_detected && context.session_pii_detected == true &&
1292
+ context has tool_name &&
1293
+ (context.tool_name == "http_post" ||
1294
+ context.tool_name == "send_email" ||
1295
+ context.tool_name == "http_request" ||
1296
+ context.tool_name == "webhook")
1297
+ };
1298
+
1299
+ @id("multi-agent-pii-block-unverified-file-write")
1300
+ @name("Block unverified agents from writing files after PII detection")
1301
+ @description("If PII was detected in the session, unverified agents cannot write files. Prevents PII persistence by untrusted agents")
1302
+ @severity("high")
1303
+ @tags("profile,multi-agent,pii,file-write,cross-turn,a2a")
1304
+ forbid (
1305
+ principal is Guardrails::Agent,
1306
+ action == Guardrails::Action::"write_file",
1307
+ resource
1308
+ ) when {
1309
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
1310
+ context has session_pii_detected && context.session_pii_detected == true
1311
+ };
1312
+
1313
+ // -----------------------------------------------------------------------------
1314
+ // Secrets Containment — Lock Down After Credential Exposure
1315
+ // -----------------------------------------------------------------------------
1316
+
1317
+ @id("multi-agent-secrets-lockdown")
1318
+ @name("Lock down sensitive tools after secrets detection")
1319
+ @description("If secrets (API keys, tokens) were detected in any prior turn, block all non-first-party agents from sensitive tool calls. Prevents credential exfiltration in compromised sessions")
1320
+ @severity("critical")
1321
+ @tags("profile,multi-agent,secrets,lockdown,cross-turn,a2a")
1322
+ forbid (
1323
+ principal is Guardrails::Agent,
1324
+ action == Guardrails::Action::"call_tool",
1325
+ resource
1326
+ ) when {
1327
+ context has agent_trust_level && context.agent_trust_level != "first_party" &&
1328
+ context has session_secrets_detected && context.session_secrets_detected == true &&
1329
+ context has tool_is_sensitive && context.tool_is_sensitive == true
1330
+ };
1331
+
1332
+ // -----------------------------------------------------------------------------
1333
+ // Injection Escalation — Tighten After Prior Attacks
1334
+ // -----------------------------------------------------------------------------
1335
+
1336
+ @id("multi-agent-post-injection-lockdown")
1337
+ @name("Restrict unverified agents after injection detection")
1338
+ @description("If injection was detected in any prior turn, block unverified agents from all tool calls. An injection in a prior turn may have poisoned the context, making subsequent unverified agent actions high risk")
1339
+ @severity("critical")
1340
+ @tags("profile,multi-agent,injection,lockdown,cross-turn,a2a")
1341
+ forbid (
1342
+ principal is Guardrails::Agent,
1343
+ action == Guardrails::Action::"call_tool",
1344
+ resource
1345
+ ) when {
1346
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
1347
+ context has session_injection_detected && context.session_injection_detected == true
1348
+ };
1349
+
1350
+ @id("multi-agent-post-command-injection-block-shell")
1351
+ @name("Block all agent shell access after command injection")
1352
+ @description("If command injection was detected in any prior turn, no agent (regardless of trust) can execute shell commands. Defense against persistent shell compromise")
1353
+ @severity("critical")
1354
+ @tags("profile,multi-agent,command-injection,shell,cross-turn,a2a")
1355
+ forbid (
1356
+ principal is Guardrails::Agent,
1357
+ action == Guardrails::Action::"call_tool",
1358
+ resource
1359
+ ) when {
1360
+ context has session_command_injection && context.session_command_injection == true &&
1361
+ context has tool_name &&
1362
+ (context.tool_name == "shell" ||
1363
+ context.tool_name == "execute_command" ||
1364
+ context.tool_name == "bash")
1365
+ };
1366
+
1367
+ // -----------------------------------------------------------------------------
1368
+ // Cumulative Risk — Session-Level Circuit Breaker
1369
+ // -----------------------------------------------------------------------------
1370
+
1371
+ @id("multi-agent-high-cumulative-risk-restrict")
1372
+ @name("Restrict non-first-party agents in high-risk sessions")
1373
+ @description("When cumulative session risk exceeds 200, restrict non-first-party agents to safe tools only. Acts as a circuit breaker for sessions that have accumulated multiple risk signals across turns")
1374
+ @severity("high")
1375
+ @tags("profile,multi-agent,cumulative-risk,circuit-breaker,a2a")
1376
+ forbid (
1377
+ principal is Guardrails::Agent,
1378
+ action == Guardrails::Action::"call_tool",
1379
+ resource
1380
+ ) when {
1381
+ context has agent_trust_level && context.agent_trust_level != "first_party" &&
1382
+ context has session_cumulative_risk_score && context.session_cumulative_risk_score > 200 &&
1383
+ context has tool_is_sensitive && context.tool_is_sensitive == true
1384
+ };
1385
+
1386
+ @id("multi-agent-extreme-risk-full-lockdown")
1387
+ @name("Full lockdown for unverified agents in extreme-risk sessions")
1388
+ @description("When cumulative session risk exceeds 500 or more than 5 threat turns are detected, block ALL tool calls from unverified agents. Emergency circuit breaker for compromised sessions")
1389
+ @severity("critical")
1390
+ @tags("profile,multi-agent,extreme-risk,lockdown,a2a")
1391
+ forbid (
1392
+ principal is Guardrails::Agent,
1393
+ action == Guardrails::Action::"call_tool",
1394
+ resource
1395
+ ) when {
1396
+ context has agent_trust_level && context.agent_trust_level == "unverified" &&
1397
+ (
1398
+ (context has session_cumulative_risk_score && context.session_cumulative_risk_score > 500) ||
1399
+ (context has session_threat_turns && context.session_threat_turns > 5)
1400
+ )
1401
+ };
1402
+ `;
983
1403
  // =============================================================================
984
1404
  // CATEGORIES
985
1405
  // =============================================================================
@@ -988,6 +1408,7 @@ export const GUARDRAILS_CATEGORIES = [
988
1408
  { id: 'privacy', name: 'Privacy', description: 'Detect and block personally identifiable information (PII) in prompts and responses' },
989
1409
  { id: 'trust_safety', name: 'Trust & Safety', description: 'Detect and block toxic, violent, hateful, sexual, or profane content' },
990
1410
  { id: 'agentic_security', name: 'Agentic Security', description: 'Detect tool abuse, data exfiltration patterns, infinite loops, and budget violations' },
1411
+ { id: 'agent_identity', name: 'Agent-to-Agent Security', description: 'Trust-based access control for AI agents — tiered permissions by trust level, agent type restrictions, cross-turn session lockdowns for multi-agent orchestration' },
991
1412
  { id: 'organization', name: 'Organization', description: 'Organization-wide baselines and default permit/deny policies' },
992
1413
  ];
993
1414
  // =============================================================================
@@ -1079,6 +1500,15 @@ export const GUARDRAILS_DEFAULTS = [
1079
1500
  // ALL TEMPLATES
1080
1501
  // =============================================================================
1081
1502
  export const GUARDRAILS_TEMPLATES = [
1503
+ {
1504
+ id: 'agent-identity-trust',
1505
+ name: 'Agent Identity & Trust',
1506
+ description: 'Trust-based access control for AI agents: block unverified agents from dangerous/sensitive tools, apply stricter thresholds for autonomous agents, restrict unverified agents after session threats',
1507
+ category: 'agent_identity',
1508
+ cedarText: GUARDRAILS_AGENT_IDENTITY_TRUST_CEDAR,
1509
+ severity: 'critical',
1510
+ tags: ['agent-identity', 'trust', 'a2a', 'autonomous', 'cross-turn'],
1511
+ },
1082
1512
  {
1083
1513
  id: 'mcp-tool-permissions',
1084
1514
  name: 'MCP Tool Permissions',
@@ -1160,6 +1590,24 @@ export const GUARDRAILS_TEMPLATES = [
1160
1590
  severity: 'critical',
1161
1591
  tags: ['profile', 'data-pipeline', 'exfiltration', 'tools'],
1162
1592
  },
1593
+ {
1594
+ id: 'multi-agent-trust',
1595
+ name: 'Multi-Agent Orchestration — Agent Trust',
1596
+ description: 'Tiered trust policies for multi-agent systems: only first-party agents can use dangerous tools, unverified agents restricted to safe tools, autonomous agents have lower risk ceilings, MCP server connection trust enforcement',
1597
+ category: 'agent_identity',
1598
+ cedarText: GUARDRAILS_MULTI_AGENT_TRUST_CEDAR,
1599
+ severity: 'critical',
1600
+ tags: ['profile', 'multi-agent', 'trust', 'a2a', 'autonomous', 'mcp'],
1601
+ },
1602
+ {
1603
+ id: 'multi-agent-safety',
1604
+ name: 'Multi-Agent Orchestration — Cross-Turn Safety',
1605
+ description: 'Session-aware agent safety policies: PII containment across agents, secrets lockdown, injection escalation response, cumulative risk circuit breakers for multi-agent sessions',
1606
+ category: 'agent_identity',
1607
+ cedarText: GUARDRAILS_MULTI_AGENT_SAFETY_CEDAR,
1608
+ severity: 'critical',
1609
+ tags: ['profile', 'multi-agent', 'cross-turn', 'a2a', 'pii', 'secrets', 'injection', 'circuit-breaker'],
1610
+ },
1163
1611
  ];
1164
1612
  // =============================================================================
1165
1613
  // TEMPLATES METADATA
@@ -1190,6 +1638,11 @@ export const GUARDRAILS_TEMPLATES_JSON = `{
1190
1638
  "name": "Agentic Security",
1191
1639
  "description": "Detect tool abuse, data exfiltration patterns, infinite loops, and budget violations"
1192
1640
  },
1641
+ {
1642
+ "id": "agent_identity",
1643
+ "name": "Agent-to-Agent Security",
1644
+ "description": "Trust-based access control for AI agents — tiered permissions by trust level, agent type restrictions, cross-turn session lockdowns for multi-agent orchestration"
1645
+ },
1193
1646
  {
1194
1647
  "id": "organization",
1195
1648
  "name": "Organization",
@@ -1279,6 +1732,15 @@ export const GUARDRAILS_TEMPLATES_JSON = `{
1279
1732
  }
1280
1733
  ],
1281
1734
  "templates": [
1735
+ {
1736
+ "id": "agent-identity-trust",
1737
+ "name": "Agent Identity & Trust",
1738
+ "description": "Trust-based access control for AI agents: block unverified agents from dangerous/sensitive tools, apply stricter thresholds for autonomous agents, restrict unverified agents after session threats",
1739
+ "category": "agent_identity",
1740
+ "file": "defaults/agent_identity.cedar",
1741
+ "severity": "critical",
1742
+ "tags": ["agent-identity", "trust", "a2a", "autonomous", "cross-turn"]
1743
+ },
1282
1744
  {
1283
1745
  "id": "mcp-tool-permissions",
1284
1746
  "name": "MCP Tool Permissions",
@@ -1359,6 +1821,24 @@ export const GUARDRAILS_TEMPLATES_JSON = `{
1359
1821
  "file": "profiles/data_pipeline/agentic_security.cedar",
1360
1822
  "severity": "critical",
1361
1823
  "tags": ["profile", "data-pipeline", "exfiltration", "tools"]
1824
+ },
1825
+ {
1826
+ "id": "multi-agent-trust",
1827
+ "name": "Multi-Agent Orchestration — Agent Trust",
1828
+ "description": "Tiered trust policies for multi-agent systems: only first-party agents can use dangerous tools, unverified agents restricted to safe tools, autonomous agents have lower risk ceilings, MCP server connection trust enforcement",
1829
+ "category": "agent_identity",
1830
+ "file": "profiles/multi_agent/agent_trust.cedar",
1831
+ "severity": "critical",
1832
+ "tags": ["profile", "multi-agent", "trust", "a2a", "autonomous", "mcp"]
1833
+ },
1834
+ {
1835
+ "id": "multi-agent-safety",
1836
+ "name": "Multi-Agent Orchestration — Cross-Turn Safety",
1837
+ "description": "Session-aware agent safety policies: PII containment across agents, secrets lockdown, injection escalation response, cumulative risk circuit breakers for multi-agent sessions",
1838
+ "category": "agent_identity",
1839
+ "file": "profiles/multi_agent/agent_safety.cedar",
1840
+ "severity": "critical",
1841
+ "tags": ["profile", "multi-agent", "cross-turn", "a2a", "pii", "secrets", "injection", "circuit-breaker"]
1362
1842
  }
1363
1843
  ],
1364
1844
  "profiles": [
@@ -1385,6 +1865,14 @@ export const GUARDRAILS_TEMPLATES_JSON = `{
1385
1865
  "severity": "critical",
1386
1866
  "tags": ["data-pipeline", "pii", "secrets", "exfiltration"],
1387
1867
  "template_ids": ["data-pipeline-privacy", "data-pipeline-security", "data-pipeline-agentic-security"]
1868
+ },
1869
+ {
1870
+ "id": "multi-agent",
1871
+ "name": "Multi-Agent Orchestration",
1872
+ "description": "Production-grade A2A guardrails for multi-agent systems — tiered trust access control, autonomous agent safeguards, cross-turn PII/secrets containment, injection escalation response, cumulative risk circuit breakers",
1873
+ "severity": "critical",
1874
+ "tags": ["multi-agent", "a2a", "trust", "cross-turn", "circuit-breaker"],
1875
+ "template_ids": ["agent-identity-trust", "multi-agent-trust", "multi-agent-safety"]
1388
1876
  }
1389
1877
  ]
1390
1878
  }