Security

WeKnora: SQL check bypass in data_analysis reads server files

WeKnora data_analysis agent tool - SQL validator bypass via a WITH clause inside a subquery allows reading local files (GHSA-w597-p2cf-f35v)

PUBLISHED SEVERITY HIGHSTATUS PatchedGHSA-w597-p2cf-f35v
Patched

Fixed in WeKnora 0.8.2 (2026-09-24) by #3305, which makes the SQL validator inspect every part of the query, rejects WITH clauses anywhere in it, and allows only SELECT statements in the data_analysis tool. Track the fix at Tencent/WeKnora#3305.

Product
WeKnora (data_analysis agent tool) in Tencent/WeKnora
Affected versions
WeKnora before 0.8.2. Fixed in 0.8.2 (2026-09-24).
Severity
HIGH
Status
Patched
Weaknesses
  • CWE-22Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
  • CWE-89Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
As filed on the advisory.
GitHub advisory
GHSA-w597-p2cf-f35v
Private; in triage, not yet published by the maintainer
CVE
Pending (requested via MITRE CNA-LR)
Published
Credit
Finder: Aaron Elijah Mars of Aeon. Tool: Aeon (https://www.aeon.fun).

What users should do now

  1. Update WeKnora to the latest release. 0.8.2 is the first fixed release.
  2. If you ran an older version that other people could sign in to, treat secrets readable by the app process (environment files, config, keys on disk) as exposed and rotate them.
  3. Until you update, turn off the data_analysis tool or stop attaching CSV and Excel files to agents, and do not run the app with secrets in files it can read.

Summary

When a chat has a CSV or Excel file attached, WeKnora offers the agent a data_analysis tool that loads the file into DuckDB and runs SQL the model writes. Before running it, the tool checks that the query starts with select and passes it through utils.ValidateSQL with an allowed-table list, a single-statement rule and a block list of dangerous functions. Two gaps in that validator added up to a full bypass. It did not look inside WITH clauses (common table expressions), and when the main FROM was a subquery it found no table names at all, so the allowed-table check passed by default. A WITH clause placed inside a subquery was never inspected, and DuckDB ran it as written.

Affected versions

WeKnora before 0.8.2, in any deployment where the data_analysis tool is offered. It is offered whenever the attached knowledge is a CSV or Excel file; it is not an opt-in feature.

Impact

  • Server file reads. DuckDB has built-in functions that read files from disk. Inside the unchecked part of the query they could read any file the WeKnora process can read, such as environment files and keys, and the result came straight back in the chat.
  • Other sessions' data. One DuckDB in-memory database is shared by every tenant's analysis sessions, so the same gap could read another active session's table if its name was known or guessed.
  • Low bar. Any signed-in user of any tenant could do this with no admin rights. Text inside an uploaded spreadsheet that steers the agent (indirect prompt injection) could also trigger it without the user meaning to.

The report rated this High. It was found by reading the code; it was not run against a live instance. A working exploit is withheld.

Affected code

Permalinks at 2bc1261, the last commit on main before the fix.

Fix

  • d7ccd5b, part of #3305 (merged 2026-09-16), makes ValidateSQL walk every node of the parsed query. It rejects a WITH clause, a set operation or a function in FROM anywhere in the query, checks every function call against the block list, and collects table names from subqueries too, so the allowed-table check sees them.
  • The same change limits the data_analysis tool to SELECT statements (it no longer accepts SHOW, DESCRIBE, EXPLAIN or PRAGMA) and adds the select-only rule to its validator call.
  • Released in 0.8.2 (2026-09-24). Checked again at main (1ab3977) on 2026-11-25: the full-query walk and the select-only rule are still in place.

Timeline

  1. Reported privately via GitHub PVR (GHSA-w597-p2cf-f35v), with a suggested fix.
  2. Maintainers merge #3305, which includes the fix (d7ccd5b).
  3. We confirm the fix at main on the advisory.
  4. WeKnora 0.8.2 released with the fix.
  5. We ask the maintainer to publish the advisory and request a CVE.
  6. We ask again.
  7. We tell the maintainer this write-up will go public on 2026-11-25 and invite changes; no reply.
  8. Public write-up; CVE requested via MITRE CNA-LR.

Credit

Finder: Aaron Elijah Mars of Aeon. Tool: Aeon.

References