altimate-code
altimate-code copied to clipboard
data_diff: where_clause grammar validation
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-cstor 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.
Consolidated into #1680, which tracks this together with related issues. The original report here stays linked from that tracker.