LlamaIndex Retrievers Integration: DuckDBRetriever SQL Injection
The DuckDB retriever built SQL queries without prepared statements, allowing an attacker to inject arbitrary SQL. This could lead to remote code execution by installing the shellfs extension and running malicious commands.
run-llama/llama_index
Originally disclosed on huntr
A SQL injection vulnerability exists in the duckdb_retriever component of the run-llama/llama_index repository, specifically in llama-index-retrievers-duckdb-retriever prior to v0.4.0. The vulnerability arises from the construction of SQL queries without using prepared statements, allowing an attacker to inject arbitrary SQL code. This can lead to remote code execution (RCE) by installing the shellfs extension and executing malicious commands.
From the GitHub Advisory Database (GHSA-339r-cjv9-x78g, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the retriever concatenated user input directly into SQL strings instead of using parameterised queries.
Impact
An attacker could inject arbitrary SQL and potentially achieve remote code execution by installing the shellfs extension and executing malicious commands.
What the attacker needed
Access to the DuckDB retriever component
The fix
The issue was fixed in v0.4.0 by using prepared statements.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program builds a database query by gluing together text, a user can sneak in extra database commands. Here the DuckDB retriever did that, so an attacker could run their own SQL and even execute system commands.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.