You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Legacy explore save: chart is committed before the dashboard permission check, and invalid save_to_dashboard_id returns 500 #46324
In superset/views/core.py, Superset.save_or_overwrite_slice creates or overwrites the chart and calls db.session.commit() BEFORE it validates the dashboard it should be added to:
The chart is created/updated and committed (ChartDAO.create / ChartDAO.update + db.session.commit()).
Only afterwards is save_to_dashboard_id / new_dashboard_name handled, including the permission checks (security_manager.is_editor(dash), can_access("can_write", "Dashboard")).
If the dashboard check fails, the request returns 403 ("You don't have the rights to alter this dashboard"), but the chart has already been saved or overwritten. The operation is not atomic.
Additionally, int(save_to_dashboard_id) and .one() are unguarded: a non-numeric value raises ValueError, and a nonexistent dashboard id raises NoResultFound. Both return a 500 instead of a 400/404, and again happen after the chart was committed.
Steps to reproduce:
Log in as a user who can create charts but cannot edit dashboard X.
Send a request to the legacy explore endpoint with action=saveas, a slice_name, valid form_data, and save_to_dashboard_id=<id of dashboard X>.
Observe the 403 response.
Check the chart list: the new chart exists despite the 403.
Repeat with save_to_dashboard_id=abc or a nonexistent id: observe a 500 and a saved chart.
Expected behavior: dashboard id parsing and permission checks happen before any chart is committed. On failure, nothing is persisted, and invalid or nonexistent ids return 400/404.
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.11
Node version
16
Browser
Chrome
Additional context
No response
Checklist
I have searched Superset docs and Slack and didn't find a solution to my problem.
I have searched the GitHub issue tracker and didn't find a similar bug report.
I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Activity
fix(explore): validate dashboard target before saving chart (#46324) (#…
test(core): add forbidden-dashboard overwrite test, drop stale handles
fix(explore): validate dashboard target before saving chart (#46324) (#…