Skip to content

How to test row permissions in AI analytics

Updated 6 min readFor security reviewers and data engineers assessing AI analytics

To test row permissions in AI analytics, compare what each real role receives against a reference produced for that same role, never against an administrator’s report. Check aggregates, explanations, charts and error text as well as rows, because a total or a helpful sentence can reveal what a row filter hid. Confirm queries execute as the requesting user, since a common integration login or an owner’s-rights view can bypass the rule entirely. An answer containing data its reader should not see is wrong, however accurate its arithmetic.

A correct sum can be a wrong answer

A company-wide total shown to a regional employee may add up perfectly and still be a defect. So permission scope belongs in the definition of correct, next to arithmetic and business meaning. Most evaluations miss this for a mundane reason: they run under one account, typically a powerful one, and everything looks right.

The reverse error also occurs. Compare a restricted user’s answer with an administrator’s report and you get a false failure, since the two should differ. Each test case therefore needs a reference produced through an approved path for the same role. Of all the changes to a test plan, that’s the one I’d make first.

Find out who ran the query

Start with the identity path, since everything else depends on it. An assistant that reaches the warehouse with one integration login shows the warehouse one identity, and row rules keyed to the user can’t fire. Rebuilding those rules in an application layer gives you two sources of truth, and they will drift apart.

Views add a subtler trap. Snowflake’s documentation points out that a row access policy on a view can check the view owner, using INVOKER_ROLE, or the operator running the query, using CURRENT_ROLE. A policy written against the wrong one can be correct in every direct test and wrong through the view the assistant uses. It also recommends IS_ROLE_IN_SESSION where the policy should respect role hierarchy, because a plain CURRENT_ROLE comparison does not.

Verify this from the warehouse’s side instead of relying on a claim. Run a test question, then read the ACCOUNT_USAGE QUERY_HISTORY view for the user and role recorded against it. The view can lag by up to 45 minutes, so allow for that before concluding a query is missing. In Salesforce, a query run WITH USER_MODE enforces the running user’s object permissions, field-level security and sharing, whereas system mode skips field and object checks, so ask which is in use.

CREATE ROW ACCESS POLICY sales.policies.region_rows
AS (region_code VARCHAR) RETURNS BOOLEAN ->
  CASE
    WHEN IS_ROLE_IN_SESSION('FINANCE_ALL') THEN TRUE
    WHEN IS_ROLE_IN_SESSION('SALES_EMEA') AND region_code = 'EMEA' THEN TRUE
    ELSE FALSE
  END;

-- After the test question: who does the warehouse say ran it?
SELECT user_name, role_name, query_text
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD(hour, -2, CURRENT_TIMESTAMP())
  AND user_name = 'TEST_EMEA_USER';

Same question, two people, and the leak in between

Row filtering is silent. Snowflake’s output contains only rows where the policy evaluates to true, with no error for the rest. The good news is that results are correct for each reader without any application logic. The bad news is that a filtered result looks exactly like a complete one, so the leak risk moves to everything surrounding the rows.

Finance userAssistantWarehouseEMEA userTotal revenue?Run as FinanceAll regions totalTotal revenue?Run as EMEA userEMEA total onlyMust never reuse Finance totalFinanceuserAssistantWarehouseEMEA userTotal revenue?Run as FinanceAll regions totalTotal revenue?Run as EMEA userEMEA total onlyMust never reuse Finance total
Different numbers for different people is correct behavior. The risk is anything shared between the two paths, particularly a cache keyed without identity.

Places a filtered value can still escape

Work through these with an account that has narrow access, because a broad account cannot reveal any of them.

  • Application cachesA key built from question text alone will serve one person’s result to the next. Test by asking the same words from two accounts, in both orders, within seconds. Snowflake’s own result reuse has its own conditions, including role privileges on the tables; its reuse page does not discuss row policies, so test your configuration instead of inferring.
  • Aggregates and differencingA small group’s average can identify a person, and two permitted totals can be subtracted to reveal a third. Snowflake aggregation policies, in Enterprise Edition and above, set a minimum group size and combine smaller groups into a remainder. The documentation itself says they do not guarantee protection against deliberate queries, so treat them as one control among several.
  • Explanations and errorsAsk for a restricted region and read the whole reply. A model trying to help may name the excluded region, the policy or the number of hidden rows. Error messages deserve the same read.
  • Retrieved contextSample values, query history and semantic search indexes are built by some account. If the index was built with broad access, a suggested filter value can reveal a customer name the row policy would have hidden.
  • Follow-upsBegin with a permitted view, then ask for a restricted entity. Authority must be evaluated again on each turn, from the user’s current access.
  • Cross-source joinsAccess to a Salesforce account does not grant its warehouse revenue. Test a person who has one side only, and check that the join reveals nothing beyond what each source allows.

A test matrix you can finish in a day

Use three real roles: broad, regional and one with a masked or hidden field. All counts and names here are generic. Produce references using each role’s existing approved report. Then run the same set of cases under each role, and record what came back, including the wording.

CaseWhat to doPass condition
ScopeAsk a total under each roleEach matches that role’s own reference
LabelRead the chart title and sentenceSays region or scope; does not imply company total
Hidden fieldGroup by a field this role cannot seeNo values; field not silently dropped
Small groupBreak down by a sensitive attributeFollows your written policy on small groups
Cache orderTwo roles ask identical words, both ordersEach gets their own number
RevocationRemove a role, then ask a new questionNew requests reflect it; timing documented
Direct bypassAsk for the restricted region by nameNo value and no hint of the value in the reply

Scope labels are part of the control

Suppose a manager receives a total for their assigned accounts and the answer calls it company revenue. The calculation is right, the access is right, and the statement is misleading. When that screenshot reaches a slide, the qualifying context is gone. Test the words as well as the number: the answer should describe the population it covers, without describing what it excluded in a way that reveals it.

Also expect performance effects, because they can tempt people to weaken controls. Snowflake notes that row policies stop some statistics shortcuts, so a COUNT(*) must scan the table and queries may run slower. Budget for that in advance, so nobody later proposes one broad integration login as a speed fix.

Revocation and things already seen

Role changes are routine, so test one. Remove a role through your approved process, record when a new question reflects it, and note whether a reconnect is required. That gives administrators a procedure in place of a general promise.

Revoking future access does not recall answers already delivered. Saved conversations, exports and shared links need their own rule. Decide who owns that decision and write it in the rollout plan, because no query-time control can reach a CSV on someone’s laptop.

What to check in Nexatron

Nexatron sends every question under the asker’s sign-in. In Snowflake their roles, row access policies and masking policies decide what comes back; in Salesforce, sharing rules, field-level security and the role hierarchy do. We don’t widen them, two people can get different numbers, and nobody, including admins, can ask as someone else. Answers display Answered as and Why you can see this.

Don’t take our word for any of it. Run the matrix with your own roles, then confirm the identity from the warehouse side, using the query history check. I’d want your security reviewer to read that output personally.

Bring three business questions

Explore your sources, definitions, and review criteria with our team. Please keep credentials and sensitive records out of the inquiry.