Skip to content

fix: SQLite schema reads interpolate table names #929

Closed

Description

@EVWorth

In src-tauri/crates/mas-sqlite/src/schema.rs:

  1. Unescaped table names. get_columns builds PRAGMA table_info("{}"), and the row count in get_tables builds SELECT COUNT(*) FROM "{}". Both put the table name inside double quotes without doubling any " in it. A table whose name contains " breaks the read, and a crafted name in an opened database file can inject SQL into those statements. Use pragma_table_info(?1) with a bound parameter, and quote identifiers properly (double every ") for the count.
  2. Index columns from DDL text. get_indexes finds index columns by parsing the CREATE INDEX text and splitting on commas. Expression indexes and columns with COLLATE or DESC come out wrong. Use pragma_index_xinfo(?1) instead.

Add tests with a table and an index whose names contain " and ;, an expression index, and a DESC column. sqlite_get_foreign_keys (#927) already binds the name and can serve as the pattern.

Activity

  1. added
    bug
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions