@highflame/policy 2.1.3 → 2.1.5

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 (43) hide show
  1. package/README.md +41 -0
  2. package/_schemas/guardrails/context.json +466 -76
  3. package/_schemas/guardrails/schema.cedarschema +39 -3
  4. package/_schemas/guardrails/templates/defaults/injection.cedar +6 -6
  5. package/_schemas/guardrails/templates/profiles/chat_assistant/security.cedar +2 -2
  6. package/_schemas/guardrails/templates/profiles/data_pipeline/security.cedar +1 -1
  7. package/_schemas/overwatch/context.json +443 -5
  8. package/_schemas/overwatch/schema.cedarschema +42 -4
  9. package/_schemas/palisade/context.json +1 -1
  10. package/_schemas/sentry/context.json +1165 -0
  11. package/_schemas/sentry/schema.cedarschema +388 -0
  12. package/_schemas/sentry/templates/defaults/baseline.cedar +24 -0
  13. package/_schemas/sentry/templates/defaults/content_safety.cedar +232 -0
  14. package/_schemas/sentry/templates/defaults/file_safety.cedar +174 -0
  15. package/_schemas/sentry/templates/defaults/organization.cedar +207 -0
  16. package/_schemas/sentry/templates/defaults/pii.cedar +229 -0
  17. package/_schemas/sentry/templates/defaults/semantic.cedar +167 -0
  18. package/_schemas/sentry/templates/templates.json +93 -0
  19. package/dist/builder.d.ts +32 -0
  20. package/dist/builder.js +6 -6
  21. package/dist/condition-groups.d.ts +69 -0
  22. package/dist/condition-groups.js +305 -0
  23. package/dist/guardrails-context.gen.d.ts +19 -2
  24. package/dist/guardrails-context.gen.js +19 -2
  25. package/dist/guardrails-defaults.gen.js +9 -9
  26. package/dist/index.d.ts +6 -1
  27. package/dist/index.js +6 -1
  28. package/dist/overwatch-context.gen.d.ts +17 -0
  29. package/dist/overwatch-context.gen.js +17 -0
  30. package/dist/sentry-context.gen.d.ts +76 -0
  31. package/dist/sentry-context.gen.js +77 -0
  32. package/dist/sentry-defaults.gen.d.ts +61 -0
  33. package/dist/sentry-defaults.gen.js +1235 -0
  34. package/dist/sentry-entities.gen.d.ts +11 -0
  35. package/dist/sentry-entities.gen.js +33 -0
  36. package/dist/service-schemas.gen.d.ts +12 -2
  37. package/dist/service-schemas.gen.js +861 -25
  38. package/dist/types.d.ts +6 -1
  39. package/dist/types.js +6 -1
  40. package/package.json +1 -1
  41. package/_schemas/guardrails/templates/profiles/chat_assistant.cedar +0 -85
  42. package/_schemas/guardrails/templates/profiles/code_agent.cedar +0 -125
  43. package/_schemas/guardrails/templates/profiles/data_pipeline.cedar +0 -111
@@ -0,0 +1,174 @@
1
+ // =============================================================================
2
+ // File & Attachment Safety Policy (Default)
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.
7
+ //
8
+ // Detection layers:
9
+ // 1. MIP label enforcement — sensitivity_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
14
+ //
15
+ // Compliance:
16
+ // Microsoft Information Protection (MIP) — label-based access control
17
+ // NIST 800-53 SC-28 (Protection of Information at Rest)
18
+ // GDPR Art. 32 (Security of Processing)
19
+ // ISO 27001 A.8.2 (Information Classification)
20
+ //
21
+ // Category: file_safety
22
+ // Namespace: Sentry
23
+ // =============================================================================
24
+
25
+ // ---------------------------------------------------------------------------
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.
29
+ // ---------------------------------------------------------------------------
30
+
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
85
+ @id("sentry-file-block-secrets")
86
+ @name("Block files with secrets")
87
+ @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
+ @severity("critical")
89
+ @tags("secrets,file-upload,credentials,nist-sc-28")
90
+ @reject_message("Upload blocked: secrets or credentials detected in the file. Files containing API keys, tokens, or passwords must not be shared with AI services.")
91
+ forbid (
92
+ principal,
93
+ action == Sentry::Action::"upload_file",
94
+ resource
95
+ )
96
+ when {
97
+ context has contains_secrets && context.contains_secrets
98
+ };
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.")
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.")
107
+ forbid (
108
+ principal,
109
+ action == Sentry::Action::"upload_file",
110
+ resource
111
+ )
112
+ when {
113
+ context has pii_count && context.pii_count >= 3
114
+ };
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
+ };
@@ -0,0 +1,207 @@
1
+ // =============================================================================
2
+ // Organization Rules Policy (Default)
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
8
+ //
9
+ // These rules complement category-specific policies (PII, Content Safety,
10
+ // File Safety) with cross-cutting organizational controls.
11
+ //
12
+ // Category: organization
13
+ // Namespace: Sentry
14
+ // =============================================================================
15
+
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.
136
+ // ---------------------------------------------------------------------------
137
+
138
+ // Block messages with high code content
139
+ @id("sentry-org-block-code-messages")
140
+ @name("Block messages with source code")
141
+ @description("Block messages when source code constitutes more than 80% of the content. Prevents bulk source code exfiltration to external AI services.")
142
+ @severity("high")
143
+ @tags("source-code,ip-protection,data-leakage")
144
+ @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.")
145
+ forbid (
146
+ principal,
147
+ action == Sentry::Action::"send_message",
148
+ resource
149
+ )
150
+ when {
151
+ context has contains_code && context.contains_code &&
152
+ context has code_ratio && context.code_ratio > 80
153
+ };
154
+
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
+ // ---------------------------------------------------------------------------
173
+ // Section 3: Session-Aware Escalation
174
+ // Escalate protections when threats are detected across the session.
175
+ // ---------------------------------------------------------------------------
176
+
177
+ // Block all actions after repeated threat detection
178
+ @id("sentry-org-session-threat-escalation")
179
+ @name("Escalate after repeated threats")
180
+ @description("Block all actions when threats have been detected in 3+ turns of the session. Repeated threat detections indicate either a persistent attacker or a compromised data source requiring investigation.")
181
+ @severity("high")
182
+ @tags("session,escalation,behavioral,defense-in-depth")
183
+ @reject_message("Session blocked: security threats have been detected in multiple turns of this conversation. This session has been flagged for review. Please start a new session or contact your security team.")
184
+ forbid (
185
+ principal,
186
+ action,
187
+ resource
188
+ )
189
+ when {
190
+ context has session_threat_turns && context.session_threat_turns >= 3
191
+ };
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
+ };
@@ -0,0 +1,229 @@
1
+ // =============================================================================
2
+ // PII Detection Policy (Default)
3
+ // =============================================================================
4
+ // Detects and blocks personally identifiable information across messages,
5
+ // pasted content, file uploads, and AI responses. Uses multi-layered detection:
6
+ //
7
+ // 1. PII boolean flag (pii_detected) — broadest catch from detection engine
8
+ // 2. Granular PII type matching (pii_types) — type-specific blocking
9
+ // 3. PII confidence score (pii_confidence) — ML classifier confidence
10
+ // 4. Detection rule triggers (detected_threats) — named rule matches
11
+ // 5. Bulk PII exposure (pii_count) — data dump prevention
12
+ //
13
+ // PII Types Detected by Shield PIIRegexDetector:
14
+ // ssn, credit_card, email, phone_us, ip_address, date_of_birth,
15
+ // passport, iban, aws_key, api_key_generic
16
+ //
17
+ // Compliance:
18
+ // PCI DSS 3.4, 4.1 (Payment Card Data)
19
+ // GDPR Art. 32 (Security of Processing)
20
+ // HIPAA §164.312 (Technical Safeguards)
21
+ // CCPA §1798.150 (Data Protection)
22
+ // OWASP LLM06 (Sensitive Information Disclosure)
23
+ //
24
+ // Category: pii
25
+ // Namespace: Sentry
26
+ // =============================================================================
27
+
28
+ // ---------------------------------------------------------------------------
29
+ // Section 1: Primary PII Detection
30
+ // Fires when the detection pipeline identifies PII in any content.
31
+ // ---------------------------------------------------------------------------
32
+
33
+ // Block messages containing detected PII
34
+ @id("sentry-pii-block-messages")
35
+ @name("Block messages with PII")
36
+ @description("Block messages when the detection engine identifies any PII patterns. Prevents employees from accidentally sharing personal data with AI chat services.")
37
+ @severity("critical")
38
+ @tags("pii,privacy,data-protection,gdpr-art-32,owasp-llm06")
39
+ @reject_message("Your message was blocked because personally identifiable information was detected. Remove all PII (names, addresses, SSNs, credit cards, etc.) before sending to AI services.")
40
+ forbid (
41
+ principal,
42
+ action == Sentry::Action::"send_message",
43
+ resource
44
+ )
45
+ when {
46
+ context has pii_detected && context.pii_detected
47
+ };
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
+ // ---------------------------------------------------------------------------
82
+ // Section 2: Granular PII Type Blocking
83
+ // Blocks specific PII types based on regulatory requirements.
84
+ // ---------------------------------------------------------------------------
85
+
86
+ // Block credit card numbers (PCI DSS compliance)
87
+ @id("sentry-pii-block-credit-cards")
88
+ @name("Block credit card numbers")
89
+ @description("Block content containing credit card number patterns across all actions. PCI DSS 3.4 requires PANs are rendered unreadable — AI services must never receive raw card numbers.")
90
+ @severity("critical")
91
+ @tags("pci,credit-card,payment,compliance,pci-dss-3.4")
92
+ @reject_message("Content blocked: credit card number patterns detected. Sharing payment card data with AI services violates PCI DSS. Use tokenized references instead.")
93
+ forbid (
94
+ principal,
95
+ action,
96
+ resource
97
+ )
98
+ when {
99
+ (context has pii_types && context.pii_types.contains("credit_card")) ||
100
+ (context has detected_threats && context.detected_threats.contains("credit_card"))
101
+ };
102
+
103
+ // Block Social Security Numbers
104
+ @id("sentry-pii-block-ssn")
105
+ @name("Block Social Security Numbers")
106
+ @description("Block content containing SSN patterns (XXX-XX-XXXX and variants). SSNs are high-value identity theft targets — exposure through AI services is a critical privacy violation.")
107
+ @severity("critical")
108
+ @tags("ssn,identity,privacy,compliance,nist-si-4")
109
+ @reject_message("Content blocked: Social Security Number patterns detected. SSNs must never be shared with AI services.")
110
+ forbid (
111
+ principal,
112
+ action,
113
+ resource
114
+ )
115
+ when {
116
+ (context has pii_types && context.pii_types.contains("ssn")) ||
117
+ (context has detected_threats && context.detected_threats.contains("ssn"))
118
+ };
119
+
120
+ // Block passport numbers
121
+ @id("sentry-pii-block-passport")
122
+ @name("Block passport numbers")
123
+ @description("Block content containing passport number patterns. Passport numbers are government-issued identifiers with high identity theft risk.")
124
+ @severity("critical")
125
+ @tags("passport,identity,privacy,gdpr")
126
+ @reject_message("Content blocked: passport number patterns detected. Government-issued identifiers must not be shared with AI services.")
127
+ forbid (
128
+ principal,
129
+ action,
130
+ resource
131
+ )
132
+ when {
133
+ context has pii_types && context.pii_types.contains("passport")
134
+ };
135
+
136
+ // Block IBAN (International Bank Account Numbers)
137
+ @id("sentry-pii-block-iban")
138
+ @name("Block bank account numbers")
139
+ @description("Block content containing IBAN patterns. Bank account numbers are sensitive financial identifiers that must not be exposed to AI services.")
140
+ @severity("critical")
141
+ @tags("iban,financial,privacy,gdpr,pci-dss")
142
+ @reject_message("Content blocked: bank account number (IBAN) patterns detected. Financial account numbers must not be shared with AI services.")
143
+ forbid (
144
+ principal,
145
+ action,
146
+ resource
147
+ )
148
+ when {
149
+ context has pii_types && context.pii_types.contains("iban")
150
+ };
151
+
152
+ // Block bulk PII exposure
153
+ @id("sentry-pii-block-bulk-exposure")
154
+ @name("Block bulk PII exposure")
155
+ @description("Block content containing 3 or more PII matches. Multiple PII items indicate a data dump — customer lists, CSV exports, or database content being leaked to AI services.")
156
+ @severity("critical")
157
+ @tags("pii,bulk,data-exfiltration,gdpr-art-32,ccpa")
158
+ @reject_message("Content blocked: multiple PII items detected (3+). Bulk personal data must never be shared with AI services. Use data masking or tokenization.")
159
+ forbid (
160
+ principal,
161
+ action,
162
+ resource
163
+ )
164
+ when {
165
+ context has pii_count && context.pii_count >= 3
166
+ };
167
+
168
+ // ---------------------------------------------------------------------------
169
+ // Section 3: PII Confidence Detection
170
+ // Catches PII patterns via ML classifier that escape regex detection.
171
+ // ---------------------------------------------------------------------------
172
+
173
+ // Block high-confidence PII
174
+ @id("sentry-pii-block-high-confidence")
175
+ @name("Block high-confidence PII")
176
+ @description("Block content when the PII confidence score exceeds threshold (80/100). Catches novel PII patterns including names, addresses, and identifiers that regex rules may miss.")
177
+ @severity("critical")
178
+ @tags("pii,confidence,privacy,compliance,ml-classifier")
179
+ @reject_message("Content blocked: the ML classifier detected personally identifiable information with high confidence. The content appears to contain personal data.")
180
+ forbid (
181
+ principal,
182
+ action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
183
+ resource
184
+ )
185
+ when {
186
+ context has pii_confidence && context.pii_confidence >= 80
187
+ };
188
+
189
+ // ---------------------------------------------------------------------------
190
+ // Section 4: PII Threat Category
191
+ // Defense-in-depth via threat aggregation layer.
192
+ // ---------------------------------------------------------------------------
193
+
194
+ // Block PII threat category
195
+ @id("sentry-pii-block-threat-category")
196
+ @name("Block PII threat category")
197
+ @description("Block content when threat categorization identifies PII. Defense-in-depth behind the pii_detected boolean — catches cases where PII is flagged at the aggregation layer.")
198
+ @severity("high")
199
+ @tags("pii,privacy,data-protection,gdpr")
200
+ @reject_message("Content blocked: threat scanners detected personally identifiable information. Remove all PII before submitting.")
201
+ forbid (
202
+ principal,
203
+ action in [Sentry::Action::"send_message", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
204
+ resource
205
+ )
206
+ when {
207
+ context has threat_categories && context.threat_categories.contains("pii")
208
+ };
209
+
210
+ // ---------------------------------------------------------------------------
211
+ // Section 5: AI Response PII Blocking
212
+ // Prevent AI responses containing PII from reaching the user.
213
+ // ---------------------------------------------------------------------------
214
+
215
+ // Block AI responses containing PII
216
+ @id("sentry-pii-block-responses")
217
+ @name("Block AI responses with PII")
218
+ @description("Block AI responses when PII is detected in the output. Prevents AI services from exposing personal data in generated responses (e.g., when the model echoes back or generates PII from training data).")
219
+ @severity("high")
220
+ @tags("pii,response-safety,data-protection,owasp-llm06")
221
+ @reject_message("AI response blocked: personally identifiable information detected in the AI response. The AI service generated content containing personal data.")
222
+ forbid (
223
+ principal,
224
+ action == Sentry::Action::"receive_response",
225
+ resource
226
+ )
227
+ when {
228
+ context has pii_detected && context.pii_detected
229
+ };