Repository navigation
Fixes #35086: enforce RBAC on /v1/search/aggregate endpoint - #35148
Merged
mohityadav766 merged 2 commits intoOct 12, 2026
Merged
mohityadav766 merged 2 commits into
mohityadav766 merged 2 commits into
Conversation
Contributor
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
harshach
approved these changes
Oct 11, 2026
…, add fail-closed coverage Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mohityadav766
approved these changes
Oct 12, 2026
mohityadav766
enabled auto-merge
October 12, 2026 06:39
mohityadav766
added this pull request to the merge queue
Oct 12, 2026
|
mohityadav766
deleted the
detail/bug-fix/fixes-35086-enforce-rbac-on-v1-search-aggregate-en-d14b0b
branch
October 12, 2026 13:52
8 of 10 tasks
timothybrush
pushed a commit
to timothybrush/OpenMetadata
that referenced
this pull request
Oct 16, 2026
…cluster (open-metadata#35477) The restricted user's client signs its token with the harness key, which a deployed cluster rejects. Three of the four tests have failed with 401 on every nightly cluster run since open-metadata#35148, and scale-it, which runs only when search-it passes, was skipped with them. They now skip in external mode, as the other search ITs that cannot run against a cluster do. Embedded runs are unchanged.
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Detail bug report: View on Detail
Describe your changes:
Fixes #35086
I worked on closing an RBAC bypass in the
/v1/search/aggregateendpoint (both GET and POST) because the aggregation query was built from the caller-supplied request with only the org-wide ContextMemory privacy filter applied — the caller's RBAC policy conditions were never evaluated, even though the parallel search-listing path (/v1/search) enforces them for the same caller.Type of change:
High-level design:
Root cause:
SearchResource.aggregate/aggregateSearchRequestcaptured@Context SecurityContext securityContext(auth required) but never calledgetSubjectContext(securityContext)and never threaded aSubjectContextintosearchRepository.aggregate(AggregationRequest). TheAggregationManagementClientinterface had noaggregate(AggregationRequest, SubjectContext)overload, so the handler had no way to supply a subject even if it wanted to. The class's ownapplyRbacQueryhelper and Javadoc warning about aggregations leaking denied documents already existed — the HTTP endpoint was simply never wired to use them.Fix: Thread a
SubjectContextfromSecurityContextthrough to both search backends, mirroring the listing path (SearchResource.search→searchRepository.search(request, subjectContext)):SearchResource— both aggregate endpoints now resolveSubjectContextviaDefaultAuthorizer.getSubjectContext(securityContext)and callsearchRepository.aggregate(aggregationRequest, subjectContext).AggregationManagementClient/SearchRepository/ElasticSearchClient/OpenSearchClient— newaggregate(AggregationRequest, SubjectContext)overload (default delegates to the subject-less overload for backward compat).ElasticSearchAggregationManager/OpenSearchAggregationManager— the new overload replaces the unconditionalrestrictToOrgWideMemories(query)terminator withapplySubjectFilters(query, subjectContext), which:applyRbacQuery(fail-closed withmatchNonewhen policies had to apply but produced no query).When
subjectContextisnull, admin, or access control is disabled, behavior is unchanged — RBAC is skipped and the org-wide memory filter applies, preserving exact backward compatibility for internal callers that do not thread aSubjectContext.Both Elasticsearch and OpenSearch backends are fixed with identical security semantics.
Tests:
Use cases covered
enableAccessControl=trueandDomainOnlyAccessRolesees aggregation buckets andtopHitssnippets only for documents in their own domains (GET and POST endpoints).topHitsover all documents (unfiltered by RBAC).enableAccessControl=false, a non-admin user sees aggregation buckets over all documents (backward compat — no RBAC filtering).aggregate(AggregationRequest)overload produces a query identical toaggregate(AggregationRequest, null)— no regression for internal callers.Unit tests
I added unit tests for the new/changed logic.
Files added/updated:
openmetadata-service/src/test/java/org/openmetadata/service/search/elasticsearch/ElasticSearchAggregationRbacTest.java(new — 5 tests)openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/OpenSearchAggregationRbacTest.java(new — 5 tests)openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java(updated — added subject-aware delegation assertion)These verify that the aggregation query sent to the search engine includes the RBAC policy filter (e.g.,
domains.idterms for the caller's own domains) for non-admin subjects with access control on, and does NOT include it for admin, null, or access-control-off subjects.Backend integration tests
I added integration tests in
openmetadata-integration-tests/for new/changed API endpoints.Files added/updated:
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/SearchAggregateRbacIT.java(new — 4 tests)This IT creates two domains with tables, a non-admin user with
DomainOnlyAccessRoleassigned to one domain, enablesenableAccessControl=true, and asserts via the real HTTP endpoint that:topHitssnippets.topHits.enableAccessControl=false, the restricted user sees both domains (backward compat).Ran locally against both Elasticsearch (
-Pmysql-elasticsearch) and OpenSearch (-Ppostgres-opensearch) — all 4 tests pass on both backends.Existing regression ITs also pass:
SearchResourceIT(77 tests, includingtestAggregateQuery,testAggregateQueryWithQueryText,testAggregateQueryWithEmptyQueryText) on both backends;DomainIsolationIT(9 tests) on Elasticsearch.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Verified the full end-to-end flow through
SearchAggregateRbacITagainst live Testcontainers Elasticsearch and OpenSearch instances: created domains, ingested tables, created a restricted user withDomainOnlyAccessRole, toggledenableAccessControlvia the/v1/system/settingsPUT endpoint, and confirmed the aggregation endpoint and the listing endpoint return consistent document sets for the same caller.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Automatic Fixes PRs can be configured here.