You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Yassuip (via GitHub)" <gi...@apache.org> on 2025/05/02 17:49:29 UTC

[I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Yassuip opened a new issue, #33346:
URL: https://github.com/apache/superset/issues/33346

   ### Bug description
   
   **Issue Summary**
   When querying a dataset with Row-Level Security (RLS) applied in SQL Lab, the results are correctly filtered. However, if I click "Create Chart" directly from SQL Lab (without saving the dataset/virtual dataset), the chart displays the entire unfiltered data, ignoring the RLS restrictions. Ideally, it should only show the filtered data returned in SQL Lab.
   We can clearly see that SQL Lab returns only 3 rows — as expected. However, on the chart screen, it displays 125 rows, which is incorrect and indicates that the RLS filter is not being applied.
   
   **Expected Behavior:**
   The chart should reflect only the filtered results returned by SQL Lab (i.e., RLS-applied data).
   
   **đź“· Evidence:**
   **SQL Lab Data Records(RLS)**
   <img width="1590" alt="Image" src="https://github.com/user-attachments/assets/83057f64-7a5b-4aeb-a166-ac23a18747c4" />
   
   **Chart Screen Data Records**
   <img width="1199" alt="Image" src="https://github.com/user-attachments/assets/2cdf06fa-5fd2-45ce-a01f-70ea5e021aa3" />
   
   **Steps to Reproduce:**
   
   - Query a dataset with RLS in SQL Lab.
   - Verify that RLS filters are applied (returns limited rows).
   - Click "Create Chart" directly from SQL Lab.
   - Observe that the chart ignores RLS and shows all rows.
   
   **Notes:**
   This seems to be due to the chart being created from a raw SQL result, which doesn't preserve RLS constraints unless it's saved as a dataset or virtual dataset.
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   4.1.2
   
   ### Python version
   
   3.10
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [x] 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.


-- 
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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "Yassuip (via GitHub)" <gi...@apache.org>.
Yassuip commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-2857073988

   If RLS is not supported when creating charts from raw SQL queries, then allowing users to build charts without first saving the dataset poses a potential data security risk. Currently, I haven't found any permission setting that restricts this behavior—aside from completely removing SQL Lab or dataset access. If RLS can't be enforced in this flow, there should be a built-in mechanism to disable chart creation from raw queries to prevent unintended data exposure.
   Given this, we should treat the ability to bypass RLS as a data exposure issue and consider implementing a fix. Ideally, RLS should be enforced even for raw queries, especially **_since SQL Lab itself applies RLS when returning raw query results. And  a user clicks “Create Chart” from the same SQL Lab screen, the chart should be based on the already-filtered data—not the full underlying dataset_**.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-5099514542

   Yeah, this checks out. RLS lives on the dataset model, and charting directly from an unsaved SQL Lab query skips that layer entirely since there's no dataset object to hang the filter on. Worth a real fix rather than a docs note, since it lets a restricted user see unfiltered data through a side door.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "b-yacoubi (via GitHub)" <gi...@apache.org>.
b-yacoubi commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-3852894292

   > [@Yassuip](https://github.com/Yassuip) have you tried later versions like 5.x or master to see if this is still an issue there?
   
   Still an issue indeed, in 6.0.0 as well.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "Ujjwaljain16 (via GitHub)" <gi...@apache.org>.
Ujjwaljain16 commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-5582144712

   I looked into this in detail against current `master` (not #43090, which was closed without merging).
   
   the originally reported symptom is already fixed on master
   Building a chart directly from an unsaved SQL Lab query no longer bypasses RLS i verified this with a live reproduction (RLS-restricted user vs. unrestricted user, on real Postgres): the restricted user's chart query correctly gets the underlying table's RLS predicate injected, the unrestricted user's doesn't.
   
   What actually fixed it: not #43090 (never merged). The fix is in `ExploreMixin.get_from_clause` (shared by `SqlaTable` virtual datasets and the SQL-Lab-ad-hoc `Query` datasource alike)  it parses the chart's raw SQL for referenced tables and injects those tables' RLS predicates at query-construction time, added generically for virtual datasets in #36061 and hardened to fail closed (aborts instead of running unfiltered on a parse error) in #42929. Neither commit references this issue, which is presumably why it's stayed open despite being resolved. There was no regression test covering the SQL-Lab-ad-hoc path specifically so i added one.
   
   One adjacent gap i found while verifying this, distinct from the original report: 
   the query-result *cache key* for a SQL-Lab-ad-hoc chart never varied by the viewer's RLS (unlike every other datasource type), so a shared Explore permalink viewed by two differently-RLS-scoped users could, with query-result caching enabled, serve one viewer's cached result to the other. Filed as [[#43985](https://github.com/apache/superset/pull/43985)], separate from this issue since it's a caching-isolation gap, not the query-execution bypass this issue describes.
   
   Happy to add anything here that would help close this out, or if a maintainer wants the regression test coverage broken out as its own PR against this issue specifically.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "suryanshpratap825 (via GitHub)" <gi...@apache.org>.
suryanshpratap825 commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-2847851590

   Yes, this happens because RLS isn't applied when creating a chart directly from SQL Lab unless the query is saved as a dataset. Saving it first is a good workaround for now. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-2855374361

   If anyone wants to add some clarity here in the docs, that would be SO VERY welcome :D 
   
   Is that answer sufficient to close the issue for now?


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-3504068231

   @Yassuip have you tried later versions like 5.x or master to see if this is still an issue there?


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "Yassuip (via GitHub)" <gi...@apache.org>.
Yassuip commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-2847863657

   @suryanshpratap825  Do we have any specific permission that can hide the "Create Chart" button or disable the related API? Since that option allows users to access the entire dataset, it could potentially expose all data.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-5588692895

   Thanks for chasing this down, @Ujjwaljain16. Good to hear #36061 and #42929 already fixed the RLS gap for ad-hoc SQL Lab charts on master. Closing this out, reopen if it still reproduces on a recent build. The cache-key gap you found is worth its own review over in #43985.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "suryanshpratap825 (via GitHub)" <gi...@apache.org>.
suryanshpratap825 commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-2847886153

   @Yassuip , I found these two link it will helps you out to achevie it.
   
   https://github.com/apache/superset/issues/28760
   
   
   https://stackoverflow.com/questions/68478219/restrict-access-to-a-table-in-sql-lab-in-superset#:~:text=If%20you%20give%20access%20to,and%20query%20from%20that%20dataset.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #33346:
URL: https://github.com/apache/superset/issues/33346#issuecomment-2847779823

   <!-- Answer -->
   The issue you're experiencing is related to how Apache Superset handles Row-Level Security (RLS) when creating charts directly from SQL Lab. When you create a chart directly from SQL Lab without saving the query as a dataset, the RLS filters are not applied. This is because the chart creation process from SQL Lab does not automatically incorporate RLS constraints unless the query is saved as a dataset or virtual dataset first.
   
   In Superset, RLS is typically applied when queries are executed within SQL Lab, and the results are correctly filtered. However, when transitioning directly to chart creation from SQL Lab, the RLS predicates are not automatically included in the chart's data source unless the query is saved as a dataset. This behavior is due to the way Superset handles data sources for charts, which requires the dataset to be explicitly defined with RLS constraints.
   
   To ensure that RLS is applied when creating charts, you should save the SQL Lab query as a dataset first. This will preserve the RLS constraints and ensure that the chart reflects the filtered data as expected.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   
   ---
   <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5a0545ad-bf9e-426f-a08a-6edb4a73cbaa?feedback_type=other)</sup>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #33346: RLS does not apply when creating a chart directly from SQL Lab without first saving the query as a dataset.
URL: https://github.com/apache/superset/issues/33346


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org