Vitor-Avila commented on code in PR #38243:
URL: https://github.com/apache/superset/pull/38243#discussion_r2854338559
##########
superset/security/manager.py:
##########
@@ -2590,14 +2590,28 @@ def raise_for_access( # noqa: C901
or (
# Chart.
form_data.get("type") != "NATIVE_FILTER"
- and (slice_id := form_data.get("slice_id"))
+ and (
+ # Use parent_slice_id if present
+ # (for multilayer chart children)
+ # Otherwise use slice_id directly
+ slice_id := (
+ form_data.get("parent_slice_id")
+ or form_data.get("slice_id")
+ )
+ )
and (
slc := self.session.query(Slice)
.filter(Slice.id == slice_id)
.one_or_none()
)
and slc in dashboard_.slices
- and slc.datasource == datasource
+ and (
+ # For parent charts, check datasource directly
+ # For child charts of multilayer
+ # parent is already validated
+ slc.datasource == datasource
+ or form_data.get("parent_slice_id") is not None
+ )
)
Review Comment:
Could we make this flow a little bit different? Right now you're checking
that:
1. `form_data` includes a `parent_slice_id`
2. `parent_slice_id` belongs to the dashboard
But we're not validating if `slice_id` (the child) actually is included in
the `parent_slice_id` by default, so a `GuestUser` could forge a payload with a
`parent_slice_id` to get unauthorized access to a chart that's not really used
by the parent one.
Ideally we should check if `parent_slice_id` is present, and if so confirm
that `slice_id` is used in this `parent_slice_id`'s default config.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]