LlamaIndex DuckDBVectorStore vulnerable to SQL injection through ref_doc_id
The delete function in DuckDBVectorStore did not properly sanitise the ref_doc_id parameter, allowing SQL injection. An attacker could use this to read and write arbitrary files on the server, potentially leading to remote code execution.
run-llama/llama_index
Originally disclosed on huntr
An SQL injection vulnerability exists in the delete function of DuckDBVectorStore in run-llama/llama_index version v0.12.19. This vulnerability allows an attacker to manipulate the ref_doc_id parameter, enabling them to read and write arbitrary files on the server, potentially leading to remote code execution (RCE).
From the GitHub Advisory Database (GHSA-6mcc-q3mg-3qg6, 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 ref_doc_id parameter was concatenated directly into a SQL query without parameterisation or sanitisation.
Impact
An attacker could read and write arbitrary files on the server, potentially leading to remote code execution.
What the attacker needed
Access to the delete function; control over ref_doc_id
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.
SQL injection is when user input is inserted into a database command without being checked, so an attacker can change the command. Here, the delete function took a document ID and put it directly into a database query, letting an attacker run their own database commands. That could let them read or write files on the server, which might lead to running malicious code.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.