You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][security] SyncPreview USE ${targetDatabase} uses raw string concat — targetDatabase not escaped via escapeId #372
Schema Compare & Sync generates USE database before applying the sync statements.
Problem
src/components/compare/SyncPreview.tsx:74 uses raw USE ${targetDatabase} interpolation — no escapeId call. Database names cannot legally contain backticks in MySQL, but the helper-name pattern matches userPrivileges.ts:62-64 (admin F16) and RoutineViewer (routine F1/F5). The escapeId helper at sync-sql-generator.ts:5-7 exists and is used in CREATE/DROP/ALTER statements in the same file — SyncPreview just doesn't use it. Refactor-prone: a future change that allows unusual names, or a database alias layer, would silently create SQLi.
Files
src/components/compare/SyncPreview.tsx:74
Repro (test-only)
Construct a SyncPreview with targetDatabase = "weird`name". The rendered SQL is USE weird\name` — invalid.
Expected
USE \weird``name`` and runs without error.
Proposed fix
Replace the raw interpolation with escapeId(targetDatabase) from sync-sql-generator.ts. Or extract to src/lib/sql-quote.ts exporting quoteDbName, quoteIdentifier, quoteLiteral and call at every IPC boundary (RoutineViewer F1/F5, Admin F16 all share this pattern). Scope: S.
Acceptance
A test with targetDatabase = "weird`name" produces USE \weird``name`` and runs without error.
Schema compare could not back the claim it made — foreign keys were absent from the snapshot entirely, DDL was compared after lowercasing and collapsing whitespace, and column order was ignored — while the sync half could leave a target half-migrated. A compare tool that is quietly wrong is worse than none, because people act on its answer.
Fixing that properly is a real piece of work, most of it a genuine DDL comparison rather than string normalisation, and the feature is not part of how this project is used. Removed rather than carried: the history has it if someone wants it back.
Removed in the PR closing this issue: SchemaCompare, SyncPreview, schema-diff, sync-sql-generator, their tests, the compare editor tab type, and the menu, title-bar and toolbar entry points.
Activity
EVWorth commentedon Sep 9, 2026
Closed by removing the feature.
Schema compare could not back the claim it made — foreign keys were absent from the snapshot entirely, DDL was compared after lowercasing and collapsing whitespace, and column order was ignored — while the sync half could leave a target half-migrated. A compare tool that is quietly wrong is worse than none, because people act on its answer.
Fixing that properly is a real piece of work, most of it a genuine DDL comparison rather than string normalisation, and the feature is not part of how this project is used. Removed rather than carried: the history has it if someone wants it back.
Removed in the PR closing this issue: SchemaCompare, SyncPreview, schema-diff, sync-sql-generator, their tests, the
compareeditor tab type, and the menu, title-bar and toolbar entry points.feat: remove schema compare (#577)