Conversation
Introduces strict validation for Row Level Security (RLS) clauses to prevent SQL injection. - Adds `validate_rls_clause` utility using `sqlglot` to parse and check for forbidden SQL constructs (subqueries, CTEs, mutations, etc.). - Updates `CreateRLSRuleCommand` and `UpdateRLSRuleCommand` to enforce this validation. - Addresses a potential boolean-based blind SQL injection vulnerability where subqueries could be used to exfiltrate data. Co-authored-by: sha174n <105581038+sha174n@users.noreply.github.com>
|
👋 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. |
- Fix MyPy error by annotating `forbidden_types` tuple with `type[exp.Expression]`. - Fix MyPy error in `CreateRLSRuleCommand` by ensuring `validate_rls_clause` receives a `str`. - Fix Unsorted imports in `superset/utils/rls.py`, `superset/commands/security/create.py`, and `superset/commands/security/update.py` to satisfy Ruff. - Remove unused `ValidationError` imports in commands. - Ensure RLS clause validation handles `exp.Delete`, `exp.Insert`, `exp.Update` which are not subclasses of `exp.Command` in sqlglot v29. Co-authored-by: sha174n <105581038+sha174n@users.noreply.github.com>
This PR adds a validation layer to Row Level Security (RLS) clauses to prevent SQL injection attacks, specifically targeting boolean-based blind SQL injection via subqueries.
Changes:
superset.utils.rls.validate_rls_clausefunction.sqlglotto parse the RLS clause and ensures it does not contain:Subquery,Select,Values,Union,CTE,DDL,Command,Delete,Insert,Update, andMutation.CreateRLSRuleCommandandUpdateRLSRuleCommandinsuperset/commands/security.marshmallow.ValidationErrorif the clause is invalid, which is handled by the API to return a 422 error.Tests:
PR created automatically by Jules for task 4104895394640590304 started by @sha174n