Author policy once, in one place. Enforce it everywhere an agent touches data, including inside the database.
Code: github.com/sfc-gh-kkeller/snowflake-agent-authz-pdp (MIT). Cedar policies, an AuthZEN 1.0 PDP, an agent gateway, Entra ID setup, Snowflake deployment scripts, nine scripted scenarios, a local console and offline policy tests.
Personal project. This is an “art of the possible” demo. It isn’t an official Snowflake solution or reference architecture, isn’t endorsed or supported by Snowflake, and isn’t production guidance. Views are my own.
The question security architects are asking#
In Beyond RBAC I argued that agents need purpose-aware access control: not just can this role read this table, but can this agent read this column, for this purpose, on behalf of this person, right now? I also wrote that the unified policy engine to answer that question doesn’t exist yet.
Since then, many security teams have decided to build it themselves. The pattern I keep seeing in banks and insurers looks like this:
- Cedar as the policy language: readable, analysable, open source.
- OpenID AuthZEN 1.0 as the vendor-neutral API to ask for decisions.
- A central Policy Decision Point (PDP), owned by security architecture, as the system of record for which agents exist and what each one may do.
- Every platform an agent touches becomes a Policy Enforcement Point (PEP) for those decisions.
The question they bring to me is always the same: where does Snowflake fit, without becoming a second, competing policy engine? I built a working demo to answer it, with real Entra ID identities and a real Snowflake account.
The scenario#
The demo models a European bank with three AI agents:
| Agent | Mode | Ceiling | AI Act risk tier |
|---|---|---|---|
| Advisor Copilot | Delegated: acts for a relationship manager (Entra On-Behalf-Of) | Up to sensitivity 3, UK and IE customers | High |
| Fraud Sentinel | Autonomous: its own workload identity (Entra client credentials) | Up to sensitivity 2, UK, IE and NL | Limited |
| Marketing Genie | Autonomous | Up to sensitivity 1, UK | Minimal (and revoked) |
The design rules are strict, because that’s what regulated customers ask for:
- Finest granularity: one decision per column and per row scope, for every request.
- Fail closed: no PDP means no data.
- Regulatory context: DORA, the EU AI Act and GDPR purpose limitation.
The architecture in one picture#
Entra ID Agent gateway (PEP) PDP (system of record)
┌──────────────┐ token ┌────────────────────┐ AuthZEN ┌───────────────────────┐
│ delegated: │───────► │ tool call: │────────► │ validates Entra token │
│ OBO token │ │ table, columns, │ per col, │ Cedar policies │
│ appid + upn │ │ purpose, approval │ per row │ agent registry │
│ autonomous: │ └─────────┬──────────┘ scope │ human clearances │
│ client cred │ │ └──────────┬────────────┘
└──────────────┘ │ only permitted SQL │ every PERMIT,
│ QUERY_TAG = PDP batch ids │ before replying
▼ ▼
┌──────────────────────────────── Snowflake ────────────────────────────────────┐
│ External OAuth, IS_AGENTIC = TRUE ──► agent session │
│ │
│ DECISION_GRANTS (session, identity, role, resource, TTL) ◄────────────────────┘
│ PDP heartbeat │
│ │ │
│ ▼ │
│ Horizon: tag-based masking + row access policies ──► BANKING data │
│ Restricted Session Scope (read-only) · Data Movement Policy (bulk brake) │
│ ACCESS_HISTORY / QUERY_HISTORY ◄──joined──► PDP_DECISIONS (policy hash) │
└───────────────────────────────────────────────────────────────────────────────┘
▲
└── Horizon classification is harvested into the PDP as Cedar resource attributesPer tool call, this is what happens:
- The agent authenticates to Entra. A delegated agent exchanges the user’s token On-Behalf-Of, so the token carries both the agent (
appid) and the human (upn). An autonomous agent uses client credentials, so the token carries only the agent. - The gateway opens a Snowflake session with that token. The External OAuth integration has
IS_AGENTIC = TRUE, so Snowflake marks the session as agent-driven. Delegated sessions run as the human’s user; autonomous ones as aSERVICE_AGENTuser. - The gateway asks the PDP, through AuthZEN, for one decision per requested column and one per row scope, with the declared purpose, any human approval, and its Snowflake session ID.
- The PDP validates the Entra token itself. It never trusts a subject the gateway asserts. It derives the agent and the human, looks up the human’s clearance in its own store, and evaluates Cedar.
- Every permit is written to Snowflake as a short-lived decision grant bound to that session, identity and role, before the PDP replies.
- The gateway runs only the permitted SQL and tags it with the PDP batch IDs.
- Inside Snowflake, Horizon policies reveal data only where a live decision grant exists for the current session, and fail closed if the PDP heartbeat goes stale.
- The decision log is shipped to Snowflake and joined to query and access history for audit.
The policies: Cedar, owned by security#
The PDP is the only place where policy is written. The Cedar file reads almost like the requirements document. A delegated agent gets the intersection of its own ceiling and the human’s clearance:
// An agent can never see more than the person it acts for.
@id("delegated-column-read")
permit (principal is Agent, action == Action::"read_column", resource is Column)
when {
principal.mode == "delegated" &&
context has on_behalf_of &&
principal.tables.contains(resource.table) &&
resource.sensitivity <= principal.max_sensitivity &&
resource.sensitivity <= context.on_behalf_of.clearance
};Regulatory requirements become forbid rules that override any permit:
// EU AI Act Art. 14: high-risk agents need a human approval for the most sensitive data.
@id("ai-act-human-oversight")
forbid (principal is Agent, action == Action::"read_column", resource is Column)
when {
principal.risk_tier == "high" &&
resource.sensitivity >= 3 &&
!(context has human_approval && context.human_approval)
};
// GDPR Art. 5(1)(b): personal data only for a purpose the agent is registered for
// AND the data owner allowed AND the request declared.
@id("purpose-limitation")
forbid (principal is Agent, action == Action::"read_column", resource is Column)
when {
(resource.privacy_category == "IDENTIFIER" ||
resource.privacy_category == "QUASI_IDENTIFIER" ||
!resource.allowed_purposes.isEmpty()) &&
!(context has purpose &&
principal.purposes.contains(context.purpose) &&
resource.allowed_purposes.contains(context.purpose))
};There’s also a registry kill switch (forbid when !principal.approved) and two confused-deputy guards: a delegated agent must always carry the human it acts for, and an autonomous agent must never claim to.
Notice where resource.sensitivity, resource.privacy_category and resource.allowed_purposes come from. The PDP owns who may do what. Snowflake Horizon owns what the data is. A sync job harvests Horizon classification (SYSTEM$CLASSIFY privacy categories and the data owner’s sensitivity and purpose tags) and publishes it to the PDP as Cedar resource attributes. Data owners classify once, in Snowflake, and the policies follow the data. Unclassified columns default to the highest sensitivity.

Why a gateway alone isn’t enough#
The obvious design is to let the gateway ask the PDP and then query Snowflake with whatever it was allowed. That’s only as strong as the gateway. A gateway bug, an agent that asks for two columns and queries five, or an agent that skips the gateway and uses its perfectly valid Entra token directly: all of these go straight through.
There are three ways to connect an external PDP to a data platform:
| Pattern | How | Strength | Weakness |
|---|---|---|---|
| A. Decide at the gateway | PEP calls the PDP per tool call, then queries | Finest granularity, full request context | Bypassable with a valid token |
| B. Decide at token issuance | PDP shapes the token (role scope, session scope) | Enforced natively, no runtime dependency | Session-level only; can’t express per-column, per-purpose decisions |
| C. Decisions as data in Snowflake | PDP decisions are materialised in Snowflake and enforced by Horizon policies | Holds even if the gateway is bypassed; fails closed in the engine | Needs a sync channel and freshness handling |
The demo combines A and C, and uses B where it fits. The gateway asks at the finest granularity. The PDP pushes each permit into Snowflake as a decision grant. And the role comes from the token, with a read-only Restricted Session Scope capping every agent session whatever the PDP decides.
Decision grants: how Snowflake enforces the PDP’s decision#
Snowflake can’t call an external PDP from inside a masking policy. So the PDP pushes its decisions instead, into a small table:
CREATE TABLE DECISION_GRANTS ( -- a hybrid table in production
DECISION_ID STRING NOT NULL, -- joins to the PDP decision log
SESSION_ID NUMBER NOT NULL, -- CURRENT_SESSION() of the agent
SNOWFLAKE_LOGIN STRING NOT NULL, -- token subject: upn or service principal id
SNOWFLAKE_ROLE STRING NOT NULL,
KIND STRING NOT NULL, -- COLUMN | ROWS
RESOURCE_ID STRING NOT NULL, -- CUSTOMERS.EMAIL | CUSTOMERS/UK
EXPIRES_AT TIMESTAMP_LTZ NOT NULL
);One function answers the only question Snowflake needs to ask: did the PDP permit this, for this session, recently?
CREATE OR REPLACE FUNCTION PDP_PERMITS(kind STRING, resource_id STRING)
RETURNS BOOLEAN AS $$
-- humans without an agent: normal RBAC, untouched
NOT COALESCE(SYS_CONTEXT('SNOWFLAKE$CURRENT', 'IS_AGENT_ACTIVATED')::BOOLEAN, FALSE)
OR (
PDP_IS_FRESH() -- fail closed on a stale heartbeat
AND EXISTS (
SELECT 1 FROM DECISION_GRANTS g
WHERE g.SESSION_ID = CURRENT_SESSION()::NUMBER
AND g.SNOWFLAKE_LOGIN IN (SELECT LOGIN_NAME FROM USER_DIRECTORY
WHERE USER_NAME = CURRENT_USER())
AND g.SNOWFLAKE_ROLE = CURRENT_ROLE()
AND g.KIND = kind
AND g.RESOURCE_ID = resource_id
AND g.EXPIRES_AT > CURRENT_TIMESTAMP()))
$$;Then one tag puts every governed column under PDP control, through tag-based masking, and row access policies enforce row scopes such as data residency:
CREATE OR REPLACE MASKING POLICY PDP_MASK_STRING AS (val STRING) RETURNS STRING ->
IFF(PDP_PERMITS('COLUMN',
SYSTEM$GET_TAG_ON_CURRENT_COLUMN('GOVERNANCE.PDP_RESOURCE_ID')),
val, '***PDP-DENIED***');
ALTER TAG PDP_RESOURCE_ID SET MASKING POLICY PDP_MASK_STRING; -- plus NUMBER, DATE, ...
CREATE OR REPLACE ROW ACCESS POLICY PDP_ROWS_CUSTOMERS AS (region STRING) RETURNS BOOLEAN ->
PDP_PERMITS('ROWS', 'CUSTOMERS/' || region);Snowflake never re-implements Cedar. It doesn’t know about purposes, risk tiers or clearances. It only checks for a fresh, session-bound permit. Policy is authored in one place, and enforced in two.
What the nine scenarios show#
All scenarios run against real Entra tokens and a real Snowflake account.
| # | Scenario | Result |
|---|---|---|
| 1 | Autonomous agent reads transactions, asks for IBAN | Permitted columns returned across its regions; IBAN denied (above its ceiling) |
| 2a | Delegated high-risk agent, KYC review, no human approval | Name and date of birth denied (AI Act oversight); only the human’s region (UK) |
| 2b | Same request, human approval recorded | Identifiers permitted |
| 2c | Purpose customer_service asks for date of birth | Denied (purpose limitation); email permitted |
| 3 | Agent queries more than the PDP permitted | Snowflake masks the extra columns |
| 4 | Agent bypasses the gateway with a valid token | 0 rows |
| 5 | Unapproved agent, then a live revocation | Everything denied |
| 6 | PDP unreachable, heartbeat stale | Gateway refuses; Snowflake returns 0 rows |
| 7 | Bulk extraction of 1,000 rows | Blocked by the Data Movement Policy |
| 8 | Same human, no agent | Normal access |
| 9 | Audit | Query history joined to PDP decisions and policy hash |
Three of them are the reason this design exists.
Scenario 3: the agent queries more than it asked for. The gateway asked for CUSTOMER_ID and SEGMENT. The agent then ran SELECT CUSTOMER_ID, SEGMENT, FULL_NAME, IBAN, REGION in the same session. Snowflake returned the permitted columns and masked the rest:

Scenario 4: the agent skips the gateway. It connects to Snowflake directly with its valid Entra token and runs SELECT * FROM TRANSACTIONS. The session is agentic, has no decision grants, and gets zero rows. Authentication succeeded; authorisation didn’t.
Scenario 6: the PDP goes down. The gateway fails closed immediately. Grants issued a moment earlier still work for their short TTL (five minutes here). But as soon as the PDP heartbeat is older than two minutes, Snowflake masks everything for agents, including data that was just granted:

Throughout all of this, humans are untouched. The same relationship manager querying without an agent gets normal RBAC (scenario 8), because every policy only acts when IS_AGENT_ACTIVATED is true.
Defence in depth that doesn’t depend on the PDP#
Two Horizon controls sit underneath the decision grants and work even if a Cedar policy is wrong:
- Restricted Session Scope. Every agent session is capped at read-only. An agent can’t write or change objects, whatever the PDP permits.
- Data Movement Policy. Attached to the
DATA_SENSITIVITYclassification tag, it limits agents to 200 classified rows per statement and blocks any external unload. In scenario 7 a 1,000-row pull fails withData movement policy triggered, independent of the PDP.
These are the “privilege ceiling” and “data movement limits” from Keep Shipping. Here they act as the blast-radius limit for an externally governed design.
Audit evidence for DORA and the AI Act#
The gateway tags every query with the PDP batch IDs it was based on. The PDP ships its decision log, including which Cedar policy decided and a hash of the policy set, into Snowflake. One view then joins the decision to what actually happened:
-- one row per agent query: who asked, which agent, which decisions,
-- which Cedar policies, which policy version, and what was really read
SELECT query_id, user_name, role_name, agent, purpose,
pdp_decisions, policy_hash, on_behalf_of, ai_act_risk_tier,
agents_info, base_objects_accessed
FROM GOVERNANCE.AGENT_AUDIT_TRAIL;QUERY_HISTORY and ACCESS_HISTORY (including agents_info) provide the evidence of what each agent actually read, down to the column. The PDP log provides why it was allowed. Together they answer the auditor’s question: show me every time this agent touched customer identifiers, who it acted for, and which version of which rule allowed it.

An illustrative mapping of the controls to the regulations the scenario assumes:
| Requirement | Mechanism in the demo |
|---|---|
| EU AI Act Art. 14: human oversight | ai-act-human-oversight: high-risk agents need a recorded human approval for restricted data |
| EU AI Act Art. 12 / 19: logging | Decision log with policy hash, joined to Snowflake access history |
| EU AI Act Art. 26: deployer monitoring | Decisions per agent, policy and risk tier |
| DORA Art. 9: least privilege | Per-column and per-row decisions, read-only session scope, data movement limits |
| DORA Art. 17: incident management | Registry kill switch on the next request; grants expire within minutes |
| DORA Art. 28: ICT third-party register | Agent registry attributes: owner, ICT third party, risk tier |
| GDPR Art. 5(1)(b): purpose limitation | purpose-limitation over Horizon privacy categories and the owner’s allowed purposes |
This shows how the controls could support those obligations. It isn’t legal advice or a compliance claim.
What production would need#
The PDP, gateway and sync are deliberately small Python services, written for readability. Before anything like this goes near production:
- A highly available PDP. At least two instances, mTLS between gateway and PDP, signed policy bundles, Cedar schema validation and the policy test suite as a CI gate.
- Low-latency grants. Use a hybrid table for decision grants, a dedicated warehouse for the PDP sink, and a clean-up task for expired grants.
- Signed approvals.
human_approvalis a boolean asserted by the gateway in the demo. In production it should be a signed approval artefact from the workflow tool, verified by the PDP. - A real directory. Feed the identity mapping and human clearances from SCIM or your IGA tool, not static files.
- Scheduled classification sync, so new columns are onboarded automatically.
- Detection. Turn on the Trust Center AI Security and Data Security scanner packages, and alert on Data Movement Policy violations, agent sessions with zero grants (bypass attempts) and PDP heartbeat staleness.
- Close the identity gap. An agent that logs in as a regular user with a password, PAT or key pair isn’t recognised as an agent, so none of the agent-aware policies apply. Route agents through agentic OAuth or
SERVICE_AGENTusers. - Plan for Snowflake’s own agents. Cortex Agents and the managed MCP server are also marked agentic, so the same policies apply. Without a gateway in front they get no decision grants and see nothing, until you add a PEP path for them, for example a tool procedure that calls the PDP through an external access integration.
Try it#
You need Pixi, an Azure CLI login that can register apps and grant admin consent in a test tenant, and a Snowflake CLI ACCOUNTADMIN connection to a test Enterprise account.
git clone https://github.com/sfc-gh-kkeller/snowflake-agent-authz-pdp && cd snowflake-agent-authz-pdp
pixi run test # offline Cedar policy tests
pixi run entra-setup # Entra app registrations -> .env
# add SNOWFLAKE_ACCOUNT, SNOWFLAKE_CONNECTION, PDP_ADMIN_KEY to .env
pixi run sf-deploy # Snowflake objects (idempotent)
pixi run pdp & # PDP and console on 127.0.0.1:8180
pixi run sync-horizon # Horizon classification -> PDP
pixi run demo # all nine scenarios (or: python demo/run_demo.py 3 4)Open http://127.0.0.1:8180/console for the registry, the scenario buttons and the live decision feed. Add ?redact=1 to hide the demo identities when you share your screen. Tear everything down with pixi run sf-teardown && pixi run entra-teardown.
One gotcha: Snowflake allows one External OAuth integration per issuer. If your account already has one for your tenant, reuse it or use another account.
The takeaway#
A central PDP and a governed data platform aren’t competing answers to agent security. They’re two halves of one. The PDP is where security architecture writes policy, in Cedar, behind a vendor-neutral API. Snowflake Horizon contributes what only the data platform knows (what the data is, which session is an agent, what each query actually read) and enforces the PDP’s decisions inside the engine. That’s what makes the design hold when the gateway has a bug, when an agent bypasses it, and when the PDP goes down.
References#
- Cedar policy language · OpenID AuthZEN Authorization API 1.0
- Snowflake agent identity · External OAuth with Microsoft Entra ID
- Tag-based masking policies · Row access policies · Sensitive data classification
- Restricted Session Scope for agents · Data movement policies · Access History
Feature behaviour reflects Snowflake as of November 2026. Check the current documentation for your edition and region. Views are my own.
