Skip to main content

Detect sensitive data with a service policy

Beta

This feature is in Beta. Workspace admins can control access to this feature from the Previews page by opting into the Unity Gateway Service Policies preview. See Manage workspace-level previews.

Sensitive Data Detection is a built-in service policy that finds sensitive data, such as personally identifiable information (PII), in requests and responses and either denies the interaction or masks the matched value in place. Unlike the LLM-as-a-judge built-in policies, it's deterministic and adds little latency.

You attach Sensitive Data Detection to a Model Service, Model Provider Service, or MCP Service. You choose which categories to look for and what happens on a match. A match can block the interaction or redact the matched value on any of these services. On an MCP service, it can additionally hold the tool call for approval.

Attach the policy​

note

During the Beta, the policy UI might change. If a label differs from these steps, follow the in-product labels. The Principals and scope fields aren't configurable yet: a policy applies to all account users on the service.

You attach Sensitive Data Detection through the Unity Gateway UI, the same way you attach any built-in policy. You need MANAGE on the target service. During the Beta, built-in policies are Databricks-managed and don't appear as functions you can browse or grant on in the system.ai schema, so there's no EXECUTE privilege to set; you select the policy by name in the UI.

  1. In the workspace sidebar, click Unity Gateway.
  2. Select the service to govern. A model service on the Models tab, a model provider service on the Providers tab, or an MCP service on the MCPs tab.
  3. Open the Policies tab, then click New policy.
  4. Enter a Name for the policy.
  5. In Guardrail type, select Sensitive Data Detection.
  6. Select the Classification tags to detect, and choose the action on a match. On a model or model provider service, you can select Deny or Mask. On an MCP service, you can select Deny, Mask, or Ask.
  7. Under Phase, select Input, Output, or both.
  8. Set the Rank to control evaluation order relative to other policies on the service. See Order of evaluation.
  9. Under Advanced options, select Enforce to apply the action or Log to evaluate without changing the request or response.
  10. (Optional) On a model or model provider service, select Full response evaluation under Response evaluation.
  11. Click Create policy.

The policy appears on the service's Policies tab. During the Beta, allow a short time for it to propagate before you test.

How the policy works​

When you attach the policy, configure the following settings:

  • Categories: the types of sensitive data to detect.
  • Action: what happens when the policy finds a match.
  • Phase: whether to inspect the input, the output, or both.
  • Mode: whether to enforce the action or log what it would have done.
  • Response evaluation: how output checks handle streaming responses.

Categories​

Select at least one category in Classification tags. Categories apply to chat requests, embedding inputs, and MCP tool calls. See Supported categories.

Action​

Choose Deny to block an interaction or Mask to replace matched values with placeholder tokens, such as [US_SSN]. These actions apply to all service types:

Request type

Deny

Mask

Chat-style model APIs

Returns HTTP 200 with an assistant turn that reports the block.

Redacts the request sent to the model and the response returned to the caller.

Embeddings

A match in any item rejects the whole request with HTTP 400 before the model runs.

Redacts each item and preserves its position in the batch, so the resulting vectors can differ. See Embedding input guardrails.

MCP tool calls

Denies the tool call.

Redacts tool-call arguments on the input phase and the tool result on the output phase.

Request type

Deny

Mask

Chat-style model APIs

Returns HTTP 200 with an assistant turn that reports the block.

Redacts the request sent to the model and the response returned to the caller.

Embeddings

A match in any item rejects the whole request with HTTP 400 before the model runs.

Redacts each item and preserves its position in the batch, so the resulting vectors can differ. See Embedding input guardrails.

MCP tool calls

Denies the tool call.

Redacts tool-call arguments on the input phase and the tool result on the output phase.

For a denied chat request, the assistant turn names the blocking service policy. The top-level databricks_service_policy object carries the block reason, which names the matched categories, for example Detected sensitive data (US_SSN, CREDIT_CARD).

MCP services also support Ask, which holds the tool call for human approval before it runs. It uses the elicitation flow of a custom ASK policy. Ask applies to the input phase. On the output phase, a match blocks instead, because the tool has already run.

Detection is deterministic. Mask matches a category's format, plus a checksum where one applies. Deny uses stricter checks for categories that are only digits, requiring a checksum or a nearby context word to avoid blocking random numbers. Distinctive formats such as email and IP addresses block on the match alone.

Phase​

Choose which content to inspect:

  • Chat-style model APIs: Select Input, Output, or both to inspect the request, the response, or both.
  • Embeddings: Select Input, because no policy inspects vectors. An enforcing output-only policy rejects embedding requests with HTTP 400. A policy configured for both phases evaluates only embedding input and continues to inspect chat output on the same service. See Embedding input guardrails.
  • MCP tool calls: Select Input to inspect tool-call arguments, Output to inspect the tool result, or both.

Mode​

Select Enforce to apply the chosen action or Log to record what the policy would have done. In Log mode, chat requests and responses, embedding inputs, and MCP tool-call arguments and results remain unchanged.

The policy_evaluated trace event records the would-be action. For Mask, policy.dry_run_transformed_message contains the fully rewritten payload that enforcement would have forwarded.

Response evaluation​

On model and model provider services, choose how output checks handle streaming responses. If a streaming mask requires changing released text, the stream ends with an error. The client might already have received sensitive data, which can't be recalled. Select Full response evaluation to mask the complete response before releasing text. See Streaming responses.

Supported categories​

Sensitive Data Detection detects the following 15 categories, grouped by jurisdiction. In the Classification tags field, select the tags you want to detect. Each is listed in the Tag column below, for example, class.us_ssn. See Data Classification system tags for accepted tag values.

The Detection method column shows how Databricks identifies each category:

  • Regex: a pattern match on the value's format.
  • Checksum: a validation check on the matched value, such as the Luhn check on a card number, that rejects values that fit the format but can't be valid.
  • Context keywords: a related word must appear near the match, for example "SSN" near a nine-digit number. Because a bare number is ambiguous, these categories require a nearby keyword to block, though redaction still fires on the format alone.

Global identifiers​

Tag

Detects

Detection method

class.email_address

Email address

Regex

class.ip_address

IP address

Regex

class.mac_address

MAC address

Regex

class.vin

Vehicle Identification Number

Regex + check digit + context keywords

class.credit_card

Credit card number

Regex + Luhn checksum

class.iban_code

International Bank Account Number

Regex + ISO 7064 checksum

class.phone_number

Phone number

Regex + context keywords

Tag

Detects

Detection method

class.email_address

Email address

Regex

class.ip_address

IP address

Regex

class.mac_address

MAC address

Regex

class.vin

Vehicle Identification Number

Regex + check digit + context keywords

class.credit_card

Credit card number

Regex + Luhn checksum

class.iban_code

International Bank Account Number

Regex + ISO 7064 checksum

class.phone_number

Phone number

Regex + context keywords

United States​

Tag

Detects

Detection method

class.us_ssn

US Social Security Number

Regex + context keywords

class.us_itin

US Individual Taxpayer Identification Number

Regex + context keywords

class.us_passport

US passport

Regex + context keywords

class.us_bank_number

US bank account number

Regex + context keywords

Tag

Detects

Detection method

class.us_ssn

US Social Security Number

Regex + context keywords

class.us_itin

US Individual Taxpayer Identification Number

Regex + context keywords

class.us_passport

US passport

Regex + context keywords

class.us_bank_number

US bank account number

Regex + context keywords

United Kingdom​

Tag

Detects

Detection method

class.uk_nhs

UK NHS number

Regex + mod-11 checksum + context keywords

class.uk_nino

UK National Insurance Number

Regex

Tag

Detects

Detection method

class.uk_nhs

UK NHS number

Regex + mod-11 checksum + context keywords

class.uk_nino

UK National Insurance Number

Regex

India​

Tag

Detects

Detection method

class.in_pan

Indian Permanent Account Number

Regex

class.in_aadhaar

Indian Aadhaar number

Regex + Verhoeff checksum + context keywords

Tag

Detects

Detection method

class.in_pan

Indian Permanent Account Number

Regex

class.in_aadhaar

Indian Aadhaar number

Regex + Verhoeff checksum + context keywords

What isn't detected​

Sensitive Data Detection covers structured data that a pattern can match reliably. It doesn't detect:

  • Names, locations, and organizations, and other free-text entities that need language understanding to identify. Detecting these reliably requires a model, not a pattern. To cover this content, see Block other sensitive data with an LLM judge.
  • Identifiers that are only a run of digits with no checksum or standard format, such as some national IDs and device identifiers. Matching these on shape alone would flag too much ordinary text.

Detection accuracy​

Sensitive Data Detection is tuned differently for its two actions. Redaction should catch as much sensitive data as possible, since a missed value is worse than an over-redaction, so it is optimized for recall. A block denies the request outright, so it should fire only when confident, and is optimized for precision.

On public benchmarks, block precision is 0.99 across the 15 categories, so blocks rarely fire on non-sensitive content, and redaction recall is 0.96. Recall is at or near 1.0 for most categories; it is lower for a few types, such as US passport numbers, where the benchmark data carries heavy format variety rather than the detector missing well-formed values.

Detection is deterministic and fast. It adds under 50 ms per turn.

These numbers come from public sources: the AI4Privacy pii-masking-200k dataset, the Faker generator, and values built from each identifier's published check-digit and format specifications (for example, the Aadhaar Verhoeff and UK NHS mod-11 checks).

Block other sensitive data with an LLM judge​

To also catch the names and other free-text data that Sensitive Data Detection can't identify, add a custom LLM-as-a-judge guardrail to the same service:

  • Keep Sensitive Data Detection at a lower rank to mask structured data.
  • On the input phase, give the LLM judge a higher rank than Sensitive Data Detection, so it evaluates the already-masked content. Ranks run in reverse on the output phase, so on that phase give the judge the lower rank.
  • In the judge's instruction, describe the sensitive data to flag, and tell it to ignore the redaction placeholders (such as [US_SSN]) left behind by the first guardrail.

Example judge instruction​

You are a data-privacy classifier for an AI gateway guardrail. Decide whether the content contains personal information about a private individual, such as a person's name (including a first name used to address or refer to someone), home or personal contact details, or other identifiers tied to that individual.

Set flagged to true whenever the content names or refers to a private individual, even if only a first name is given and no other identifying details are present. For example, a message addressed to "Kattie" or one that mentions a colleague by name contains personal information.

Do not flag:
- Public figures, executives, politicians, celebrities, or historical people named in a public, business, or newsworthy context (for example, Warren Buffett, Elon Musk).
- Companies, brands, organizations, funds, or institutions (for example, Morgan Stanley, Apple, Goldman Sachs).
- Redaction placeholders that already mask a value, such as [EMAIL_ADDRESS], [US_SSN], [PHONE_NUMBER], or any similar bracketed category token in square brackets; these have already been handled and are not personal information.
- Obvious placeholders that do not refer to a real person (for example, "John Doe", "test user").
- Content with no reference to an individual.

Limitations​

The following limitations apply:

  • On model and model provider services, Sensitive Data Detection follows the service-policy API coverage.
  • Sensitive Data Detection inspects embedding input when the input phase is selected. It does not inspect embedding vectors. See Embedding input guardrails.
  • Sensitive Data Detection applies to model services, model provider services, and MCP services. Deny and Mask are available on all three; Ask (hold for approval) is available only on MCP services.
  • Only the categories listed in Supported categories are supported. Free-text entities such as names, locations, or organizations are not supported. See What isn't detected.