NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · LlamaIndex

CVE-2023-39662: llama-index vulnerable to arbitrary code execution

criticalCVSS 4.0 9.3 · 3.1 9.8GHSA-2xxc-73fv-36f7

llama-index before 0.9.14 lets a remote attacker run code through PandasQueryEngine, which executes Python the LLM writes from the user's question. A jailbreak-style prompt makes the model emit os.system calls. Upgrade llama-index to 0.9.14, and keep the engine away from untrusted input.

Published Aug 15, 2023 · Updated Sep 30, 2024 · Analysis Nov 2, 2026

What an attacker can do

PandasQueryEngine turns a question about a dataframe into Python generated by the LLM and runs it with exec. The reporter in issue 7054 used a jailbreak-style prompt to get the model to produce __import__('os').system(...), which created a file on the host. A first, direct attempt failed, and the jailbreak worked.

An attacker needs only to send a prompt to an application that exposes the engine, with no account if the app is public. The CVSS vector (AV:N, AC:L, PR:N, UI:N) scores 9.8. Success gives command execution as the application's user, with its keys, files and network access.

The maintainer said the implementation probably should not be used to handle arbitrary user input. The issue closed as completed by pull request 8890 on November 20, 2023, which, per the thread, restricted execution to a limited set of builtins and allowed imports. The reporter then showed a bypass using __class__.__mro__ and __subclasses__() to reach os through __globals__. The thread does not confirm that a block on magic methods shipped.

Who is affected

The pip package llama-index before 0.9.14. The CVE text names v0.7.13 and earlier. Applications that pass untrusted user text to PandasQueryEngine are the exposed ones. Check:

pip show llama-index

Search your code for PandasQueryEngine.

llama-index

Ecosystem
PyPI
Affected
< 0.9.14
Fixed in
0.9.14
Check
pip show llama-index

How to fix it

Upgrade llama-index to 0.9.14 or later:

pip install --upgrade "llama-index>=0.9.14"

The thread describes a restricted exec, but also a reported bypass, so the sources do not show the engine to be safe for arbitrary input. The maintainer's own advice is not to feed it arbitrary user input. If you must use it with untrusted users, run it in an isolated container with no secrets and no network.

How to tell if you were hit

Search logs of user questions and generated pandas code for __import__, os.system, subprocess, __subclasses__, __globals__ and __mro__. Look for files created in the working directory by the service, unexpected child processes, and outbound connections it should not make.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

An issue in llama_index v.0.7.13 and before allows a remote attacker to execute arbitrary code via the exec parameter in PandasQueryEngine function.

Credited to KaliforniaShell.

Questions

Which class is affected?

PandasQueryEngine, which runs LLM-generated Python with exec, per issue 7054.

Does 0.9.14 make it safe for public users?

The maintainer said it probably should not handle arbitrary user input, and a bypass of the restricted exec was reported in the thread. Isolate it.

Which version fixes CVE-2023-39662?

llama-index 0.9.14 is the patched version in the advisory data.

Is it exploited in the wild?

The sources do not say so, and the entry has no CISA catalog data.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More LlamaIndex vulnerabilities

All LlamaIndex entries