PII Detector
The pii-detector policy is the shared PII redaction control. It checks request
content before the upstream call. It also redacts supported buffered responses.
For SSE traffic, the gateway buffers the assistant text before it emits the
redacted stream.
Configuration
pack:
name: pii-protection
version: "1.0.0"
enabled: true
policies:
chain:
- pii-detector
policy:
pii-detector:
action: redact
healthcare_mode: false
pci_mode: true
detect_patterns: []
redaction:
marker_format: label
include_metadata: true
preserve_length: false
custom_markers: {}
Fields
| Field | Type | Description | Default |
|---|---|---|---|
action | "redact" | "block" | Controls the request-phase verdict. redact marks input for redaction. block rejects input. Output continues to use shared redaction. | "redact" |
healthcare_mode | boolean | Adds HIPAA text checks for names, addresses, fax numbers, MRNs, health-plan IDs, license numbers, device IDs, and biometric terms. | false |
pci_mode | boolean | Enables PCI detection for PAN/card numbers, CVV/CVC values, and expiration dates. Today it does not detect cardholder names. | true |
detect_patterns | string[] | More regexes evaluated against request and response text. Matches from these regexes are recorded as the generic generic_id type. Named capture groups do not create custom labels. | [] |
redaction.marker_format | "label" | "asterisk" | "partial" | label uses markers such as [REDACTED:SSN]. asterisk uses asterisks. partial has special masks only for SSNs, PANs, and email. | "label" |
redaction.include_metadata | boolean | Emits detailed redaction metadata, including replacement spans and span hashes. | true |
redaction.preserve_length | boolean | Keeps the input character length for asterisk replacements. | false |
redaction.custom_markers | object | Overrides replacements by marker key. Use lowercase keys such as ssn, email, mrn, or generic_id. Custom regex matches use generic_id. | {} |
What the detector actually matches
Base detector
Always-active matching includes:
- email addresses
- SSNs
- phone numbers
- public IPv4 and IPv6 addresses
- URLs with identifying paths or queries
- MAC addresses, IMEIs, and VINs
- ZIP codes and dates
- account numbers and routing-like identifiers
- license plates
Healthcare mode rules
When healthcare_mode: true, the shared redaction pipeline also runs HIPAA-style heuristics for:
- names
- address and city terms
- fax numbers
- MRNs
- health-plan or policy identifiers
- certificate and driver's license numbers
- device IDs
- biometric terms
- photo or facial-image terms
PCI mode rules
When pci_mode: true, the policy adds:
- payment card numbers (PAN)
- CVV/CVC values
- expiration dates
How it works
- Request phase: The gateway checks one string made from the request messages.
- Detection: It runs the base detector and optional HIPAA and PCI checks.
- It applies custom regex matches as
generic_id. - Input verdict: The first match returns the configured
redactorblockverdict. - Response phase: The chain entry also enables supported output redaction.
- Audit details: With
include_metadata, metadata includes match type, replacement text, offsets, and the source span SHA-256 hash.
For stream: true, redaction prevents token-by-token pass-through. The gateway
holds the assistant text until the stream is complete.
Correct examples
Default request redaction and output redaction
pack:
name: pii-defaults
version: "1.0.0"
enabled: true
policies:
chain:
- pii-detector
policy:
pii-detector:
action: redact
redaction:
marker_format: label
include_metadata: true
Healthcare mode with custom MRN marker
pack:
name: healthcare-redaction
version: "1.0.0"
enabled: true
policies:
chain:
- pii-detector
policy:
pii-detector:
action: redact
healthcare_mode: true
redaction:
marker_format: label
custom_markers:
mrn: "[MEDICAL-RECORD-REDACTED]"
PCI-sensitive request blocking
pack:
name: pci-request-block
version: "1.0.0"
enabled: true
policies:
chain:
- pii-detector
policy:
pii-detector:
action: block
pci_mode: true
Custom regexes with generic marker override
pack:
name: custom-identifiers
version: "1.0.0"
enabled: true
policies:
chain:
- pii-detector
policy:
pii-detector:
action: redact
detect_patterns:
- 'EMP-\d{6}'
- 'ACCT-\d{8,12}'
redaction:
marker_format: label
custom_markers:
generic_id: "[REDACTED-ID]"
Use with HIPAA heuristics
pack:
name: healthcare-stack
version: "1.0.0"
enabled: true
policies:
chain:
- prompt-injection
- pii-detector
- hipaa-phi-detector
policy:
pii-detector:
action: redact
healthcare_mode: true
pci_mode: false
redaction:
marker_format: label
include_metadata: true
hipaa-phi-detector:
action: redact
Use with other policies
Recommended groups that map to active policy types:
| Combination | Purpose |
|---|---|
prompt-injection → pii-detector | Block adversarial requests before redacting PII |
pii-detector → dlp-filter | Redact structured identifiers first, then apply broader pattern controls |
pii-detector with data-routing-policy | Redact identifiers and independently restrict targets by their declared data metadata |
Best practices
- Use
action: redactunless request-phase hard blocks are necessary. - Keep
include_metadata: trueif audit evidence for changed content is necessary. - Use lowercase marker keys in
custom_markers. - Custom regexes make
generic_iddetections. They do not make custom labels. - Enable
healthcare_modeonly where HIPAA-like heuristics are necessary. - Test buffered and streaming response paths. Streaming redaction changes delivery latency.
Next steps
- DLP Filter — more sensitive-pattern enforcement
- Data Routing Policy — restrict targets by declared data metadata
- Citation Verifier — add groundedness checks after redaction-sensitive workflows