Repository navigation
fix(jdbc): quote savepoint name before interpolating into sql - #1487
Merged
Merged
Conversation
gotson
reviewed
Oct 26, 2026
gotson
approved these changes
Oct 27, 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.
Unquoted savepoint name in SAVEPOINT/RELEASE/ROLLBACK statements
JDBC3Connectionbuilds the savepoint statements withString.format("SAVEPOINT %s", ...)and hands the result straight toDB.exec, so the name supplied toConnection.setSavepoint(String)lands in an identifier position of the generated SQL with no quoting. I came across this while tracing where application supplied strings reachexec: unlike the metadata queries that were hardened earlier, the four savepoint sites interpolate the name verbatim. Any name that is not a bare SQLite token therefore corrupts the statement. A name such asa bora"bthrows at prepare time (SQLITE_ERROR ... unrecognized token/syntax error), and becausegetSavepointName()keeps the original string, the laterRELEASE/ROLLBACK TOfor the same savepoint is mis-generated as well.The root cause is the missing identifier quoting, not the caller.
DB.execprepares a single statement, so a trailing; ...is discarded rather than executed, which keeps this short of stacked-query execution, but the name still breaks out of the identifier it was meant to be and quietly changes which statement SQLite compiles. It is the same class of unescaped user input in SQL that the metadata getters carried, and it is addressed the same way, by quoting the value where it is used. The patch wraps the name as a double quoted SQLite identifier (doubling any embedded double quote) at all four build sites, so a name is always treated as one identifier and round-trips cleanly through rollback and release. The generatedSQLITE_SAVEPOINT_<id>form is unaffected, since quoting an already-valid identifier is a no-op in SQLite. Left unfixed, callers that derive savepoint names from external input hit spurious failures and unpredictable transaction control. The addedSavepointTestcase fails on the current tree and passes with the fix.