@highflame/policy 2.1.32 → 2.1.34

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.
@@ -4,7 +4,7 @@
4
4
  "description": "Sentry browser security — monitors AI chat interactions and enforces data-protection, content-safety, and compliance policies",
5
5
  "actions": [
6
6
  {
7
- "name": "send_message",
7
+ "name": "process_prompt",
8
8
  "description": "User sends a message (prompt) to an AI chat service via the browser",
9
9
  "context_attributes": [
10
10
  {
@@ -23,7 +23,7 @@
23
23
  "key": "event",
24
24
  "type": "string",
25
25
  "required": true,
26
- "description": "Event type (always 'send_message')"
26
+ "description": "Event type (always 'process_prompt')"
27
27
  },
28
28
  {
29
29
  "key": "user_email",
@@ -62,7 +62,7 @@ entity User;
62
62
  // ENTITIES - Resources (scoped under Project)
63
63
  // =============================================================================
64
64
 
65
- /// AI chat session — resource for send_message and receive_response actions
65
+ /// AI chat session — resource for process_prompt and receive_response actions
66
66
  entity ChatSession in [Project];
67
67
 
68
68
  /// Document or file being uploaded — resource for upload_file action
@@ -74,14 +74,14 @@ entity Document in [Project];
74
74
 
75
75
  // User sends a message (prompt) to an AI chat service
76
76
  // Threat focus: data leakage (PII, secrets, confidential data), injection, content safety
77
- action send_message appliesTo {
77
+ action process_prompt appliesTo {
78
78
  principal: [User],
79
79
  resource: [ChatSession],
80
80
  context: {
81
81
  // --- Core Metadata ---
82
82
  content: String, // Raw message content being sent
83
83
  source: String, // Browser extension identifier: "sentry"
84
- event: String, // Event type: "send_message"
84
+ event: String, // Event type: "process_prompt"
85
85
  user_email: String, // User identifier (SSO/OAuth verified)
86
86
  target_app: String, // AI service: "chatgpt", "gemini", "claude", "copilot", "custom"
87
87
  target_url?: String, // Full URL of the AI chat service
@@ -4,10 +4,15 @@
4
4
  // Controls over paste operations into AI chat services. Covers:
5
5
  // - Blanket paste blocking (admin-configurable)
6
6
  // - Paste-with-secrets blocking
7
+ // - Paste-with-PII blocking
7
8
  // - Paste-with-source-code blocking
9
+ // - Large-paste threat blocking
10
+ // - Paste-with-encoded-payload blocking
11
+ // - Paste-with-invisible-character blocking
8
12
  //
9
- // Cross-cutting secret rules (e.g. high-risk credential types) are defined
10
- // in secrets.cedar and apply to paste content as well.
13
+ // All policies in this file are scoped to action == "paste_content". Other
14
+ // templates (semantic.cedar, content_safety.cedar, pii.cedar, secrets.cedar)
15
+ // cover process_prompt and upload_file for the same threat categories.
11
16
  //
12
17
  // Category: clipboard
13
18
  // Namespace: Sentry
@@ -58,19 +63,36 @@ when {
58
63
  context has pii_detected && context.pii_detected
59
64
  };
60
65
 
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.")
66
+ // Block pastes containing encoded injection payloads
67
+ @id("sentry-clipboard-block-paste-encoded")
68
+ @name("Block encoded paste content")
69
+ @description("Block paste operations when encoded injection payloads (base64, hex, unicode) are detected. Attackers use encoding to smuggle injection payloads via clipboard transfer.")
65
70
  @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.")
71
+ @tags("paste-safety,encoding,injection,clipboard")
72
+ @reject_message("Paste blocked: encoded injection payloads detected in pasted content. Content with hidden encoded instructions cannot be shared with AI services.")
68
73
  forbid (
69
74
  principal,
70
75
  action == Sentry::Action::"paste_content",
71
76
  resource
72
77
  )
73
78
  when {
74
- context has contains_code && context.contains_code &&
75
- context has code_ratio && context.code_ratio > 80
79
+ context has encoded_content_detected && context.encoded_content_detected &&
80
+ context has encoded_score && context.encoded_score >= 60
81
+ };
82
+
83
+ // Block pastes with invisible characters
84
+ @id("sentry-clipboard-block-paste-invisible")
85
+ @name("Block paste with invisible characters")
86
+ @description("Block paste operations containing invisible Unicode characters (zero-width, bidi overrides). These can hide malicious instructions that appear invisible to users but are processed by AI models.")
87
+ @severity("high")
88
+ @tags("paste-safety,unicode,invisible-chars,clipboard")
89
+ @reject_message("Paste blocked: invisible Unicode characters detected. Hidden characters can disguise malicious instructions that AI models process but users cannot see.")
90
+ forbid (
91
+ principal,
92
+ action == Sentry::Action::"paste_content",
93
+ resource
94
+ )
95
+ when {
96
+ context has contains_invisible_chars && context.contains_invisible_chars &&
97
+ context has invisible_chars_score && context.invisible_chars_score >= 50
76
98
  };
@@ -2,8 +2,10 @@
2
2
  // Content Safety Policy (Default)
3
3
  // =============================================================================
4
4
  // Detects and blocks violent, harmful, hateful, sexual, and profane content
5
- // in AI chat interactions. Includes cut-and-paste safety rules to prevent
6
- // unsafe content from being transferred into AI services.
5
+ // in AI chat interactions across messages and file uploads.
6
+ //
7
+ // Paste-specific content safety rules live in clipboard.cedar — see
8
+ // "Clipboard Policy".
7
9
  //
8
10
  // The detection engine runs ML classifiers (toxicity, content safety) and
9
11
  // produces normalized scores (0-100) for each category.
@@ -21,19 +23,19 @@
21
23
  // ---------------------------------------------------------------------------
22
24
  // Section 1: Violence & Weapons
23
25
  // Blocks content promoting, describing, or instructing violence and weapons.
24
- // Applies to messages, paste, and file uploads.
26
+ // Applies to messages and file uploads.
25
27
  // ---------------------------------------------------------------------------
26
28
 
27
29
  // Block violent content across all input channels
28
30
  @id("sentry-cs-block-violence")
29
31
  @name("Block violent content")
30
- @description("Block content when the ML violence detection score exceeds threshold (80/100). Catches graphic violence descriptions, instructions for causing harm, and violent threat language in messages, pastes, and uploads.")
32
+ @description("Block content when the ML violence detection score exceeds threshold (80/100). Catches graphic violence descriptions, instructions for causing harm, and violent threat language in messages and uploads.")
31
33
  @severity("critical")
32
34
  @tags("violence,content-safety,trust-safety,nist-si-4,iso-42001")
33
35
  @reject_message("Content blocked: violent content detected. AI services must not process violent content in enterprise environments. Please rephrase without violence-related language.")
34
36
  forbid (
35
37
  principal,
36
- action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
38
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
37
39
  resource
38
40
  )
39
41
  when {
@@ -49,7 +51,7 @@ when {
49
51
  @reject_message("Content blocked: weapons-related content detected. AI services must not process weapons manufacturing, procurement, or specification content.")
50
52
  forbid (
51
53
  principal,
52
- action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
54
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
53
55
  resource
54
56
  )
55
57
  when {
@@ -70,7 +72,7 @@ when {
70
72
  @reject_message("Content blocked: hate speech or discriminatory content detected. AI services must not process hateful, discriminatory, or dehumanizing content.")
71
73
  forbid (
72
74
  principal,
73
- action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
75
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
74
76
  resource
75
77
  )
76
78
  when {
@@ -90,7 +92,7 @@ when {
90
92
  @reject_message("Content blocked: criminal activity content detected. AI services must not process content related to illegal activities or fraud.")
91
93
  forbid (
92
94
  principal,
93
- action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
95
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
94
96
  resource
95
97
  )
96
98
  when {
@@ -110,7 +112,7 @@ when {
110
112
  @reject_message("Content blocked: sexual content detected. AI services must not process sexually explicit material in enterprise environments.")
111
113
  forbid (
112
114
  principal,
113
- action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
115
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
114
116
  resource
115
117
  )
116
118
  when {
@@ -131,102 +133,10 @@ when {
131
133
  @reject_message("Content blocked: excessive profanity detected. Please rephrase in a professional manner.")
132
134
  forbid (
133
135
  principal,
134
- action in [Sentry::Action::"send_message", Sentry::Action::"paste_content"],
136
+ action == Sentry::Action::"process_prompt",
135
137
  resource
136
138
  )
137
139
  when {
138
140
  context has profanity_score && context.profanity_score >= 90
139
141
  };
140
142
 
141
- // ---------------------------------------------------------------------------
142
- // Section 6: Cut & Paste Safety
143
- // Specific rules for content pasted from external sources into AI chats.
144
- // Paste operations are a primary vector for data leakage.
145
- // ---------------------------------------------------------------------------
146
-
147
- // Block large pastes with any detected threats
148
- @id("sentry-cs-block-large-paste-threats")
149
- @name("Block large pastes with threats")
150
- @description("Block large paste operations (>5000 chars) when any threats are detected. Large pastes with threats likely indicate bulk data dumps from emails, documents, or databases being leaked to AI services.")
151
- @severity("high")
152
- @tags("paste-safety,data-leakage,content-safety")
153
- @reject_message("Large paste operation blocked: security threats were detected in the pasted content. Large data transfers to AI services require threat-free content.")
154
- forbid (
155
- principal,
156
- action == Sentry::Action::"paste_content",
157
- resource
158
- )
159
- when {
160
- context has paste_length && context has threat_count &&
161
- context.paste_length > 5000 && context.threat_count >= 1
162
- };
163
-
164
- // Block pastes containing encoded injection payloads
165
- @id("sentry-cs-block-paste-encoded")
166
- @name("Block encoded paste content")
167
- @description("Block paste operations when encoded injection payloads (base64, hex, unicode) are detected. Attackers use encoding to smuggle injection payloads via clipboard transfer.")
168
- @severity("high")
169
- @tags("paste-safety,encoding,injection,content-safety")
170
- @reject_message("Paste blocked: encoded injection payloads detected in pasted content. Content with hidden encoded instructions cannot be shared with AI services.")
171
- forbid (
172
- principal,
173
- action == Sentry::Action::"paste_content",
174
- resource
175
- )
176
- when {
177
- context has encoded_content_detected && context.encoded_content_detected &&
178
- context has encoded_score && context.encoded_score >= 60
179
- };
180
-
181
- // Block pastes with invisible characters
182
- @id("sentry-cs-block-paste-invisible")
183
- @name("Block paste with invisible characters")
184
- @description("Block paste operations containing invisible Unicode characters (zero-width, bidi overrides). These can hide malicious instructions that appear invisible to users but are processed by AI models.")
185
- @severity("high")
186
- @tags("paste-safety,unicode,invisible-chars,content-safety")
187
- @reject_message("Paste blocked: invisible Unicode characters detected. Hidden characters can disguise malicious instructions that AI models process but users cannot see.")
188
- forbid (
189
- principal,
190
- action == Sentry::Action::"paste_content",
191
- resource
192
- )
193
- when {
194
- context has contains_invisible_chars && context.contains_invisible_chars &&
195
- context has invisible_chars_score && context.invisible_chars_score >= 50
196
- };
197
-
198
- // ---------------------------------------------------------------------------
199
- // Section 7: AI Response Safety
200
- // Block harmful content in AI responses before user sees it.
201
- // ---------------------------------------------------------------------------
202
-
203
- // Block violent/harmful AI responses
204
- @id("sentry-cs-block-response-safety")
205
- @name("Block harmful AI responses")
206
- @description("Block AI responses containing high-severity violent, hateful, or criminal content. Prevents harmful AI-generated content from reaching users in enterprise environments.")
207
- @severity("critical")
208
- @tags("response-safety,content-safety,owasp-llm02")
209
- @reject_message("AI response blocked: harmful content detected in the response. The AI service generated content that violates enterprise content safety policies.")
210
- forbid (
211
- principal,
212
- action == Sentry::Action::"receive_response",
213
- resource
214
- )
215
- when {
216
- context has violence_score && context.violence_score >= 80
217
- };
218
-
219
- @id("sentry-cs-block-response-hate")
220
- @name("Block hateful AI responses")
221
- @description("Block AI responses with hate speech or discriminatory content.")
222
- @severity("critical")
223
- @tags("response-safety,hate-speech,content-safety,owasp-llm02")
224
- @reject_message("AI response blocked: hate speech or discriminatory content detected in the response.")
225
- forbid (
226
- principal,
227
- action == Sentry::Action::"receive_response",
228
- resource
229
- )
230
- when {
231
- context has hate_speech_score && context.hate_speech_score >= 75
232
- };
@@ -1,89 +1,29 @@
1
1
  // =============================================================================
2
2
  // File & Attachment Safety Policy (Default)
3
3
  // =============================================================================
4
- // Enforces document sensitivity controls for files uploaded to AI chat services.
5
- // Integrates with Microsoft Information Protection (MIP) labels to prevent
6
- // confidential and restricted documents from being shared with AI.
4
+ // Blocks file uploads to AI chat services when document content contains
5
+ // secrets or PII.
7
6
  //
8
7
  // Detection layers:
9
- // 1. MIP label enforcementsensitivity_level from document metadata
10
- // 2. PII/secrets in file content — from Shield PIIRegexDetector/SecretsDetector
11
- // 3. Injection payloads in files — from Shield InjectionDetector
12
- // 4. File type restrictions — block dangerous extensions
13
- // 5. Phishing link detection — from CheckPhishDetector
8
+ // 1. Secrets in file content — from Shield SecretsDetector
9
+ // 2. PII in file content — from Shield PIIRegexDetector
14
10
  //
15
11
  // Compliance:
16
- // Microsoft Information Protection (MIP) — label-based access control
17
12
  // NIST 800-53 SC-28 (Protection of Information at Rest)
18
13
  // GDPR Art. 32 (Security of Processing)
19
- // ISO 27001 A.8.2 (Information Classification)
20
14
  //
21
15
  // Category: file_safety
22
16
  // Namespace: Sentry
23
17
  // =============================================================================
24
18
 
25
19
  // ---------------------------------------------------------------------------
26
- // Section 1: MIP Label Enforcement
27
- // Block uploads based on Microsoft Information Protection sensitivity labels.
28
- // Labels are read from document metadata via MIP SDK / Graph API.
20
+ // Section 1: File Content Security
21
+ // Block text files containing secrets or PII.
29
22
  // ---------------------------------------------------------------------------
30
23
 
31
- // Block restricted documents
32
- @id("sentry-file-block-restricted")
33
- @name("Block restricted documents")
34
- @description("Block uploads of documents with 'restricted' sensitivity level. Restricted documents contain the most sensitive data (board materials, M&A, legal privilege) and must never be shared with AI services.")
35
- @severity("critical")
36
- @tags("mip,restricted,classification,compliance,iso-27001")
37
- @reject_message("Upload blocked: this document is classified as RESTRICTED. Restricted documents must never be shared with AI services. Contact your security team if you need to process this content.")
38
- forbid (
39
- principal,
40
- action == Sentry::Action::"upload_file",
41
- resource
42
- )
43
- when {
44
- context has sensitivity_level && context.sensitivity_level == "restricted"
45
- };
46
-
47
- // Block confidential documents
48
- @id("sentry-file-block-confidential")
49
- @name("Block confidential documents")
50
- @description("Block uploads of documents with 'confidential' sensitivity level. Confidential documents (financial reports, customer data, internal strategy) should not be shared with external AI services.")
51
- @severity("critical")
52
- @tags("mip,confidential,classification,compliance,iso-27001")
53
- @reject_message("Upload blocked: this document is classified as CONFIDENTIAL. Confidential documents should not be shared with AI services without explicit authorization.")
54
- forbid (
55
- principal,
56
- action == Sentry::Action::"upload_file",
57
- resource
58
- )
59
- when {
60
- context has sensitivity_level && context.sensitivity_level == "confidential"
61
- };
62
-
63
- // Block rights-managed documents
64
- @id("sentry-file-block-rights-managed")
65
- @name("Block rights-managed documents")
66
- @description("Block uploads of documents with IRM/RMS rights management restrictions. Rights-managed documents have explicit access controls that would be bypassed by sharing with AI services.")
67
- @severity("critical")
68
- @tags("mip,irm,rms,rights-management,compliance")
69
- @reject_message("Upload blocked: this document has rights management restrictions that prohibit sharing with AI services.")
70
- forbid (
71
- principal,
72
- action == Sentry::Action::"upload_file",
73
- resource
74
- )
75
- when {
76
- context has is_rights_managed && context.is_rights_managed
77
- };
78
-
79
- // ---------------------------------------------------------------------------
80
- // Section 2: File Content Security
81
- // Block files containing secrets, PII, or injection payloads.
82
- // ---------------------------------------------------------------------------
83
-
84
- // Block files containing secrets
24
+ // Block text files with secrets
85
25
  @id("sentry-file-block-secrets")
86
- @name("Block files with secrets")
26
+ @name("Block text files with secrets")
87
27
  @description("Block file uploads when secrets or credentials are detected in document content. Prevents uploading configuration files, code, or documents containing API keys, tokens, or passwords to AI services.")
88
28
  @severity("critical")
89
29
  @tags("secrets,file-upload,credentials,nist-sc-28")
@@ -97,9 +37,9 @@ when {
97
37
  context has contains_secrets && context.contains_secrets
98
38
  };
99
39
 
100
- // Block file uploads containing PII
40
+ // Block text files with PII
101
41
  @id("sentry-pii-block-uploads")
102
- @name("Block file uploads with PII")
42
+ @name("Block text files with PII")
103
43
  @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
44
  @severity("critical")
105
45
  @tags("pii,file-upload,data-protection,gdpr-art-32")
@@ -112,63 +52,3 @@ forbid (
112
52
  when {
113
53
  context has pii_detected && context.pii_detected
114
54
  };
115
-
116
- // Block files with phishing links
117
- @id("sentry-file-block-phishing")
118
- @name("Block files with phishing links")
119
- @description("Block file uploads when phishing URLs are detected in document content. Prevents sharing of compromised documents that could expose phishing links to AI processing.")
120
- @severity("high")
121
- @tags("phishing,file-upload,security")
122
- @reject_message("Upload blocked: phishing URLs detected in the file. Documents containing phishing links cannot be shared with AI services.")
123
- forbid (
124
- principal,
125
- action == Sentry::Action::"upload_file",
126
- resource
127
- )
128
- when {
129
- context has phishing_detected && context.phishing_detected
130
- };
131
-
132
- // ---------------------------------------------------------------------------
133
- // Section 3: File Type & Size Restrictions
134
- // Block potentially dangerous file types and oversized files.
135
- // ---------------------------------------------------------------------------
136
-
137
- // Block large file uploads with any threats
138
- @id("sentry-file-block-large-threats")
139
- @name("Block large files with threats")
140
- @description("Block file uploads over 10MB when any threats are detected. Large files with threats likely contain data dumps or bulk exports being exfiltrated to AI services.")
141
- @severity("high")
142
- @tags("file-upload,size-limit,data-protection")
143
- @reject_message("Upload blocked: security threats detected in a large file. Large data transfers to AI services require threat-free content.")
144
- forbid (
145
- principal,
146
- action == Sentry::Action::"upload_file",
147
- resource
148
- )
149
- when {
150
- context has file_size_bytes && context has threat_count &&
151
- context.file_size_bytes > 10485760 && context.threat_count >= 1
152
- };
153
-
154
- // ---------------------------------------------------------------------------
155
- // Section 4: Source Code Protection
156
- // Block source code uploads to AI services.
157
- // ---------------------------------------------------------------------------
158
-
159
- // Block files with high code content
160
- @id("sentry-file-block-source-code")
161
- @name("Block source code uploads")
162
- @description("Block file uploads when source code constitutes more than 80% of the content. Prevents bulk source code exfiltration to external AI services where it may be used for training or exposed.")
163
- @severity("high")
164
- @tags("source-code,ip-protection,file-upload,data-leakage")
165
- @reject_message("Upload blocked: the file appears to be primarily source code (>80%). Bulk source code should not be shared with external AI services to protect intellectual property.")
166
- forbid (
167
- principal,
168
- action == Sentry::Action::"upload_file",
169
- resource
170
- )
171
- when {
172
- context has contains_code && context.contains_code &&
173
- context has code_ratio && context.code_ratio > 80
174
- };
@@ -6,7 +6,6 @@
6
6
  // in clipboard.cedar.
7
7
  //
8
8
  // This template covers:
9
- // - Source code protection in messages (non-paste channels)
10
9
  // - Session-aware threat escalation
11
10
  //
12
11
  // Category: organization
@@ -14,30 +13,7 @@
14
13
  // =============================================================================
15
14
 
16
15
  // ---------------------------------------------------------------------------
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.
20
- // ---------------------------------------------------------------------------
21
-
22
- // Block messages with high code content
23
- @id("sentry-org-block-code-messages")
24
- @name("Block messages with source code")
25
- @description("Block messages when source code constitutes more than 80% of the content. Prevents bulk source code exfiltration to external AI services.")
26
- @severity("high")
27
- @tags("source-code,ip-protection,data-leakage")
28
- @reject_message("Message blocked: the content appears to be primarily source code (>80%). Bulk source code should not be shared with external AI services to protect intellectual property.")
29
- forbid (
30
- principal,
31
- action == Sentry::Action::"send_message",
32
- resource
33
- )
34
- when {
35
- context has contains_code && context.contains_code &&
36
- context has code_ratio && context.code_ratio > 80
37
- };
38
-
39
- // ---------------------------------------------------------------------------
40
- // Section 2: Session-Aware Escalation
16
+ // Section 1: Session-Aware Escalation
41
17
  // Escalate protections when threats are detected across the session.
42
18
  // ---------------------------------------------------------------------------
43
19