Skip to main content

Control access to sensitive data

Use privileges in Unity Catalog to set who can access a catalog, schema, or table. Some tables also hold data that only certain users should see, such as salaries, government IDs, or rows for a specific region. For those tables, add fine-grained access controls that set which rows and column values each user sees. Unity Catalog enforces these controls on every query that runs on supported compute, from any tool.

The following video explains row-level security and column masking with attribute-based access control (ABAC) in Unity Catalog:

Access control mechanisms in Unity Catalog​

Unity Catalog has four access control mechanisms, and you can use them together:

Mechanism

Applies to

Defined using

Instructions

Privileges and ownership

Catalogs, schemas, tables, and other securable objects

GRANT and REVOKE statements, and ownership

Manage privileges in Unity Catalog

ABAC policies

Rows and column values in every table with a matching governed tag

Policies that use governed tags and user-defined functions (UDFs)

Attribute-based access control in Unity Catalog

Row filters and column masks

Rows and column values in one table

UDFs on the table

Row filters and column masks

Workspace bindings

Catalogs, external locations, and credentials

Workspace assignment

Workspace-catalog binding

Mechanism

Applies to

Defined using

Instructions

Privileges and ownership

Catalogs, schemas, tables, and other securable objects

GRANT and REVOKE statements, and ownership

Manage privileges in Unity Catalog

ABAC policies

Rows and column values in every table with a matching governed tag

Policies that use governed tags and user-defined functions (UDFs)

Attribute-based access control in Unity Catalog

Row filters and column masks

Rows and column values in one table

UDFs on the table

Row filters and column masks

Workspace bindings

Catalogs, external locations, and credentials

Workspace assignment

Workspace-catalog binding

Databricks recommends ABAC to centralize and scale fine-grained access control. With ABAC, you tag sensitive columns with governed tags, and define one policy on a catalog or schema. The policy applies to every table in its scope that has the matching tag, including tables that you create later. Use table-level row filters and column masks only when you need logic that is specific to one table. See Access control in Unity Catalog.

Choose the tag type​

ABAC policies match only governed tags, so decide which type to use before you tag columns. Unity Catalog has three tag types:

Type

Who sets it

Works with ABAC policies

Use for

Ungoverned tags

Anyone with the APPLY TAG privilege on the object

No

Discovery, search, and team labels

Governed tags

Users with the ASSIGN permission on the tag and the APPLY TAG privilege on the object, using values from a tag policy that you define

Yes

Sensitivity levels and any tag that a policy matches

System governed tags

Databricks (class.* tags from Data Classification); ASSIGN permission required to apply or remove

Yes

Classification results that Databricks detects

Type

Who sets it

Works with ABAC policies

Use for

Ungoverned tags

Anyone with the APPLY TAG privilege on the object

No

Discovery, search, and team labels

Governed tags

Users with the ASSIGN permission on the tag and the APPLY TAG privilege on the object, using values from a tag policy that you define

Yes

Sensitivity levels and any tag that a policy matches

System governed tags

Databricks (class.* tags from Data Classification); ASSIGN permission required to apply or remove

Yes

Classification results that Databricks detects

Each governed tag has a tag policy, which sets its allowed values and who can assign it. With a tag policy, pii, PII, and Personally Identifiable can't become three different tags. Tagging is a security boundary: anyone who can change a column's tags can change which policies apply to it, so limit who has the ASSIGN permission on each governed tag. Governed tags are account-level objects. To create one, see Create and manage governed tags.

Detect PII with Data Classification​

Data Classification scans your tables for columns that hold personally identifiable information (PII) and other sensitive data, such as email addresses and Social Security numbers. After you turn on automatic tagging, it applies class.* system governed tags to those columns, such as class.email_address and class.us_ssn. ABAC policies can match these tags, so a policy that matches them covers new tables without a manual tagging step.

To turn on Data Classification, open the catalog in Catalog Explorer, click the Details tab, and then click Enable next to Data Classification. You must own the catalog or have the MANAGE privilege on it. Data Classification runs on serverless compute, and typically scans new tables and columns within 24 hours.

Review the detections on the Data Classification results page before you turn on automatic tagging. After you turn it on, existing detections get tags in the next scan, not immediately. See Data Classification and Supported classification tags.

Choose a masking strategy​

A column mask returns one of three kinds of value to users who aren't exempt:

  • Redaction: Returns NULL or a fixed placeholder, so no part of the value remains. Use redaction when analysts don't need to correlate on the value, such as a salary, a diagnosis, or a full Social Security number.
  • Partial masking: Returns part of the value, such as the domain of an email address or the last 4 digits of a card number. Use partial masking when readers need enough of the value to recognize a record.
  • Hashing (pseudonymization): Returns a Secure Hash Algorithm 256 (SHA-256) hash with SHA2(value, 256). The same input always produces the same hash, so analysts can join two tables on a hashed column without seeing the real values. Anyone who can guess the possible inputs can hash each guess and compare the results. Treat a hashed column of predictable values, such as Social Security numbers, as sensitive, and use hashing only when cross-dataset joins matter.

The following table lists common sensitive columns, the masked value that most users see, and the groups that are typically exempt from the mask:

Sensitive column

Masked value

Exempt groups

Common industries

salary DOUBLE

NULL

hr_admin, finance

All industries

ssn STRING

'XXX-XX-XXXX'

hr_admin, compliance

HR, insurance, finance

email STRING

'***@domain.com', or a SHA-256 hash when analysts need joins

data_owners

Retail, software as a service (SaaS), marketing

card_number STRING

'****-****-****-1234'

fraud_team

Retail, financial services

phone STRING

'+1-XXX-XXX-1234'

support_ops

Telecom, retail, healthcare

dob DATE

NULL

medical_staff, actuaries

Healthcare, insurance

diagnosis STRING

NULL

clinical_staff

Healthcare, under the Health Insurance Portability and Accountability Act (HIPAA)

ip_address STRING

'XXX.XXX.X.X'

security_ops

Tech, security

Sensitive column

Masked value

Exempt groups

Common industries

salary DOUBLE

NULL

hr_admin, finance

All industries

ssn STRING

'XXX-XX-XXXX'

hr_admin, compliance

HR, insurance, finance

email STRING

'***@domain.com', or a SHA-256 hash when analysts need joins

data_owners

Retail, software as a service (SaaS), marketing

card_number STRING

'****-****-****-1234'

fraud_team

Retail, financial services

phone STRING

'+1-XXX-XXX-1234'

support_ops

Telecom, retail, healthcare

dob DATE

NULL

medical_staff, actuaries

Healthcare, insurance

diagnosis STRING

NULL

clinical_staff

Healthcare, under the Health Insurance Portability and Accountability Act (HIPAA)

ip_address STRING

'XXX.XXX.X.X'

security_ops

Tech, security

The lab implements the salary, Social Security number (SSN), email, card number, and phone patterns for the employees table, with a SHA-256 variant for email. See Protect sensitive data with ABAC policies.

Filter rows with a policy​

A column mask controls what a visible row shows. A row filter controls which rows are visible at all. A row filter policy uses ROW FILTER with a function that returns BOOLEAN, and USING COLUMNS to pass the tagged column to that function.

Use a row filter when different groups should see different slices of the same table, such as a regional manager who sees only their region, or a business unit that sees only its own cost center. Use a column mask when the row is visible but one field on it isn't.

SQL
CREATE OR REPLACE FUNCTION main.security.filter_region(region STRING)
RETURNS BOOLEAN
RETURN is_account_group_member('region_emea') AND region = 'EMEA';

CREATE OR REPLACE POLICY region_policy
ON SCHEMA main.hr
ROW FILTER main.security.filter_region
TO `account users` EXCEPT hr_admin
FOR TABLES
MATCH COLUMNS has_tag_value('pii', 'region') AS region
USING COLUMNS (region);

In this example, the TO and EXCEPT clauses set which users the filter applies to, and the function returns TRUE for the rows that each of those users can see. The pii tag must be a governed tag in your account. See Choose the tag type. The lab's version of this function handles three regions.

note

ABAC policies require serverless compute, standard compute on Databricks Runtime 16.4 and above, or dedicated compute on Databricks Runtime 16.4 and above with fine-grained access control filtering enabled. Standard and dedicated compute on Databricks Runtime versions earlier than 16.4 can't access ABAC-secured tables. See Compute requirements.

Adopt access control​

To adopt access control, complete the following steps:

Grant privileges to groups​

Assign ownership of catalogs and schemas to groups, and grant baseline access to the groups that use the data. See Transfer Unity Catalog object ownership to groups.

Create governed tags​

Define a small set of governed tags for sensitive data, such as a pii tag with allowed values like ssn and email. See Governed tags.

Create ABAC policies​

Define row filter and column mask policies on your catalogs or schemas, and exempt the groups that need to see the raw data. See Create and manage row filter and column mask policies.

Enable access requests​

Configure access request destinations, so that users can request access to data that they can discover but can't read. See Configure access request destinations.

For recommendations on tag taxonomy and policy scope, see Best practices for ABAC policies.

Next steps​