Skip to content
Back to blog

Iceberg Fine-Grained Access Control for AI Agents

Governed data access for AI agents is one authorization chain: who the agent is, whom it acts for, which rows and columns it may see, and where that is enforced across engines.

Jonathan Saring

Jonathan Saring

21 min read
Governed data access illustration titled AI-Governed Data Access: a person, a laptop, and code connect through an AI agent and a policy checklist to a lakehouse protected by a shield and lock

Fine-grained access control for AI agents means deciding, for every query an agent runs, which tables, rows, and columns it may see, based on both the agent and the person it acts for, and enforcing that decision at a point the agent cannot route around. On an Apache Iceberg lakehouse that decision can live in the catalog, in each engine, or in a proxy in front of the engines, and each choice has a different failure mode once several engines read the same tables.

Gartner expects weak governance enforcement to be a leading cause of agent failures. Its 2026 predictions say that by 2030, 50% of AI agent deployment failures will be due to insufficient runtime enforcement of governance for capabilities and multisystem interoperability. OWASP's entry on excessive agency gives the engineering rule behind that: implement authorization in downstream systems, rather than relying on the model to decide whether an action is allowed.

Governed data access for agents is therefore an authorization chain, not a feature: authenticate the agent, record whom it acts for, map both to a catalog principal, filter rows and mask columns where every engine is covered, keep raw storage credentials out of the agent's hands, and write one audit record that names both identities. This guide walks through each hop with the real syntax for Polaris, Unity Catalog, Lake Formation, Trino, and a policy proxy, and ends with a bypass checklist to run before any agent gets access.

Access control is only half of running agents on a lakehouse; the tables they query also have to stay fast and correctly laid out, or every filtered query scans more than it should. A control plane such as LakeOps handles that operational side on the Iceberg stack you already run: it connects to your catalogs, reads table metadata, keeps tables maintained in place, and gives agents scoped access to operate the lakehouse over MCP. For agent SQL on the data itself, QueryFlux, the open-source SQL proxy maintained by the LakeOps team, is one place the row filters and column masks in this guide can be enforced in front of every engine.

Watercolor diagram of AI agents feeding a LakeOps control plane with layers for MCP, guardrails, routing, storage optimization, observability, and workload policies above Iceberg tables
Agent access is a stack of separate decisions, from the protocol the agent speaks to the tables it finally reads.

For the platform view, the lakehouse MCP server and guardrails for AI agents page covers how agents connect and what they may operate, and the enterprise data for AI agents guide maps the eight layers between an agent and enterprise data. This guide goes deep on one of them: who may see which rows and columns, and how to make that hold across engines.

The authorization chain for one agent query

Every agent query passes through the same six questions, whether or not your stack answers them deliberately. Most incidents come from a hop that nobody owns.

HopQuestionMechanism on an Iceberg lakehouseWhere it breaks
1. AuthenticateWhich agent is calling?OAuth 2.1 bearer token or a scoped API key per agentOne shared key for every agent
2. DelegateOn whose behalf?Token exchange with an act claim, or a verified session valueThe agent picks the subject from the prompt
3. Authorize objectsWhich tables may it reach?Catalog roles and grants, routing-group allowlistsGrants sized for humans, inherited by agents
4. Filter and maskWhich rows and columns?Row filters and column masks in the catalog, engine, or proxyEnforced in one engine, bypassed through another
5. Scope storageCan it read files directly?Vended credentials only for the enforcing layerAgent holds credentials that read whole files
6. RecordWho saw what, and why?Query history with actor, subject, and policy decisionAudit shows a service account, not the agent

The rest of this guide takes the hops in order. The hard parts are hops 2, 4, and 5, because that's where an agent differs most from a person running the same SQL.

Identity: the agent, the person, and the purpose

A person querying a lakehouse has one identity. An agent has at least two: its own, and the person or system it is acting for. The MCP authorization specification, optional but standard for HTTP servers, covers the hop from agent to server. When a server uses it, authorization servers must implement OAuth 2.1, clients must send the RFC 8707 resource parameter so every token is bound to one server, and servers must validate that a token was issued specifically for them. The token identifies the user and the registered client, not a distinct agent, which is why the agent needs its own identity on top. The spec also forbids the shortcut that breaks audit: an MCP server must not pass through the token it received from the client to upstream APIs. The security best practices page calls token passthrough an anti-pattern because it circumvents controls and erases accountability downstream.

The second identity needs delegation, not impersonation. OAuth 2.0 Token Exchange (RFC 8693) draws the line precisely: with impersonation, A is B; with delegation, A keeps its own identity and acts for B, and the issued token says so in an act claim. A token an agent presents on a user's behalf looks like this:

json
1{2  "iss": "https://idp.example.com",3  "sub": "maria@example.com",4  "aud": "https://sql.example.com",5  "act": { "sub": "agent:renewals-assistant" },6  "scope": "sql:read",7  "exp": 17959700008}

sub is the person whose data rights apply; act.sub is the agent doing the work. Policies can then require both: Maria must be allowed to see the row, and the renewals agent must be allowed to touch the table at all. That only works if both identities reach the layer that enforces policy, as verified token claims mapped into the policy input, not as values the agent writes itself. The Iceberg REST catalog doesn't carry delegation for you; the 1.12.0 OpenAPI spec marks its own token-exchange endpoint as deprecated for removal.

Effective permission is an intersection

The rule that keeps agents from becoming privilege amplifiers is simple to state: an agent acting for a person gets the intersection of three sets, never the union.

SetComes fromExample
What the person may seeThe user's grants in the catalog or policy engineMaria sees EU accounts
What the agent may touchThe agent's own principal and allowlistsThe renewals agent reads crm and billing, never hr
What the task needsThe agent's profile and allowlists for this jobRenewal analysis needs invoices, not payment details

Two failure modes come from skipping a set. If you only honor the person's grants, an agent built for one task can read everything its most privileged user can, and summarize it for someone else. If you only honor the agent's grants, every user of a shared agent gets the agent's access. Background agents with no signed-in user are the third case: give them their own service principal with grants sized for the job, and treat every one of them as a separate identity in audit.

One more rule, from the QueryFlux docs on querying on behalf of an account: never take the subject from an untrusted string. The application that authenticated the person resolves which account the agent works on, and passes it on a connection the agent doesn't control. QueryFlux forwards session values as the client sent them, so the policy must check that the actor may act for that account and validate the value before building a filter from it. An agent that can write WHERE account_id = … into its own SQL has no row-level security at all.

Where to enforce fine-grained access control on Iceberg

Once identities are right, the question is where a row filter or column mask actually runs. On a single-engine stack the engine's native policies are enough. On an Iceberg lakehouse with Spark for pipelines, Trino or DuckDB for interactive queries, and a warehouse reading the same tables, each enforcement point covers a different slice of traffic.

Enforcement pointExamplesCoversGap for agents
CatalogPolaris grants, Unity Catalog filters and masks, Lake Formation data filters, Snowflake HorizonObject access for every client that goes through the catalog; row and column rules only for engines that ask and complyEngines that read files with vended credentials see raw data
EngineTrino file-based rules or the OPA plugin, Ranger-backed SparkEvery query through that engineEach engine needs its own copy of the policy
ProxyQueryFlux with OPA or CerbosEvery query through the proxy, whatever engine runs itClients that skip the proxy
Spec-level, at load timeIceberg REST read-restrictionsReaders that implement the fieldReaders that ignore it, and direct file access
Illustration of AI agents sending queries through a query layer with guardrail, performance, filtering, and SQL processing capabilities before reaching an Iceberg lakehouse
Row filters and masks belong in a layer every agent query has to pass, not in each client or each engine separately.

Catalog-level rules

Catalogs decide which objects a principal can reach, and that layer is mature. In Apache Polaris, privileges are granted to catalog roles, catalog roles to principal roles, and principal roles to principals, so an agent gets its own principal with exactly the namespaces it needs:

bash
1polaris principals create support-agent2polaris principal-roles create support_agent3polaris principal-roles grant --principal support-agent support_agent4polaris catalog-roles create --catalog lake billing_reader5polaris catalog-roles grant --catalog lake --principal-role support_agent billing_reader6polaris privileges namespace grant --namespace billing --catalog lake --catalog-role billing_reader TABLE_READ_PROPERTIES

Note what this grant leaves out. TABLE_READ_DATA lets a principal receive short-lived read-only storage credentials from the catalog, which means reading whole Parquet files directly. An agent that holds it can bypass every row filter above the storage layer. If an agent needs row-level limits, keep TABLE_READ_DATA on the service account of the layer that enforces them, and let the agent reach data only through that layer. The zero-trust guide to vended credentials covers the storage side in depth.

Row and column rules at the catalog are newer and vendor-specific. Unity Catalog attaches SQL functions to tables:

sql
1CREATE FUNCTION us_filter(region STRING)2RETURN IF(IS_ACCOUNT_GROUP_MEMBER('admin'), true, region='US');3ALTER TABLE sales SET ROW FILTER us_filter ON (region);4 5CREATE FUNCTION ssn_mask(ssn STRING)6  RETURN CASE WHEN is_account_group_member('HumanResourceDept') THEN ssn ELSE '***-**-****' END;7ALTER TABLE users ALTER COLUMN ssn SET MASK ssn_mask;

The limit for a multi-engine lakehouse is in the Unity Catalog docs: tables with row filters or column masks can't be accessed through the Iceberg REST catalog or Unity REST APIs, except for reads from external engines through cross-engine ABAC, which filters data on Databricks serverless compute that you pay for, and currently requires recent Iceberg-Spark and Spark versions. AWS Lake Formation data filters provide row-, column-, and cell-level rules for reads in integrated engines such as Athena, EMR, and Redshift Spectrum, and third-party engines must enforce them and fail queries they can't enforce. Snowflake enforces row access and masking policies for external engines reading Iceberg tables through its Scan Plan API, a preview feature that runs on Snowflake compute, and its own docs state it can't enforce policies on users with direct storage access.

The common thread: a catalog can enforce rows and columns only for engines that ask it to and comply, and only when nobody holds raw storage credentials.

Read restrictions in the Iceberg REST spec

The Iceberg project standardized the catalog-to-engine contract in 2026. Pull request #13879 added read-restrictions to the loadTable response, and it shipped in the 1.12.0 REST spec. A catalog can now return a required row filter and per-column actions, keyed by field ID:

json
1{2  "read-restrictions": {3    "required-row-filter": {4      "type": "eq",5      "left": { "type": "reference", "id": 14 },6      "right": { "type": "literal", "value": "US" }7    },8    "required-column-projections": [9      { "field-id": 4, "action": "show-last-4" },10      { "field-id": 6, "action": "replace-with-null" },11      { "field-id": 10, "action": "sha-256-global" }12    ]13  }14}

A reader that supports the field must apply every restriction or fail the query, and must never silently return raw, partial, or empty results. That fail-closed rule is the right design. It still trusts the reader: Google's announcement of the change notes that the spec does not ship enforcement and that engine support comes next. Until every engine an agent can reach implements it, and until agents can't fetch storage credentials, read restrictions complement an enforcement point rather than replace one.

Engine-level rules

Engines enforce what passes through them. Trino's file-based access control attaches a filter and column rules to a table rule for a given user:

json
1{2  "tables": [3    {4      "user": "support-agent",5      "catalog": "lake",6      "schema": "billing",7      "table": "invoices",8      "privileges": ["SELECT"],9      "filter": "region = 'EU'",10      "columns": [11        { "name": "iban", "mask": "'****' || substr(iban, -4)" },12        { "name": "tax_id", "allow": false }13      ]14    }15  ]16}

For policy as code, Trino's OPA access control calls separate OPA endpoints for row filters and column masks. Open-source Spark ships no row or column policy of its own; teams typically add the Apache Kyuubi Spark AuthZ plugin backed by Apache Ranger. Each engine works, and that's the problem: three engines mean three policy copies, three test suites, and three chances to drift, while agents generate exactly the kind of exploratory SQL that finds the engine with the weakest copy.

Row-level security and column masks above the engines

A proxy in front of the engines moves the decision to one place. QueryFlux's access control works this way: it extracts the tables and columns a query touches, asks a policy provider (OPA or Cerbos), then allows, denies, or rewrites the SQL before dialect translation and engine dispatch. QueryFlux doesn't author policy; the Rego bundle or Cerbos policy files live in your own repository. The configuration connects the provider and sets the failure behavior:

yaml
1accessControl:2  enabled: true3  defaultConnection: prod4  connections:5    prod:6      provider: opa7      opa:8        url: http://opa.internal:81819        decisionPath: /v1/data/queryflux/access10        timeoutMs: 100011      operations: [table.select]12      onMissingSchema: deny13      failOpen: false14      sessionParamKeys: [account_id]

Without a catalog integration, onMissingSchema: deny stops a SELECT * from slipping past column masks when QueryFlux can't resolve the column list. For each query, QueryFlux sends the verified identity, the tables and columns, and only the session values listed in sessionParamKeys. Per the OPA provider docs, the policy answers per table:

json
1{2  "result": {3    "resources": [4      {5        "table": "invoices",6        "allow": true,7        "rowFilters": [{ "expression": "account_id = 'acct_9f3a'" }],8        "columnMasks": [{ "column": "iban", "type": "SHOW_LAST_4" }]9      }10    ]11  }12}

Four properties matter for agents:

  • The filter is applied at every scan site. The table reference becomes a filtered subquery wherever it appears, including CTEs, subqueries, and self-joins, so an agent can't escape a filter by restructuring the SQL.
  • It fails closed. A missing or empty decision is treated as deny-all, and failOpen: false turns a provider outage into denied queries rather than unfiltered ones.
  • The same rule covers every engine behind it. Trino, DuckDB, StarRocks, ClickHouse, Snowflake, and others get identical enforcement, whether or not the engine has native row-level security.
  • Masks are typed. The built-in mask types include NULL, CONSTANT, REDACT, SHOW_LAST_4, SHOW_FIRST_4, DATE_SHOW_YEAR, HASH, and CUSTOM.

QueryFlux's post on row filters above the engines makes the distinction that keeps teams from conflating layers: guardrails decide whether SQL is safe to run at all, while access control decides which rows and columns an identity may see. A row_limit of 5,000 stops a runaway scan; it doesn't stop an agent from reading another customer's 4,999 rows.

Identity reaches the proxy through its authentication layer: OIDC, LDAP, or static users, with auth.required: true rejecting anonymous callers on every frontend. Where an engine must also see the real user, query authentication modes can impersonate the user (Trino, ClickHouse) or exchange the client's token under RFC 8693 (Trino, Snowflake), and fail closed when they can't. Two limits: QueryFlux's MCP frontend validates bearer tokens through the same provider rather than implementing the MCP spec's own OAuth flow, and agent context fields such as agent_id and conversation_id are labels the client sends for attribution and replay, not authenticated identity. Authorization decisions should key off the verified identity, never the label.

Purpose-based profiles for agents

Per-agent policies are easier to review when every agent matches a named profile. A profile fixes the identity type, what it can reach, and how rows and columns are restricted:

ProfileIdentityTablesRowsColumns
Analytics assistantDelegated user (sub = person, act = agent)Curated marts onlyThe person's own row filtersPerson's masks, plus PII masked for the agent
Support agentAgent principal + verified account_idBilling and subscription tablesaccount_id from the support appPayment fields SHOW_LAST_4
Finance reporting agentBackground service principalFinance martsAll rows in scopePersonal names HASH (or CUSTOM for identical output across engines)
Research agentAgent principal, no userPublic and aggregated tablesNone neededNone needed
Lakehouse operator agentScoped operations keyTable metadata, not row dataNot applicableNot applicable

The last profile is a different kind of access. An agent that triages table health or runs maintenance reads metadata and calls operations; it never needs row data. Keep those keys separate from any data-access identity, so a maintenance agent can't become a data exfiltration path.

Writes and operations need their own grants

Read policies are the common case, but agents also write: corrections, enrichments, memory, generated tables. Writes aren't checked by default in QueryFlux: operations defaults to [table.select]. Add write operations (table.insert, table.update, table.delete, table.merge, and others) and QueryFlux evaluates write targets as their own operations, while the reads inside a write are evaluated as selects, so an INSERT … SELECT can't copy rows the agent isn't allowed to read. Catalog-side, keep write grants off agent principals unless a task requires them, and isolate the writes that are allowed on a branch per run with an audit step before publishing; the Iceberg lakehouse for agentic AI guide walks through that pattern.

Copies are the quiet leak. Data an agent writes into its own memory table, scratch table, or cache no longer carries the source table's row filter. Treat agent-written tables as new data products: classify them, put them under the same policy provider, and give them retention, or they become the easiest way around every rule above.

Operating the lakehouse is the third kind of access. In LakeOps, agents call the MCP server with an organization API key, and each key carries scopes. The agent connection guide defines three profiles: read-only (read) for discovery, insights, and analysis; run maintenance (read plus tables:write) to execute one maintenance operation on one table; and manage policies (read plus policies:write). The docs also note that a key with tables:write can rename, roll back, and delete tables over the REST API, so treat it as a destructive grant and keep it off agents that only need to read.

Audit: both identities and the decision

An audit record for an agent query needs four things: the authenticated actor, the subject it acted for, the policy decision, and the SQL that actually ran. QueryFlux records each access decision as a guard action with the tables, whether rows were filtered, which columns were masked, and the rewritten SQL, and stores agent context alongside every query for session replay. With history in Postgres, a weekly review is one query:

sql
1-- Queries and guard denials (access control and guardrails)2-- per authenticated identity and agent label, last 7 days3SELECT username,4       agent_id,5       count(*)                                   AS queries,6       count(*) FILTER (WHERE was_guard_blocked)  AS blocked7FROM query_records8WHERE created_at >= now() - interval '7 days'9GROUP BY username, agent_id10ORDER BY blocked DESC;

One caveat: with the QueryFlux result cache turned on, some guard denials may not be written to query history, so treat the blocked count as a floor rather than an exact total.

Keep the actor as the agent, and put the account or person in a separate field. The QueryFlux on-behalf-of guidance is explicit about this: never set the identity to the customer, or the audit trail shows a fake customer login instead of the agent that looked the account up.

Test the policy before an agent does

Agents probe systematically; one QueryFlux experiment followed a single question through 13 tool calls. Assume every gap will be found, and test for these before granting access:

  1. 1.Storage credentials. Can any agent principal obtain vended credentials or bucket access for a filtered table? It must not.
  2. 2.Direct engine endpoints. Can an agent reach Trino, Spark Thrift, or a warehouse endpoint without passing the enforcing layer? Close it at the network or credential level.
  3. 3.Engine hints and routing. If a proxy lets clients request a specific engine, restrict which groups each identity may reach (in QueryFlux, authorization.allowGroups per group with auth.required: true).
  4. 4.Exempt principals. Admin, owner, and service accounts often skip filters. Make sure no agent can obtain or impersonate one.
  5. 5.Subject spoofing. Change the account or tenant value an agent sends. The request must be rejected unless the authenticating application issued it.
  6. 6.Query shapes. Run each policy against SELECT *, CTEs, self-joins, UNION, and INSERT … SELECT, and confirm the filter and masks hold in every one.
  7. 7.Copies. Check whether agent memory, scratch tables, caches, and exports keep the source restrictions.
  8. 8.Failure paths. Stop the policy provider and confirm queries are denied, not unfiltered.
  9. 9.Audit. Pick one agent query and reconstruct actor, subject, decision, and executed SQL from the logs alone.

Run the matrix per identity profile, not once. A policy that is correct for the analytics assistant can still leak for the support agent.

How LakeOps fits governed agent access

LakeOps doesn't decide which rows an agent may read; that belongs to your catalog, engines, or a policy proxy, as above. What it adds is the operational half that access control depends on, run from the LakeOps control plane on the Iceberg tables you already have.

Tables that make filtered queries cheap. A row filter is a WHERE clause. If the table is partitioned or sorted on the filter column, an engine prunes most files; if it isn't, every agent query scans the whole table and then discards most of it. LakeOps reads each table's metadata, raises insights against fixed thresholds (small files, snapshot and manifest buildup, delete ratio, partition skew), and derives health from them. Adaptive Maintenance then runs compaction, snapshot expiry, delete-file handling, and manifest rewrites when each table's signals say they are due, compacting with binpack or with the table's Iceberg sort order. Agent traffic multiplies the cost of a badly laid out table, so this is where governed access stays affordable.

LakeOps dashboard with 30-day optimization activity and counts of total, critical, warning, and healthy tables
The lake-wide view first: how many tables are Critical, Warning, or Healthy before agents start querying them.
LakeOps tables list showing each Iceberg table's namespace, records, size, and Healthy, Warning, or Critical status
Per-table health for the tables agents read, filterable by catalog and namespace.

Scoped access for agents that operate the lake. Beyond the key profiles above, read-only MCP tools are marked as such, and the destructive ones (execute_optimization, execute_policy, and delete_table) carry destructiveHint, so clients that honor the annotation ask a person before running them. The MCP server reference lists all 31 tools with their scopes.

One record of operations. Every operation lands in Events with status, duration, and impact, whether a policy, a person in the console, a REST call, or an agent started it. That is the operations half of the audit trail; the query half lives in your proxy or engine history.

LakeOps events log listing compaction, snapshot expiry, and manifest rewrite operations with impact, duration, and status
Every operation on one record, including the ones an agent started over MCP.

A query layer for agent traffic. Because LakeOps query routing is built on QueryFlux, agent queries can run in their own QueryFlux cluster group with their own engines, concurrency limits, guardrails, and access-control connection. The multi-engine query routing page covers groups and strategies; the console routing screens currently show sample data, while routing itself runs on QueryFlux.

LakeOps routing groups for analytics, BI, ETL, and reports, each with its own endpoints
Workload groups give each kind of traffic its own lane. The console routing screens are in alpha and show sample data.

Together these cover the parts of the agentic lakehouse around access control: tables that stay fast under agent load, scoped operations, and one record of what ran.

Governed agent access is an enforcement-point decision

Fine-grained access control for AI agents works when three things are true: every query carries the agent's identity and the subject it acts for, row filters and column masks run in a layer that every engine path passes through, and no agent holds credentials that read files directly. Catalog rules, engine rules, and the new Iceberg read restrictions all help, but in a multi-engine lakehouse one enforcement point in front of the engines is what makes the policy hold. Keep the tables underneath healthy so filtered queries stay cheap, and if you'd rather not run that operational loop yourself, LakeOps runs it on the Iceberg lakehouse you already have.

Related articles

Found this useful? Share it with your team.