Repository navigation
Layer 2: check query text that isn't UTF-8 instead of skipping it - #98
Merged
Merged
Conversation
The database handler read the SQL argument as UTF-8 and ran the query unchecked when it wasn't, so one invalid byte anywhere in a query (a comment is enough) skipped layer 2 for every route. Read it with the invalid bytes replaced: such a byte is never ASCII, so the statement's structure reads as the server reads it. (cherry picked from commit 3aa4b88)
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.
This is the layer 2 commit from #97 (3aa4b88), split out so the hole closes now rather than waiting for the layer 3 gateway's review.
The hole:
db::checkread the SQL withZval::str(), which returns nothing for text that isn't valid UTF-8, and on that path the query ran with no check. One\xffbyte anywhere, even inside a comment, skipped layer 2's database rules on every route for any plugin. Demonstrated on main's build in #97:SELECT user_login, user_pass FROM wp_users /* \xff */went through. Shipped canaries are affected.Fix: layer 2 reads the text with invalid bytes replaced, so the statement is still parsed and checked.
Evidence: #97's test runs, with a revert proof; see #97's body. CI runs here too.
-claude