Skip to content

fix(reports): check the report target as the identity the report runs as - #45698

Merged
rebenitez1802 merged 7 commits into
apache:masterfrom
preset-io:fix-report-executor-dashboard-access
Oct 29, 2026
Merged

rebenitez1802 merged 7 commits into
apache:masterfrom
preset-io:fix-report-executor-dashboard-access

Conversation

@fitzee

@fitzee fitzee commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

A scheduled report's chart or dashboard access was checked only as the saving user. The identity the report actually runs as (the legacy ALERT_REPORTS_EXECUTORS resolution, e.g. a fixed service account, or the SIP-209 "Run As" user) was never checked. If that identity couldn't see the target (for example, because access came from grants only the creator holds), the report saved successfully but could never deliver:

  • Dashboards with a tab anchor, URL params, or native filters: building the permalink as the executor raised a bare DashboardAccessDeniedError before the execution was claimed. No execution log row was written, the report state never changed, and no one was notified. The reason only reached the Celery worker log. The editors' failure notification also built that permalink as the executor, so it failed too.
  • Plain dashboard URLs: the dashboard page returned a 404 to the executor and the run failed as a generic screenshot error, with no access reason.

This PR:

  1. Validates the execution identity at save time. On create/update, resolve the executor the saved schedule will run as and check the chart/dashboard under that identity. A denial returns a field-level 422 on dashboard/chart. Exempt: paused schedules (so a broken schedule can always be paused), alerts without attachments, executors that can't be resolved until run time, and edits that leave the target, executor, delivery, and active state unchanged. The executor's username is shown only to admins or to a saver who is the executor; everyone else gets a generic message.
  2. Records executor access failures at execution. Dashboard access is checked as the executor before any URL is built. A denial raises ReportScheduleExecutorAccessDeniedError, which names the executor and the security manager's specific reason. The pre-claim permalink pre-commit step skips this denial, so the claimed state machine records it as an ERROR log row and ERROR state and notifies editors. The failure notification falls back to a plain dashboard link. The denial is not retried.
  3. Keeps public responses unchanged. DashboardDAO.get_by_id_or_slug and the permalink API/view are untouched and still return the generic "You don't have access to this dashboard." The specific reason is read from the denial's __cause__ only inside report execution, so a custom security manager's denial text never reaches users without access.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A (backend only)

TESTING INSTRUCTIONS

Automated:

  • tests/unit_tests/commands/report/executor_target_access_test.py (new, 17 tests): save-time executor resolution and checks, exemptions, username disclosure, execution-time conversion of the denial using __cause__, and the pre-commit skip.
  • tests/integration_tests/reports/api_tests.py: create/update returns 422 when the saving user can access the dashboard but the configured executor can't; a paused report still saves; an admin-chosen "Run As" user without access returns 422. These returned 201/200 before the fix.
  • tests/integration_tests/reports/commands_tests.py: tab-permalink and plain-URL dashboard reports whose executor lacks access end with an ERROR log row, ERROR state, and an editors' email carrying the specific reason. Before the fix, no log row was written.
  • tests/integration_tests/dashboards/permalink/api_tests.py: with a security manager that returns a specific denial reason, the permalink API and the /superset/dashboard/p/<key>/ view still return the generic message.

Manual:

  1. Configure ALERT_REPORTS_EXECUTORS with a fixed user that cannot access dashboard D, while your own user can.
  2. Create a report on D → expect a 422 on the dashboard field (previously saved fine).
  3. For an existing report in that state, trigger execution → expect an ERROR entry in the report's execution log naming the access failure, and a failure email to editors (previously no log entry for dashboards with tabs/filters).

Not covered: a real-webdriver run of the old plain-URL 404 behaviour. With this change the access check fails before the browser loads anything, so that path is no longer reached for this case.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

A report's chart or dashboard access was checked only as the saving user.
When ALERT_REPORTS_EXECUTORS or the "Run As" choice resolved to a different
identity that could not access the target, the report saved but could never
deliver. For dashboards with tab anchors, URL params or native filters the
executor failed building the permalink before the execution was claimed,
so no log row was written, the state never changed and no one was
notified; a plain dashboard URL failed as a generic screenshot error.

- On create/update, resolve the executor the saved schedule will run as and
  check the target as that user, returning a field-level 422. Paused
  schedules, attachment-free alerts, unresolvable executors and edits that
  leave the target/executor/delivery unchanged are exempt, so an
  already-broken schedule can always be paused or edited. Only admins and
  self-executors are told the executor's username.
- At execution, check dashboard access as the executor before building any
  URL and raise an error naming the executor and the security manager's
  reason (recovered from the DAO denial's cause, leaving the DAO's generic
  public message unchanged). The pre-claim permalink pre-commit skips this
  denial so the state machine records it: ERROR log, ERROR state and the
  editors' failure notification, which falls back to a plain dashboard link.
  The denial is not retried.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.57%. Comparing base (56cd2bc) to head (982dc32).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45698      +/-   ##
==========================================
- Coverage   84.62%   84.57%   -0.05%     
==========================================
  Files        3069     3060       -9     
  Lines      205473   204702     -771     
  Branches    48295    47909     -386     
==========================================
- Hits       173875   173130     -745     
+ Misses      28305    28279      -26     
  Partials     3293     3293              
Flag Coverage Δ
hive 34.48% <22.42%> (-0.02%) ⬇️
mysql 52.55% <87.85%> (+0.04%) ⬆️
postgres 52.56% <87.85%> (+0.04%) ⬆️
presto 36.21% <22.42%> (-0.02%) ⬇️
python 87.74% <100.00%> (+0.01%) ⬆️
sqlite 52.32% <87.85%> (+0.04%) ⬆️
unit 82.47% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Regenerate messages.pot so it carries the three executor-access strings
added by this change, which the template drift check requires.

Make the unchanged-target shortcut in the executor access validation
kind-aware. A report moved from a chart to a dashboard with the same
numeric id previously matched the stored target and skipped the check.

Release the integration test's report schedule in a finally block so a
failing assertion cannot leak state into later tests.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Oct 25, 2026
@sadpandajoe
sadpandajoe marked this pull request as ready for review October 26, 2026 15:53
Comment thread superset/commands/report/execute.py Outdated
if user is None or getattr(user, "is_anonymous", False):
return
try:
security_manager.raise_for_access(dashboard=self._report_schedule.dashboard)

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.

Suggestion: This RBAC check ignores EXTRA_ACCESS_QUERY_EXCLUSIONS; an excluded executor passes save validation, then permalink creation raises uncaught DashboardNotFoundError before claiming or logging.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Api mismatch

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/commands/report/execute.py
**Line:** 848:848
**Comment:**
	*Api Mismatch: This RBAC check ignores `EXTRA_ACCESS_QUERY_EXCLUSIONS`; an excluded executor passes save validation, then permalink creation raises uncaught `DashboardNotFoundError` before claiming or logging.

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 fix
👍 | 👎

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmed, and fixed in 0ed1af3. raise_for_access does not consult EXTRA_ACCESS_QUERY_EXCLUSIONS, but DashboardDAO.get_by_id_or_slug (used by the permalink command) does, so an executor the hook withholds the dashboard from passed both checks and then hit an unhandled DashboardNotFoundError before the claim. Now a withheld dashboard is treated as an executor access denial: validate_executor_target_access rejects it at save time, and _raise_for_executor_dashboard_access raises ReportScheduleExecutorAccessDeniedError before any permalink is built (covers single-tab, multi-tab and plain-URL paths), so the state machine records and notifies. Regression tests added in executor_target_access_test.py.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 0ed1af3.

After the dashboard access check, the code now checks is_excluded_by_extra_access("dashboards", dashboard.id) and raises ReportScheduleExecutorAccessDeniedError for excluded dashboards.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 74a40cf.

After the dashboard access check, the code now checks is_excluded_by_extra_access("dashboards", dashboard.id) and raises ReportScheduleExecutorAccessDeniedError for excluded dashboards.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of e7c849d.

After the normal dashboard access check, the code now checks is_excluded_by_extra_access("dashboards", dashboard.id) and raises ReportScheduleExecutorAccessDeniedError for excluded dashboards.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 982dc32.

After the normal dashboard access check, the code now checks is_excluded_by_extra_access("dashboards", dashboard.id) and raises ReportScheduleExecutorAccessDeniedError for excluded dashboards.

If that's not right, unresolve this thread and CodeAnt will leave it open.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; executor access checks now catch dashboard exclusions before permalink creation, with regression tests covering the failure path.

Assessed commit: 982dc32e863e

…or's dashboard

raise_for_access does not consult EXTRA_ACCESS_QUERY_EXCLUSIONS, but the
permalink command's dashboard lookup does. An executor the hook withholds the
dashboard from therefore passed the save-time check and the pre-claim access
check, then hit an unhandled DashboardNotFoundError while building a tab
permalink, aborting the run before it was claimed or logged.

Treat a withheld dashboard as an executor access denial both when the schedule
is saved and when the dashboard URLs are built.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@netlify

netlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 982dc32
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae24c34e6b07148ed3ead81
😎 Deploy Preview https://deploy-preview-45698--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@rebenitez1802

Copy link
Copy Markdown
Contributor

Request changes: excluded dashboards still bypass the new error handling. All 795 unit tests passed, but two focused regression checks reproduced this gap; integration tests were not run.

🟡 Medium — Excluded dashboards still suppress failure notifications
In _get_tab_url(), the handler catches DashboardAccessDeniedError, but dashboard exclusions raise DashboardNotFoundError. With saved dashboard state and ALERT_REPORT_TABS enabled, content generation and failure notifications reach this path directly, losing the actionable denial, allowing retries, and preventing the editors’ failure email. Fix: apply the executor access check before these permalink lookups so exclusions consistently become ReportScheduleExecutorAccessDeniedError and trigger the plain-link fallback.

…lookup

Dashboard exclusions make the permalink command answer with a not-found
error, which only get_dashboard_urls translated into the executor
access-denied error. Content generation and failure notifications reach
the stored-state permalink through _get_url, so the not-found error escaped
there, defeating the plain-link fallback and the editors' failure
notification. Run the executor access check inside _get_tab_url so every
caller sees the same access-denied error.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sadpandajoe

Copy link
Copy Markdown
Member

Thanks for the catch, this was a real gap. _get_url (used by content generation and by the failure-notification link) reaches _get_tab_url without going through get_dashboard_urls, so a dashboard withheld by EXTRA_ACCESS_QUERY_EXCLUSIONS surfaced as an uncaught DashboardNotFoundError there.

Fixed in 74a40cf: _get_tab_url now runs the executor access check (including the exclusion check) before any permalink lookup, so every caller gets ReportScheduleExecutorAccessDeniedError. That restores the plain-link fallback in _get_failure_notification_url and the non-retried, logged failure with the editors' notification. Added regression tests for the failure-notification path, _get_url with stored dashboard state, and the non-excluded case; the report unit tests pass (1259 passed). Integration tests were not run locally.

@rebenitez1802 rebenitez1802 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.

Approve: commit 74a40cfd7b fixes the previous finding; the team found no new issues. All 523 unit tests and both exclusion regression checks passed. Integration tests were not run.

sadpandajoe and others added 2 commits October 27, 2026 23:17
Resolve the messages.pot POT-Creation-Date conflict; the report executor
access strings from this branch are retained.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@rebenitez1802
rebenitez1802 merged commit 9809f84 into apache:master Oct 29, 2026
74 checks passed
@rebenitez1802
rebenitez1802 deleted the fix-report-executor-dashboard-access branch October 29, 2026 19:39
hainenber pushed a commit that referenced this pull request Nov 14, 2026
… as (#45698)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: sadpandajoe <[email protected]>
Co-authored-by: Joe Li <[email protected]>
villebro added a commit that referenced this pull request Nov 14, 2026
The quoted native-filter round-trip test patched
BaseReportState._raise_for_executor_dashboard_access, which comes from
master's #45698 and doesn't exist on 7.0, where get_dashboard_urls doesn't
call it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n Namespace | Anything related to localization size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants