Repository navigation
fix(security): bind promiscuous viewer access to the dashboard's and chart's own requests - #44215
Conversation
Code Review Agent Run #86542bActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| chart.datasource is not None | ||
| and security_manager.can_drill_dataset_via_dashboard_access( | ||
| chart.datasource, dashboard | ||
| ) |
There was a problem hiding this comment.
Suggestion: Semantic-view charts have no chart.datasource, so this check never runs and removes form_data even when the chart's resolved datasource is dashboard-authorized. [api mismatch]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/dashboards/api.py
**Line:** 777:780
**Comment:**
*Api Mismatch: Semantic-view charts have no `chart.datasource`, so this check never runs and removes `form_data` even when the chart's resolved datasource is dashboard-authorized.
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.
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 fixThere was a problem hiding this comment.
Good catch — semantic-view charts have no table-backed chart.datasource, so the original guard skipped the check and stripped form_data for them.
Rather than patch the guard, I reworked the approach to match the intended model: full dashboard → chart → dataset access inheritance. A dashboard's /charts and /datasets sub-resources only ever return members of that dashboard, so the correct test is a pure dashboard-entitlement predicate, not a per-dataset membership check. Added SecurityManager.can_inherit_access_via_dashboard(dashboard) (embedded guest with access, or viewer of a published dashboard under VIEWER_PROMISCUOUS_MODE) and the serializers now use it. This is datasource-type agnostic, so semantic-view charts render correctly, and it's resolved once per request instead of per member. can_drill_dataset_via_dashboard_access still layers the dataset-membership guard on top for the drill endpoints, which resolve the dataset from an untrusted request param. Fixed in 1cf6da5.
There was a problem hiding this comment.
Addressed structurally in 3f094b1. Rather than guard chart.datasource in the serializer, the access inheritance now lives in the access primitive (raise_for_access): can_access_chart / can_access_datasource themselves recognize a promiscuous viewer of a published dashboard the chart/dataset belongs to. Because that check is dashboard-level rather than per-datasource, it's datasource-type agnostic — semantic-view charts (whose table-only chart.datasource is None) render correctly with no special-casing. The dashboard serializers revert to pristine as a result. The tangled datasource branch of raise_for_access was also refactored into named helpers, preserving the embedded-guest strict per-request binding (validated against the existing guest/drill/multi-layer suite).
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 4fb6f17.
The current code no longer contains the chart.datasource check or the form_data removal it referred to; this section now filters dashboard charts by can_access_chart.
If that's not right, unresolve this thread and CodeAnt will leave it open.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #44215 +/- ##
==========================================
- Coverage 85.17% 85.14% -0.03%
==========================================
Files 3082 3080 -2
Lines 210328 210375 +47
Branches 49592 49549 -43
==========================================
- Hits 179144 179128 -16
- Misses 27798 27854 +56
- Partials 3386 3393 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The flagged issue is correct. Semantic-view charts often lack a direct To resolve this, you should update the check to handle cases where the datasource is resolved through the dashboard context, even if Would you like me to implement this fix and check the rest of the PR comments for you? superset/dashboards/api.py |
|
/review |
|
Bito Review Skipped - Review Already In Progress Bito didn't start a new review because a review for this pull request is already in progress. Please wait for the current review to complete; its feedback will be posted on this pull request. To run another review after it completes, type |
Code Review Agent Run #a42f83Actionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
/review |
Code Review Agent Run #ee4ed3Actionable Suggestions - 0Additional Suggestions - 4
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #854f1fActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| # chart itself, so its definition (``form_data``) can be served for | ||
| # rendering. This is datasource-type agnostic and covers charts | ||
| # whose datasource cannot be resolved above. | ||
| if self._promiscuous_viewer_inherits_chart(chart): |
There was a problem hiding this comment.
Thanks for picking this up, we have been bitten by needing per-chart grants on top of dashboard access. So this is very welcome 🎉
There was a problem hiding this comment.
Thanks! That per-chart grant toil is exactly what prompted it — good to know it lands for your setup too. Your review also caught the editor/unpublished hole in the same area, which is now fixed in f8ac8a3.
…ublished The dashboard read gate in raise_for_access admits editors with no publication requirement and viewers only for a published dashboard. The inheritance paths applied the published gate to both, so an editor added to someone else's unpublished dashboard could open it while every chart lost form_data and the dashboard rendered empty. Reported by @madhushreeag on apache#44215. - get_inherited_slice_ids_subquery: gate published on the viewers leg only. - can_inherit_access_via_dashboard: admit editors regardless of published, so drill-to-detail works on an editor's own unpublished dashboard too. Covers the editor/viewer x published/draft matrix with tests that build real dashboards, charts, users and subjects and execute the generated SQL.
Code Review Agent Run #43bd0aActionable Suggestions - 0Additional Suggestions - 2
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
@villebro checking back in, holler if we can help move this forward. This still looks like the right fix for #44133. It needs a rebase: #45002, #44993 and #45060 all touched @madhushreeag, the editors-leg Happy to take a pass at the conflict resolution myself if you're swamped, just say the word. |
f8ac8a3 to
4fb6f17
Compare
|
Rebased onto current master (the branch history is now a single commit, so the earlier SHAs such as f8ac8a3 no longer exist; the content is unchanged). The inheritance helpers in Also added a test showing that embedded guests are excluded from the two |
… requests, for viewers only Rework the promiscuous-mode fix on the legacy DASHBOARD_RBAC model instead of dashboard-to-chart/dataset inheritance: - has_promiscuous_dashboard_access(dashboard) grants a dashboard's data only to its listed viewers (is_listed_viewer: on the viewer list, not merely an editor), only for a published dashboard, and never to embedded guests. - The grant applies only on requests bound to that dashboard: the existing chart-data leg (member chart on its own datasource, native filter target, multi-layer child, drill), drill info, and the dashboard's own chart list, /charts and /datasets endpoints. Nothing else counts it, so it can't become access to a chart or datasource outside the dashboard, and the per-path opt-outs (dashboard_inheritance_disabled, the inheritance SQL, the resolver fallback, the chart command and MCP wrappers) are removed. - Copying a dashboard, with or without duplicating its charts, requires access to each source chart in its own right, since the copy keeps them. - SECURITY.md, the config comment, the admin docs and UPDATING.md describe the model; tests are rewritten against real rows.
|
Reworked in 8bfcc78, following the legacy
Nothing outside those requests counts the grant, which removes the inheritance SQL, the context manager and the per-path opt-outs. Copying a dashboard now requires access to its charts. The description, |
madhushreeag
left a comment
There was a problem hiding this comment.
Under VIEWER_PROMISCUOUS_MODE, the native-filter branch of raise_for_access grants access to any datasource named as a filter target in a dashboard's json_metadata. Unlike the chart branch, it never checks has_member_datasource, and no save path verifies that the editor can read the target dataset, so a listed viewer of a published dashboard can read a dataset that no chart on the dashboard uses. Verified on 8bfcc785e1: as gamma (no access to cleaned_sales_data, id 397) and a listed viewer of published dashboard 612, a native filter targeting 397 loaded that dataset's year values in gamma's filter bar, even though gamma has no grant on it. Because an editor can add themselves to the viewer list and publish, one person can reach a dataset they otherwise can't. The UI picker and the MCP tool both refuse an inaccessible dataset, so persisting such a filter needs a direct PUT /api/v1/dashboard/<id> with a crafted datasetId - the same reachability as the chart-attach issue fixed in f2b559120b. The master is worse actually, since it uses is_viewer with no published gate, the PR rework narrows it without closing it.
Suggested fix: check native-filter targets on save, mirroring the chart-attach gate, so a newly added target must be readable by the editor in their own right.
… save The promiscuous grant lets a dashboard's viewers query its native-filter targets, and an editor can add themselves as a viewer, so a filter targeting a dataset the editor can't read gave them its values. Saving a native filter now requires access to any datasource it newly targets, mirroring the chart layout check: through the dashboard (update and create, with the update command refusing before its side effects) and the filters API (including the MCP filter tool). Targets the dashboard already had stay accepted. Copying a dashboard also requires access to the source's filter targets, which the copy keeps.
|
@madhushreeag, thanks, confirmed and fixed in 687ac32, following your suggestion. Saving a native filter now requires access to any datasource it newly targets, mirroring the chart layout check:
Targets the dashboard already had stay accepted, so a save never fails over a filter it doesn't change. Copying a dashboard also requires access to the source's filter targets, since the copy keeps them. |
# Conflicts: # UPDATING.md
# Conflicts: # UPDATING.md
The up-front copy check refused a copy whenever any source chart was unreadable, even one the copy's layout left out. Check the charts each copy mode actually carries: the source charts it clones (duplicate_slices), the layout's charts (set_dash_metadata, no longer exempting the source's members), or every source chart when there's no layout. The source's filter targets are checked unless the copy replaces its metadata. Tests: update apache#45538's copy integration tests for the rule (a source member is no longer exempt, and duplicating an unreadable source chart is refused), with expected messages built from the fixture's ids; cover the three copy modes in the real-row unit test; and make Gamma a real listed viewer in the semantic-view native filter test instead of mocking is_viewer.
Align the chart-level VIEWER_PROMISCUOUS_MODE grant with the dashboard one: only a chart's listed viewers load its data without dataset access, its editors need regular access, and embedded guests never get it. Document the chart grant alongside the dashboard grant.
# Conflicts: # UPDATING.md # superset/commands/dashboard/update.py # superset/daos/dashboard.py # tests/integration_tests/dashboards/api_tests.py
… layouts A copy that carries a source chart the caller cannot read is refused, so the missing-chart parity cases for the copy routes save only the stale tile.
Upstream apache#44215 binds VIEWER_PROMISCUOUS_MODE grants to dashboard-bound requests: a listed viewer reads a member chart's data only through its dashboard, never the chart or dataset themselves. The dashboard-membership grants in raise_for_access (the chart branch and the slice_id datasource helper) fired on any bare chart/datasource check, so they over-granted under promiscuous mode -- the two new tests in test_promiscuous_dashboard_access.py failed, and an unbound chart-data request for a member chart was granted too. Gate both grants on promiscuous mode not applying; the legacy dashboard-RBAC behaviour (flags off) is unchanged. Also collapse the _current_subject_ids set comprehension to the single line ruff-format requires (pre-commit failure on the rebased head).
…harts listing Upstream apache#44215 pins that a dashboard viewer without promiscuous mode keeps form_data stripped for its inaccessible charts in the dashboard charts listing, but the dashboard-membership chart grant in raise_for_access also feeds can_access_chart, which the listing uses to decide the stripping -- so the listing exposed form_data and its test failed on all three database backends. Thread an allow_dashboard_membership opt-out through raise_for_access and can_access_chart (default True, preserving the Explore bootstrap behaviour) and pass False from the dashboard charts serializer, so the listing keeps stripping form_data for non-inherited charts while Explore access through dashboard RBAC is unchanged.
…chart's own requests (#44215)
…chart's own requests (reduced backport of #44215) The security manager change applies as is. On 7.0 the copy and native-filter checks build on the reduced #45538 layout check rather than master's #44028 and #45800 helpers: a copy checks the source charts it carries (all of them when duplicating or without a layout, else those its layout places) and its native-filter targets, and the update command checks new filter targets before its side effects. The dashboard datasets endpoint passes the grant to the serializer, since 7.0's DAO takes no access callback. Tests for files absent on 7.0 are left out, and 7.0's copy test now expects the refusal. (cherry picked from commit 2645396, reduced)
SUMMARY
Fixes #44133.
VIEWER_PROMISCUOUS_MODE(withENABLE_VIEWERS) is meant to let a viewer of a published dashboard render that dashboard's charts without explicit chart or dataset grants, as the legacyDASHBOARD_RBACdid. In practice charts hung on the loading spinner. The chart-data query already honored the flag, but to issue it the frontend first callsGET /dashboard/<id>/chartsfor each chart'sform_data, and that endpoint (andGET /dashboard/<id>/datasets) narrowed members throughcan_access_chart/can_access_datasource, which know nothing about the dashboard. This regressed with #42716, whose tests mocked exactly those checks.DESIGN
The grant follows the
DASHBOARD_RBACmodel. Its rules:Who.
has_promiscuous_dashboard_access(dashboard)holds only for the dashboard's listed viewers (is_listed_viewer: on the viewer list directly or through a role or group, not merely an editor), only for a published dashboard, never for embedded guests (who keep their token-scoped grant), and only withENABLE_VIEWERSandVIEWER_PROMISCUOUS_MODEon. Editors keep their regular access only.Where. The grant applies only to requests bound to that dashboard:
dashboardIdis validated against what it names: a member chart on its own datasource, a native filter in the dashboard's configuration targeting that datasource, a multi-layer child configured in a member parent, or drill, pluscan_access_dashboard;/chartsand/datasetsendpoints (the Promiscuous viewer mode requires access to charts in addition to dashboard #44133 fix).Charts. The flag also grants a chart's data to the chart's own listed viewers, on the same terms (
has_promiscuous_chart_access(chart)): listed viewers only, never editors or embedded guests, and only for chart-data requests whoseslice_idnames that chart on its own datasource. Charts have no publish state, so there's no published check.Nothing else counts either grant:
can_access_chart/can_access_datasource, Explore, SQL Lab, chart create, repoint and Save as, the MCP tools. So neither grant can become access to a dataset outside the dashboard's or chart's own requests.What a dashboard may gain. A dashboard's charts and native-filter targets are editor-written configuration, and editors control the viewer list, so anything a dashboard newly gains must be readable by the editor in their own right:
PUT/create; the update command refuses before its report side effects) or the filters API (also used by the MCPmanage_native_filterstool);What the dashboard already has stays accepted, so a save never fails over something it doesn't change.
Consequences:
DASHBOARD_RBACowners could with roles.SECURITY.mddocuments the flag as an opt-in relaxation and lists what stays in scope.Earlier revisions propagated dashboard access to charts and datasets everywhere and opted write paths out one by one; review kept finding new paths (attach, create, repoint, Save as, copy, MCP). Binding the grant to the dashboard's own requests closes that class by design, leaving rule 3 as the only write-side check.
This changes behavior on master: dashboard and chart editors who aren't listed viewers no longer get the grant, a viewer's grant now also requires a published dashboard on the chart-data path, and copy now checks chart and filter-target access.
UPDATING.mdcovers it.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
With
ENABLE_VIEWERSon andVIEWER_PROMISCUOUS_MODE = True, add a role as a viewer of a published dashboard with no chart or dataset grants:GET /api/v1/dashboard/<id>/chartsreturnsform_dataand/datasetsreturns full metadata.VIEWER_PROMISCUOUS_MODEoff, and the metadata is narrowed again.PUT /api/v1/dashboard/<id>or/filters) returns 422, as does copying a dashboard whose charts or filter targets you can't read.Automated:
tests/unit_tests/subjects/test_promiscuous_dashboard_access.py, against real rows:raise_for_accesswith the original signature keeps working.tests/integration_tests/dashboards/api_tests.py: a Gamma listed viewer getsform_dataand dataset metadata, an editor-only Gamma doesn't, plus the unpublished and flag-off cases.ADDITIONAL INFORMATION
ENABLE_VIEWERS(withVIEWER_PROMISCUOUS_MODE)