Repository navigation
Description
Detail Bug Report
Introduced in #17064 by @ulixius9 on Jul 22, 2024
Summary
- Context:
LineageResourceexposes lineage-management endpoints; lineage mutations are supposed to be authorized against the actual entity being modified so that role policies with conditions (owners, tags, domains) are enforced. - Bug: The
DELETE /v1/lineage/{entityType}/{entityId}/type/{lineageSource}endpoint (deleteLineageByType) authorizes against a pseudo-resource context that returnsnullfor the entity, owners, tags and domains — it never loads the entity whose lineage edges are about to be bulk-deleted. - Actual vs. expected: The endpoint should authorize per-entity like its five sibling endpoints (
addLineage,patchLineageEdge,deleteLineageby-id and by-FQN,deleteLineageByTypeAndName), which build a realResourceContextfor the entity. Instead, conditional ALLOW rules fail open (hasDomain(),noOwner()evaluate true on nulls) and conditional DENY rules never fire. - Impact: A user with a conditioned lineage-edit privilege can silently wipe all lineage edges of arbitrary entities — including entities in domains they are explicitly excluded from, or entities tagged PII that a deny rule is supposed to protect — bypassing the policy engine entirely.
Code with Bug
openmetadata-service/src/main/java/org/openmetadata/service/resources/lineage/LineageResource.java
public Response deleteLineageByType(
@Context UriInfo uriInfo,
@Context SecurityContext securityContext,
... String entityType, UUID entityId, String lineageSource) {
authorizer.authorize(
securityContext,
new OperationContext(LINEAGE_FIELD, MetadataOperation.EDIT_LINEAGE),
new LineageResourceContext()); // <-- BUG 🔴 pseudo-resource with all-null getters
dao.deleteLineageBySource(
entityId, entityType, lineageSource, securityContext.getUserPrincipal().getName());
return Response.status(Status.OK).build();
} static class LineageResourceContext implements ResourceContextInterface {
@Override
public String getResource() {
return LINEAGE_FIELD;
}
@Override
public List<EntityReference> getOwners() {
return null; // <-- BUG 🔴 null owners -> noOwner() == true, isOwner() == false
}
@Override
public List<TagLabel> getTags() {
return null; // <-- BUG 🔴 null tags -> tag-based DENY rules can never fire
}
@Override
public EntityInterface<?> getEntity() {
return null; // <-- BUG 🔴 null entity -> hasDomain() returns true ("post-filtering" logic)
}
@Override
public List<EntityReference> getDomains() {
return null; // <-- BUG 🔴 null domains -> noDomain() == true
}
}Explanation
deleteLineageByType authorizes EDIT_LINEAGE using LineageResourceContext, which returns null for entity/owners/tags/domains. The policy evaluator treats these nulls as a “list operation” context and evaluates conditions incorrectly:
hasDomain()returnstruewhengetEntity() == null(intended for list post-filtering), so domain-scoped ALLOW rules can pass without checking the target entity.noOwner()/noDomain()returntrueon nulls, so ALLOW rules conditioned on those checks can pass.- Tag/domain matchers (
matchAnyTag,matchAnyDomain) returnfalseon nulls, so conditional DENY rules based on tags/domains never fire.
After this fail-open authorization, dao.deleteLineageBySource(...) bulk-deletes lineage edges for the provided entityType/entityId/lineageSource without performing additional authorization or validating the entity.
Codebase Inconsistency
Sibling endpoints authorize against the real entity context. For example, the FQN variant uses the per-entity helper:
public Response deleteLineageByTypeAndName(... String entityType, String entityFQN, String lineageSource) {
authorizeLineageReference(securityContext, entityType, entityFQN, Include.ALL); // <-- FIX 🟢 pattern to apply
dao.deleteLineageBySourceByFQN(...);Exploit Scenario
- Admin configures conditional lineage governance (e.g., ALLOW
EditLineagewith conditionhasDomain(), or a DENYEditLineageconditioned onmatchAnyTag('PII')). - A user with that role calls
DELETE /api/v1/lineage/table/{entityId}/type/PipelineLineagefor an entity outside their domain or tagged PII. - Authorization is evaluated against the null
LineageResourceContext(conditions fail open / DENY conditions never match). - The DAO deletes all matching lineage edges for the target entity.
Recommended Fix
Authorize per-entity like the sibling endpoints by resolving the entity reference from entityType/entityId and calling the existing helper:
// Resolve entity reference via Entity.getEntityReferenceById(entityType, entityId, Include.ALL) and:
authorizeLineageReference(securityContext, entityReference); // <-- FIX 🟢 same pattern as deleteLineageByTypeAndNameHistory
This bug was introduced in commit 5140203 (PR #17064, "Fix #16692: Override Lineage Support for View & Dashboard Lineage", Jul 2024). The commit added the new DELETE /v1/lineage/{entityType}/{entityId}/type/{lineageSource} endpoint (deleteLineageByType) for bulk-deleting lineage edges by source, and it copied the then-conventional authorizer.authorize(..., new LineageResourceContext()) pseudo-resource check (all-null owners/tags/domains/entity) instead of building a per-entity ResourceContext, even though the endpoint receives a concrete entityType/entityId. The pseudo-context was a long-standing accepted pattern on lineage endpoints — it originated in b8f1491b8f (PR #6238, Jul 2022) and PR f9f7cde43e (#15513, Mar 2024) had applied it to the FQN delete endpoint — not a pattern unique to the #17064 author. Only one later commit (a3fca2466b, FQN-based lineage APIs) touched the deleteLineageByType method itself, changing the DAO call signature (while converting the FQN delete endpoint to per-entity authorization); the December 2024 per-entity authorization sweep (PR #19070, 939f458da0) hardened the sibling endpoints but skipped this one, leaving the weak all-null check as the last-standing instance of the old pattern.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity