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)
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')
- 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
- Update WeKnora to the latest release. 0.8.2 is the first fixed release.
- 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.
- 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.
- Prefix check that only looks at the first word: internal/agent/tools/data_analysis.go#L241
- Validator call with no rule against WITH clauses: internal/agent/tools/data_analysis.go#L258-L262
- WITH clause checked only when that option is on, and never looked inside: internal/utils/inject.go#L1352
- Table-name lookup returns nothing for a subquery in FROM: internal/utils/inject.go#L404-L407
- One shared in-memory DuckDB for all sessions: internal/container/container.go#L1605-L1606
Fix
- d7ccd5b, part of #3305 (merged 2026-09-16), makes
ValidateSQLwalk 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_analysistool toSELECTstatements (it no longer acceptsSHOW,DESCRIBE,EXPLAINorPRAGMA) 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
- Reported privately via GitHub PVR (GHSA-w597-p2cf-f35v), with a suggested fix.
- Maintainers merge #3305, which includes the fix (d7ccd5b).
- We confirm the fix at
mainon the advisory. - WeKnora 0.8.2 released with the fix.
- We ask the maintainer to publish the advisory and request a CVE.
- We ask again.
- We tell the maintainer this write-up will go public on 2026-11-25 and invite changes; no reply.
- Public write-up; CVE requested via MITRE CNA-LR.
Credit
Finder: Aaron Elijah Mars of Aeon. Tool: Aeon.
References
- Fix PR (merged 2026-09-16): Tencent/WeKnora#3305; fix commit d7ccd5b
- Fixed release: WeKnora 0.8.2
- GitHub advisory: GHSA-w597-p2cf-f35v (private; in triage)
- Affected repository: Tencent/WeKnora