Skip to content

Fixes #32361: Align App endpoint permission checks with the platform RBAC model - #32427

Merged
Shreyansh100704 merged 4 commits into
mainfrom
fix/app-resource-authz-hardening
Sep 4, 2026
Merged

Shreyansh100704 merged 4 commits into
mainfrom
fix/app-resource-authz-hardening

Conversation

@Shreyansh100704

@Shreyansh100704 Shreyansh100704 commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #32361

I worked on aligning AppResource's permission checks with the platform RBAC model because the class had accumulated three different styles as endpoints were added: action endpoints each repeated the same authorization boilerplate, the run-data read endpoints had no check at all, and several mutating endpoints ran their side effects before the authoritative check.

Callers holding ViewAll — which the default DataConsumer role grants on resource all — see no change in behavior.

Type of change:

  • Improvement

High-level design:

Three coordinated changes to one resource class, no schema, migration, or API contract change.

  1. Shared helper. Two authorizeAppOperation(securityContext, name|id, operation) overloads replace the repeated OperationContext + authorizer.authorize(...) pairs. The five action endpoints (schedule, configure, trigger, stop, deploy) now call it with the operation they already used, so their behavior is unchanged.

  2. Two-tier reads. /status, /runs/latest, /logs, /extension and /live-indexing-queue gate on ViewAll; /installed gates on ViewBasic at collection level. This is the convention already used by IngestionPipelineResource and AIAutomationResource, where the same run/log data is gated this way: the entity is readable at basic view, run history and logs require ViewAll.

  3. Authorization ahead of side effects and lookups. POST, PUT, both PATCH variants and both DELETE variants authorize before touching AppScheduler or ApplicationHandler. On PATCH and DELETE the check also precedes the entity lookup and the SystemApp guard, so a caller without permission gets 403 rather than a 404 disclosing whether the app exists or a 400 disclosing that it is a system app. Authorized callers are unaffected: the resource context resolves the entity itself and treats a missing one as absent, so an admin still receives 404 or 400 as before. Each boundary check evaluates the same operation against the same resource as the base EntityResource method that follows it:

  • POST → Create against a CreateResourceContext.
  • PUT → EntityUtil.createOrUpdateOperation(...) decides Create (against the incoming entity) or EditAll (against the stored one), mirroring EntityResource.createOrUpdate. An earlier draft used ANY(Create, EditAll) against the request payload; that could pass for a caller whose EditAll is owner-scoped on the stored app, unschedule it, and then be rejected by the base check.
  • PATCH → OperationContext(entityType, patch) with the Operation.PATCH resource context, matching patchInternal.
  • DELETE → Delete via the shared helper. The base uses the Operation.DELETE resource-context variant; both resolve with Include.ALL and the same authorization field set, so the check is equivalent.

The stored app is therefore read more than once on PUT, PATCH and DELETE — the boundary check, the handler's own lookup, and the base check. On PATCH and PUT those reads bypass the repository cache by design (ResourceContext.useRepositoryCache() excludes both), so the extra work is real. That is the cost of gating the side effect rather than leaving it ahead of authorization, and it is noted in the code.

Alternative rejected: an EditAll fallback on the scoped action operations (as IngestionPipelineResource carries) was not added. App action endpoints have been scoped-only since #26590 , so there is no legacy grant population to preserve and adding one would loosen shipped behavior.

Tests:

Use cases covered

  • An admin and a DataConsumer read app run records, logs, extension data and the indexing queue exactly as before.
  • A principal denied ViewAll on app cannot read any app's run records, logs, extension data or indexing queue, and cannot enumerate installed apps.
  • A principal without the matching permission cannot trigger, stop, deploy, schedule or configure an app (unchanged).
  • An unauthorized PATCH leaves the application's schedule intact instead of unscheduling it before returning 403.
  • An unauthorized PUT against an existing app is rejected on EditAll against the stored entity, before the scheduler is touched.
  • DELETE on a non-existent app returns 403 to an unauthorized caller instead of disclosing 404.
  • An unauthorized PATCH of a non-existent app, or of a SystemApp, is rejected with 403 rather than disclosing existence or type.
  • Unauthenticated requests to the read endpoints return 401.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files updated: AppResourceRetryQueueTest.java (6 tests: 2 existing updated to inject a mock authorizer, 4 new covering the ViewAll gate, denied-read short-circuit, and PATCH/PUT side-effect ordering).
  • Result: mvn test -pl openmetadata-service -Dtest='AppResource*Test' → 9 tests, 0 failures.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/.
  • Files updated: AppOperationPermissionsIT.java (+4 tests: deny-ViewAll persona across all six read endpoints, unauthenticated 401, a DataConsumer regression guard, and an unauthorized PATCH of a non-existent app).
  • Result: AppOperationPermissionsIT 14 tests, 0 failures. AppsResourceIT 36 tests, 0 failures, 6 skipped

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

Captured a behavior baseline on a running server before the change, then re-ran the same probes after, on a server rebuilt from this branch (47 probes total):

  1. Created a test principal with a policy denying ViewAll on app, plus a plain user inheriting DataConsumer.
  2. Before: that principal received 403 on GET /v1/apps/name/{app} yet 200 with full run history from /status, /runs/latest, /logs, /live-indexing-queue and /installed.
  3. After: 403 on all six, with the denial naming the intended operation (ViewAll for run data, ViewBasic for /installed); admin and DataConsumer results byte-identical to the baseline.
  4. Verified PUT against an existing app is denied on [EditAll] and leaves the entity unmodified (version, enabled and config unchanged).
  5. Verified DELETE on a non-existent app returns 403 rather than 404, confirming authorization now precedes the lookup.
  6. Verified an unauthorized PATCH of a non-existent app returns 403 instead of 404, and of a SystemApp returns 403 instead of 400, matching the delete endpoints.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes 32361: Align App endpoint permission checks with the platform RBAC model
  • My PR is linked to a GitHub issue via Fixes #32361 above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable, no schema changes.
  • For UI changes: not applicable.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Copilot AI lite review requested due to automatic review settings September 2, 2026 06:10
@Shreyansh100704
Shreyansh100704 requested a review from a team as a code owner September 2, 2026 06:10

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Sep 2, 2026
Copilot AI review requested due to automatic review settings September 2, 2026 06:32

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 165ee3c2c7d39b6b52a4cc382d999ee26b6839ee in Playwright run 33820742128, attempt 1.

✅ 765 passed · ❌ 0 failed · 🟡 1 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) 52m 25s

⏱️ Max setup 4m 42s · max shard execution 18m 57s · max shard-job elapsed before upload 23m 25s · reporting 7s

🌐 236.85 requests/attempt · 2.51 app boots/UI scenario · 10.82% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 236.85 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.51 per UI scenario (1979 boots / 790 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 133 0 0 0 0 0
🟡 Shard chromium-02 147 0 1 0 0 0
✅ Shard chromium-03 173 0 0 0 0 0
✅ Shard chromium-04 154 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 1 0 0 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
🟡 1 flaky test(s) (passed on retry)
  • Pages/CustomProperties.spec.ts › Date (shard chromium-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

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-02T15:59:07Z)

Blocked the queue: playwright-summary, py-checkstyle

@Shreyansh100704
Shreyansh100704 added this pull request to the merge queue Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-03T10:21:09Z)

Blocked the queue: playwright-summary

Copilot AI review requested due to automatic review settings September 4, 2026 00:11

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 4, 2026

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

Aligns App endpoint permission checks with the platform RBAC model by introducing a shared authorization helper, gating run data and logs on ViewAll (matching IngestionPipelineResource convention), and authorizing mutating operations before side effects. PATCH now authorizes after entity lookup, preventing unintended state changes on denied requests. Comprehensive unit and integration tests confirm no regressions for admin and DataConsumer roles, and proper denial of unauthorized access. No issues found.

✅ 1 resolved
✅ Security: PATCH authorizes after entity lookup and system check

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java:974-982 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java:1026-1034 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java:1129 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/apps/AppResource.java:1172
In both patchApplication overloads the stored app is loaded via repository.get/getByName and the getSystem() check runs (lines 974-978 and 1026-1030) before the new authorizer.authorize call. An unauthorized caller therefore still receives a 404 for a non-existent app or a 400 for a SystemApp before the 403, disclosing existence/type — the opposite of the ordering the PR deliberately applied to DELETE (authorizeAppOperation runs before the lookup at lines 1129 and 1172). Consider moving the authorize call ahead of the lookup (using getResourceContextById/ByName with the PATCH operation, which resolves the entity itself) so PATCH matches the DELETE hardening and does not leak existence to unauthorized callers.

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@Shreyansh100704
Shreyansh100704 added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 00a77a6 Sep 4, 2026
137 checks passed
@Shreyansh100704
Shreyansh100704 deleted the fix/app-resource-authz-hardening branch September 4, 2026 20:07
Shreyansh100704 added a commit that referenced this pull request Sep 8, 2026
…RBAC model (#32427) (#32934)

* fix(apps): align App endpoint permission checks with the platform RBAC model

* fix(apps): authorize App patch before the entity lookup
pmbrull pushed a commit that referenced this pull request Sep 9, 2026
…RBAC model (#32427) (#32937)

* fix(apps): align App endpoint permission checks with the platform RBAC model

* fix(apps): authorize App patch before the entity lookup

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

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align App endpoint permission checks with the platform RBAC model

3 participants