fix(security): apply RLS to UPDATE/DELETE statements in SQL Lab - #5
google-labs-jules[bot] wants to merge 1 commit into
Conversation
This patch addresses a security vulnerability where Row Level Security (RLS) policies were bypassed for UPDATE and DELETE statements in SQL Lab. Changes: - Modified `superset/sql/parse.py` to ensure `extract_tables_from_statement` correctly identifies target tables in UPDATE and DELETE statements (which are skipped by `sqlglot`'s `traverse_scope`). - Updated `RLSAsPredicateTransformer` in `superset/sql/parse.py` to inject RLS predicates into UPDATE and DELETE statements by appending them to the WHERE clause. - Added unit tests in `tests/unit_tests/sql/parse_tests.py` to verify the fix. Note: RLS in SQL Lab requires the `RLS_IN_SQLLAB` feature flag to be enabled. This fix ensures that when enabled, it correctly protects data modifications.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Fixes a high-severity security vulnerability where RLS was not applied to UPDATE and DELETE statements in SQL Lab.
The fix involves:
extract_tables_from_statementto manually extract the target table fromUPDATEandDELETEstatements, assqlglot's scope traversal logic doesn't consider them "sources" in the typical sense. This ensures that Superset knows which table is being targeted.RLSAsPredicateTransformerto handleexp.Updateandexp.Deletenodes. It now injects the RLS predicate into theWHEREclause of the mutation statement, ensuring that only rows matching the RLS policy can be modified or deleted. ExistingWHEREclauses are preserved and combined with the RLS predicate usingAND.Verified with a reproduction script (integration test) and new unit tests.
PR created automatically by Jules for task 13879926642217173526 started by @sha174n