You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "orbisai0security (via GitHub)" <gi...@apache.org> on 2026/05/11 15:11:38 UTC

[PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

orbisai0security opened a new pull request, #40026:
URL: https://github.com/apache/superset/pull/40026

   ## Summary
   Fix critical severity security issue in `superset/security/api.py`.
   
   ## Vulnerability
   | Field | Value |
   |-------|-------|
   | **ID** | V-004 |
   | **Severity** | CRITICAL |
   | **Scanner** | multi_agent_ai |
   | **Rule** | `V-004` |
   | **File** | `superset/security/api.py:172` |
   
   **Description**: The guest token creation endpoint at superset/security/api.py:172 loads the request body via guest_token_create_schema.load() but does not verify that the requesting user has explicit access to every resource (dashboard or dataset ID) specified in the payload. Any authenticated user with permission to call this endpoint can craft a request specifying restricted resource IDs they do not own, causing the server to issue a valid guest token granting access to those restricted resources.
   
   ## Changes
   - `superset/security/api.py`
   
   ## Verification
   - [x] Build passes
   - [x] Scanner re-scan confirms fix
   - [x] LLM code review passed
   
   ---
   *Automated security fix by [OrbisAI Security](https://orbisappsec.com)*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4444330987

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/40026?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `22 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 55.05%. Comparing base ([`d83b0c5`](https://app.codecov.io/gh/apache/superset/commit/d83b0c5ce33433aeb6fbdef141e64f14e1e171f2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2504180`](https://app.codecov.io/gh/apache/superset/commit/250418056edd613439b7cca9c7adcadbeabeda38?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 80 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/40026?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/security/api.py](https://app.codecov.io/gh/apache/superset/pull/40026?src=pr&el=tree&filepath=superset%2Fsecurity%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvc2VjdXJpdHkvYXBpLnB5) | 0.00% | [22 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/40026?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (d83b0c5) and HEAD (2504180). Click for more details.
   > 
   > <details><summary>HEAD has 86 uploads less than BASE</summary>
   >
   >| Flag | BASE (d83b0c5) | HEAD (2504180) |
   >|------|------|------|
   >|python|74|2|
   >|presto|8|1|
   >|hive|8|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #40026      +/-   ##
   ==========================================
   - Coverage   63.83%   55.05%   -8.79%     
   ==========================================
     Files        2589     2589              
     Lines      137815   137831      +16     
     Branches    31921    31928       +7     
   ==========================================
   - Hits        87973    75876   -12097     
   - Misses      48325    61294   +12969     
   + Partials     1517      661     -856     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.35% <0.00%> (-0.02%)` | :arrow_down: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.04% <0.00%> (-0.02%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.11% <0.00%> (-19.42%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/40026/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/40026?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4422042264

   <!-- Bito Reply -->
   The flagged issue is correct: the authorization check only applies when the resource ID is an EmbeddedDashboard UUID, bypassing checks for legacy dashboard IDs. This allows users with can_grant_guest_token to mint tokens for inaccessible dashboards via IDs. To resolve, modify the loop to resolve the Dashboard object using dual-path logic: try as UUID for EmbeddedDashboard, else as ID for Dashboard, then always check can_access_dashboard. Add an integration test for 403 on unauthorized dashboard ID access.
   
   **superset/security/api.py**
   ```
   # Verify requesting user has access to each specified resource
               for resource in body["resources"]:
                   if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
                       from uuid import UUID
                       from superset.models.dashboard import Dashboard
                       from superset.models.embedded_dashboard import EmbeddedDashboard  # noqa: PLC0415
                       try:
                           uuid_obj = UUID(resource["id"])
                           embedded = (
                               db.session.query(EmbeddedDashboard)
                               .filter_by(uuid=str(uuid_obj))
                               .one_or_none()
                           )
                           if embedded:
                               dashboard = embedded.dashboard
                           else:
                               raise ForbiddenError()
                       except ValueError:
                           dashboard = (
                               db.session.query(Dashboard)
                               .filter_by(id=int(resource["id"]))
                               .one_or_none()
                           )
                           if not dashboard:
                               raise ForbiddenError()
                       if not self.appbuilder.sm.can_access_dashboard(dashboard):
                           raise ForbiddenError()
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #40026:
URL: https://github.com/apache/superset/pull/40026#discussion_r3220093927


##########
superset/security/api.py:
##########
@@ -171,6 +171,19 @@ def guest_token(self) -> Response:
         try:
             body = guest_token_create_schema.load(request.json)
             self.appbuilder.sm.validate_guest_token_resources(body["resources"])
+            # Verify requesting user has access to each specified resource
+            for resource in body["resources"]:
+                if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
+                    from superset.models.embedded_dashboard import EmbeddedDashboard  # noqa: PLC0415
+                    embedded = (
+                        db.session.query(EmbeddedDashboard)
+                        .filter_by(uuid=resource["id"])
+                        .one_or_none()
+                    )
+                    if embedded and not self.appbuilder.sm.can_access_dashboard(
+                        embedded.dashboard
+                    ):
+                        raise ForbiddenError()

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>N+1 Query in Access Validation</b></div>
   <div id="fix">
   
   The added access validation loop performs a separate database query for each dashboard resource, potentially causing N+1 query performance issues when multiple dashboards are specified in guest token requests. Batching the queries would improve efficiency on plausible execution paths.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
               # Verify requesting user has access to each specified resource
               dashboard_uuids = [resource["id"] for resource in body["resources"] if resource["type"] == GuestTokenResourceType.DASHBOARD.value]
               if dashboard_uuids:
                   from superset.models.embedded_dashboard import EmbeddedDashboard  # noqa: PLC0415
                   embedded_dashboards = db.session.query(EmbeddedDashboard).filter(EmbeddedDashboard.uuid.in_(dashboard_uuids)).all()
                   for embedded in embedded_dashboards:
                       if not self.appbuilder.sm.can_access_dashboard(embedded.dashboard):
                           raise ForbiddenError()
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #b2d947</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4423530453

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4422005279

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 99c0f4c580184466919eed6dc1887046d1f68a42 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a01f1ac70321f0008015814 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-40026--superset-docs-preview.netlify.app](https://deploy-preview-40026--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQwMDI2LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.rvpEwkG0KkQJqIZx9L3-b1A2nLUNOPAwZkqv_UArOeg)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcvJDYQwDADAXvzGkr3Lpe1gywjGAcSRKAkIhOid_OYzN_jgVp_gB1BAF8wmY7adTjyIShx2jQmTm3XDoNHtQRSNiMaIMqrMefXqF3f9-_xqQ2zZSEPfD1siaomrlkt4Xg) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-40026--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4421993235

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "anupamme (via GitHub)" <gi...@apache.org>.
anupamme commented on code in PR #40026:
URL: https://github.com/apache/superset/pull/40026#discussion_r3220150286


##########
superset/security/api.py:
##########
@@ -171,6 +171,19 @@ def guest_token(self) -> Response:
         try:
             body = guest_token_create_schema.load(request.json)
             self.appbuilder.sm.validate_guest_token_resources(body["resources"])
+            # Verify requesting user has access to each specified resource
+            for resource in body["resources"]:
+                if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
+                    from superset.models.embedded_dashboard import EmbeddedDashboard  # noqa: PLC0415
+                    embedded = (
+                        db.session.query(EmbeddedDashboard)
+                        .filter_by(uuid=resource["id"])
+                        .one_or_none()
+                    )
+                    if embedded and not self.appbuilder.sm.can_access_dashboard(
+                        embedded.dashboard
+                    ):
+                        raise ForbiddenError()

Review Comment:
   @orbisai0security can you address the code review comments?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4700687008

   Thanks for the pass here, but I don't think the premise holds. The `/guest_token/` endpoint isn't reachable by any authenticated user, it's gated behind `@permission_name("grant_guest_token")`, which per SECURITY.md is the trusted embedding-service role, not something Public/Gamma can call. And the resources do get checked: line 185 already runs `validate_guest_token_resources(body["resources"])` before a token is issued. So the scenario as written isn't reachable. Closing this, but if you can point to a specific role from the SECURITY.md capability matrix that reaches this without `grant_guest_token`, please reopen with that and we'll dig in.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed pull request #40026: fix: the guest token creation endpoint at superset/s... in api.py
URL: https://github.com/apache/superset/pull/40026


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #40026:
URL: https://github.com/apache/superset/pull/40026#discussion_r3220026344


##########
superset/security/api.py:
##########
@@ -171,6 +171,19 @@ def guest_token(self) -> Response:
         try:
             body = guest_token_create_schema.load(request.json)
             self.appbuilder.sm.validate_guest_token_resources(body["resources"])
+            # Verify requesting user has access to each specified resource
+            for resource in body["resources"]:
+                if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
+                    from superset.models.embedded_dashboard import EmbeddedDashboard  # noqa: PLC0415
+                    embedded = (
+                        db.session.query(EmbeddedDashboard)
+                        .filter_by(uuid=resource["id"])
+                        .one_or_none()
+                    )
+                    if embedded and not self.appbuilder.sm.can_access_dashboard(
+                        embedded.dashboard
+                    ):
+                        raise ForbiddenError()

Review Comment:
   **🔴 Architect Review — CRITICAL**
   
   The authorization check in the guest token endpoint only enforces `can_access_dashboard` when the resource ID resolves to an `EmbeddedDashboard` UUID; if a dashboard resource is specified by legacy dashboard ID, `embedded` is `None` and no access check is performed. Since `validate_guest_token_resources` still accepts dashboard IDs and `has_guest_access` still honors them, a user with `can_grant_guest_token` can mint guest tokens for dashboards they cannot access by using dashboard IDs.
   
   **Suggestion:** For each dashboard resource, resolve a concrete `Dashboard` object using the same dual-path logic as `validate_guest_token_resources` (dashboard ID or embedded UUID), and always enforce `can_access_dashboard` on that resolved dashboard; add an integration test ensuring that a caller without access submitting a dashboard ID receives 403.
   
   
   [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20an%20%2A%2AArchitect%20%2F%20Logical%20Review%2A%2A%20comment%20left%20during%20a%20code%20review.%20These%20reviews%20are%20first-class%2C%20important%20findings%20%E2%80%94%20not%20optional%20suggestions.%20Do%20NOT%20dismiss%20this%20as%20a%20%27big%20architectural%20change%27%20just%20because%20the%20title%20says%20architect%20review%3B%20most%20of%20these%20can%20be%20resolved%20with%20a%20small%2C%20localized%20fix%20once%20the%20intent%20is%20understood.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fsecurity%2Fapi.py%0A%2A%2ALine%3A%2A%2A%20175%3A186%0A%2A%2AComment%3A%2A%2A%0A%09%2ACRITICAL%3A%20The%20authorization%20check%20in%20the%20guest%20token%20endpoint%20only%20enforces%20%60can_access_dashboard%60%20when%20the%20resource%20ID%20resolves%20to%20an%20%60EmbeddedDashboard%60%20UUID%3B%20if%20a%20dashboard%20resource%20is%20specified%20by%20legacy%20dashboard%20ID%2C%20%60embedded%60%20is%20%60No
 ne%60%20and%20no%20access%20check%20is%20performed.%20Since%20%60validate_guest_token_resources%60%20still%20accepts%20dashboard%20IDs%20and%20%60has_guest_access%60%20still%20honors%20them%2C%20a%20user%20with%20%60can_grant_guest_token%60%20can%20mint%20guest%20tokens%20for%20dashboards%20they%20cannot%20access%20by%20using%20dashboard%20IDs.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AIf%20a%20suggested%20approach%20is%20provided%20above%2C%20use%20it%20as%20the%20authoritative%20instruction.%20If%20no%20explicit%20code%20suggestion%20is%20given%2C%20you%20MUST%20still%20draft%20and%20apply%20your%20own%20minimal%2C%20localized%20fix%20%E2%80%94%20do%20not%20punt%20back%20with%20%27no%20suggestion%20provided%2C%20review%20manually%27.%20Keep%20the%20change%20as%20small%20as%20possible%3A%20add%20a%20guard%20clause%2C%
 20gate%20on%20a%20loading%20state%2C%20reorder%20an%20await%2C%20wrap%20in%20a%20conditional%2C%20etc.%20Do%20not%20refactor%20surrounding%20code%20or%20expand%20scope%20beyond%20the%20finding.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20an%20%2A%2AArchitect%20%2F%20Logical%20Review%2A%2A%20comment%20left%20during%20a%20code%20review.%20These%20reviews%20are%20first-class%2C%20important%20findings%20%E2%80%94%20not%20optional%20suggestions.%20Do%20NOT%20dismiss%20this%20as%20a%20%27big%20architectural%20change%27%20just%20because%20the%20title%20says%20architect%20review%3B%20most%20of%20these%20can%20be%2
 0resolved%20with%20a%20small%2C%20localized%20fix%20once%20the%20intent%20is%20understood.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fsecurity%2Fapi.py%0A%2A%2ALine%3A%2A%2A%20175%3A186%0A%2A%2AComment%3A%2A%2A%0A%09%2ACRITICAL%3A%20The%20authorization%20check%20in%20the%20guest%20token%20endpoint%20only%20enforces%20%60can_access_dashboard%60%20when%20the%20resource%20ID%20resolves%20to%20an%20%60EmbeddedDashboard%60%20UUID%3B%20if%20a%20dashboard%20resource%20is%20specified%20by%20legacy%20dashboard%20ID%2C%20%60embedded%60%20is%20%60None%60%20and%20no%20access%20check%20is%20performed.%20Since%20%60validate_guest_token_resources%60%20still%20accepts%20dashboard%20IDs%20and%20%60has_guest_access%60%20still%20honors%20them%2C%20a%20user%20with%20%60can_grant_guest_token%60%20can%20mint%20guest%20tokens%20for%20dashboards%20they%20cannot%20access%20by%20using%20dashboard%20IDs.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20t
 his%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AIf%20a%20suggested%20approach%20is%20provided%20above%2C%20use%20it%20as%20the%20authoritative%20instruction.%20If%20no%20explicit%20code%20suggestion%20is%20given%2C%20you%20MUST%20still%20draft%20and%20apply%20your%20own%20minimal%2C%20localized%20fix%20%E2%80%94%20do%20not%20punt%20back%20with%20%27no%20suggestion%20provided%2C%20review%20manually%27.%20Keep%20the%20change%20as%20small%20as%20possible%3A%20add%20a%20guard%20clause%2C%20gate%20on%20a%20loading%20state%2C%20reorder%20an%20await%2C%20wrap%20in%20a%20conditional%2C%20etc.%20Do%20not%20refactor%20surrounding%20code%20or%20expand%20scope%20beyond%20the%20finding.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20vali
 date%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.
   
   **Path:** superset/security/api.py
   **Line:** 175:186
   **Comment:**
   	*CRITICAL: The authorization check in the guest token endpoint only enforces `can_access_dashboard` when the resource ID resolves to an `EmbeddedDashboard` UUID; if a dashboard resource is specified by legacy dashboard ID, `embedded` is `None` and no access check is performed. Since `validate_guest_token_resources` still accepts dashboard IDs and `has_guest_access` still honors them, a user with `can_grant_guest_token` can mint guest tokens for dashboards they cannot access by using dashboard IDs.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
   Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #40026:
URL: https://github.com/apache/superset/pull/40026#discussion_r3220154131


##########
superset/security/api.py:
##########
@@ -171,6 +171,19 @@ def guest_token(self) -> Response:
         try:
             body = guest_token_create_schema.load(request.json)
             self.appbuilder.sm.validate_guest_token_resources(body["resources"])
+            # Verify requesting user has access to each specified resource
+            for resource in body["resources"]:
+                if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
+                    from superset.models.embedded_dashboard import EmbeddedDashboard  # noqa: PLC0415
+                    embedded = (
+                        db.session.query(EmbeddedDashboard)
+                        .filter_by(uuid=resource["id"])
+                        .one_or_none()
+                    )
+                    if embedded and not self.appbuilder.sm.can_access_dashboard(
+                        embedded.dashboard
+                    ):
+                        raise ForbiddenError()

Review Comment:
   Yes — the review comment is **correct**.
   
   ### Why this is a real issue
   The new check only validates access when the resource maps to an `EmbeddedDashboard` UUID.  
   If the request uses a legacy dashboard ID, `embedded` is `None`, so the code skips the authorization check entirely.
   
   That means a user who can call `guest_token` could still mint a guest token for a dashboard they **shouldn’t** be able to access, which defeats the intent of the fix.
   
   ### Minimal fix
   Apply the access check to the resolved dashboard in **both** cases:
   
   - legacy dashboard ID
   - embedded dashboard UUID
   
   For example, resolve the dashboard using the same logic already used by `validate_guest_token_resources`, then always call `can_access_dashboard(...)` on the resolved dashboard.
   
   ```python
   for resource in body["resources"]:
       if resource["type"] == GuestTokenResourceType.DASHBOARD.value:
           # resolve dashboard by legacy ID or embedded UUID
           dashboard = ...
           if not self.appbuilder.sm.can_access_dashboard(dashboard):
               raise ForbiddenError()
   ```
   
   ### Recommendation
   I’d keep the change localized in `guest_token()` and add an integration test that verifies:
   
   - a caller without dashboard access gets `403`
   - this works for both dashboard ID and embedded UUID inputs
   
   So the fix is necessary, and the current patch should be adjusted rather than merged as-is.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "orbisai0security (via GitHub)" <gi...@apache.org>.
orbisai0security commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4423026962

   ✅ **Changes Applied**
   
   I've updated the code based on your feedback:
   
   The fix addresses two code review concerns:
   
   1. **Legacy dashboard ID bypass**: The original code only checked `can_access_dashboard` when `embedded` was non-None (i.e., the ID matched an EmbeddedDashboard UUID). For legacy integer dashboard IDs, `embedded` would be `None` and the access check was silently skipped, allowing users to mint guest tokens for dashboards they can't access. The fix now resolves both UUID-based and integer-based IDs, and always enforces the access check — raising `ForbiddenError` even when no matching dashboard is found.
   
   2. **N+1 query**: The original loop issued one DB query per dashboard resource. The fix collects all dashboard IDs upfront, separates UUID-style IDs from legacy integer IDs, and resolves them in at most two batched queries (one for `EmbeddedDashboard` by UUID, one for `Dashboard` by integer ID), then iterates the resolved map to check access.
   
   **Files modified:**
   - `superset/security/api.py`
   
   The changes have been pushed to this PR branch. Please review!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: the guest token creation endpoint at superset/s... in api.py [superset]

Posted by "orbisai0security (via GitHub)" <gi...@apache.org>.
orbisai0security commented on PR #40026:
URL: https://github.com/apache/superset/pull/40026#issuecomment-4701756246

   Thanks for the detailed explanation. I want to clarify one point, though: `validate_guest_token_resources` only checks that the referenced resource *exists* (raising `EmbeddedDashboardNotFoundError` if not), it doesn't enforce that the calling user has *access* to that resource. So the authorisation gap is real at the code level.
   
   That said, I take your point about the threat model: the endpoint is gated behind `grant_guest_token`, which is intended for a trusted backend service, not end users. In a well-configured deployment, that service would only ever request tokens for dashboards it is legitimately serving.
   
   Where this matters is in misconfiguration or multi-tenant scenarios: if `grant_guest_token` is granted to a role that multiple backend services share, one service could (accidentally or maliciously) mint tokens for dashboards belonging to another tenant. The fix I added would catch that.
   
   I'll leave it to you whether that's a risk worth guarding against in the codebase itself. If you'd like, I'm happy to reframe this as a hardening/defence-in-depth PR rather than a critical vulnerability fix; the code change is the same, the framing is just more accurate. Happy to reopen and update the description if that's useful.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org