Three authorization gaps I found by enforcing one RBAC model on two engines

"We enforce one RBAC model on both engines" is the kind of sentence that gets written into an architecture document and never tested. I wrote the same sentence, then wrote the tests, and the tests disagreed three times.

The setting is a proof of concept for an Iceberg warehouse served by two engines, Trino and Apache Kyuubi on Spark, behind one REST catalog (repository). The role model is small on purpose: admins see everything; analysts read the gold marts and the non-PII silver tables; restricted analysts can additionally read a customer PII table, but with masked columns and a row filter; nobody but Spark writes. Trino enforces it with its file-based system access control. Kyuubi enforces it with the Kyuubi Spark AuthZ plugin, which embeds the Apache Ranger plugin inside every Spark engine and evaluates Ranger policies.

The useful decision was to write one set of pytest expectations and run it against both engines. Same users, same queries, same assertions about what is denied, masked or filtered. That is what found the gaps.

Gap 1: Kyuubi's AuthZ plugin does not see Iceberg metadata tables

Iceberg exposes a table's history as SQL. In Spark that is lakehouse.silver.customer_pii.snapshots, .history, .files. The policies grant analysts nothing on bronze and nothing on the PII table, so I expected the metadata tables of those tables to be denied as a matter of course.

They were not. An analyst could run SELECT snapshot_id FROM lakehouse.silver.customer_pii.snapshots and get every snapshot id, and SELECT file_path FROM lakehouse.bronze.transactions_raw.files and get every Parquet path. The plugin builds its privilege requests from the logical plan, and the relation for a metadata table does not resolve to a database/table pair the Hive-style policy model knows how to check. No request, no denial.

Trino, by contrast, names metadata tables "customer_pii$snapshots", so a single file rule matching .*\$.* with no privileges hides all of them from non-admins. Verified on both.

What it means in practice is narrower than it sounds. The file paths are useless without storage credentials, and the catalog in this design never vends any (that is its own post). The snapshot ids enable time travel, and time travel turned out to go through the same checks as a current read (analysts denied, restricted users masked). So the leak is metadata, not data. It is still a leak, and the test that asserts denial is marked xfail(strict=True) so the day a Kyuubi release fixes it, the suite fails loudly and the documentation gets updated.

Gap 2: COUNT(*) with no columns is, apparently, not a read

The second one surprised me more. SELECT transaction_id FROM lakehouse.bronze.transactions_raw was denied for analysts, as it should be. SELECT COUNT(*) FROM lakehouse.bronze.transactions_raw returned 1,005,000.

The plugin's privilege objects are column-based. A scan with no projected columns produces no column requests, and nothing in the path turned the empty column list into a table-level request. Disabling Iceberg's aggregate push-down did not change the result, so this is not a push-down artefact; the plan simply contained nothing the plugin chose to check.

Row counts leak existence. SELECT COUNT(*) FROM customer_pii WHERE national_id LIKE '1%' answered 5,013 for a user who may not read national_id. That is the version of this bug that a security reviewer will care about.

One role modeladmins / analysts / restricted Trino: file-based system access control ✓ table grants ✓ masks + row filter ✓ "t$snapshots" via regex rule ✓ COUNT(*) (table rule) ✗ ALTER TABLE … EXECUTE (fixed: read_only) Kyuubi: Ranger plugin inside each Spark engine ✓ column reads ✓ masks + row filter ✓ time travel ✗ metadata tables (xfail) ✗ COUNT(*) (fixed: row filter)
Same model, two enforcement points, three boxes that only a test would have drawn.

The fix is a compensating control rather than a plugin change: a Ranger row-filter policy on every table analysts must not read, with a predicate that returns no rows. The first version used 1 = 0 and made things worse, which is a story of its own, so the final predicate is customer_id < 0 AND customer_id > 0: a contradiction Catalyst does not fold, so the relation survives analysis, the column check still fires for real reads, and Iceberg prunes the scan to nothing for the count. After that, COUNT(*) returns 0 for analysts on bronze and on the PII table, and column reads are still denied with the proper error.

Gap 3: Trino's file rules do not govern ALTER TABLE ... EXECUTE

The third one is on the Trino side, and it is the one I would have bet against. An analyst with SELECT on a gold table, on a catalog marked read-only in the rules, ran:

ALTER TABLE lakehouse.gold.event_funnel_daily EXECUTE expire_snapshots(retention_threshold => '7d');
ALTER TABLE lakehouse.gold.event_funnel_daily EXECUTE optimize;
ALTER TABLE lakehouse.gold.event_funnel_daily EXECUTE remove_orphan_files(retention_threshold => '7d');

All three succeeded. The query log shows them finishing in the analyst's own resource group. CALL lakehouse.system.rollback_to_snapshot(...) was denied, SET PROPERTIES was denied, DELETE was denied, but table procedures are not covered by the file-based access control's table privileges, and "read-only" at the catalog rule level does not reach them. The damage is bounded by the connector's seven-day minimum retention, but an analyst rewriting data files with optimize during the ETL window is not a thing I want to explain to anyone.

The fix was a design decision rather than a rule: Spark owns every write and all maintenance in this architecture, so Trino's Iceberg connector now runs with iceberg.security=read_only. Procedures, CALLs and DML are denied for everyone on Trino, admins included, and the test covers all three roles. In production with Ranger or OPA as the system access control, the connector can return to system security with explicit procedure policies.

What a reviewer should ask

When someone presents "centralised authorization across engines", the questions that would have caught these three are short:

  1. Show me the metadata tables denied, on each engine, with a query.
  2. Show me a column-less aggregate on a denied table.
  3. Show me a table procedure attempted by a read-only user.
  4. Show me the test that fails when the engine version changes.

None of them need a security team. They need the same expectations run twice.

What I took from it

  1. One policy model is a document; one test suite run against every enforcement point is a control.
  2. Authorization plugins check what they parse. Anything that resolves to an unusual relation (metadata tables, column-less scans, procedures) needs its own test.
  3. When a plugin cannot deny, remove the capability: a read-only connector or a row filter is a stronger control than a policy nobody evaluates.
  4. Pin known gaps with strict expected failures. A silent fix upstream is as dangerous as a silent regression, because your compensating controls stop being reviewed.