OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

Add asset-level RBAC for read-only SPARQL queries

Open fmcardoso opened this issue 2 months ago • 3 comments

Problem

The RDF query spike recommends a model-authored SPARQL agent tool for 2.1. Asset-wide execution needs authorization across the entities and relationships participating in a query. Filtering returned rows after execution is insufficient: aggregates, existence checks and paths can reveal inaccessible assets.

Follow-up to https://github.com/open-metadata/OpenMetadata/issues/32048 and evidence in https://github.com/open-metadata/ai-platform/pull/1292.

Scope

  • Design and implement non-admin, read-only SPARQL execution that uses the caller identity and existing role/resource policies. Document how persona scope applies where supported.
  • Define the authorized query dataset and treatment of paths through inaccessible intermediate entities. Cover joins, aggregates, ASK/existence queries, subqueries and named graphs. Reject unsupported shapes safely rather than broadening access.
  • Enforce authorization before query evaluation can expose restricted information, including aggregate computation. Specify whether a query evaluates over an authorized view or is rejected; do not assume post-filtering can repair a count.
  • Evaluate reuse of the existing glossary-scoped execution/authoring surfaces, OntologySparqlQueryValidator, SparqlFederationGuard and SparqlQueryLimits. Glossary access is a precedent, not proof of asset-wide authorization.
  • Define permission-change/cache behavior, read-only operation restrictions, federation restrictions, bounded execution and explicit failure/completeness signals. Do not lower the existing admin-only RDF boundary until the replacement is enforced.
  • Agree the typed request/response and authorization-error contract with the ai-platform graph tool; document the chosen design and tradeoffs before implementation.

Acceptance criteria

  • [ ] Authorized callers can traverse/filter/aggregate permitted assets using the agreed contract.
  • [ ] Tests cover non-admin allowed/denied cases, mixed-access paths and joins, aggregates, existence checks, subqueries/named graphs, and permission changes; inaccessible entities cannot influence visible answers contrary to the documented policy.
  • [ ] Authorization is applied before aggregation, not only to returned rows.
  • [ ] Validation, timeout, authorization and projection failures are distinguishable from successful empty results; limited results report completeness explicitly.
  • [ ] Existing glossary-scoped and admin behaviors have regression coverage.
  • [ ] Server API contract and companion agent integration are linked and documented.

Target: 2.1. This is implementation follow-up, not a condition of accepting the spike results.

fmcardoso avatar Sep 11 '26 15:09 fmcardoso

Hi @pmbrull , @fmcardoso , @harshach sir I’d like to work on this implementation follow-up for 2.1.

I’ve gone through the issue and the current SPARQL implementation, including OntologySparqlQueryValidator, OntologySparqlQueryService, SparqlFederationGuard, and SparqlQueryLimits. I understand that the main challenge is not just exposing SPARQL to non-admin users, but enforcing authorization on the RDF dataset before query evaluation so that aggregates, ASK queries, joins, subqueries, and paths cannot leak information from inaccessible assets.

My proposed approach is:

  1. Define the authorized RDF dataset/view based on the caller identity and existing role/resource policies.
  2. Apply authorization before SPARQL evaluation rather than filtering the result rows afterward.
  3. Define safe semantics for joins and paths that pass through inaccessible entities.
  4. Reuse the existing OntologySparqlQueryValidator, SparqlFederationGuard, and SparqlQueryLimits instead of creating a separate validation/security layer.
  5. Keep the existing admin-only RDF boundary unchanged until the new authorization path is fully enforced.
  6. Add tests for non-admin allowed/denied access, mixed-access joins and paths, aggregates, ASK/existence queries, subqueries, named graphs, permission changes, limits, and failure/empty-result distinction.
  7. Define the typed request/response and authorization-error contract needed by the ai-platform graph tool.
  8. Document the authorization model, query semantics, completeness/limit behavior, and design trade-offs.

I’d prefer to break this into smaller PRs, starting with the authorization/dataset layer, then SPARQL execution integration, followed by the security/regression tests and finally the ai-platform contract.

I’m happy to take ownership of this and start by preparing the design/implementation proposal and tracing the existing authorization utilities before making changes.

Please let me know if this approach aligns with the expected direction.

Darshan3690 avatar Sep 12 '26 07:09 Darshan3690

Hi @pmbrull , @fmcardoso , @harshach sir I’d like to work on this implementation follow-up for 2.1.

I’ve gone through the issue and the current SPARQL implementation, including OntologySparqlQueryValidator, OntologySparqlQueryService, SparqlFederationGuard, and SparqlQueryLimits. I understand that the main challenge is not just exposing SPARQL to non-admin users, but enforcing authorization on the RDF dataset before query evaluation so that aggregates, ASK queries, joins, subqueries, and paths cannot leak information from inaccessible assets.

My proposed approach is:

  1. Define the authorized RDF dataset/view based on the caller identity and existing role/resource policies.
  2. Apply authorization before SPARQL evaluation rather than filtering the result rows afterward.
  3. Define safe semantics for joins and paths that pass through inaccessible entities.
  4. Reuse the existing OntologySparqlQueryValidator, SparqlFederationGuard, and SparqlQueryLimits instead of creating a separate validation/security layer.
  5. Keep the existing admin-only RDF boundary unchanged until the new authorization path is fully enforced.
  6. Add tests for non-admin allowed/denied access, mixed-access joins and paths, aggregates, ASK/existence queries, subqueries, named graphs, permission changes, limits, and failure/empty-result distinction.
  7. Define the typed request/response and authorization-error contract needed by the ai-platform graph tool.
  8. Document the authorization model, query semantics, completeness/limit behavior, and design trade-offs.

I’d prefer to break this into smaller PRs, starting with the authorization/dataset layer, then SPARQL execution integration, followed by the security/regression tests and finally the ai-platform contract.

I’m happy to take ownership of this and start by preparing the design/implementation proposal and tracing the existing authorization utilities before making changes.

Please let me know if this approach aligns with the expected direction.

Thanks for reviewing the existing SPARQL implementation and for outlining the security concerns. I’m going to take this issue because it is tightly coupled to the ai-platform graph-tool work I’m
│ implementing and requires coordinating the authorization semantics and cross-repo API contract together. I appreciate the offer and the analysis.

fmcardoso avatar Sep 14 '26 08:09 fmcardoso

Progress update: I have documented the proposed authorization semantics and built a test-only experiment that evaluates SPARQL over a caller-authorized RDF model. Tests cover counts, existence checks, paths through hidden assets, hidden-only mutation invariance, and conflicting structured-node ownership.

The latest local run passed 56 in-process tests and 56 tests with retrieval from an isolated Fuseki 6.2.0 container. Query evaluation remains on the local sanitized Jena model. Existing admin-only boundaries are unchanged; this is not production RBAC or a scale validation.

Draft PR: https://github.com/open-metadata/OpenMetadata/pull/33279. It currently contains the design/research documents; experiment commits are being reviewed locally and will follow. Real caller integration, broader field/relationship permission mapping, complete bounded retrieval, freshness, and practical resource limits remain open.

Feedback on alignment with existing asset-discovery and field-level permissions would be especially helpful.

fmcardoso avatar Sep 14 '26 19:09 fmcardoso