altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

data_diff: where_clause grammar validation

Open anandgupta42 opened this issue 7 months ago • 1 comments

Flagged during v0.5.22 release review (Security / Chaos Gremlin persona).

where_clause is passed verbatim into generated SQL at native/connections/data-diff.ts:484 (WHERE ${whereClause}) and :696 ((${params.where_clause}) AND (${partWhere})). It is LLM-supplied, gated by sql_execute_read permission, but not parsed.

Short-term mitigation shipped in 0.5.22:

  • Permission prompt now surfaces the where_clause value (informed consent)
  • Tool description explicitly warns it is interpolated verbatim and must not accept untrusted input

Proper fix (this issue):

  • Parse the clause with a SQL parser (sql-parser-cst or similar) and reject DDL/multi-statement/UNION
  • Or whitelist to a safe grammar (comparison ops on column names + literals)
  • Keep verbatim mode available behind a config flag for power users

Deferred because: parser integration is meaningful design work; short-term mitigations hold the line.

anandgupta42 avatar Apr 17 '26 14:04 anandgupta42

Consolidated into #1680, which tracks this together with related issues. The original report here stays linked from that tracker.

anandgupta42 avatar Nov 05 '26 21:11 anandgupta42