Skip to content

Restrict cross-user follower changes - #32322

Merged
sonika-shah merged 6 commits into
mainfrom
harshach/validate-followers-advisory
Sep 4, 2026
Merged

sonika-shah merged 6 commits into
mainfrom
harshach/validate-followers-advisory

Conversation

@harshach

@harshach harshach commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Follower mutations now allow users to change only their own follower state while preserving admin management, and all 41 entity-resource add/delete follower pairs delegate through the shared authorization guard. Missing follower user IDs are rejected with a deterministic 400 response before authorization or persistence.

Type of change:

  • Bug fix

High-level design:

EntityResource owns guarded add/delete follower helpers that validate the requested user ID, compare it with the authenticated subject using null-safe equality, and require admin authorization for cross-user mutations. Every current follower endpoint delegates to those helpers before calling the repository, keeping authorization in the resource layer and preserving configured Authorizer behavior. The repository contract, response payloads, self-follow behavior, and admin compatibility remain unchanged; no schema, migration, or rollout work is required.

Note on the included cache fix (EntityRepository.buildReadBundle):

This PR also carries a required one-line cache fix: buildReadBundle used the read-bundle cache for every non-deleted read, ignoring UNCACHED_ENTITY_TYPES (user, task, workflow*, bot, domain, dataProduct). For those types a mutation followed by an immediate re-read — exactly the follower add/delete then hasFollower fetch in DataProductResourceIT — could serve a stale cached bundle. Without it, the follower tests fail on the cache-enabled integration lanes (postgres-elasticsearch-redis, postgres-opensearch) with expected <false> but was <true> after a delete. The fix gates the read-bundle cache on isCacheableEntityType(entityType) so uncached types always reflect current entity_relationship state. It is not separable from this security fix — it is what makes the follower tests pass on cache-enabled deployments.

Tests:

Use cases covered

  • A non-admin user cannot add another user as a follower, and denied requests do not mutate state.
  • A non-admin user cannot remove another user's follower relationship, and denied requests preserve state.
  • A non-admin user can add and remove themselves as a follower.
  • An admin can add and remove another user as a follower.
  • A null follower user ID returns 400 with userId is required.

Unit tests

  • I added unit tests for the new/changed logic.
  • Not applicable — this is HTTP authorization behavior covered by backend integration tests.
  • Coverage: Not collected; no unit-test-only logic was introduced.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for the changed API behavior.
  • File updated: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java
  • Result: 5 tests passed, 0 failures, 0 errors, 0 skipped.

Ingestion integration tests

  • Not applicable — no ingestion changes.

Playwright (UI) tests

  • Not applicable — no UI changes.

Manual testing performed

  1. Ran the five focused follower tests with mvn -pl openmetadata-integration-tests -am package -Dtest='DataProductResourceIT#put_addFollowerForAnotherUser_403+delete_removeFollowerForAnotherUser_403+put_deleteFollowerForSelf_200+put_deleteFollowerForAnotherUserAsAdmin_200+put_addFollowerWithNullUserId_400' -Dsurefire.failIfNoSpecifiedTests=false; the full 11-module reactor passed.
  2. Ran mvn spotless:apply and mvn spotless:check; all 16 modules passed.
  3. Audited all follower routes: 41 add and 41 delete endpoints use the guard, with no direct resource-to-repository bypasses.

UI screen recording / screenshots:

Not applicable — no UI changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation> — N/A: this security fix links the private GHSA instead of a public issue.
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above — N/A: publishing a separate issue would disclose the private advisory.
  • I have commented on my code, particularly in hard-to-understand areas — N/A: the authorization helper is self-explanatory and comments would restate the code.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed — N/A: no schema changes.
  • For UI changes: I attached a screen recording and/or screenshots above — N/A: no UI changes.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Copilot AI lite review requested due to automatic review settings September 1, 2026 02:22
@harshach
harshach requested a review from a team as a code owner September 1, 2026 02:22
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses GHSA-962g-h22r-w7hg by preventing non-admin users from adding/removing followers on behalf of other users, centralizing the cross-user authorization guard in EntityResource and routing all entity follower endpoints through it.

Changes:

  • Added guarded addFollowerInternal / deleteFollowerInternal helpers to enforce “self-only unless admin” follower mutations.
  • Updated follower endpoints across entity resources to delegate to the guarded helpers (eliminating direct resource → repository follower mutations).
  • Added integration tests ensuring non-admin cross-user follower add/remove attempts are rejected and do not mutate state.

Reviewed changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java Introduces shared follower mutation helpers + centralized authorization guard.
openmetadata-service/src/main/java/org/openmetadata/service/resources/topics/TopicResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/storages/ContainerResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/storage/StorageServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/security/SecurityServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/searchIndexes/SearchServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/pipeline/PipelineServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/mlmodel/MlModelServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/metadata/MetadataServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/messaging/MessagingServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/mcp/McpServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/llm/LLMServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/drive/DriveServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/database/DatabaseServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/dashboard/DashboardServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/services/apiservices/APIServiceResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/searchindex/SearchIndexResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/query/QueryResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/pipelines/PipelineResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/mlmodels/MlModelResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/knowledge/KnowledgePageResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/WorksheetResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/SpreadsheetResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/FileResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/DirectoryResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DomainResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DataProductResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/datamodels/DashboardDataModelResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/StoredProcedureResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/DatabaseSchemaResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/DatabaseResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/dashboards/DashboardResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/charts/ChartResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/apis/APIEndpointResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/PromptTemplateResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/McpServerResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/LLMModelResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIGovernancePolicyResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIApplicationResource.java Delegates follower add/remove endpoints to the shared guarded helpers.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java Adds IT coverage for non-admin cross-user follower mutation rejection + non-mutation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 0f8564710d7ec8d109a78c7325c5dd53836a8eb9 in Playwright run 33737619880, attempt 1.

✅ 997 passed · ❌ 0 failed · 🟡 5 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) 1h 24m 31s

⏱️ Max setup 4m 35s · max shard execution 19m 36s · max shard-job elapsed before upload 23m 3s · reporting 7s

🌐 203.95 requests/attempt · 2.42 app boots/UI scenario · 34.27% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 34.27% (convergence target: at most 15%).
  • Browser traffic was 203.95 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.42 per UI scenario (2575 boots / 1065 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
🟡 Shard chromium-01 153 0 2 0 0 0
✅ Shard chromium-02 145 0 0 0 0 0
🟡 Shard chromium-03 145 0 1 0 0 0
🟡 Shard chromium-04 182 0 1 0 0 0
✅ Shard chromium-05 152 0 0 0 0 0
✅ Shard data-asset-rules-01 65 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 ingestion-01 29 0 0 0 0 0
🟡 Shard ingestion-02 34 0 1 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
🟡 5 flaky test(s) (passed on retry)
  • Features/ContextCenterArticles.spec.ts › Article list cards, recently viewed widget, and pagination work (shard chromium-01, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Text formatting (shard chromium-01, 1 retry)
  • Pages/CustomProperties.spec.ts › Date (shard chromium-03, 1 retry)
  • Features/Table.spec.ts › should persist page size (shard chromium-04, 1 retry)
  • Features/DataQuality/DataQuality.spec.ts › Pagination functionality in test cases list (shard ingestion-02, 1 retry)

📦 Download artifacts

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

Copilot AI review requested due to automatic review settings September 1, 2026 03:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java:248

  • This test name is prefixed with put_ but it exercises the DELETE follower endpoint; renaming it keeps the method-name convention (HTTP verb prefix) consistent and avoids confusion when scanning test failures.
  void put_deleteFollowerForAnotherUserAsAdmin_200(TestNamespace ns) {

buildReadBundle used the read-bundle cache for every non-deleted read,
ignoring UNCACHED_ENTITY_TYPES (user, task, workflow*, bot, domain, dataProduct).
For those types a mutation followed by an immediate re-read — e.g. the follower
add/delete then fetch in this PR's DataProductResourceIT — could serve a stale
cached bundle. Without this, the follower authorization tests fail under a
cache-enabled deployment (postgres-elasticsearch-redis / postgres-opensearch
integration lanes) with `expected <false> but was <true>` after a delete.

Gate the read-bundle cache on isCacheableEntityType(entityType) so uncached
types take the already-supported bundleCache == null path and always reflect the
current entity_relationship state. Required for the follower tests to pass on the
Redis/OpenSearch lanes (documents why this caching change is part of the security
fix, per reviewer request).
Copilot AI review requested due to automatic review settings September 3, 2026 04:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The centralized guard enforces the intended authorization/validation behavior and the added integration tests cover the key success/denial cases.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java:248

  • Test name prefix uses put_ but the behavior under test is deleting another user’s follower relationship (this test calls HttpMethod.DELETE). Renaming to a delete_...-prefixed name aligns with the existing naming convention in this file.

openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java:235

  • Test name prefix uses put_ but this test primarily validates DELETE follower behavior (and calls HttpMethod.DELETE). Renaming it to a delete_...-prefixed name keeps naming consistent with other tests in this class and makes targeted test runs by method name less confusing.
  void put_deleteFollowerForSelf_200(TestNamespace ns) {
  • Files reviewed: 44/44 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

…_ prefix

The two round-trip tests exercise the DELETE follower endpoint (add is setup),
so name them with the delete_ verb prefix to match the method-name convention
(addresses the Copilot review comment).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The centralized guard enforces the intended authorization behavior consistently across resources, the cache fix aligns with existing cacheability gating, and the added integration tests cover the critical scenarios.

Review details
  • Files reviewed: 44/44 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The authorization guard is centralized and consistently applied, the cache edge case is addressed, and integration tests cover the key allowed/denied behaviors plus the null-input 400 response.

Review details
  • Files reviewed: 44/44 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@gitar-bot

gitar-bot Bot commented Sep 3, 2026

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

Restricts cross-user follower mutations to admin users while allowing non-admin users to manage only their own follower state. All 41 entity-resource add/delete follower pairs now delegate through a shared authorization guard that validates user IDs and enforces role-based access control. Also includes a required cache fix for buildReadBundle to bypass the read-bundle cache for uncached entity types, ensuring follower state mutations are immediately reflected on re-read. No issues found.

✅ 1 resolved
✅ Bug: Follower guard blocks non-admin bots from cross-user mutations

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java:189-194
authorizeFollowerMutation calls authorizer.authorizeAdmin, which only passes when user.getIsAdmin() is true; bots are not treated as admins (isBot() vs isAdmin() are distinct in SubjectContext). Any non-admin bot or automation that previously set followers on behalf of other users will now receive a 403. If bot-driven follower automation (e.g. ingestion) is a supported flow, use authorizer.authorizeAdminOrBot(securityContext) instead; otherwise this is an intentional tightening and can be left as-is.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The authorization guard is centralized and consistently applied across follower endpoints, the cache fix aligns behavior with documented uncached entity types, and integration tests cover the key permission and validation cases.

Review details
  • Files reviewed: 44/44 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

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

backend safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants