Repository navigation
Fix SQL injection in connector sample path and validate source queries - #688
Open
vishwasvaidya-cloudsufi wants to merge 2 commits into
Open
vishwasvaidya-cloudsufi wants to merge 2 commits into
vishwasvaidya-cloudsufi wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces SQL identifier quoting to prevent SQL injection vulnerabilities across various database connectors, and adds query validation using jsqlparser to ensure that import and bounding queries are read-only SELECT statements. Feedback on these changes highlights several potential NullPointerException risks when database or schema parameters are null during identifier quoting, as well as a recommendation to use Locale.ROOT with toLowerCase() to avoid locale-sensitive string comparison issues.
vishwasvaidya-cloudsufi
force-pushed
the
sql-identifier-escaping
branch
2 times, most recently
from
November 2, 2026 05:10
54ea798 to
890fafd
Compare
vishwasvaidya-cloudsufi
force-pushed
the
sql-identifier-escaping
branch
from
November 2, 2026 08:14
890fafd to
8e7560e
Compare
vishwasvaidya-cloudsufi
force-pushed
the
sql-identifier-escaping
branch
from
November 10, 2026 12:15
a32509a to
6fef409
Compare
harishhk107
approved these changes
Nov 11, 2026
vishwasvaidya-cloudsufi
force-pushed
the
sql-identifier-escaping
branch
from
November 13, 2026 05:52
6fef409 to
7614b6c
Compare
vikasrathee-cs
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's this about
A VRP report found a SQL injection in the Cloud SQL PostgreSQL connector's sample path. A table path containing a
"could break out of the quoted name and run extra statements, like anUPDATE, using the connection's saved credential. The same unescaped pattern existed in every connector.What changed
Connectors: table names and the strata column are now properly escaped, so a quote inside a
name can't break out anymore. This is the fix for the reported vulnerability.
Source plugins (Import Query / Bounding Query): these run user-written SQL under the
connection's credential, so they're now validated to be a single read-only
SELECTbeforereaching the database. The check is lexical-primary (aware of strings, comments and quoted
identifiers), with JSqlParser as a secondary check, so it:
INTO, andFOR UPDATE/SHARE(including insidesubqueries);
$$…$$/$tag$…$tag$, Oracleq'…', MySQL/*! … */executable comments);TABLESAMPLE,FOR READ ONLY,LOCKING …, doubled backticks, MySQL\'and#comments).Use the Database action plugins for
SET,EXEC,UPDATEand anything that isn't a plainSELECT.Split-By is now validated as a single column name (it's concatenated into generated SQL at
runtime).
Init queries:
SET LANGUAGE/SET SESSION sql_modenow escape the interpolated value.SQL Server
[bracket]names keep working.Design note (please read before "fixing" it)
The validator is a security gate, not a SQL linter. A malformed-but-harmless query (e.g.
select;) is intentionally allowed through to fail at the database. Valid-but-exotic stringliterals (
$$…$$,q'…',/*! … */) are rejected as a deliberate trade-off against the lexer-mismatch bypasses.Heads up (behavior change)
Existing pipelines whose Import or Bounding Query isn't a single
SELECT(multiple statements,SET …; SELECT,EXEC/CALL,FOR UPDATE) will fail and need to move that logic to an action. A small set of valid-but-exotic literals (dollar quotes, Oracleq'…', MySQL/*!*/hints) are also rejected — worth a release note.Testing
Unit tests for escaping in every connector (including the exact payload from the report), extensive validator tests (bypass attempts and valid dialect SQL), and end-to-end pipeline tests (HSQLDB) confirming bad import/bounding/split-by queries are blocked and no data is changed. The per-plugin e2e "invalid bounding query" scenarios were switched to a stacked write and assert the validation error. All CI suites, including the live-database e2e, pass.