fix(mysql): escape SQL identifiers and literals in metadata/DDL paths (#1914) - #2172
Merged
Conversation
Contributor
Author
|
Converting to draft: final adversarial review pass is still in progress for this branch. Will mark ready for review once it completes. (process note: PR was opened prematurely by automation) |
HandSonic
marked this pull request as ready for review
July 26, 2026 10:28
This was referenced Jul 26, 2026
Merged
…processor (OtterMind#1914) - MysqlDmlValueTemplate.wrapHex: require hex digits for the 0x template, matching wrapBit's requireBitLiteral - MysqlBinaryProcessor/MysqlVarBinaryProcessor: only pass values through raw when they are well-formed 0x hex literals (isHexLiteral), closing the 0x-prefixed injection passthrough in generated DML - MysqlIdentifierProcessor.quoteIdentifier: double embedded backticks via MysqlSqlEscapes.quoteIdentifierRaw instead of wrapping verbatim - add regression tests for all three paths
…tainer review (OtterMind#1914) - MysqlIdentifierProcessor (SPI ISQLIdentifierProcessor): INSTANCE, always-quote backtick quoteIdentifier with one-pair strip + doubling, escapeString with backslash-first-then-quote doubling, static escapeIdentifier for quoted templates - MysqlMetaData call sites use getSQLIdentifierProcessor(); builders/managers/enums/ value processors use MysqlIdentifierProcessor.INSTANCE - non-escapable validation moved to MysqlSqlGuards (engine/charset/collation names, numeric defaults, bit/hex literals, definers, asc/desc, enum constants, enum/set lists) - MysqlSqlEscapes removed; tests migrated to MysqlIdentifierProcessorTest (630 green)
openai0229
force-pushed
the
fix/sqli-mysql
branch
from
July 29, 2026 03:35
ef95811 to
107a909
Compare
openai0229
approved these changes
Jul 29, 2026
openai0229
left a comment
Contributor
There was a problem hiding this comment.
Rebased onto #2234 and verified the final MySQL implementation. Identifier round trips, DEFINER handling, ENUM/SET literals, fallback type rendering, export titles, DROP VIEW, and generated DDL behavior are covered. Local clean reactor result: 653 tests, 0 failures or errors.
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.
Related issue
Part of the SQL-injection hardening tracked in #1914. This PR covers the MySQL plugin and now builds on the shared forced-quote SPI merged in #2234.
Summary
ISQLIdentifierProcessor.quoteIdentifierAlwaysfor MySQL DDL and metadata identifier positions, including embedded-backtick escaping and raw-value round trips.'can''t'are not escaped twice; malformed lists are rejected.NO_BACKSLASH_ESCAPESsessions.DROP VIEWgeneration while preserving calls that omit the database name.Table.partitionandModifyView.viewBodyremain intentional raw SQL surfaces and are not reinterpreted by this identifier/literal hardening PR.Affected surfaces
Verification
mvn -B -f chat2db-community-server/pom.xml -pl chat2db-community-plugins/chat2db-community-mysql -am -Dmaven.test.skip=false -DskipTests=false clean testBUILD SUCCESS; tests run: 653, failures: 0, errors: 0, skipped: 0.Risk and compatibility
Reviewer map
MysqlIdentifierProcessor,MysqlSqlGuards, andMysqlIdentifierProcessorTest.Contributor declaration
AI assistance: The fix, review, verification, and PR description were produced with AI coding assistance.