llama-index-core Command Injection vulnerability
The safe_eval function in llama-index-core tried to block dangerous code by rejecting underscores, but an attacker could supply code without underscores that still ran operating system commands. This allowed remote code execution on the server running the application.
run-llama/llama_index
Originally disclosed on huntr
A command injection vulnerability exists in the run-llama/llama_index repository, specifically within the safe_eval function. Attackers can bypass the intended security mechanism, which checks for the presence of underscores in code generated by LLM, to execute arbitrary code. This is achieved by crafting input that does not contain an underscore but still results in the execution of OS commands. The vulnerability allows for remote code execution (RCE) on the server hosting the application.
From the GitHub Advisory Database (GHSA-r6gp-rff2-p3hf, 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 security control relied on a denylist of a single character (underscore) rather than safely evaluating or sandboxing the code, so alternative syntax could achieve the same dangerous operations.
Impact
An attacker could execute arbitrary operating system commands on the server hosting the application, leading to remote code execution.
What the attacker needed
Ability to supply code evaluated by safe_eval
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.
A program used a simple check to stop harmful code: it refused to run anything containing an underscore character. An attacker found a way to write harmful instructions that did not use an underscore, so the check passed and the server ran their commands. This is called remote code execution, meaning someone else can make the server do things it should not.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.