Conversation
This fix addresses a security vulnerability where tables referenced in raw 'VALUES' clauses were not being detected by 'extract_tables_from_statement', allowing RLS bypass. The fix manually traverses 'exp.Values' nodes and extracts tables, filtering out CTEs using 'cte.alias' to prevent false positives. 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. |
…overage This change corrects the logic for extracting CTE names in `superset/sql/parse.py` by using `cte.alias` instead of iterating over the CTE object itself. It also adds a comprehensive test case `test_extract_tables_values_clause` to `tests/unit_tests/sql/parse_tests.py` that verifies: 1. Detection of tables in raw `VALUES` clauses (the original vulnerability). 2. Proper exclusion of CTEs defined in `WITH` clauses when referenced in `VALUES` clauses (wrapped in `SELECT` for parser compatibility). 3. Handling of mixed expressions in `VALUES`. This ensures robust prevention of RLS bypass via `VALUES` clauses while avoiding false positives from CTEs. Co-authored-by: sha174n <105581038+sha174n@users.noreply.github.com>
This commit fixes a vulnerability where tables referenced inside `VALUES` clauses (e.g., `VALUES ((SELECT * FROM sensitive_table))`) were not detected by the SQL parser. This could allow users to bypass Row Level Security (RLS) policies. The fix involves manually traversing `exp.Values` nodes in `extract_tables_from_statement` since `sqlglot`'s `traverse_scope` does not visit them in all contexts. We also filter out CTEs to prevent false positives. A regression test `test_extract_tables_values_clause` has been added to `tests/unit_tests/sql/parse_tests.py`. Co-authored-by: sha174n <105581038+sha174n@users.noreply.github.com>
This commit fixes a vulnerability where tables referenced inside `VALUES` clauses (e.g., `VALUES ((SELECT * FROM sensitive_table))`) were not detected by the SQL parser. This could allow users to bypass Row Level Security (RLS) policies. The fix involves manually traversing `exp.Values` nodes in `extract_tables_from_statement` since `sqlglot`'s `traverse_scope` does not visit them in all contexts. We also filter out CTEs to prevent false positives. A regression test `test_extract_tables_values_clause` has been added to `tests/unit_tests/sql/parse_tests.py`. This commit also ensures that no new files without license headers are introduced, as previous unneeded script files were deleted. Co-authored-by: sha174n <105581038+sha174n@users.noreply.github.com>
This commit fixes a vulnerability where tables referenced inside `VALUES` clauses (e.g., `VALUES ((SELECT * FROM sensitive_table))`) were not detected by the SQL parser. This could allow users to bypass Row Level Security (RLS) policies. The fix involves manually traversing `exp.Values` nodes in `extract_tables_from_statement` since `sqlglot`'s `traverse_scope` does not visit them in all contexts. We also filter out CTEs to prevent false positives. A regression test `test_extract_tables_values_clause` has been added to `tests/unit_tests/sql/parse_tests.py`. This version also fixes linting (line length) and formatting issues identified by CI. Co-authored-by: sha174n <105581038+sha174n@users.noreply.github.com>
This fix addresses a security vulnerability where tables referenced in raw 'VALUES' clauses were not being detected by 'extract_tables_from_statement', allowing RLS bypass. The fix manually traverses 'exp.Values' nodes and extracts tables, filtering out CTEs using 'cte.alias' to prevent false positives.
PR created automatically by Jules for task 10463745502226431995 started by @sha174n