bito-code-review[bot] commented on PR #40839:
URL: https://github.com/apache/superset/pull/40839#issuecomment-4645853898

   <!-- Bito Reply -->
   The flagged issue is correct. The current implementation of the cache key in 
`superset/datasource/api.py` relies on `get_user_id()`, which returns `None` 
for guest users, causing them to share cache entries regardless of their 
specific RLS rules. 
   
   To resolve this, you should incorporate the effective RLS context into the 
cache key. You can achieve this by including the result of 
`security_manager.get_rls_cache_key(datasource)` in the cache key dictionary. 
   
   Here is the minimal fix for `superset/datasource/api.py`:
   
   ```python
                           "col": column_name,
                           "limit": row_limit,
                           "denorm": denormalize_column,
                           "user": get_user_id(),
                           "rls": 
security_manager.get_rls_cache_key(datasource),
                           "changed_on": str(getattr(datasource, "changed_on", 
"")),
                       },
   ```
   
   This change ensures that the cache key is unique to the RLS context, 
preventing cross-session data leakage for guest users.
   
   **superset/datasource/api.py**
   ```
   "col": column_name,
                           "limit": row_limit,
                           "denorm": denormalize_column,
                           "user": get_user_id(),
                           "rls": 
security_manager.get_rls_cache_key(datasource),
                           "changed_on": str(getattr(datasource, "changed_on", 
"")),
                       },
   ```


-- 
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]

Reply via email to