Skip to content

[Detail Bug] Lineage API: bulk delete-by-source bypasses conditional authorization (domain/owner/tag rules) #39150

Backlog

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_3377c26d-da48-4ccd-b83a-22c542f4fe83/bugs/bug_d08ba11e-938f-4ab6-af6b-dab52456601a

Introduced in #17064 by @ulixius9 on Jul 22, 2024

Summary

  • Context: LineageResource exposes 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 returns null for 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, deleteLineage by-id and by-FQN, deleteLineageByTypeAndName), which build a real ResourceContext for 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() returns true when getEntity() == null (intended for list post-filtering), so domain-scoped ALLOW rules can pass without checking the target entity.
  • noOwner() / noDomain() return true on nulls, so ALLOW rules conditioned on those checks can pass.
  • Tag/domain matchers (matchAnyTag, matchAnyDomain) return false on 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

  1. Admin configures conditional lineage governance (e.g., ALLOW EditLineage with condition hasDomain(), or a DENY EditLineage conditioned on matchAnyTag('PII')).
  2. A user with that role calls DELETE /api/v1/lineage/table/{entityId}/type/PipelineLineage for an entity outside their domain or tagged PII.
  3. Authorization is evaluated against the null LineageResourceContext (conditions fail open / DENY conditions never match).
  4. 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 deleteLineageByTypeAndName

History

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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions