Skip to content

[P0][security] CSV import uses string interpolation (escapeValue); no parameterized inserts #364

Closed

Description

@EVWorth

Context

CSV import path. Per docs/audits/import.md F2.

Problem

src/lib/sql-import.ts:32-49 generateBatchInsert builds INSERT by concatenating escapeValue(value). Current escaping correct but surface for bugs wide: any future change to escapeValue that drops a transformation is direct SQL injection. Architecture should use parameterized queries via mysql_async exec_drop/exec_batch with bound params.

Files

  • src/lib/sql-import.ts:11-30 (escapeValue)
  • src/lib/sql-import.ts:32-49 (generateBatchInsert)
  • src/components/import/ImportDialog.tsx:300-330 (CSV -> INSERT call)

Repro

  1. Generate malicious CSV cell: "x'); DROP TABLE users; --"
  2. Round-trip through generateBatchInsert
  3. Observe SQL contains literal containing '; DROP TABLE — single quote escapes correctly today, but escape table completeness is the security boundary

Expected

generateBatchInsert produces SQL with ? placeholders; values bound via mysql_async exec_batch.

Proposed fix

M: add execute_query_with_params(connection_id, sql, params: Vec) in Tauri command; route through mysql_async::Queryable::exec_drop(&mut conn, sql).bind(params). Refactor generateBatchInsert to return (sql_template_with_placeholders, values_per_row) tuples.

Acceptance

Malicious CSV cell round-trips through generateBatchInsert and produces SQL with single ? placeholder; integration test imports malicious CSV and asserts users table still present.

Needs human verify

yes

Activity

  1. added
    audit
    severity/p0
    kind/security
    area/import
    on Jul 31, 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

    area/importauditkind/securityseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions