Skip to content

PBAC on Snowflake

Overview

On Snowflake, a purpose is enforced through Snowflake roles. Trust3 AI merges the purpose's row filters and masks with the data product's other policies (see How Policies Combine), and the Snowflake connector built on Omni writes the result as Snowflake row access policies and masking policies for the roles the purpose is applied for.

A user who holds one of those roles sees the data product with the purpose's row filters and masks applied: the purpose can remove rows, and its masks can mask or show columns. Users who hold none of those roles see the data product as its other policies allow.

Before you begin

  • Use the Snowflake connector built on Omni, on a Self-Managed or Partially Managed (D2P) runtime plane. The legacy PolicySync Snowflake connector does not enforce purposes.
  • Set up the connector for row filters and column masks, including CREATE SCHEMA on each governed database, so that the connector can create its PRIVACERA_SECURITY schema there, and the grants to apply row access and masking policies. See Prerequisites on the data platform.
  • Make sure PBAC is enabled for your tenant. See Manage Purposes.
  • Create the Snowflake roles the purpose will be applied for, and grant them to users. Trust3 AI does not create Snowflake roles.
  • Tag the columns the purpose's policies act on.

How Trust3 AI roles and groups map to Snowflake roles

Snowflake applies row filters and masks through roles only. When you apply a purpose for a Trust3 AI role or an identity provider (IdP) group, the purpose is enforced on the Snowflake role with the same name.

Names are matched without regard to upper and lower case. The Trust3 AI role Marketing_Analyst maps to the Snowflake role MARKETING_ANALYST. Permissions go only to the Snowflake role with the same name: permissions for MARKETING_ANALYST never reach a role named MARKETING_TEAM.

If a Trust3 AI role and a group have the same name, the role's grants, row filters and masks are used on the Snowflake role, and the group's own grants, row filters and masks of the same kind are not. A purpose applied for the group still applies: its row filters are added with AND. If purposes of both the role and the group mask the same column, the mask whose policy name sorts first applies.

Groups whose names differ only in upper and lower case, such as Finance and finance, map to the same Snowflake role, FINANCE. A purpose applied for either one applies to every user who holds that role, and only one group's own row filters and masks of each kind are used.

Groups that are not mapped

These groups are not mapped to a Snowflake role. A purpose applied for one has no effect, and no warning is shown:

  • a group named after a Snowflake built-in administrator role: ACCOUNTADMIN, ORGADMIN, GLOBALORGADMIN, SECURITYADMIN, SYSADMIN or USERADMIN;
  • a group whose name becomes PUBLIC in upper case, other than the everyone group public itself;
  • a group whose name changes in more than case when put in upper case: one with leading or trailing spaces, invisible characters, or letters whose upper case is spelled differently, such as ß;
  • a group whose name starts with FEDUSER or FEDGROUP, in any case.

The everyone group public maps to the Snowflake role PUBLIC, which every user and role in the account holds. A purpose applied for public applies to everyone. Do not apply a purpose with Show policies for public.

When no Snowflake role matches

A Trust3 AI role or group whose name matches no Snowflake role is not enforced: the purpose has no effect for it, and no warning is shown. Check that each role or group you apply a purpose for has a Snowflake role with the same name.

Snowflake role names created with double quotes in mixed case, which Snowflake treats as case-sensitive, are not supported.

Example

An admin applies a Marketing purpose to a data product for the Trust3 AI role MARKETING_ANALYST. Users who hold the Snowflake role MARKETING_ANALYST see the purpose's restrictions, for example no customers who lack marketing consent. Users who do not hold that role see the data product as before.

What the connector writes

Snowflake allows one row access policy per table and one masking policy per column. So the connector writes:

  • one native row access policy per table, which merges every row filter on the table: resource, tag, data product and purpose;
  • one native masking policy per column, which merges every mask on the column, in the order described in How Policies Combine.

Each policy tests whether the user holds a role with CURRENT_AVAILABLE_ROLES(), which lists every role granted to the user, directly or through another role.

For example, with a data product that filters out members without consent, and a Research purpose that filters out population B, the row access policy on the MEMBERS table is, in simplified form:

SQL
1
2
3
4
5
-- data product
consent = 'Y'
-- Research purpose, for anyone who holds the RESEARCH role
AND NOT (ARRAY_CONTAINS('RESEARCH'::VARIANT, PARSE_JSON(CURRENT_AVAILABLE_ROLES()))
         AND population = 'B')

With a tag policy that redacts member IDs, and a Claims Processing purpose that shows them, the masking policy on the MEMBER_ID column is, in simplified form:

SQL
1
2
3
4
5
6
7
CASE
  -- Claims Processing purpose: Show Member ID
  WHEN ARRAY_CONTAINS('CLAIMS_PROCESSING'::VARIANT, PARSE_JSON(CURRENT_AVAILABLE_ROLES()))
    THEN member_id
  -- tag policy: Redact Member ID
  ELSE '*******'
END

The role names and SQL are simplified. The policies the connector generates are longer.

Which roles are checked

Every rule is checked against every role granted to the user, directly or through another role, whatever roles their session has active. USE ROLE and USE SECONDARY ROLES do not change what a user sees. A purpose follows the person: a user who holds a role the purpose is applied for gets the purpose's row filters and masks under any role they use.

  • Rules that give rows add up across the roles a user holds that a row filter names. A role that no row filter names gives every row only to users who hold none of the named roles.
  • A purpose's row filters are applied last, for anyone holding a role the purpose is applied for.
  • An Exclude filter written for one role is part of that role's rows. If the user holds another role that is given the same rows, they see them.

Planned: Exclude filters for everyone they name

An Exclude filter will apply to every user who holds a role it names, and another role will not widen it.

See How Policies Combine for how masks combine across roles.

A purpose reaches every role above its own

A user holds a role through any role it is granted to. If the role a purpose is applied for is granted to another role, such as SYSADMIN, every user of that other role gets the purpose's row filters and masks. This covers their writes as well as their reads: a CREATE TABLE … AS SELECT, a MERGE, a backup or a pipeline run under that role writes the filtered, masked data, with no error.

Do not grant a purpose's role to an administrative, service or pipeline role, and load data through a role outside that hierarchy.

A user who reaches the same data only through roles the purpose is not applied for is not detected, and sees the data as those roles allow. See Scope and limits.

Users that no rule names

Planned: data product tables closed by default

On a data product's tables, a user that no rule gives rows to will see no rows, and on a column with at least one mask rule, such a user will see NULL. Tables outside any data product are not affected. Applying a purpose will warn when a selected role is given no rows by the data product.

Until this is available, a user that no row filter names sees every row of the table.

What is not enforced

A purpose is not enforced in these cases, and the purpose still shows as applied. Trust3 AI records the first, third and fourth in its logs and metrics for an operator; the others are not detected:

  • External, dynamic and Iceberg tables. The connector cannot attach row access or masking policies to them, so a purpose's row filters and masks are not applied, and reads stay as they are. Ordinary row filters and masks on these tables withhold SELECT instead; see the Omni Connector page.
  • A view over a table the purpose does not reach, such as an untagged copy of the table. A view over a table the purpose does reach is filtered and masked through that table.
  • A purpose mask that is skipped: on a table whose name contains #, or on a column the metadata scan has not found. The column shows as the other policies allow.
  • A purpose row filter that is skipped: one that uses a Record Identifier, on a table that lacks one of its columns or has not been scanned yet. Because the purpose gives the role read access, the role reads that table unfiltered.
  • Tasks, owner's-rights procedures and dynamic tables. A Snowflake task, and a stored procedure that runs with its owner's rights, hold no roles in this check, so a purpose does not filter or mask what they read. A dynamic table's refresh may not be restricted either. Any user who can create and run one on a governed database can read its tables this way. Restrict CREATE TASK, EXECUTE TASK, CREATE PROCEDURE and CREATE DYNAMIC TABLE on governed databases.
  • A custom mask (MASK_CUSTOM). It is accepted but cannot be written to Snowflake. The column keeps its previous mask.

A purpose policy that cannot be compiled for another reason, for example because its tag points at a column it cannot use, fails safe instead: for the purpose's holders, a row filter shows no rows and a mask shows NULL, until the policy, the tag or the scan is fixed.

Limits

  • Snowflake roles must already exist. Trust3 AI does not create them or warn when they are missing.
  • A purpose is applied for roles and groups. Individual Snowflake users are not supported.