fix(security): prevent SQL injection in Postgres schema prequery - #4
google-labs-jules[bot] wants to merge 6 commits into
Conversation
Secures the `get_prequeries` method in `PostgresEngineSpec` by using `database.quote_identifier` to sanitize the schema name in the `SET search_path` statement. This prevents attackers from injecting arbitrary SQL via the schema parameter in SQL Lab. Includes regression test in `tests/unit_tests/db_engine_specs/test_postgres.py`.
|
👋 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. |
Secures the `get_prequeries` method in `PostgresEngineSpec` by using `database.quote_identifier` to sanitize the schema name in the `SET search_path` statement. This prevents attackers from injecting arbitrary SQL via the schema parameter in SQL Lab. Includes regression test in `tests/unit_tests/db_engine_specs/test_postgres.py`.
Secures the `get_prequeries` method in `PostgresEngineSpec` by using `database.quote_identifier` to sanitize the schema name in the `SET search_path` statement. This prevents attackers from injecting arbitrary SQL via the schema parameter in SQL Lab. Includes regression test in `tests/unit_tests/db_engine_specs/test_postgres.py`.
Secures the `get_prequeries` method in `PostgresEngineSpec` by using `database.quote_identifier` to sanitize the schema name in the `SET search_path` statement. This prevents attackers from injecting arbitrary SQL via the schema parameter in SQL Lab. Includes regression test in `tests/unit_tests/db_engine_specs/test_postgres.py`.
Secures the `get_prequeries` method in Postgres, IBM Db2, Databricks, and StarRocks engine specs. Uses `database.quote_identifier` to sanitize user-controlled parameters (schema, catalog, username) in pre-session queries, preventing SQL injection. Includes regression tests for all affected engines.
Secures the `get_prequeries` method in Postgres, IBM Db2, Databricks, and StarRocks engine specs. Uses `database.quote_identifier` to sanitize user-controlled parameters (schema, catalog, username) in pre-session queries, preventing SQL injection. Includes: - Regression tests for all affected engines. - A new meta-test (`test_security_regression.py`) that scans all engine specs to prevent future regressions.
This PR fixes a reported SQL injection vulnerability where the
schemaparameter in SQL Lab execution was directly interpolated into aSET search_pathquery for Postgres databases.Changes:
superset/db_engine_specs/postgres.pyto usedatabase.quote_identifier(schema)instead of raw string interpolation.test_get_prequeries_injectionintests/unit_tests/db_engine_specs/test_postgres.pyto verify that malicious payloads are correctly escaped.tests/unit_tests/db_engine_specs/test_postgres.pyto mockquote_identifier.PR created automatically by Jules for task 4026538467311462713 started by @sha174n