CVE-2023-39662: llama-index vulnerable to arbitrary code execution
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-indexSearch 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
Read for this analysis:
- https://github.com/jerryjliu/llama_index/issues/7054
- https://github.com/advisories/GHSA-2xxc-73fv-36f7
- https://nvd.nist.gov/vuln/detail/CVE-2023-39662
- https://github.com/run-llama/llama_index/commit/9f3e50a803f519af9ab62e63d413441c43001d81
- https://github.com/run-llama/llama_index/commit/aa6726706476e0f957a8d57a5ca89e519e93bad7
- https://github.com/pypa/advisory-database/tree/main/vulns/llama-index/PYSEC-2023-148.yaml
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 entriesCVE-2025-6208
llama-index-core vulnerable to Uncontrolled Resource Consumption
medium5.3Feb 2, 2026CVE-2025-7707
llama-index has Insecure Temporary File
high7.1Oct 13, 2025CVE-2025-7647
llama-index-core insecurely handles temporary files
high7.3Sep 27, 2025CVE-2025-5302
LlamaIndex affected by a Denial of Service (DOS) in JSONReader
high8.6Aug 26, 2025CVE-2025-6211
LlamaIndex vulnerable to data loss through hash collisions in its DocugamiReader class
medium6.5Jul 10, 2025CVE-2025-3108
LlamaIndex has Incomplete Documentation of Program Execution related to JsonPickleSerializer component
medium5.0Jul 7, 2025
