Skip to content

Layer 2: check query text that isn't UTF-8 instead of skipping it - #98

Merged
samifouad merged 1 commit into
mainfrom
claude/l2-non-utf8-sql
Nov 11, 2026
Merged

samifouad merged 1 commit into
mainfrom
claude/l2-non-utf8-sql

Conversation

@samifouad

Copy link
Copy Markdown
Member

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::check read the SQL with Zval::str(), which returns nothing for text that isn't valid UTF-8, and on that path the query ran with no check. One \xff byte 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

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)
@samifouad
samifouad merged commit ddc23cb into main Nov 11, 2026
3 checks passed
@samifouad
samifouad deleted the claude/l2-non-utf8-sql branch November 11, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant