Repository navigation
Fixes 33420: authorize the target domain when an asset is reassigned - #33471
Conversation
Domain reassignment was authorized only against the domain an asset was already in. The PATCH path evaluated the stored entity, so hasDomain() saw the source domain — and nothing at all for a domainless asset, where it deliberately returns true. The domain bulk-asset endpoints authorized the target domain but never the assets, so a domain's asset picker could pull assets out of domains the caller had no rights over. Add an EditDomains operation so domain reassignment can be granted without granting EditAll, re-run the policy decision against the domains an update moves an asset into, and authorize each asset on the domain and data product bulk endpoints. Co-Authored-By: Claude Opus 5 <[email protected]>
The batched variant of authorizeAssetsOperation enriched each asset with only its directly-set owners and domains, never the ones inherited from a parent (schema/database/service). An asset that inherited an unheld domain then looked domainless to the policy, so hasDomain() returned true and the cross-domain move this PR blocks was allowed again; an asset owned only through its parent was wrongly denied. Go back to the per-asset load, which resolves inherited owners and domains the same way every other authorization check does. The N+1 this briefly optimized was a deferrable note, not a blocker, and batching with inheritance belongs in its own change. Adds an IT for a table that inherits its schema's unheld domain: pulling it into the caller's domain must be denied.
🚦 Removed from the merge queue —
|
The backend now authorizes a domain change with the EditDomains operation, but the UI still showed the Domains edit control based on EditAll. A policy that grants EditAll yet denies EditDomains (or grants EditDomains alone) was therefore not reflected in the UI. Derive a canEditDomains flag the same way the other field flags are built (getPrioritizedEditPermission: the field permission, falling back to EditAll), so the control follows the exact rule the server enforces. Route the three domain-edit gates through it: the generic DomainLabel hook, the connection-service header, and the incident-manager header. Backward compatible: EditAll still subsumes EditDomains, so existing setups are unchanged.
The first pass moved the generic DomainLabel hook, the connection-service header and the incident-manager header onto canEditDomains. Auditing every DomainLabel permission binding surfaced more reassignment controls still keyed to EditAll: the main data-asset header, the classification page, both test-suite views, and the team header. Point each at canEditDomains so the control appears exactly when the server would authorize the change. Owner/tier/type/experts controls stay on EditAll (those are not domain operations); read-only and admin-gated domain displays are unchanged.
…0-asset-reassignment-authz # Conflicts: # openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DataProductResource.java # openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DomainResource.java
| if (entity == null) { | ||
| return null; | ||
| } | ||
| return readDomains(JsonUtils.applyPatch(entity, patch)); |
There was a problem hiding this comment.
Inherited target domain goes unchecked
If a table has explicit domain A but its schema belongs to domain B, removing /domains makes getPatchedDomains() return an empty list. A user scoped to A passes hasDomain() for that list, but the repository then returns the table with inherited domain B. The user can therefore move the asset into a domain they do not hold. Resolve the effective inherited domains before the second permission check.
How this was verified: The PATCH path authorizes the empty list, removes the explicit domain relationship, and then applies the parent’s domains before returning the table.
🚦 Removed from the merge queue —
|
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
| private static boolean isDomainsPath(String path) { | ||
| return path != null && (path.equals(DOMAINS_PATH) || path.startsWith(DOMAINS_PATH_PREFIX)); |
There was a problem hiding this comment.
Whole-document patches bypass domain checks
A user with EditAll conditioned on hasDomain() can replace a table’s whole document using op: "replace" and path: "", with its domains changed from held domain A to unheld domain B. The first permission check sees A. But patchTouchesDomains() ignores the empty root path, so the target-domain check never runs. The repository still applies the replacement and stores B.
Treat root replacements as possible domain changes, or reject them before applying the patch.
How this was verified: The PATCH helper accepts the empty root pointer, the domain detector skips it, and the repository validates and stores the replacement’s domain IDs without checking the caller’s access to B.
|
| Count | Rule |
|---|---|
| 8 | react-hooks/exhaustive-deps |
| 4 | openmetadata-imports/no-lower-layer-page-imports |
| 1 | openmetadata-imports/review-sequential-api-calls |
| 1 | openmetadata-imports/no-cross-page-imports |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/Classifications/ClassificationDetails/ClassificationDetails.tsx:295:8 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'isVersionView' and 'navigate'. Either include them or remove the dependency array. |
| 🟡 | src/components/Classifications/ClassificationDetails/ClassificationDetails.tsx:459:8 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/Classifications/ClassificationDetails/ClassificationDetails.tsx:535:7 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/Classifications/ClassificationDetails/ClassificationDetails.tsx:585:8 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'fetchClassificationChildren', 'handlePageChange', and 'isAddingTag'. Either include them or remove the dependenc |
| 🟡 | src/components/DataQuality/IncidentManager/IncidentManagerPageHeader/useTestCaseIncidentHeader.ts:29:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/DataQuality/IncidentManager/IncidentManagerPageHeader/useTestCaseIncidentHeader.ts:222:27 |
openmetadata-imports/review-sequential-api-calls |
Review these sequential API requests. If they are independent, start them together with Promise.all/Promise.allSettled; keep sequencing only when data-dependent |
| 🟡 | src/components/Settings/Team/TeamDetails/TeamsHeaderSection/TeamsInfo.component.tsx:110:9 |
react-hooks/exhaustive-deps |
The 'onEmailSave' function makes the dependencies of useMemo Hook (at line 289) change on every render. Move it inside the useMemo callback. Alternatively, wrap |
| 🟡 | src/components/Settings/Team/TeamDetails/TeamsHeaderSection/TeamsInfo.component.tsx:136:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'updateTeamHandler'. Either include it or remove the dependency array. If 'updateTeamHandler' changes too often |
| 🟡 | src/components/Settings/Team/TeamDetails/TeamsHeaderSection/TeamsInfo.component.tsx:185:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/Settings/Team/TeamDetails/TeamsHeaderSection/TeamsInfo.component.tsx:355:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx:36:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx:37:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/TestSuiteDetail/TestSuiteDetail.tsx:38:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/pages/TestSuiteDetailsPage/TestSuiteDetailsPage.component.tsx:55:1 |
openmetadata-imports/no-cross-page-imports |
Page features must not import another page feature. Move shared code to components, hooks, interfaces, or pure utilities. |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed
✅ Generated Sources Auto-UpdatedThe generated TypeScript types ( |
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · Adding target-domain checks to asset PATCH/PUT and bulk reassignment changes authorization; bypasses could let users move assets into domains they cannot access. Adds an ✅ 2 closed✅ Performance: Per-asset authorize resolves each asset without bulk hydration
✅ Security: Domain check trusts client FQN in patch; persisted domain is by id
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|



Describe your changes:
Fixes #33420
Domain reassignment was authorized only against the domain an asset was already in, never the one it was moving into. The two write paths each checked half the move:
PATCH /v1/<entity>/{id}on/domainsEditAllon the asset, against its old domainPUT /v1/domains/{name}/assets/addEditAllon the target domainSo a user scoped with
hasDomain()could move assets into domains they do not hold, and anyone able to edit their own domain could pull any asset in the catalog into it via the domain asset picker.Type of change:
High-level design:
EditDomainsoperation. There was no operation for domains, so a/domainspatch fell through toEditAll— reassignment could not be granted or denied without grantingEditAllwholesale. Additive and migration-free:CompiledRule.matchesBySubsumptionalready grants anything matchingstartsWith("Edit")under an existingEditAll.UpdatedDomainsResourceContext(new), which delegates entity/owners/tags to the stored resource and overrides onlygetDomains(). That is what keeps the change invisible to policies with no domain conditions — both passes evaluate the same rules and differ only on domains. Gated on the domain set actually changing, and the patch is inspected before the entity is resolved, so an unrelated patch costs nothing.JsonUtils.applyPatch— the same helper the repository uses, so authorization sees exactly the post-state that will be persisted rather than a second, drifting reading of the patch. Load-bearing: that helper skips read-only auto-generated fields (href,changeDescription) and convertsreplace→addfor absent paths. Applying the client's diff strictly instead fails, because the UI diffs its own copy of the entity and emitsremove /domains/0/hrefagainst a field that is never stored.authorizer.authorizerather than the existingauthorizeBulkAssetsPermission, which is a resource-type check matchingAccess.ALLOW— a conditional rule resolves toCONDITIONAL_ALLOWthere, so it would have denied ahasDomain()-scoped admin every asset, including ones they may legitimately edit.PolicyEvaluator.hasDomainPermission— zero callers since its call site was deleted ine77d1940cb(Domain policy must be evaluated during PolicyEvaluator #23302).Still open, deliberately out of scope: the CSV import path (
EntityRepository.updateDomainsForImport) has no target-domain check.Tests:
Use cases covered
A user scoped to Domain A by a
hasDomain()policy cannot move a domainless asset into Domain B, cannot move an asset from A into B, and cannot claim an asset sitting in B via A's asset picker — while still being able to move assets into a sub-domain of A and to claim assets they may edit. An entity owner with no domain policy in play can still set a domain.Unit tests
openmetadata-service/.../policyevaluator/UpdatedDomainsResourceContextTest.java(new, 3 tests)openmetadata-service/.../util/JsonPatchUtilsTest.java(+5 tests, plus/domains→EditDomainsin the mapping table) — including the verbatim 7-operation patch the UI sends on a domain reassignmentopenmetadata-service/.../exception/CatalogExceptionMessageTest.java(+2 tests) — the denial must name the domainLine coverage on changed classes (
mvn test jacoco:report -Pstatic-code-analysis):UpdatedDomainsResourceContext100%,JsonPatchUtils83.1%,ResourceRegistry34.8%.EntityResource/DomainResource/DataProductResourceshow 0% here — they have no unit tests in this module; their changed paths are covered by the integration test below, which lives in a different module and so does not contribute to this report.Backend integration tests
openmetadata-integration-tests/.../it/tests/DomainReassignmentAuthorizationIT.java(new, 6 tests), all passing.Verified not to be vacuous — with the enforcement removed, exactly the three security tests fail and the three non-regression tests still pass:
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Built and ran the full stack locally (
./docker/run_local_docker.sh -m ui -d mysql -i false) and drove the scenario by hand through the UI and the REST API: domainsFinanceandMarketing, ahasDomain()policy onResources: All, aBUAdminrole andFinanceTeamscoped to Finance, userbu.admin, and a table starting with no domain.bu.admin, scoped to Finance)Marketing(not held)Finance(held)Finance→Marketing(not held)This found two defects the test suite missed, both fixed in the follow-up commit and now covered by tests:
remove /domains/0/hrefagainst a field the server never stores, and RFC-6902removeon a missing path throws. The integration test missed it because it hand-builds a cleanadd /domainspatch that no real client sends.domains [null]— the references come from the patch and carry noname, defeating the purpose of the domain-specific message.Also run locally:
mvn spotless:checkclean onopenmetadata-spec,openmetadata-serviceandopenmetadata-integration-tests.UI screen recording / screenshots:
No code change to the UI beyond five regenerated type files and one entry in the Admin Permission Debugger's operation list, so there is no interaction or layout change to record.
Verified by hand in the UI: BU Admin scoped to
Financeattempts to move a table intoMarketing; the toast names the domain and the operation, and the Domains chip still readsFinance(the move was blocked, not applied). The exact toast text is quoted under Manual testing performed above. Screenshot to follow as an attachment.Checklist:
Fixes <issue-number>: <short explanation>Fixes #33420above.EditDomainsis additive and existingEditAllgrants already subsume it.DomainReassignmentAuthorizationIT, verified to fail without the fix).🤖 Generated with Claude Code
Summary by Gitar
canEditDomains(EditDomains, falling back to EditAll) in header, team, classification, and test suite componentsEDIT_ALLThis will update automatically on new commits.
The PR should not merge until the two previously reported ways to bypass target-domain checks are fixed.
Findings
Summary
The PR adds
EditDomainsand checks target domains during PATCH and PUT updates.EditDomainspermission.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[PATCH or PUT update] --> B[Check permission on stored asset] B --> C{Domains change?} C -->|No| F[Save update] C -->|Yes| D[Resolve supplied target domains] D --> E[Check EditDomains with target domains] E -->|Allowed| F E -->|Denied| G[Reject update]Reviews (6) · Last reviewed commit: "Update generated TypeScript types and de..." · Reviewed by Greptile