Skip to content

fix(security): apply RLS to UPDATE/DELETE statements in SQL Lab - #5

Draft
google-labs-jules[bot] wants to merge 1 commit into
masterfrom
fix-rls-bypass-sqllab-update-13879926642217173526
Draft

google-labs-jules[bot] wants to merge 1 commit into
masterfrom
fix-rls-bypass-sqllab-update-13879926642217173526

Conversation

@google-labs-jules

Copy link
Copy Markdown

Fixes a high-severity security vulnerability where RLS was not applied to UPDATE and DELETE statements in SQL Lab.

The fix involves:

  1. Extending extract_tables_from_statement to manually extract the target table from UPDATE and DELETE statements, as sqlglot's scope traversal logic doesn't consider them "sources" in the typical sense. This ensures that Superset knows which table is being targeted.
  2. Updating RLSAsPredicateTransformer to handle exp.Update and exp.Delete nodes. It now injects the RLS predicate into the WHERE clause of the mutation statement, ensuring that only rows matching the RLS policy can be modified or deleted. Existing WHERE clauses are preserved and combined with the RLS predicate using AND.

Verified with a reproduction script (integration test) and new unit tests.


PR created automatically by Jules for task 13879926642217173526 started by @sha174n

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.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants