fix(dashboard): do not add importer as owner when overwriting existing dashboard#38615
fix(dashboard): do not add importer as owner when overwriting existing dashboard#38615nitishagar wants to merge 1 commit intoapache:masterfrom
Conversation
Code Review Agent Run #70873fActionable 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 |
Sequence DiagramThis PR changes dashboard import behavior to prevent ownership escalation during overwrite. The importer is now added as an owner only when creating a new dashboard, not when updating an existing one by UUID. sequenceDiagram
participant User
participant ImportService
participant Database
User->>ImportService: Import dashboard with overwrite option
ImportService->>Database: Check dashboard by UUID
Database-->>ImportService: Existing dashboard or none
alt Existing dashboard found
ImportService->>Database: Update existing dashboard
ImportService-->>User: Return dashboard without adding importer to owners
else No existing dashboard
ImportService->>Database: Create new dashboard
ImportService->>ImportService: Add importer to owners
ImportService-->>User: Return new dashboard with importer as owner
end
Generated by CodeAnt AI |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #38615 +/- ##
==========================================
- Coverage 65.01% 64.39% -0.62%
==========================================
Files 1817 2529 +712
Lines 72318 128953 +56635
Branches 23032 29719 +6687
==========================================
+ Hits 47016 83042 +36026
- Misses 25302 44466 +19164
- Partials 0 1445 +1445
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…g dashboard When a user imports a dashboard that already exists (same UUID), the importer was unconditionally added as an owner even if they had no prior ownership. This was a privilege escalation: any user with can_write on Dashboard could gain ownership of any dashboard by importing it. Fix: guard the owner-append with `not existing` so the importer is only added as owner when creating a brand-new dashboard, not when overwriting one. Closes apache#36244
Code Review Agent Run #7b8dc3Actionable 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 |
User description
SUMMARY
When a user with
can_writeon Dashboard imports an existing dashboard (matching UUID), they were unconditionally added to the dashboard'sownerslist. This is a privilege escalation: User B could gain ownership of any dashboard they didn't originally own simply by importing it.Root cause —
superset/commands/dashboard/importers/v1/utils.py:The variable
existingis already in scope earlier in the same function (existing = db.session.query(Dashboard).filter_by(uuid=config["uuid"]).first()). Guarding onnot existingrestricts owner auto-assignment to brand-new dashboards only.Fixes #36244
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only change.
TESTING INSTRUCTIONS
can_writeon Dashboard, but is not an owner of Dashboard A).overwrite=True.Unit tests added:
test_import_existing_dashboard_does_not_add_importer_as_owner— proves the bug and verifies the fixtest_import_new_dashboard_adds_importer_as_owner— regression guard (new dashboards still get the importer as owner)ADDITIONAL INFORMATION
CodeAnt-AI Description
Do not add importer as owner when overwriting existing dashboard
What Changed
Impact
✅ Prevents accidental escalation to dashboard owner during overwrite import✅ Fewer unauthorized owner assignments when importing dashboards✅ Clearer, more predictable import ownership behavior💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.