@highflame/policy 2.2.3 → 2.2.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 (27) hide show
  1. package/_schemas/ai_gateway/templates/defaults/pii.cedar +164 -0
  2. package/_schemas/ai_gateway/templates/defaults/pii_advanced.cedar +465 -0
  3. package/_schemas/ai_gateway/templates/defaults/pii_model.cedar +90 -0
  4. package/_schemas/ai_gateway/templates/secrets.cedar +46 -0
  5. package/_schemas/ai_gateway/templates/templates.json +88 -11
  6. package/_schemas/guardrails/templates/defaults/pii.cedar +137 -28
  7. package/_schemas/guardrails/templates/defaults/pii_model.cedar +90 -0
  8. package/_schemas/guardrails/templates/profiles/advanced_detection/pii.cedar +433 -31
  9. package/_schemas/guardrails/templates/templates.json +158 -43
  10. package/_schemas/sentry/templates/defaults/clipboard.cedar +3 -18
  11. package/_schemas/sentry/templates/defaults/file_safety.cedar +2 -17
  12. package/_schemas/sentry/templates/defaults/pii.cedar +102 -96
  13. package/_schemas/sentry/templates/defaults/pii_advanced.cedar +465 -0
  14. package/_schemas/sentry/templates/defaults/pii_model.cedar +90 -0
  15. package/_schemas/sentry/templates/templates.json +68 -11
  16. package/dist/ai_gateway-defaults.gen.d.ts +1 -1
  17. package/dist/ai_gateway-defaults.gen.js +838 -59
  18. package/dist/ai_gateway-detectors.gen.js +18 -4
  19. package/dist/guardrails-defaults.gen.js +834 -226
  20. package/dist/overwatch-defaults.gen.js +703 -114
  21. package/dist/overwatch-detectors.gen.js +31 -1
  22. package/dist/sentry-defaults.gen.js +746 -138
  23. package/dist/sentry-detectors.gen.js +109 -2
  24. package/package.json +1 -1
  25. package/_schemas/ai_gateway/templates/pii_redaction.cedar +0 -94
  26. package/_schemas/guardrails/templates/profiles/chat_assistant/privacy.cedar +0 -35
  27. package/_schemas/guardrails/templates/profiles/data_pipeline/privacy.cedar +0 -63
@@ -0,0 +1,90 @@
1
+ // =============================================================================
2
+ // Contextual PII (Tier 2)
3
+ // =============================================================================
4
+ // Blocks the same high-sensitivity identifier groups inferred from surrounding context by the ML PII model — catches unstructured or novel PII the structural patterns miss (higher recall). Requires the pii_model detector.
5
+ //
6
+ // Sensitivity tiers and the structural (regex) / contextual (model) type
7
+ // vocabulary are defined canonically in schemas/_shared/pii_taxonomy.json and
8
+ // enforced by tools/lint-templates.
9
+ //
10
+ // Context keys consumed:
11
+ // - pii_types: Set<String> (union of structural lowercase + contextual uppercase types)
12
+ //
13
+ // Category: privacy
14
+ // Namespace: AIGateway
15
+ // =============================================================================
16
+
17
+ @id("privacy.block-pii-national-id-model")
18
+ @name("Block national ID numbers (contextual)")
19
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a national ID (SSN, passport, or driver's license).")
20
+ @severity("high")
21
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
22
+ @reject_message("Content blocked: national identifier (SSN, passport, or driver's license) patterns detected.")
23
+ forbid (
24
+ principal,
25
+ action in [AIGateway::Action::"process_prompt", AIGateway::Action::"call_tool", AIGateway::Action::"read_file", AIGateway::Action::"write_file"],
26
+ resource
27
+ )
28
+ when {
29
+ context has pii_types && context.pii_types.contains("NATIONAL_ID")
30
+ };
31
+
32
+ @id("privacy.block-pii-credit-card-model")
33
+ @name("Block credit card numbers (contextual)")
34
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credit card number.")
35
+ @severity("critical")
36
+ @tags("category:privacy,threat:pii,detection:ml,compliance:pci-dss,owasp:llm06")
37
+ @reject_message("Content blocked: credit card number patterns detected.")
38
+ forbid (
39
+ principal,
40
+ action in [AIGateway::Action::"process_prompt", AIGateway::Action::"call_tool", AIGateway::Action::"read_file", AIGateway::Action::"write_file"],
41
+ resource
42
+ )
43
+ when {
44
+ context has pii_types && context.pii_types.contains("CREDIT_CARD")
45
+ };
46
+
47
+ @id("privacy.block-pii-bank-account-model")
48
+ @name("Block bank account numbers (contextual)")
49
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a bank account number (IBAN, SWIFT/BIC, or routing number).")
50
+ @severity("critical")
51
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
52
+ @reject_message("Content blocked: bank account (IBAN) number patterns detected.")
53
+ forbid (
54
+ principal,
55
+ action in [AIGateway::Action::"process_prompt", AIGateway::Action::"call_tool", AIGateway::Action::"read_file", AIGateway::Action::"write_file"],
56
+ resource
57
+ )
58
+ when {
59
+ context has pii_types && context.pii_types.contains("ACCOUNT_NUMBER")
60
+ };
61
+
62
+ @id("privacy.block-pii-medical-model")
63
+ @name("Block medical identifiers (contextual)")
64
+ @description("Blocks prompts, tool calls, and file reads/writes that contain medical data (record number, MBI, NPI, or blood type).")
65
+ @severity("medium")
66
+ @tags("category:privacy,threat:pii,detection:ml,compliance:hipaa,owasp:llm06")
67
+ @reject_message("Content blocked: medical record identifier patterns detected.")
68
+ forbid (
69
+ principal,
70
+ action in [AIGateway::Action::"process_prompt", AIGateway::Action::"call_tool", AIGateway::Action::"read_file", AIGateway::Action::"write_file"],
71
+ resource
72
+ )
73
+ when {
74
+ context has pii_types && context.pii_types.contains("MEDICAL")
75
+ };
76
+
77
+ @id("privacy.block-pii-credential-model")
78
+ @name("Block credentials (contextual)")
79
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credential or secret (API key, token, password hash, or private key).")
80
+ @severity("critical")
81
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
82
+ @reject_message("Content blocked: credential or API key patterns detected.")
83
+ forbid (
84
+ principal,
85
+ action in [AIGateway::Action::"process_prompt", AIGateway::Action::"call_tool", AIGateway::Action::"read_file", AIGateway::Action::"write_file"],
86
+ resource
87
+ )
88
+ when {
89
+ context has pii_types && context.pii_types.contains("CREDENTIAL")
90
+ };
@@ -0,0 +1,46 @@
1
+ // =============================================================================
2
+ // Secrets Detection
3
+ // =============================================================================
4
+ // Blocks AI Gateway operations when secrets or credentials are detected in the
5
+ // content. Covers both LLM prompt processing and MCP tool calls. PII is handled
6
+ // by the canonical privacy.* templates (defaults/pii*.cedar).
7
+ //
8
+ // Context keys consumed:
9
+ // - secrets_detected: Bool
10
+ //
11
+ // Compliance:
12
+ // - OWASP LLM06
13
+ //
14
+ // Category: data-protection
15
+ // Namespace: AIGateway
16
+ // =============================================================================
17
+
18
+ @id("data-protection.block-secrets")
19
+ @name("Block secrets in prompts")
20
+ @description("Blocks process_prompt when secrets_detected is true.")
21
+ @severity("critical")
22
+ @tags("category:data-protection,threat:secrets,detection:rule,surface:process-prompt,owasp:llm06")
23
+ @reject_message("Prompt blocked: secrets or credentials were detected — remove sensitive data and retry.")
24
+ forbid (
25
+ principal,
26
+ action == AIGateway::Action::"process_prompt",
27
+ resource
28
+ )
29
+ when {
30
+ context has secrets_detected && context.secrets_detected == true
31
+ };
32
+
33
+ @id("data-protection.block-secrets-tools")
34
+ @name("Block secrets in tool calls")
35
+ @description("Blocks call_tool when secrets_detected is true.")
36
+ @severity("critical")
37
+ @tags("category:data-protection,threat:secrets,detection:rule,surface:call-tool,owasp:llm06")
38
+ @reject_message("Tool execution blocked: secrets or credentials were detected in tool arguments.")
39
+ forbid (
40
+ principal,
41
+ action == AIGateway::Action::"call_tool",
42
+ resource
43
+ )
44
+ when {
45
+ context has secrets_detected && context.secrets_detected == true
46
+ };
@@ -21,7 +21,12 @@
21
21
  {
22
22
  "id": "data-protection",
23
23
  "name": "Data Protection",
24
- "description": "Prevent secrets and PII leakage in LLM chat completions and MCP operations."
24
+ "description": "Prevent secrets leakage in LLM chat completions and MCP operations."
25
+ },
26
+ {
27
+ "id": "privacy",
28
+ "name": "Privacy",
29
+ "description": "Block personally identifiable information (PII) in LLM prompts and MCP tool calls."
25
30
  },
26
31
  {
27
32
  "id": "organization",
@@ -59,7 +64,13 @@
59
64
  "category": "semantic",
60
65
  "file": "defaults/semantic.cedar",
61
66
  "severity": "critical",
62
- "tags": ["category:semantic", "threat:injection", "threat:jailbreak", "owasp:llm01", "owasp:llm02"]
67
+ "tags": [
68
+ "category:semantic",
69
+ "threat:injection",
70
+ "threat:jailbreak",
71
+ "owasp:llm01",
72
+ "owasp:llm02"
73
+ ]
63
74
  },
64
75
  {
65
76
  "id": "tools.defaults",
@@ -68,7 +79,12 @@
68
79
  "category": "tools",
69
80
  "file": "defaults/tools.cedar",
70
81
  "severity": "critical",
71
- "tags": ["category:tools", "threat:command-injection", "owasp:llm06", "owasp:asi02"]
82
+ "tags": [
83
+ "category:tools",
84
+ "threat:command-injection",
85
+ "owasp:llm06",
86
+ "owasp:asi02"
87
+ ]
72
88
  },
73
89
  {
74
90
  "id": "agent-security.defaults",
@@ -77,7 +93,15 @@
77
93
  "category": "agent-security",
78
94
  "file": "defaults/agent_security.cedar",
79
95
  "severity": "critical",
80
- "tags": ["category:agent-security", "threat:tool-poisoning", "threat:rug-pull", "threat:indirect-injection", "threat:supply-chain", "owasp:asi01", "owasp:asi04"]
96
+ "tags": [
97
+ "category:agent-security",
98
+ "threat:tool-poisoning",
99
+ "threat:rug-pull",
100
+ "threat:indirect-injection",
101
+ "threat:supply-chain",
102
+ "owasp:asi01",
103
+ "owasp:asi04"
104
+ ]
81
105
  },
82
106
  {
83
107
  "id": "tools.mcp-server-allowlist",
@@ -95,16 +119,65 @@
95
119
  "category": "tools",
96
120
  "file": "mcp_tool_permissions.cedar",
97
121
  "severity": "critical",
98
- "tags": ["category:tools", "threat:supply-chain", "posture:permit-default"]
122
+ "tags": [
123
+ "category:tools",
124
+ "threat:supply-chain",
125
+ "posture:permit-default"
126
+ ]
99
127
  },
100
128
  {
101
- "id": "data-protection.pii-redaction",
102
- "name": "PII & Secrets Redaction",
103
- "description": "Block requests containing PII or secrets across LLM prompts and MCP tool calls.",
129
+ "id": "data-protection.secrets",
130
+ "name": "Secrets Detection",
131
+ "description": "Block requests containing secrets or credentials across LLM prompts and MCP tool calls.",
104
132
  "category": "data-protection",
105
- "file": "pii_redaction.cedar",
133
+ "file": "secrets.cedar",
134
+ "severity": "critical",
135
+ "tags": ["category:data-protection", "threat:secrets", "owasp:llm06"]
136
+ },
137
+ {
138
+ "id": "privacy.defaults",
139
+ "name": "Structural PII",
140
+ "description": "Block well-formatted sensitive identifiers — SSNs, credit cards, IBANs, API keys — via fast deterministic pattern matching. High precision, low latency, few false positives; use as the always-on baseline.",
141
+ "category": "privacy",
142
+ "file": "defaults/pii.cedar",
143
+ "severity": "critical",
144
+ "tags": [
145
+ "category:privacy",
146
+ "threat:pii",
147
+ "detection:pattern",
148
+ "compliance:pci-dss",
149
+ "compliance:hipaa"
150
+ ]
151
+ },
152
+ {
153
+ "id": "privacy.pii-model",
154
+ "name": "Contextual PII",
155
+ "description": "Block the same sensitive identifiers when the ML model infers them from surrounding context — catches unstructured or novel PII the structural patterns miss. Higher recall; requires the pii_model detector.",
156
+ "category": "privacy",
157
+ "file": "defaults/pii_model.cedar",
158
+ "severity": "critical",
159
+ "tags": [
160
+ "category:privacy",
161
+ "threat:pii",
162
+ "detection:ml",
163
+ "compliance:pci-dss",
164
+ "compliance:hipaa"
165
+ ]
166
+ },
167
+ {
168
+ "id": "privacy.advanced-pii",
169
+ "name": "Comprehensive PII",
170
+ "description": "Block every PII type — structural and contextual, sensitive and situational. Situational entities (names, locations, dates, etc.) are real PII but appear in ordinary text, so this tier flags often; one forbid rule per entity lets you disable the ones you don't need. Opt-in for strict environments.",
171
+ "category": "privacy",
172
+ "file": "defaults/pii_advanced.cedar",
106
173
  "severity": "critical",
107
- "tags": ["category:data-protection", "threat:pii", "threat:secrets", "threat:exfiltration", "owasp:llm06"]
174
+ "tags": [
175
+ "category:privacy",
176
+ "threat:pii",
177
+ "detection:pattern",
178
+ "compliance:pci-dss",
179
+ "compliance:hipaa"
180
+ ]
108
181
  },
109
182
  {
110
183
  "id": "organization.permit-llm-default",
@@ -113,7 +186,11 @@
113
186
  "category": "organization",
114
187
  "file": "llm_default_allow.cedar",
115
188
  "severity": "low",
116
- "tags": ["category:organization", "surface:process-prompt", "posture:permit-default"]
189
+ "tags": [
190
+ "category:organization",
191
+ "surface:process-prompt",
192
+ "posture:permit-default"
193
+ ]
117
194
  }
118
195
  ]
119
196
  }
@@ -1,55 +1,164 @@
1
1
  // =============================================================================
2
- // PII Detection (Default)
2
+ // Structural PII (Tier 1)
3
3
  // =============================================================================
4
- // Blocks LLM responses that contain personally identifiable information,
5
- // with a stricter rule for the most sensitive PII types (SSN, credit card,
6
- // passport).
4
+ // Blocks high-sensitivity identifiers that have a deterministic structure (SSNs, credit cards, IBANs, API keys) using fast regex pattern matching — high precision, low latency, few false positives. One forbid rule per identifier group.
7
5
  //
8
- // Context keys consumed:
9
- // - pii_detected: Bool
10
- // - pii_types: Set<String>
11
- // - direction: String ("input" | "output")
6
+ // Sensitivity tiers and the structural (regex) / contextual (model) type
7
+ // vocabulary are defined canonically in schemas/_shared/pii_taxonomy.json and
8
+ // enforced by tools/lint-templates.
12
9
  //
13
- // Compliance:
14
- // - GDPR, HIPAA, PCI-DSS (depending on data classification)
10
+ // Context keys consumed:
11
+ // - pii_types: Set<String> (union of structural lowercase + contextual uppercase types)
15
12
  //
16
13
  // Category: privacy
17
14
  // Namespace: Guardrails
18
15
  // =============================================================================
19
16
 
20
- @id("privacy.block-pii-output")
21
- @name("Block PII in outputs")
22
- @description("Blocks process_prompt outputs when pii_detected is true.")
17
+ @id("privacy.block-pii-national-id")
18
+ @name("Block national ID numbers (structural)")
19
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a national ID (SSN, passport, or driver's license).")
23
20
  @severity("high")
24
- @tags("category:privacy,threat:pii,detection:rule,surface:process-prompt,compliance:gdpr")
25
- @reject_message("Response blocked: personally identifiable information was detected in the output.")
21
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
22
+ @reject_message("Content blocked: national identifier (SSN, passport, or driver's license) patterns detected.")
26
23
  forbid (
27
24
  principal,
28
- action == Guardrails::Action::"process_prompt",
25
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
29
26
  resource
30
27
  )
31
28
  when {
32
- context has pii_detected && context.pii_detected == true &&
33
- context has direction && context.direction == "output"
29
+ context has pii_types &&
30
+ (
31
+ context.pii_types.contains("ssn") ||
32
+ context.pii_types.contains("passport") ||
33
+ context.pii_types.contains("national_id") ||
34
+ context.pii_types.contains("drivers_license")
35
+ )
34
36
  };
35
37
 
36
- @id("privacy.block-pii-sensitive")
37
- @name("Block sensitive PII types in outputs")
38
- @description("Blocks process_prompt outputs when pii_types contains SSN, credit_card, or passport.")
38
+ @id("privacy.block-pii-credit-card")
39
+ @name("Block credit card numbers (structural)")
40
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credit card number.")
39
41
  @severity("critical")
40
- @tags("category:privacy,threat:pii,detection:rule,surface:process-prompt,compliance:gdpr,compliance:hipaa,compliance:pci-dss")
41
- @reject_message("Response blocked: highly sensitive PII (SSN, credit card, or passport) was detected.")
42
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:pci-dss,owasp:llm06")
43
+ @reject_message("Content blocked: credit card number patterns detected.")
42
44
  forbid (
43
45
  principal,
44
- action == Guardrails::Action::"process_prompt",
46
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
47
+ resource
48
+ )
49
+ when {
50
+ context has pii_types && context.pii_types.contains("credit_card")
51
+ };
52
+
53
+ @id("privacy.block-pii-bank-account")
54
+ @name("Block bank account numbers (structural)")
55
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a bank account number (IBAN, SWIFT/BIC, or routing number).")
56
+ @severity("critical")
57
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
58
+ @reject_message("Content blocked: bank account (IBAN) number patterns detected.")
59
+ forbid (
60
+ principal,
61
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
45
62
  resource
46
63
  )
47
64
  when {
48
- context has direction && context.direction == "output" &&
49
65
  context has pii_types &&
50
66
  (
51
- context.pii_types.contains("ssn") ||
52
- context.pii_types.contains("credit_card") ||
53
- context.pii_types.contains("passport")
67
+ context.pii_types.contains("iban") ||
68
+ context.pii_types.contains("bank_account") ||
69
+ context.pii_types.contains("swift_bic") ||
70
+ context.pii_types.contains("aba_routing")
71
+ )
72
+ };
73
+
74
+ @id("privacy.block-pii-medical")
75
+ @name("Block medical identifiers (structural)")
76
+ @description("Blocks prompts, tool calls, and file reads/writes that contain medical data (record number, MBI, NPI, or blood type).")
77
+ @severity("medium")
78
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:hipaa,owasp:llm06")
79
+ @reject_message("Content blocked: medical record identifier patterns detected.")
80
+ forbid (
81
+ principal,
82
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
83
+ resource
84
+ )
85
+ when {
86
+ context has pii_types &&
87
+ (
88
+ context.pii_types.contains("medical_record") ||
89
+ context.pii_types.contains("patient_record") ||
90
+ context.pii_types.contains("medicare_beneficiary_id") ||
91
+ context.pii_types.contains("npi") ||
92
+ context.pii_types.contains("medical_term") ||
93
+ context.pii_types.contains("blood_type")
94
+ )
95
+ };
96
+
97
+ @id("privacy.block-pii-tax-id")
98
+ @name("Block tax identifiers (structural)")
99
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a tax ID (ITIN, EIN, or PTIN).")
100
+ @severity("high")
101
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
102
+ @reject_message("Content blocked: tax identifier (ITIN or EIN) patterns detected.")
103
+ forbid (
104
+ principal,
105
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
106
+ resource
107
+ )
108
+ when {
109
+ context has pii_types &&
110
+ (
111
+ context.pii_types.contains("itin") ||
112
+ context.pii_types.contains("ein") ||
113
+ context.pii_types.contains("ptin")
114
+ )
115
+ };
116
+
117
+ @id("privacy.block-pii-credential")
118
+ @name("Block credentials (structural)")
119
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credential or secret (API key, token, password hash, or private key).")
120
+ @severity("critical")
121
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
122
+ @reject_message("Content blocked: credential or API key patterns detected.")
123
+ forbid (
124
+ principal,
125
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
126
+ resource
127
+ )
128
+ when {
129
+ context has pii_types &&
130
+ (
131
+ context.pii_types.contains("aws_access_key") ||
132
+ context.pii_types.contains("api_key") ||
133
+ context.pii_types.contains("jwt_token") ||
134
+ context.pii_types.contains("encryption_key") ||
135
+ context.pii_types.contains("http_basic_auth") ||
136
+ context.pii_types.contains("gcp_credential") ||
137
+ context.pii_types.contains("gcp_api_key") ||
138
+ context.pii_types.contains("gcp_signed_policy") ||
139
+ context.pii_types.contains("session_cookie") ||
140
+ context.pii_types.contains("oauth_token") ||
141
+ context.pii_types.contains("tls_certificate") ||
142
+ context.pii_types.contains("password_hash") ||
143
+ context.pii_types.contains("csrf_token")
144
+ )
145
+ };
146
+
147
+ @id("privacy.block-pii-crypto")
148
+ @name("Block cryptocurrency addresses (structural)")
149
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a cryptocurrency wallet address.")
150
+ @severity("high")
151
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
152
+ @reject_message("Content blocked: cryptocurrency wallet address patterns detected.")
153
+ forbid (
154
+ principal,
155
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
156
+ resource
157
+ )
158
+ when {
159
+ context has pii_types &&
160
+ (
161
+ context.pii_types.contains("bitcoin_address") ||
162
+ context.pii_types.contains("ethereum_address")
54
163
  )
55
164
  };
@@ -0,0 +1,90 @@
1
+ // =============================================================================
2
+ // Contextual PII (Tier 2)
3
+ // =============================================================================
4
+ // Blocks the same high-sensitivity identifier groups inferred from surrounding context by the ML PII model — catches unstructured or novel PII the structural patterns miss (higher recall). Requires the pii_model detector.
5
+ //
6
+ // Sensitivity tiers and the structural (regex) / contextual (model) type
7
+ // vocabulary are defined canonically in schemas/_shared/pii_taxonomy.json and
8
+ // enforced by tools/lint-templates.
9
+ //
10
+ // Context keys consumed:
11
+ // - pii_types: Set<String> (union of structural lowercase + contextual uppercase types)
12
+ //
13
+ // Category: privacy
14
+ // Namespace: Guardrails
15
+ // =============================================================================
16
+
17
+ @id("privacy.block-pii-national-id-model")
18
+ @name("Block national ID numbers (contextual)")
19
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a national ID (SSN, passport, or driver's license).")
20
+ @severity("high")
21
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
22
+ @reject_message("Content blocked: national identifier (SSN, passport, or driver's license) patterns detected.")
23
+ forbid (
24
+ principal,
25
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
26
+ resource
27
+ )
28
+ when {
29
+ context has pii_types && context.pii_types.contains("NATIONAL_ID")
30
+ };
31
+
32
+ @id("privacy.block-pii-credit-card-model")
33
+ @name("Block credit card numbers (contextual)")
34
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credit card number.")
35
+ @severity("critical")
36
+ @tags("category:privacy,threat:pii,detection:ml,compliance:pci-dss,owasp:llm06")
37
+ @reject_message("Content blocked: credit card number patterns detected.")
38
+ forbid (
39
+ principal,
40
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
41
+ resource
42
+ )
43
+ when {
44
+ context has pii_types && context.pii_types.contains("CREDIT_CARD")
45
+ };
46
+
47
+ @id("privacy.block-pii-bank-account-model")
48
+ @name("Block bank account numbers (contextual)")
49
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a bank account number (IBAN, SWIFT/BIC, or routing number).")
50
+ @severity("critical")
51
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
52
+ @reject_message("Content blocked: bank account (IBAN) number patterns detected.")
53
+ forbid (
54
+ principal,
55
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
56
+ resource
57
+ )
58
+ when {
59
+ context has pii_types && context.pii_types.contains("ACCOUNT_NUMBER")
60
+ };
61
+
62
+ @id("privacy.block-pii-medical-model")
63
+ @name("Block medical identifiers (contextual)")
64
+ @description("Blocks prompts, tool calls, and file reads/writes that contain medical data (record number, MBI, NPI, or blood type).")
65
+ @severity("medium")
66
+ @tags("category:privacy,threat:pii,detection:ml,compliance:hipaa,owasp:llm06")
67
+ @reject_message("Content blocked: medical record identifier patterns detected.")
68
+ forbid (
69
+ principal,
70
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
71
+ resource
72
+ )
73
+ when {
74
+ context has pii_types && context.pii_types.contains("MEDICAL")
75
+ };
76
+
77
+ @id("privacy.block-pii-credential-model")
78
+ @name("Block credentials (contextual)")
79
+ @description("Blocks prompts, tool calls, and file reads/writes that contain a credential or secret (API key, token, password hash, or private key).")
80
+ @severity("critical")
81
+ @tags("category:privacy,threat:pii,detection:ml,owasp:llm06")
82
+ @reject_message("Content blocked: credential or API key patterns detected.")
83
+ forbid (
84
+ principal,
85
+ action in [Guardrails::Action::"process_prompt", Guardrails::Action::"call_tool", Guardrails::Action::"read_file", Guardrails::Action::"write_file"],
86
+ resource
87
+ )
88
+ when {
89
+ context has pii_types && context.pii_types.contains("CREDENTIAL")
90
+ };