[#4211] fix(catalog-jdbc): Harden database SQL generation against injection - #11780
[#4211] fix(catalog-jdbc): Harden database SQL generation against injection#11780JandyTenedora wants to merge 7 commits into
Conversation
00fb195 to
7f4edee
Compare
2e05a2e to
1a47603
Compare
07b4fba to
e4daa5d
Compare
|
@JandyTenedora |
…ck-quoted drop SQL Add validateBacktickQuotedIdentifier() in JdbcDatabaseOperations to reject database names containing SQL metacharacters before they are embedded in backtick-quoted DROP DATABASE statements. Applied to all JDBC catalog overrides that use backtick quoting (MySQL, OceanBase, Doris, StarRocks, ClickHouse).
cf84ad6 to
7d4709c
Compare
|
Hi @yuqi1129, yes it is. Was just waiting to be assigned the issue. Have updated with latest master now :) |
Code Coverage Report
Files
|
|
@JandyTenedora |
Hi @yuqi1129 thanks so much for the feedback! I did actually consider putting similar guards in for generateCreateDatabaseSql as well. I assumed the issue was scoped to generateDropDatabaseSql as per the description. Happy to fold this into this PR too? Or submit as follow ups once this lands? Let me know your preference |
…create path and fix comment escaping
I suggest you fix this problem thoroughly within a PR. |
|
Hi @yuqi1129 , I've added the guards for the create path. Apologies should have updated the comment. |


What changes were proposed in this pull request?
Add
validateBacktickQuotedIdentifier()inJdbcDatabaseOperationsto reject database names containing SQL metacharacters before they are embedded in backtick-quotedDROP DATABASEstatements. Applied to all JDBC catalog overrides that use backtick quoting (MySQL, OceanBase via parent, Doris, StarRocks, ClickHouse).Why are the changes needed?
generateDropDatabaseSqlbuilds SQL via string formatting with backtick quoting. A name containing backticks can break out of the identifier and inject arbitrary SQL. The upstreamSchemaNormalizeDispatchervalidates names today, but callingJdbcDatabaseOperations.delete()directly bypasses that validation.Fix: #4211
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added unit tests for drop-path validation in
TestJdbcDatabaseOperations,TestClickHouseDatabaseOperations,TestDorisDatabaseOperationsSqlGeneration, andTestStarRocksDatabaseOperationsSqlGeneration— covering valid names, null, empty, SQL injection strings, spaces, and overlength names.