Skip to content

feat(views)!: protect trino.run-as-owner and DEFINER view versions by default - #2212

Merged
c-thiel merged 1 commit into
mainfrom
christian/protect-view-owner-property
Nov 2, 2026
Merged

c-thiel merged 1 commit into
mainfrom
christian/protect-view-owner-property

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Trino runs a SECURITY DEFINER view as the user in its trino.run-as-owner property. Protecting this property was opt-in: Lakekeeper protected it only once Trino was configured as a trusted engine. Lakekeeper now protects it by default on servers with authentication, and also protects the version of views that carry it.

Rules

  • Only a trusted engine whose owner property is trino.run-as-owner (or another configured owner key) can set, change or remove it. Others get 403 ProtectedPropertyModification. Without a configured trusted engine, nobody can write trino.run-as-owner.
  • On a view with an owner property, only that engine can change the current view version. Others get 403 ProtectedViewVersionChange; they can still change other properties, rename and drop.
  • If the engine changes the query without sending the owner, Lakekeeper removes the owner in the same commit, so the new query never runs as the old owner. A change that keeps the query (COMMENT ON COLUMN) keeps the owner.
  • Refusals are recorded in the audit log as denied authorizations.

Operators

  • If Trino creates or changes DEFINER views, configure it as a trusted engine with OWNER_PROPERTY=trino.run-as-owner, matched to the Trino catalog's service identity. Without it, Trino can only create SECURITY INVOKER views, and existing DEFINER views cannot get a new version.
  • Do not add the OPA bridge client to the trusted engine.
  • Check existing views that carry trino.run-as-owner (see View Security → Check Existing Views).

Docs: view-security.md, opa.md, configuration.md, logging.md. The access-control-simple example and tests/docker-compose.yaml now configure Trino as a trusted engine.

Release notes

Breaking Changes

  • Trino DEFINER views are protected by default. On servers with authentication, only a trusted engine can set trino.run-as-owner or change a view that has it. Configure Trino as a trusted engine to keep creating SECURITY DEFINER views.

Upgrade Notes

  • Check views that carry trino.run-as-owner. Make sure each owner is correct; see View Security.
  • Trusting Trino turns on view chains. Tables loaded through a DEFINER view are then checked against the view owner's permissions.
  • Remove the OPA bridge client from the trusted engine. It only sends permission checks.

Downstream follow-up

  • New public field State::authentication (ServerAuthentication::Enabled / Disabled); struct literals must set it. new_full_router sets it from the authenticator.
  • View contract verifiers run after the metadata is built and the owner rules ran; their update list and CommitViewEvent::request can end with a server-added remove-properties.
  • DynAppConfig::default() protects trino.run-as-owner. Tests that create DEFINER views need a Trino engine on the request (trino_engine_request()).

Summary by CodeRabbit

  • New Features
    • Protected view-owner properties are restricted to their configured trusted engine when server authentication is enabled. Unauthorized attempts to set or change these properties, or to change a protected view’s current version, are rejected.
    • When a trusted engine changes a view’s query without retaining its owner property, that property is removed.
    • Audit records now capture denied view creation and commit attempts involving protected owner properties.
  • Documentation
    • Updated guidance explains trusted-engine requirements, Trino owner-property behavior, and related restrictions.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddc02a04-b6f9-4ebc-b4e1-b9d435b46b49
Commits

Reviewing files that changed from the base of the PR and between 0a86441 and 4580ccb.

Files selected for processing: 29
  • audit-format/unreleased/view-owner-property-refusals.md
  • crates/lakekeeper-integration-tests/src/lib.rs
  • crates/lakekeeper-integration-tests/src/view_owner_helper.rs
  • crates/lakekeeper-integration-tests/tests/audit_corpus.rs
  • crates/lakekeeper-integration-tests/tests/server_views_commit.rs
  • crates/lakekeeper-integration-tests/tests/server_views_create.rs
  • crates/lakekeeper-integration-tests/tests/view_owner_router.rs
  • crates/lakekeeper-storage-postgres/src/test_utils.rs
  • crates/lakekeeper/src/api/router.rs
  • crates/lakekeeper/src/config.rs
  • crates/lakekeeper/src/serve.rs
  • crates/lakekeeper/src/server/tables.rs
  • crates/lakekeeper/src/server/views.rs
  • crates/lakekeeper/src/server/views/commit.rs
  • crates/lakekeeper/src/server/views/create.rs
  • crates/lakekeeper/src/server/views/owner_property.rs
  • crates/lakekeeper/src/service/contract_verification.rs
  • crates/lakekeeper/src/service/events/backends/audit/fixtures/authz_failed_create_view_owner_property.json
  • crates/lakekeeper/src/service/events/backends/audit/fixtures/authz_failed_view_commit_owner_property.json
  • crates/lakekeeper/src/service/events/backends/audit/fixtures/authz_failed_view_version_change.json
  • crates/lakekeeper/src/service/events/backends/audit/tests.rs
  • crates/lakekeeper/src/service/mod.rs
  • docs/docs/configuration.md
  • docs/docs/logging.md
  • docs/docs/opa.md
  • docs/docs/view-security.md
  • examples/access-control-advanced/docker-compose.yaml
  • examples/access-control-simple/docker-compose.yaml
  • tests/docker-compose.yaml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

The pull request adds authentication-aware checks for protected view owner properties and current-version changes. Trusted-engine commits can remove stale owner properties when the view query changes. The changes also add audit coverage, integration tests, configuration updates, and documentation.

Changes

View owner-property protection

Layer / File(s) Summary
Authentication state and protected-property configuration
crates/lakekeeper/src/service/mod.rs, crates/lakekeeper/src/config.rs, crates/lakekeeper/src/api/router.rs, crates/lakekeeper/src/serve.rs, crates/lakekeeper-storage-postgres/src/test_utils.rs, crates/lakekeeper-integration-tests/tests/view_owner_router.rs
API state now records authentication status. Configuration always protects Trino’s trino.run-as-owner key and adds configured trusted-engine owner properties. Router setup synchronizes authentication state and logs warnings for mismatches or disabled authentication with configured trusted engines.
Owner-property authorization rules
crates/lakekeeper/src/server/views/owner_property.rs
The new module checks protected property writes and current-version changes against matched-engine ownership. It identifies properties to remove when a trusted engine changes the view query.
View creation checks
crates/lakekeeper-integration-tests/src/*, crates/lakekeeper/src/server/views/create.rs, crates/lakekeeper-integration-tests/tests/server_views_create.rs
View creation checks protected property writes and reports authorization failures. Tests cover trusted, untrusted, and unauthenticated requests.
View commit validation and updates
crates/lakekeeper/src/server/views/commit.rs, crates/lakekeeper/src/server/tables.rs, crates/lakekeeper/src/service/contract_verification.rs, crates/lakekeeper-integration-tests/tests/server_views_commit.rs
View commits check property writes and version changes. When needed, commits append owner-property removals and pass the applied updates to contract verification and commit events. Tests cover authorization and update propagation.
Audit coverage and operational documentation
crates/lakekeeper-integration-tests/tests/audit_corpus.rs, crates/lakekeeper/src/service/events/backends/audit/*, audit-format/unreleased/*, docs/docs/*, examples/access-control-*/docker-compose.yaml, tests/docker-compose.yaml
Audit tests and fixtures cover denied view creation and commit operations. Documentation, examples, and release notes describe the owner-property rules and trusted-engine setup.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ViewCommit
  participant owner_property
  participant build_committed_metadata
  participant ContractVerification
  participant Catalog
  participant CommitEvent
  ViewCommit->>owner_property: Check requested property writes
  ViewCommit->>build_committed_metadata: Build metadata and check version change
  build_committed_metadata-->>ViewCommit: Return metadata and applied request
  ViewCommit->>ContractVerification: Check applied updates
  ViewCommit->>Catalog: Commit view metadata
  ViewCommit->>CommitEvent: Emit commit event after retries
Loading
Merge Risk: Minimal · up to 4580c

This change protects the Trino owner property and DEFINER view versions on authenticated servers, and it is documented as a breaking change for operators who rely on Trino creating DEFINER views. No concrete merge-blocking defect was established in the supplied code or tests. Operators need to configure Trino as a trusted engine, as the release notes describe.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.07% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: protecting the Trino owner property and DEFINER view versions by default.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 62.07% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 29 functions across 18 files. (11 skipped: 11 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each view with care,
Owner keys need trust to be there.
New versions pass the proper gate,
Stale keys leave when queries change state.
Audit crumbs record each trail,
The bunny hops beyond the veil.

@c-thiel
c-thiel enabled auto-merge (squash) November 2, 2026 16:55
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant