Parent
Part of #463
Severity
High
Problem
injectSqlLimit / clamp path uses regex _limitCount.firstMatch + replaceFirst on raw SQL. A LIMIT n sequence inside a string literal (e.g. WHERE note = 'Use LIMIT 999999 rows') is treated as a real clause and rewritten. Query still parses but filters return wrong rows with no error.
Evidence
lib/core/database/sql_limit.dart (~55–65)
- Bugbot review
dev vs main (2026-07-27)
Acceptance
Suggested fix
SQL-aware scan (skip quoted spans) before applying limit regex; or only rewrite the last statement’s trailing LIMIT outside quotes.
Parent
Part of #463
Severity
High
Problem
injectSqlLimit/ clamp path uses regex_limitCount.firstMatch+replaceFirston raw SQL. ALIMIT nsequence inside a string literal (e.g.WHERE note = 'Use LIMIT 999999 rows') is treated as a real clause and rewritten. Query still parses but filters return wrong rows with no error.Evidence
lib/core/database/sql_limit.dart(~55–65)devvsmain(2026-07-27)Acceptance
LIMITinside single-quoted (and preferably dollar-quoted) literals is not clamped/replacedLIMIT/FETCHstill clampedSuggested fix
SQL-aware scan (skip quoted spans) before applying limit regex; or only rewrite the last statement’s trailing LIMIT outside quotes.