@highflame/policy 2.1.22 → 2.1.24

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.
@@ -5,44 +5,25 @@
5
5
  // Complements the MCP Server Allowlist (connect_server action)
6
6
  // with fine-grained per-tool control on call_tool action.
7
7
  //
8
+ // Defaults to permit-all. Customize per-tool gating by adding forbid rules
9
+ // scoped to specific mcp_server / tool_name combinations.
10
+ //
8
11
  // Category: tools
9
12
  // Namespace: AIGateway
10
13
  // =============================================================================
11
14
 
12
- // -- GitHub MCP: Read-only access -------------------------------------------
15
+ // -- Permit all MCP tool calls (opt-in default) -----------------------------
13
16
 
14
- @id("mcp-tool-allow-read-github")
15
- @name("Allow read-only GitHub tools")
16
- @description("Permit read operations from GitHub MCP server")
17
- @severity("medium")
18
- @tags("mcp,github,read-only,least-privilege")
17
+ @id("mcp-tool-allow-all")
18
+ @name("Allow all MCP tool calls")
19
+ @description("Permit every call_tool action. Add forbid rules below for per-tool gating.")
20
+ @severity("low")
21
+ @tags("mcp,permit-default")
19
22
  permit (
20
23
  principal,
21
24
  action == AIGateway::Action::"call_tool",
22
25
  resource
23
- ) when {
24
- context has mcp_server && context.mcp_server == "github" &&
25
- context has tool_name &&
26
- (context.tool_name == "read_issues" ||
27
- context.tool_name == "get_issue" ||
28
- context.tool_name == "list_repos" ||
29
- context.tool_name == "get_pull_request" ||
30
- context.tool_name == "search_code" ||
31
- context.tool_name == "get_file_contents")
32
- };
33
-
34
- @id("mcp-tool-deny-write-github")
35
- @name("Deny write GitHub tools")
36
- @description("Block create/update/delete operations on GitHub MCP server")
37
- @severity("high")
38
- @tags("mcp,github,write-block,least-privilege")
39
- forbid (
40
- principal,
41
- action == AIGateway::Action::"call_tool",
42
- resource
43
- ) when {
44
- context has mcp_server && context.mcp_server == "github"
45
- };
26
+ );
46
27
 
47
28
  // -- Organization-wide MCP server exclusions --------------------------------
48
29
 
@@ -89,11 +89,11 @@
89
89
  {
90
90
  "id": "tools-mcp-tool-permissions",
91
91
  "name": "MCP Tool Permissions",
92
- "description": "Per-tool access control for MCP servers -- allow specific tools while denying others, exclude servers org-wide, block unverified sources",
92
+ "description": "Permit every MCP call_tool by default. Ships two opt-in safety rails (block untrusted/deprecated servers, block unverified servers). Add forbid rules for per-tool or per-server gating.",
93
93
  "category": "tools",
94
94
  "file": "mcp_tool_permissions.cedar",
95
- "severity": "high",
96
- "tags": ["mcp", "tools", "least-privilege", "per-server", "exclusion"]
95
+ "severity": "low",
96
+ "tags": ["mcp", "tools", "permit-default", "exclusion"]
97
97
  },
98
98
  {
99
99
  "id": "data-pii-redaction",
@@ -29,7 +29,7 @@
29
29
  "key": "content_type",
30
30
  "type": "string",
31
31
  "required": true,
32
- "description": "Type of content being analyzed: 'prompt', 'response', 'tool_call', or 'file'"
32
+ "description": "Type of content being analyzed: 'prompt', 'response', 'tool_call', 'file', or 'clipboard'"
33
33
  },
34
34
  {
35
35
  "key": "detector_count",
@@ -0,0 +1,76 @@
1
+ // =============================================================================
2
+ // Clipboard Policy (Default)
3
+ // =============================================================================
4
+ // Controls over paste operations into AI chat services. Covers:
5
+ // - Blanket paste blocking (admin-configurable)
6
+ // - Paste-with-secrets blocking
7
+ // - Paste-with-source-code blocking
8
+ //
9
+ // Cross-cutting secret rules (e.g. high-risk credential types) are defined
10
+ // in secrets.cedar and apply to paste content as well.
11
+ //
12
+ // Category: clipboard
13
+ // Namespace: Sentry
14
+ // =============================================================================
15
+
16
+ // Block all paste operations
17
+ @id("sentry-org-block-all-paste")
18
+ @name("Block all paste operations")
19
+ @description("Unconditionally block all paste operations into AI chat services. Enable this rule to prevent any content from being pasted into AI chats regardless of content. Disable to allow paste (subject to other policy rules).")
20
+ @severity("high")
21
+ @tags("paste,clipboard,data-protection,organization")
22
+ @reject_message("Paste blocked: your organization does not allow pasting content into AI services. Type your message directly or contact your administrator.")
23
+ forbid (
24
+ principal,
25
+ action == Sentry::Action::"paste_content",
26
+ resource
27
+ );
28
+
29
+ // Block pasted content containing secrets
30
+ @id("sentry-org-block-secrets-paste")
31
+ @name("Block paste with secrets")
32
+ @description("Block paste operations when secrets are detected. Prevents credential leakage when users paste from terminals, config files, or code editors into AI chats.")
33
+ @severity("critical")
34
+ @tags("secrets,paste-safety,credentials,nist-sc-28")
35
+ @reject_message("Paste blocked: secrets or credentials detected in pasted content. Remove API keys, tokens, and passwords before pasting into AI services.")
36
+ forbid (
37
+ principal,
38
+ action == Sentry::Action::"paste_content",
39
+ resource
40
+ )
41
+ when {
42
+ context has contains_secrets && context.contains_secrets
43
+ };
44
+
45
+ // Block pasted content containing PII
46
+ @id("sentry-pii-block-paste")
47
+ @name("Block paste with PII")
48
+ @description("Block paste operations when PII is detected in pasted content. Prevents data leakage when employees paste content from emails, spreadsheets, or documents containing personal data into AI chats.")
49
+ @severity("critical")
50
+ @tags("pii,paste-safety,data-leakage,gdpr-art-32")
51
+ @reject_message("Paste blocked: personally identifiable information detected in pasted content. Remove PII before pasting into AI services.")
52
+ forbid (
53
+ principal,
54
+ action == Sentry::Action::"paste_content",
55
+ resource
56
+ )
57
+ when {
58
+ context has pii_detected && context.pii_detected
59
+ };
60
+
61
+ // Block pasted source code
62
+ @id("sentry-org-block-code-paste")
63
+ @name("Block pasted source code")
64
+ @description("Block paste operations when content is primarily source code (>80%). Prevents code exfiltration via clipboard from IDEs, terminals, or code repositories into AI chats.")
65
+ @severity("high")
66
+ @tags("source-code,paste-safety,ip-protection,data-leakage")
67
+ @reject_message("Paste blocked: the content appears to be primarily source code (>80%). Pasting bulk source code into AI services risks intellectual property exposure.")
68
+ forbid (
69
+ principal,
70
+ action == Sentry::Action::"paste_content",
71
+ resource
72
+ )
73
+ when {
74
+ context has contains_code && context.contains_code &&
75
+ context has code_ratio && context.code_ratio > 80
76
+ };
@@ -97,20 +97,20 @@ when {
97
97
  context has contains_secrets && context.contains_secrets
98
98
  };
99
99
 
100
- // Block files with bulk PII
101
- @id("sentry-file-block-bulk-pii")
102
- @name("Block files with bulk PII")
103
- @description("Block file uploads containing 3 or more PII matches. Files with bulk PII likely contain customer lists, employee records, or patient data that must not be shared with AI services.")
100
+ // Block file uploads containing PII
101
+ @id("sentry-pii-block-uploads")
102
+ @name("Block file uploads with PII")
103
+ @description("Block file uploads when PII is detected in document content. Prevents sharing of documents containing personal data (customer lists, HR records, medical files) with AI services.")
104
104
  @severity("critical")
105
- @tags("pii,file-upload,bulk,gdpr-art-32")
106
- @reject_message("Upload blocked: multiple PII items detected in the file (3+). Documents containing bulk personal data must not be shared with AI services.")
105
+ @tags("pii,file-upload,data-protection,gdpr-art-32")
106
+ @reject_message("File upload blocked: personally identifiable information detected in the document. Files containing PII must not be shared with AI services.")
107
107
  forbid (
108
108
  principal,
109
109
  action == Sentry::Action::"upload_file",
110
110
  resource
111
111
  )
112
112
  when {
113
- context has pii_count && context.pii_count >= 3
113
+ context has pii_detected && context.pii_detected
114
114
  };
115
115
 
116
116
  // Block files with phishing links
@@ -1,138 +1,22 @@
1
1
  // =============================================================================
2
2
  // Organization Rules Policy (Default)
3
3
  // =============================================================================
4
- // Organization-wide security policies for browser AI interactions:
5
- // - Credential/secret leakage prevention across all channels
6
- // - Source code protection
7
- // - Session-aware escalation
4
+ // Cross-cutting organization-wide rules that don't fit other categories.
5
+ // Secret/credential rules live in secrets.cedar; paste/clipboard rules live
6
+ // in clipboard.cedar.
8
7
  //
9
- // These rules complement category-specific policies (PII, Content Safety,
10
- // File Safety) with cross-cutting organizational controls.
8
+ // This template covers:
9
+ // - Source code protection in messages (non-paste channels)
10
+ // - Session-aware threat escalation
11
11
  //
12
12
  // Category: organization
13
13
  // Namespace: Sentry
14
14
  // =============================================================================
15
15
 
16
16
  // ---------------------------------------------------------------------------
17
- // Section 1: Credential & Secret Leakage Prevention
18
- // Block secrets/credentials across messages, pastes, and file uploads.
19
- // Shield SecretsDetector identifies 18+ secret types via regex.
20
- // ---------------------------------------------------------------------------
21
-
22
- // Block messages containing secrets
23
- @id("sentry-org-block-secrets-messages")
24
- @name("Block messages with secrets")
25
- @description("Block messages when detection engines identify API keys, tokens, or credential patterns. First line of defense against accidental credential exposure in AI chat interactions.")
26
- @severity("critical")
27
- @tags("secrets,credentials,messages,nist-sc-28,nist-ia-5")
28
- @reject_message("Your message was blocked because it contains detected secrets such as API keys, tokens, or credentials. Remove all secrets before sending to AI services.")
29
- forbid (
30
- principal,
31
- action == Sentry::Action::"send_message",
32
- resource
33
- )
34
- when {
35
- context has contains_secrets && context.contains_secrets
36
- };
37
-
38
- // Block pasted content containing secrets
39
- @id("sentry-org-block-secrets-paste")
40
- @name("Block paste with secrets")
41
- @description("Block paste operations when secrets are detected. Prevents credential leakage when users paste from terminals, config files, or code editors into AI chats.")
42
- @severity("critical")
43
- @tags("secrets,paste-safety,credentials,nist-sc-28")
44
- @reject_message("Paste blocked: secrets or credentials detected in pasted content. Remove API keys, tokens, and passwords before pasting into AI services.")
45
- forbid (
46
- principal,
47
- action == Sentry::Action::"paste_content",
48
- resource
49
- )
50
- when {
51
- context has contains_secrets && context.contains_secrets
52
- };
53
-
54
- // Block high-risk secret types across all actions
55
- @id("sentry-org-block-high-risk-secrets")
56
- @name("Block high-risk credential types")
57
- @description("Block content containing cloud provider keys (AWS, GCP, Azure), GitHub tokens, SSH private keys, or database connection strings across all actions. These credential types pose the highest exfiltration risk.")
58
- @severity("critical")
59
- @tags("secrets,aws,github,ssh,cloud,nist-ia-5,mitre-t1552")
60
- @reject_message("Content blocked: high-risk credentials detected (cloud keys, GitHub tokens, SSH keys). Use a secrets manager — never share credentials with AI services.")
61
- forbid (
62
- principal,
63
- action,
64
- resource
65
- )
66
- when {
67
- context has secret_types &&
68
- (context.secret_types.contains("aws_access_key") ||
69
- context.secret_types.contains("aws_secret_key") ||
70
- context.secret_types.contains("gcp_service_account") ||
71
- context.secret_types.contains("azure_connection_string") ||
72
- context.secret_types.contains("github_token") ||
73
- context.secret_types.contains("github_fine_grained") ||
74
- context.secret_types.contains("private_key"))
75
- };
76
-
77
- // Block API keys and tokens across all actions
78
- @id("sentry-org-block-api-keys")
79
- @name("Block API keys and tokens")
80
- @description("Block content containing generic API keys, JWT tokens, and OAuth credentials. These are the most commonly leaked credential types when users interact with AI services.")
81
- @severity("high")
82
- @tags("secrets,api-key,jwt,oauth,nist-ia-5")
83
- @reject_message("Content blocked: API keys, JWT tokens, or OAuth credentials detected. These must never be shared with AI services.")
84
- forbid (
85
- principal,
86
- action,
87
- resource
88
- )
89
- when {
90
- context has secret_types &&
91
- (context.secret_types.contains("generic_api_key") ||
92
- context.secret_types.contains("jwt_token") ||
93
- context.secret_types.contains("openai_key") ||
94
- context.secret_types.contains("anthropic_key") ||
95
- context.secret_types.contains("stripe_key"))
96
- };
97
-
98
- // Block bulk secret exposure
99
- @id("sentry-org-block-bulk-secrets")
100
- @name("Block bulk secret exposure")
101
- @description("Block content when 3+ distinct secrets are found. Multiple secrets indicate a configuration dump, .env file paste, or credential harvesting being sent to AI services.")
102
- @severity("critical")
103
- @tags("secrets,bulk,data-exfiltration,nist-sc-28")
104
- @reject_message("Content blocked: multiple credentials detected (3+). Configuration dumps and credential lists must never be shared with AI services.")
105
- forbid (
106
- principal,
107
- action,
108
- resource
109
- )
110
- when {
111
- context has secret_count && context.secret_count >= 3
112
- };
113
-
114
- // Block detected credential patterns
115
- @id("sentry-org-block-detected-credentials")
116
- @name("Block detected credential patterns")
117
- @description("Block content flagged by detection engine rules for credential exposure, API key leaks, and token exposure. Defense-in-depth behind contains_secrets.")
118
- @severity("critical")
119
- @tags("secrets,credentials,detection-rules,nist-ia-5")
120
- @reject_message("Content blocked: detection engines identified credential patterns including secret exposure, API keys, or token leaks.")
121
- forbid (
122
- principal,
123
- action,
124
- resource
125
- )
126
- when {
127
- context has detected_threats &&
128
- (context.detected_threats.contains("secret_exposure") ||
129
- context.detected_threats.contains("credential_leak") ||
130
- context.detected_threats.contains("api_key_exposure"))
131
- };
132
-
133
- // ---------------------------------------------------------------------------
134
- // Section 2: Source Code Protection
135
- // Prevent bulk source code from being shared with AI services.
17
+ // Section 1: Source Code Protection (Messages)
18
+ // Prevent bulk source code from being shared via messages.
19
+ // Paste-targeted code protection is in clipboard.cedar.
136
20
  // ---------------------------------------------------------------------------
137
21
 
138
22
  // Block messages with high code content
@@ -152,25 +36,8 @@ when {
152
36
  context has code_ratio && context.code_ratio > 80
153
37
  };
154
38
 
155
- // Block pasted source code
156
- @id("sentry-org-block-code-paste")
157
- @name("Block pasted source code")
158
- @description("Block paste operations when content is primarily source code (>80%). Prevents code exfiltration via clipboard from IDEs, terminals, or code repositories into AI chats.")
159
- @severity("high")
160
- @tags("source-code,paste-safety,ip-protection,data-leakage")
161
- @reject_message("Paste blocked: the content appears to be primarily source code (>80%). Pasting bulk source code into AI services risks intellectual property exposure.")
162
- forbid (
163
- principal,
164
- action == Sentry::Action::"paste_content",
165
- resource
166
- )
167
- when {
168
- context has contains_code && context.contains_code &&
169
- context has code_ratio && context.code_ratio > 80
170
- };
171
-
172
39
  // ---------------------------------------------------------------------------
173
- // Section 3: Session-Aware Escalation
40
+ // Section 2: Session-Aware Escalation
174
41
  // Escalate protections when threats are detected across the session.
175
42
  // ---------------------------------------------------------------------------
176
43
 
@@ -189,19 +56,3 @@ forbid (
189
56
  when {
190
57
  context has session_threat_turns && context.session_threat_turns >= 3
191
58
  };
192
-
193
- // Block AI responses when session has leaked secrets
194
- @id("sentry-org-session-secrets-response")
195
- @name("Block responses after secret detection")
196
- @description("Block AI responses when secrets were detected earlier in the session. If credentials were leaked in a previous turn, the AI service may have processed them and could echo or reference them in responses.")
197
- @severity("high")
198
- @tags("session,secrets,response-safety,defense-in-depth")
199
- @reject_message("AI response blocked: secrets were detected in an earlier message in this session. Responses may contain or reference the exposed credentials.")
200
- forbid (
201
- principal,
202
- action == Sentry::Action::"receive_response",
203
- resource
204
- )
205
- when {
206
- context has session_secrets_detected && context.session_secrets_detected
207
- };
@@ -46,38 +46,6 @@ when {
46
46
  context has pii_detected && context.pii_detected
47
47
  };
48
48
 
49
- // Block pasted content containing PII
50
- @id("sentry-pii-block-paste")
51
- @name("Block paste with PII")
52
- @description("Block paste operations when PII is detected in pasted content. Prevents data leakage when employees paste content from emails, spreadsheets, or documents containing personal data into AI chats.")
53
- @severity("critical")
54
- @tags("pii,paste-safety,data-leakage,gdpr-art-32")
55
- @reject_message("Paste blocked: personally identifiable information detected in pasted content. Remove PII before pasting into AI services.")
56
- forbid (
57
- principal,
58
- action == Sentry::Action::"paste_content",
59
- resource
60
- )
61
- when {
62
- context has pii_detected && context.pii_detected
63
- };
64
-
65
- // Block file uploads containing PII
66
- @id("sentry-pii-block-uploads")
67
- @name("Block file uploads with PII")
68
- @description("Block file uploads when PII is detected in document content. Prevents sharing of documents containing personal data (customer lists, HR records, medical files) with AI services.")
69
- @severity("critical")
70
- @tags("pii,file-upload,data-protection,gdpr-art-32")
71
- @reject_message("File upload blocked: personally identifiable information detected in the document. Files containing PII must not be shared with AI services.")
72
- forbid (
73
- principal,
74
- action == Sentry::Action::"upload_file",
75
- resource
76
- )
77
- when {
78
- context has pii_detected && context.pii_detected
79
- };
80
-
81
49
  // ---------------------------------------------------------------------------
82
50
  // Section 2: Granular PII Type Blocking
83
51
  // Blocks specific PII types based on regulatory requirements.
@@ -0,0 +1,155 @@
1
+ // =============================================================================
2
+ // Secrets Detection Policy (Default)
3
+ // =============================================================================
4
+ // Block credential and secret leakage across messages and AI responses.
5
+ // Shield SecretsDetector identifies 18+ secret types via regex.
6
+ //
7
+ // Paste-targeted secret rules live in clipboard.cedar; this file covers
8
+ // non-paste channels (messages, responses, and cross-cutting rules).
9
+ //
10
+ // Category: secrets
11
+ // Namespace: Sentry
12
+ // =============================================================================
13
+
14
+ // Block messages containing secrets
15
+ @id("sentry-org-block-secrets-messages")
16
+ @name("Block messages with secrets")
17
+ @description("Block messages when detection engines identify API keys, tokens, or credential patterns. First line of defense against accidental credential exposure in AI chat interactions.")
18
+ @severity("critical")
19
+ @tags("secrets,credentials,messages,nist-sc-28,nist-ia-5")
20
+ @reject_message("Your message was blocked because it contains detected secrets such as API keys, tokens, or credentials. Remove all secrets before sending to AI services.")
21
+ forbid (
22
+ principal,
23
+ action == Sentry::Action::"send_message",
24
+ resource
25
+ )
26
+ when {
27
+ context has contains_secrets && context.contains_secrets
28
+ };
29
+
30
+ // Block high-risk secret types across all actions
31
+ @id("sentry-org-block-high-risk-secrets")
32
+ @name("Block high-risk credential types")
33
+ @description("Block content containing cloud provider keys (AWS, GCP, Azure), GitHub tokens, SSH private keys, or database connection strings across all actions. These credential types pose the highest exfiltration risk.")
34
+ @severity("critical")
35
+ @tags("secrets,aws,github,ssh,cloud,nist-ia-5,mitre-t1552")
36
+ @reject_message("Content blocked: high-risk credentials detected (cloud keys, GitHub tokens, SSH keys). Use a secrets manager — never share credentials with AI services.")
37
+ forbid (
38
+ principal,
39
+ action,
40
+ resource
41
+ )
42
+ when {
43
+ context has secret_types &&
44
+ (context.secret_types.contains("aws_access_key") ||
45
+ context.secret_types.contains("aws_secret_key") ||
46
+ context.secret_types.contains("gcp_service_account") ||
47
+ context.secret_types.contains("azure_connection_string") ||
48
+ context.secret_types.contains("github_token") ||
49
+ context.secret_types.contains("github_fine_grained") ||
50
+ context.secret_types.contains("private_key"))
51
+ };
52
+
53
+ // Block API keys and tokens across all actions
54
+ @id("sentry-org-block-api-keys")
55
+ @name("Block API keys and tokens")
56
+ @description("Block content containing generic API keys, JWT tokens, and OAuth credentials. These are the most commonly leaked credential types when users interact with AI services.")
57
+ @severity("high")
58
+ @tags("secrets,api-key,jwt,oauth,nist-ia-5")
59
+ @reject_message("Content blocked: API keys, JWT tokens, or OAuth credentials detected. These must never be shared with AI services.")
60
+ forbid (
61
+ principal,
62
+ action,
63
+ resource
64
+ )
65
+ when {
66
+ context has secret_types &&
67
+ (context.secret_types.contains("generic_api_key") ||
68
+ context.secret_types.contains("jwt_token") ||
69
+ context.secret_types.contains("openai_key") ||
70
+ context.secret_types.contains("anthropic_key") ||
71
+ context.secret_types.contains("stripe_key"))
72
+ };
73
+
74
+ // Block SSH key exposure across messages, paste, and file uploads
75
+ @id("sentry-secrets-block-ssh-keys")
76
+ @name("Block SSH key exposure")
77
+ @description("Block when SSH private key content or SSH key file paths are detected. Covers messages, paste, and file uploads. AI chat services must not receive SSH credentials.")
78
+ @severity("critical")
79
+ @tags("secrets,ssh,credentials,nist-ia-5,mitre-t1552")
80
+ @reject_message("Blocked: SSH private key content or key file path detected. AI chat services must not receive SSH credentials.")
81
+ forbid (
82
+ principal,
83
+ action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
84
+ resource
85
+ )
86
+ when {
87
+ context has secret_types && context.secret_types.contains("ssh_key")
88
+ };
89
+
90
+ // Block PEM/certificate key exposure across messages, paste, and file uploads
91
+ @id("sentry-secrets-block-pem-keys")
92
+ @name("Block PEM/certificate key exposure")
93
+ @description("Block when PEM private key content or certificate key file paths (.pem, .key, .p12, .pfx) are detected. AI chat services must not receive certificate credentials.")
94
+ @severity("critical")
95
+ @tags("secrets,certificates,pem,nist-ia-5,mitre-t1552")
96
+ @reject_message("Blocked: PEM private key or certificate key file detected. AI chat services must not receive certificate credentials.")
97
+ forbid (
98
+ principal,
99
+ action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
100
+ resource
101
+ )
102
+ when {
103
+ context has secret_types && context.secret_types.contains("pem_certificate")
104
+ };
105
+
106
+ // Block bulk secret exposure
107
+ @id("sentry-org-block-bulk-secrets")
108
+ @name("Block bulk secret exposure")
109
+ @description("Block content when 3+ distinct secrets are found. Multiple secrets indicate a configuration dump, .env file paste, or credential harvesting being sent to AI services.")
110
+ @severity("critical")
111
+ @tags("secrets,bulk,data-exfiltration,nist-sc-28")
112
+ @reject_message("Content blocked: multiple credentials detected (3+). Configuration dumps and credential lists must never be shared with AI services.")
113
+ forbid (
114
+ principal,
115
+ action,
116
+ resource
117
+ )
118
+ when {
119
+ context has secret_count && context.secret_count >= 3
120
+ };
121
+
122
+ // Block detected credential patterns
123
+ @id("sentry-org-block-detected-credentials")
124
+ @name("Block detected credential patterns")
125
+ @description("Block content flagged by detection engine rules for credential exposure, API key leaks, and token exposure. Defense-in-depth behind contains_secrets.")
126
+ @severity("critical")
127
+ @tags("secrets,credentials,detection-rules,nist-ia-5")
128
+ @reject_message("Content blocked: detection engines identified credential patterns including secret exposure, API keys, or token leaks.")
129
+ forbid (
130
+ principal,
131
+ action,
132
+ resource
133
+ )
134
+ when {
135
+ context has detected_threats &&
136
+ (context.detected_threats.contains("secret_exposure") ||
137
+ context.detected_threats.contains("credential_leak") ||
138
+ context.detected_threats.contains("api_key_exposure"))
139
+ };
140
+
141
+ // Block AI responses when session has leaked secrets
142
+ @id("sentry-org-session-secrets-response")
143
+ @name("Block responses after secret detection")
144
+ @description("Block AI responses when secrets were detected earlier in the session. If credentials were leaked in a previous turn, the AI service may have processed them and could echo or reference them in responses.")
145
+ @severity("high")
146
+ @tags("session,secrets,response-safety,defense-in-depth")
147
+ @reject_message("AI response blocked: secrets were detected in an earlier message in this session. Responses may contain or reference the exposed credentials.")
148
+ forbid (
149
+ principal,
150
+ action == Sentry::Action::"receive_response",
151
+ resource
152
+ )
153
+ when {
154
+ context has session_secrets_detected && context.session_secrets_detected
155
+ };