Skip to content

Fix lineage authorization in MCP tools - #32437

Merged
Vishnuujain merged 5 commits into
mainfrom
fix/mcp-lineage-entity-scoped-authz
Sep 2, 2026
Merged

Vishnuujain merged 5 commits into
mainfrom
fix/mcp-lineage-entity-scoped-authz

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #31941

get_entity_lineage checked permissions without loading the asset first. Any policy rule that looks
at tags, owners or domains therefore got the same answer for every asset — so a rule meant to allow
one table ended up blocking all of them (or none).

What changed:

  • Check permissions against the actual asset, the way get_entity_details already does
  • Check each lineage node too, so you don't see the name of an asset you can't open
  • Remove edges left dangling when a node is dropped
  • Report how many nodes were hidden, so a trimmed graph isn't mistaken for a full one
  • Hide a pipeline's name on an edge if you can't view that pipeline
  • Return tempLineageTables only with includeSql=true, since they come from the SQL
  • Group the permission checks by entity type, so this costs a few queries instead of one per node

root_cause_analysis is left alone on purpose. It returns the same kind of node names, so it needs
the node filtering as well, not just the permission fix. Doing that separately.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Rule denies a tagged asset → lineage is denied
  • Rule denies everything except a tagged asset → that asset's lineage works
  • Neighbour you can't open → its name is gone and hiddenNodes says 1
  • Pipeline you can't open → its name is gone, but the edge still says "pipeline"
  • Admin sees everything in each case (used as the control)

Unit tests

  • Added.
  • LineagePermissionFilterTest — admin skip, bots not skipped, denied nodes dropped, over-limit
    nodes hidden instead of returned, canView allow/deny/error
  • LineageGraphPrunerTest — pruning leaves no dangling edges, drops nodes cut off behind a hidden one
  • GetLineageToolTest — pipeline hidden and shown, tempLineageTables gating
  • RuleEvaluatorTest — a permission check with no asset loaded reads a present tag as missing (the
    original cause)

Backend integration tests

  • 4 new tests in McpIntegrationIT for the cases above.
  • Confirmed they fail without this change — all 4 fail, each on its own assertion.

Ran: openmetadata-mcp 589 tests, McpIntegrationIT 12, REST lineage ITs 140, service
lineage/policy units 54. mvn spotless:check clean.

@Vishnuujain
Vishnuujain requested a review from a team as a code owner September 2, 2026 07:25
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Sep 2, 2026
@gitar-bot

gitar-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Fixes entity-scoped authorization in MCP lineage tools by authorizing against the requested entity's FQN, filtering nodes individually by VIEW_BASIC, and pruning to the root-reachable subgraph. Adds hiddenNodes and hiddenNodesUnchecked reporting so pruned graphs are not read as complete, redacts pipelines the caller cannot view, gates tempLineageTables behind includeSql=true, and batches permission checks per entity type. Comprehensive test coverage added for tag-based access control, node filtering, edge redaction, and SQL gating. No issues found.

✅ 2 resolved
✅ Bug: neighbours() omits domain-pruned nodes from hiddenNodes count

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetEntityTool.java:453-467
In GetEntityTool.neighbours the graph is fetched via getByName(...), which prunes domain-scoped nodes inside LineageRepository but discards the removed count. Only filtered.hiddenNodes() (the per-node permission removals) is reported and fed to reachNote. So for a domain-restricted caller whose neighbours were removed by domain pruning but not by the permission filter, hiddenNodes reads 0 and reachNote can claim the graph is complete / "continues beyond them" while neighbours were silently withheld. GetLineageTool deliberately uses getByNameReportingPrune to avoid exactly this. Mirror that here: call getByNameReportingPrune, add pruned.hiddenNodes() to filtered.hiddenNodes() for the reported count and pass the total through to reachNote.

✅ Quality: hiddenUnchecked note overstates the 'unchecked' node count

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetLineageTool.java:192-206 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/GetEntityTool.java:529-536
GetLineageTool.visibilityNote (and GetEntityTool.reachNote) print the total hidden count in the hiddenUnchecked branch with wording "%d node(s) beyond the limit were removed without being checked". But hidden = filtered.hiddenNodes() + domainHiddenNodes, which mixes permission-denied nodes, nodes cut off by pruning, and domain-pruned nodes together with the truly unchecked over-ceiling nodes. The user-facing message therefore attributes far more nodes to the ceiling than were actually skipped. Consider reporting the checked-hidden and unchecked counts separately, or rewording to "%d node(s) were removed (some beyond the authorization limit, unchecked)".

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit fb12b203487c4fc12c70fc7ae49399d57488605a in Playwright run 33604798644, attempt 1.

✅ 809 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 48m 26s

⏱️ Max setup 6m 12s · max shard execution 17m 42s · max shard-job elapsed before upload 21m 16s · reporting 4s

🌐 225.56 requests/attempt · 2.66 app boots/UI scenario · 17.80% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 17.8% (convergence target: at most 15%).
  • Browser traffic was 225.56 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.66 per UI scenario (2524 boots / 950 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 164 0 0 0 0 0
✅ Shard chromium-02 167 0 0 0 0 0
✅ Shard chromium-03 132 0 0 0 0 0
✅ Shard chromium-04 165 0 0 0 0 0
✅ Shard data-asset-rules-01 63 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 17 0 0 0 0 0
✅ Shard ingestion-01 9 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 2, 2026
Merged via the queue into main with commit eae0911 Sep 2, 2026
115 checks passed
@Vishnuujain
Vishnuujain deleted the fix/mcp-lineage-entity-scoped-authz branch September 2, 2026 17:09
Vishnuujain added a commit that referenced this pull request Sep 2, 2026
* fix(mcp): authorize lineage tools against the requested entity

* fix(mcp): make the lineage permission filter fail closed and batch its checks

* test(mcp): cover pipeline redaction and temp-table SQL gating in lineage edges

* fix(mcp): withhold lineage pipelines that cannot be identified, add integration coverage

* gitarbot feedback: count domain-pruned neighbours and report unchecked nodes separately

(cherry picked from commit eae0911)
Rohit0301 pushed a commit that referenced this pull request Sep 3, 2026
* fix(mcp): authorize lineage tools against the requested entity

* fix(mcp): make the lineage permission filter fail closed and batch its checks

* test(mcp): cover pipeline redaction and temp-table SQL gating in lineage edges

* fix(mcp): withhold lineage pipelines that cannot be identified, add integration coverage

* gitarbot feedback: count domain-pruned neighbours and report unchecked nodes separately
shrabantipaul-collate pushed a commit to PRADDZY/OpenMetadata that referenced this pull request Sep 3, 2026
* fix(mcp): authorize lineage tools against the requested entity

* fix(mcp): make the lineage permission filter fail closed and batch its checks

* test(mcp): cover pipeline redaction and temp-table SQL gating in lineage edges

* fix(mcp): withhold lineage pipelines that cannot be identified, add integration coverage

* gitarbot feedback: count domain-pruned neighbours and report unchecked nodes separately

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP get_entity_lineage fails entity-scoped authorization for tag/domain-based policies

2 participants