Sub topic 15
Designing a least-privilege permission model
This chapter pulls the earlier pieces together into a permission design you can apply. It assumes you know the Unity Catalog object hierarchy (metastore, catalog, schema, table), GRANT and REVOKE, privilege inheritance, ownership, workspace bindings, and basic SQL. The chapter covers how to choose where to grant, who should own objects, and how to check that the model works.
What least privilege means in Unity Catalog
Least privilege means each principal holds only the privileges its work requires, at the lowest level of the hierarchy that still makes the work practical. Unity Catalog is deny-by-default. A principal sees nothing until someone grants access, so the design task is deciding which grants to add and where to put them.
Four decisions shape the model:
- Who the principals are, meaning which groups and service principals exist.
- At which level of the hierarchy each privilege is granted.
- Who owns each object.
- Which workspaces can reach each catalog.
Step 1: Model roles as groups
Grant privileges to groups, not to individual users. People change teams, and a group lets you add or remove one membership instead of editing many grants. Name groups after a job function and, where it matters, a data domain.
A small set of groups covers many organizations:
| Group | Purpose | Typical access |
|---|---|---|
| `platform-admins` | Owns catalogs, manages bindings and storage | Owner of catalogs and external locations |
| `data-engineers` | Builds and maintains pipelines | Owner of schemas, create and modify rights in non-production catalogs |
| `etl-service-principals` | Runs production jobs | `MODIFY` and `CREATE TABLE` on specific production schemas |
| `data-analysts` | Reads curated data | `SELECT` on curated schemas |
| `pii-readers` | Sees unmasked sensitive columns | Membership checked by masks and filters |
Jobs in production should run as a service principal, not as a person. A service principal is an identity for automation. If a person leaves, the job keeps running and the audit trail shows the job identity. Put service principals in a group and grant to the group.
Step 2: Separate environments with catalogs
Catalogs are the natural boundary for environments and for large data domains. A common layout is one catalog per environment, such as dev, staging and prod, with schemas for domains inside each.
This layout works well with inheritance. You can give engineers broad rights in dev, where mistakes are cheap. In prod you give narrow rights on named schemas.
Step 3: Grant at the right level
Inheritance means a privilege granted on a catalog applies to every current and future schema and table in it. This is convenient and risky. A catalog-level SELECT is a blanket grant that will also cover schemas added next year.
Use these rules of thumb:
- Grant
USE CATALOGat the catalog level. It is a gate, and it allows no data reads. - Grant
USE SCHEMAandSELECTat the schema level for most analyst access. - Grant on individual tables only for exceptions, such as one sensitive table in an otherwise open schema.
- Grant catalog-wide
SELECTonly for catalogs where every object is meant for the whole audience.
Here is a production setup that follows these rules:
-- Ownership by groups, not people
ALTER CATALOG prod OWNER TO `platform-admins`;
ALTER SCHEMA prod.sales OWNER TO `data-engineers`;
-- Analysts: read-only on one curated schema
GRANT USE CATALOG ON CATALOG prod TO `data-analysts`;
GRANT USE SCHEMA, SELECT ON SCHEMA prod.sales TO `data-analysts`;
-- Pipelines: write access on the same schema
GRANT USE CATALOG ON CATALOG prod TO `etl-service-principals`;
GRANT USE SCHEMA, SELECT, MODIFY, CREATE TABLE
ON SCHEMA prod.sales TO `etl-service-principals`;The statements assume the catalog, the schema and the groups already exist. Run them as the current owner of the objects or as a principal that holds MANAGE on them.
Verify the result instead of trusting your memory of what you ran:
SHOW GRANTS ON SCHEMA prod.sales;
SHOW GRANTS `data-analysts` ON SCHEMA prod.sales;Step 4: Keep ownership under control
The owner of an object can grant and revoke on it, and owners also hold wide rights over it. Ownership therefore works as a privilege you cannot easily see in grant lists.
- Assign ownership of catalogs and schemas to groups. An object owned by one person becomes a problem when that person leaves or changes role.
- Keep the number of owners small. Each owner group can grant access to others.
- Use the
MANAGEprivilege when you want a team to administer grants on an object without making it the owner. - Avoid using metastore admin as a day-to-day role. Treat it like a break-glass role, used rarely and tracked in the audit log.
A common failure is that a pipeline creates tables as an individual's identity, so that person becomes the owner. Running jobs as a service principal and setting schema ownership to a group prevents this.
Step 5: Protect sensitive data below the table level
Table grants are all-or-nothing for the columns and rows of a table. When some users should see only part of it, add a row filter or a column mask to the table. Both are attached to the table, so every query sees them, whichever view or notebook the user comes from.
CREATE FUNCTION prod.sales.mask_email(email STRING)
RETURNS STRING
RETURN CASE WHEN is_account_group_member('pii_readers') THEN email ELSE '***' END;
ALTER TABLE prod.sales.customers
ALTER COLUMN email SET MASK prod.sales.mask_email;Grant SELECT on the table to data-analysts as before. The analysts can query it, and the mask hides the email values unless they are also in pii_readers. Check group membership with is_account_group_member, which uses account-level groups, so the groups in your design should be account groups.
Prefer masks and filters over a copy of the data with the sensitive columns removed. Copies drift out of date and need their own grants.
Step 6: Bind catalogs to workspaces
By default a catalog is reachable from every workspace attached to the metastore. A workspace binding restricts it to the workspaces you choose. For a prod catalog, bind it to the production workspace. Then a user with the right grants still cannot read production data from a sandbox workspace.
Bindings and grants work as two independent checks. A request must pass both. Neither one replaces the other.
Pair this with compute. Run production workloads on compute that enforces Unity Catalog permissions, such as a standard or dedicated access mode as available in your workspace. Compute that does not enforce them can let users reach data in ways the grants were meant to prevent. Check the current documentation for which access modes support row filters and column masks before you rely on them.
Step 7: Review with audit logs
A permission model drifts. Someone gets a temporary grant that is never removed. Review the audit log on a schedule.
SELECT event_time, user_identity.email, action_name
FROM system.access.audit
WHERE service_name = 'unityCatalog'
ORDER BY event_time DESC
LIMIT 20;To focus on permission changes, filter on the action name. Action names vary, so first look at what your logs contain:
SELECT DISTINCT action_name
FROM system.access.audit
WHERE service_name = 'unityCatalog'
ORDER BY action_name;Then filter on the one that records grant changes, for example updatePermissions, and review who changed what and when. Access to system.access.audit is itself controlled by grants, so give it only to the security and platform teams.
Common design mistakes
| Mistake | Why it hurts | Fix |
|---|---|---|
| Granting to individual users | Grants pile up and are hard to review | Grant to groups only |
| `SELECT` on a whole catalog for convenience | Covers future schemas without review | Grant on schemas |
| Individuals own objects | Access breaks when they leave | Transfer ownership to groups |
| Jobs run as a person | Ownership and audit entries point to a person | Use service principals |
| Forgetting `USE CATALOG` or `USE SCHEMA` | `SELECT` alone fails with a permission error | Grant the gate privileges |
| No bindings on production catalogs | Production reachable from any workspace | Bind to the production workspace |
A design checklist
- List the groups and service principals, and confirm they are account-level.
- Create catalogs per environment or domain, and set a group as owner.
- Grant
USE CATALOGbroadly, and data privileges at the schema level. - Add masks or filters for sensitive columns and rows.
- Bind production catalogs to production workspaces.
- Run jobs as service principals on compute that enforces Unity Catalog.
- Schedule an audit review and compare it with
SHOW GRANTSoutput.
Exercise
The data-analysts group needs to read prod.sales.orders and prod.sales.returns, but not prod.finance. A colleague proposes GRANT SELECT ON CATALOG prod TO data-analysts. Why is this a poor choice, and what grants would you use instead?
Show answer
A catalog-level SELECT is inherited by every schema in the catalog, including prod.finance and any schema created later, so it gives more access than needed. Instead grant USE CATALOG on prod and then USE SCHEMA and SELECT on the prod.sales schema: GRANT USE CATALOG ON CATALOG prod TO data-analysts; and GRANT USE SCHEMA, SELECT ON SCHEMA prod.sales TO data-analysts;. Confirm the result with SHOW GRANTS data-analysts ON SCHEMA prod.sales;.
Exercise
A nightly job creates tables in prod.sales and runs under an engineer's identity. What problems does this create, and how do you fix them?
Show answer
The engineer becomes the owner of the new tables and shows up in audit logs as the actor, and the job breaks if the engineer leaves. Run the job as a service principal in the etl-service-principals group, grant that group USE SCHEMA, SELECT, MODIFY and CREATE TABLE on prod.sales, and set the schema owner to the data-engineers group.