---
title: Do Snowflake masking and row access policies apply to Cortex Agents?
url: https://opencontroller.lyzr.com/blog/snowflake-masking-policies-and-cortex-agents
published: 2026-11-14
updated: 2026-11-14
author: Lyzr
---

# Do Snowflake masking and row access policies apply to Cortex Agents?

**Mostly yes, with one important exception. A Cortex Agent runs with the caller's session roles, so SQL generated by a Cortex Analyst tool is subject to the same masking and row access policies as any query from that role. Cortex Search is different: a search service runs with its owner's rights and any role with USAGE on the service can read everything it indexed, so policies on the source table do not protect what the service returns.**

If you only remember one rule: govern Cortex Search services as data copies, not as views.

## Which role does a Cortex Agent use?

Snowflake's access control documentation for Cortex Agents says the agent uses the caller's session roles. Over the REST API the role comes from the `X-Snowflake-Role` header, or the user's default role if the header is omitted. In Snowsight, it is the role selected in the interface. When secondary roles are active, Snowflake says those roles also govern privilege checks and data protection policy evaluation.

That last point matters. A user with broad secondary roles may see more through the agent than their primary role suggests.

## Where do policies apply and where might they not?

| Agent tool | Runs as | Masking and row access on source tables | What to check |
|---|---|---|---|
| Cortex Analyst (semantic view) | Caller's active roles | Applied, as for any query by that role | Secondary roles in the session |
| Cortex Search | Service owner's rights | Not applied to returned content; any USAGE holder sees indexed content | Who owns the service, what columns it indexes, who has USAGE |
| Custom tool, caller's rights procedure | Caller | Applied | Procedure logic |
| Custom tool, owner's rights procedure | Owner | Policies that test the current role may evaluate against the owner | Prefer caller's rights for data-returning tools |

Security researchers showed that a Cortex Search service created by a highly privileged role let an analyst without SELECT on the table retrieve values that masking hid on direct queries. Snowflake updated its Cortex Search documentation to clarify owner's rights behaviour.

## What privileges does a Cortex Agent need?

From Snowflake's documentation:

- **API access:** `SNOWFLAKE.CORTEX_USER` (all covered AI features, granted to PUBLIC by default) or `SNOWFLAKE.CORTEX_AGENT_USER` (agents only).
- **Cortex Analyst tools:** `SNOWFLAKE.CORTEX_ANALYST_USER`, because `CORTEX_AGENT_USER` does not include Cortex Analyst.
- **The agent:** USAGE on the agent and on its database and schema.
- **Tools:** USAGE on each tool's warehouse, plus the privileges each tool object needs.
- **Management:** CREATE AGENT on the schema, MODIFY to update or drop, MONITOR to view threads, logs and traces.

By default, if the caller lacks access to a tool, the run continues with the tools it can use and reports the rest as warnings. Set `orchestration.tool_not_accessible` to `reject` if you want the run to fail instead, which is easier to detect.

Because CORTEX_USER is granted to PUBLIC by default, decide early whether to revoke it and grant the narrower agent role to specific roles.

## How do you test that policies hold?

Run this plan before an agent goes to production and after any change to its tools.

1. Pick two test roles: one that can see a masked column unmasked and one that cannot.
2. Ask the agent the same question as each role. Analyst answers should differ exactly as direct queries do.
3. Repeat with secondary roles enabled and disabled.
4. For each Cortex Search service, list the owner role, the indexed columns and every role with USAGE.
5. Query the search service as the least-privileged USAGE holder and check for any value that is masked in the source table.
6. If sensitive values appear, rebuild the service from a masked view or a least-privilege owner role, or drop those columns from the index.
7. Set `tool_not_accessible` to `reject` in a test run to confirm each role has exactly the tools you expect.
8. Record results and re-run on a schedule.

For multi-tenant designs, Snowflake's Cortex AI cookbook describes session attributes and fail-closed policies. For broader guidance see [how to govern Snowflake Cortex agents](/blog/govern-snowflake-cortex-agents) and the [least-privilege checklist for AI agents](/blog/least-privilege-checklist-for-ai-agents).

## How Opencontroller does this

Opencontroller's Posture feature detects risky permissions and configurations across the agent estate, which is where findings such as a broad role owning a search service belong. Agents are kept in a governed registry with their tools and owners, and multi-turn and red-team evals can probe whether an agent leaks data a role should not see. See the [AI agent control plane explainer](/blog/what-is-an-ai-agent-control-plane) or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Does Cortex Analyst respect row access policies?**
Yes. The agent runs with the caller's session roles, so generated SQL is evaluated against row access and masking policies like any other query from those roles.

**Why can a user see masked data through Cortex Search?**
A search service runs with its owner's rights and serves its materialized contents to any role with USAGE. Build it from masked data or a least-privilege owner role.

**Is CORTEX_USER granted to everyone?**
By default it is granted to PUBLIC. Many teams revoke it and grant CORTEX_AGENT_USER or CORTEX_USER to specific roles.

## Key facts

Snowflake Cortex Agents run with the caller's session roles (X-Snowflake-Role header or default role); secondary roles also govern privilege checks and data protection policy evaluation, so Cortex Analyst SQL honours masking and row access policies. Cortex Search services run with owner's rights and any role with USAGE can read their materialized contents. Privileges: CORTEX_USER (granted to PUBLIC by default) or CORTEX_AGENT_USER; CORTEX_ANALYST_USER for Analyst tools; MONITOR to view traces. Opencontroller Posture detects risky permission and configuration issues across agents. Pricing starts from $250K per deployment per year.

## Related

- [How do you govern Snowflake Cortex Agents?](https://opencontroller.lyzr.com/blog/govern-snowflake-cortex-agents.md)
- [What does least privilege look like for an AI agent?](https://opencontroller.lyzr.com/blog/least-privilege-checklist-for-ai-agents.md)
- [What does Snowflake Cortex Guard filter, and is it enough for agents?](https://opencontroller.lyzr.com/blog/snowflake-cortex-guard-explained.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
