Skip to content

[P1] [security] Copy as INSERT uses hardcoded your_table placeholder — broken SQL #409

Closed

Description

@EVWorth

[P1] [security] "Copy as INSERT" generates SQL with hardcoded your_table placeholder

Context

The grid's row context menu has "Copy as INSERT" which copies INSERT INTO your_table (cols) VALUES (vals); to the clipboard.

Problem

Per docs/audits/results.md F16.

The user pastes the SQL into the editor and runs it → MySQL rejects with "Table 'sqlpilot.your_table' doesn't exist". If the user has a table literally named your_table, it silently succeeds. The export pipeline (exportResults in tauri-api.ts:104-106) already takes a tableName param but the grid's context-menu builder doesn't pass it.

Files

  • src/components/grid/ResultsGrid.tsx:191-194

Repro (if applicable)

Static analysis only.

Expected

Right-click row from SELECT * FROM users → copies INSERT INTO \users` (cols) VALUES (vals);`. For CTE/subquery where table can't be extracted → menu item is greyed out.

Proposed fix

Scope S. Run extractTableName from getCurrentSql() at menu-open time; pass the resolved table into the menu builder. If extraction fails, render the menu item as disabled.

Acceptance

Right-click → copies with detected table; no-op when table can't be detected.

Needs human verify

No (pure logic test)

Labels: audit, area/results, severity/p1, kind/security

Activity

  1. added
    audit
    severity/p1
    kind/security
    area/results
    on Jul 31, 2026
  2. added 3 commits that reference this issue on Sep 4, 2026
    36f0cc4
    c63d06a
    c02fb08
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/resultsauditkind/securityseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions