Repository navigation
Conversation
…is in A quote escaped as `\'` is not an escape under `NO_BACKSLASH_ESCAPES` — the backslash is literal and the quote ends the string. Everything after it is SQL. Found while checking #285's claim about parameterized queries. Verified against MySQL 8.0.46: a row value of `x', 1); DROP TABLE victim; -- ` in a SQLPilot backup, restored on a server in that mode, dropped the table. The exposures are not equal and it is worth being precise about which is which. The backup path is the serious one, because it crosses a trust boundary: the attacker is whoever can write a row, and the victim is whoever restores the dump. It is mitigated today — the dump's header sets SQL_MODE, which clears NO_BACKSLASH_ESCAPES — but that mitigation is load-bearing and unstated, and it is lost the moment one INSERT is copied out of the file or a restore path drops comments. The escaping should not depend on it. `quoteStringLiteral`, which builds the admin panel's user and role statements, has the same shape against a live session whose mode cannot be set. It is a correctness bug rather than an escalation — the values are typed by someone who already has the editor — but a user name containing a quote broke the statement, and on an ANSI server it broke out of it. Doubling is correct whether backslash escaping is on or off, so the quote is no longer a way out in either. Verified both ways on a live server: the hostile value round-trips as data, and a user named `ok'user` is created, granted and dropped under `NO_BACKSLASH_ESCAPES`. The backslash escaping beside it stays mode-dependent and stays as it was: in the default mode a password of `pa\ss` written literally is stored as `pass`, which is the bug that escaping exists for. Under `NO_BACKSLASH_ESCAPES` it over-escapes — a fidelity bug in a rare configuration, not a way out. Getting both right needs the session's mode, which means asking the server. Nine assertions across seven test files were written against the old form — several of them the tests specifically about injection safety — and now assert the new one. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Sep 11, 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.
Stacked on #646.
A quote escaped as
\'is not an escape underNO_BACKSLASH_ESCAPES— the backslash is literal and the quote ends the string. Everything after it is SQL.Found while checking #285's claim about parameterized queries. Verified against MySQL 8.0.46: a row value of
x', 1); DROP TABLE victim; --in a SQLPilot backup, restored on a server in that mode, dropped the table.The two exposures are not equal
The backup path is the serious one, because it crosses a trust boundary: the attacker is whoever can write a row, the victim is whoever restores the dump.
It is mitigated today — the dump's header sets
SQL_MODE, which clearsNO_BACKSLASH_ESCAPES. But that mitigation is load-bearing and unstated, and it's lost the moment one INSERT is copied out of the file, or a restore path drops comments. The escaping shouldn't depend on it.quoteStringLiteral— which builds the admin panel's user and role statements — has the same shape against a live session whose mode can't be set. That's a correctness bug rather than an escalation: the values are typed by someone who already has the editor. But a user name containing a quote broke the statement, and on an ANSI server it broke out of it.The fix
Doubling is correct whether backslash escaping is on or off, so the quote is no longer a way out in either. Verified both ways on a live server: the hostile value round-trips as data, and a user named
ok'useris created, granted and dropped underNO_BACKSLASH_ESCAPES.The backslash escaping beside it stays mode-dependent and stays as it was: in the default mode a password of
pa\sswritten literally is stored aspass, which is the bug that escaping exists for. UnderNO_BACKSLASH_ESCAPESit over-escapes — a fidelity bug in a rare configuration, not a way out. Getting both right needs the session's mode, which means asking the server; worth doing if anyone hits it.Tests
Nine assertions across seven files were written against the old form — several of them the tests specifically about injection safety — and now assert the new one. Two new tests cover the hostile payloads directly.
2629 unit + 341 browser tests.
🤖 Generated with Claude Code