Repository navigation
fix(security): accept only query-builder WHERE clauses - #3877
Conversation
Reject WHERE syntax the query builder never emits, including PostgreSQL escape strings, unicode strings, and dollar quotes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The change tightens SQL WHERE validation to match the query builder's output grammar. No actionable merge-blocking risk was identified in the supplied context. Pre-merge checks |
|
commit: |
🔗 Linked issue
No public issue. Reported as an unauthenticated SQL injection against
/__nuxt_content/:collection/queryvia a PostgreSQL escape-string mismatch inassertSafeQuery().❓ Type of change
📚 Description
assertSafeQuery()tried to allowlist WHERE clauses by stripping quotes and scanning what was left. That is not the same as the SQLcollectionQueryBuilderemits.singleQuote()only writes standard'…'literals, with''as the only escape. The builder then wraps quoted fields and a fixed operator list (=,IN,LIKE,BETWEEN,IS NULL, and theirNOTforms) inAND/ORgroups. It never emits PostgreSQLE'…'/e'…'escape strings,U&'…'unicode strings, or$tag$…$tag$dollar quotes.The WHERE check now parses that builder grammar and rejects anything else. Values the builder would actually quote, including backslashes and the characters
E', stay allowed. Bare numbers such as"id" = 1are rejected; the builder always quotes them as'1'.queryCollection()output is unchanged.📝 Checklist