Skip to content

[P1][doc-drift] Parameterized queries are promised in DESIGN_REQUIREMENTS but execute_query does not accept params #285

Closed

Description

@EVWorth

Context

TESTING_STRATEGY §4 lists test_execute_with_params and §3 explicitly says parameterized queries prevent SQL injection.

Problem

execute_query(connection_id, sql) accepts only two arguments. Frontend wraps it as api.executeQuery(connId, sql) with no parameter array. Any user-supplied value must be interpolated into the SQL string by the frontend. This contradicts the test plan.

Files

  • src-tauri/src/commands/mod.rs:157-181
  • src/lib/tauri-api.ts (executeQuery wrapper)
  • src/types/index.ts (no params type)

Repro

Static analysis only. Repro requires a feature that uses params.

Expected

execute_query accepts an optional params: Vec<Value> (or similar), frontends pass values as ? placeholders, sqlx binds them. A test demonstrates that SELECT ? with user input cannot be injected.

Proposed fix

Scope M. Add params to command signature; switch to sqlx::query_with(sql, params).fetch_many(). Update tauri-api.ts and TS types. Land test_execute_with_params from TESTING_STRATEGY §4.

Acceptance

Test passes; SQL injection via params is impossible by construction.

Needs human verify

Yes (param path itself is testable; full surface needs real usage).

Activity

  1. added
    audit
    severity/p1
    kind/security
    kind/doc-drift
    area/editor
    on Jul 24, 2026
  2. EVWorth commented on Sep 11, 2026

    @EVWorth
    OwnerAuthor

    Worth recording what checking this premise turned up, since the issue is closed as a design rejection.

    The reasoning for rejecting: execute_query runs the user's own text, so the whole statement is the input and there is no application value to bind. Where values are the app's they are bound already, in Rust. Where the app composes SQL for a human to read — a backup file, a generated INSERT — placeholders are not available at all.

    But those escaping paths used \\' for a quote, which is not an escape under NO_BACKSLASH_ESCAPES. The backslash is literal and the quote ends the string. Verified against MySQL 8.0.46: a row value of x', 1); DROP TABLE victim; -- in a SQLPilot backup, restored on a server in that mode, dropped the table.

    Fixed in #650 by doubling the quote, which is correct whether backslash escaping is on or off. Nine assertions across seven files — several of them the tests specifically about injection safety — had been written against the old form.

    So the instinct behind this issue was right even though the proposed fix was not the one that was needed.

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

    area/editorauditkind/doc-driftkind/securityseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions