CVE-2024-3271: llama-index-core Command Injection vulnerability
llama-index-core before 0.10.24 ships a `safe_eval` function whose guard against LLM-generated code can be bypassed. The guard only looks for underscores, so crafted input without one still runs OS commands. Apps that evaluate model output can suffer remote code execution. Fixed in 0.10.24.
Published Apr 16, 2024 · Updated Nov 16, 2026 · Analysis Nov 10, 2026
What an attacker can do
safe_eval is meant to run expressions produced by an LLM, for example in query engines that turn a question into Python code. Its defence is a check for underscore characters in the generated code, which blocks tricks like __import__. A payload that avoids underscores but still reaches an OS command passes the check.
The attacker does not need an account. They need a way to influence what the model writes, usually through the question or through content the model reads. The CVSS 3.0 vector is AV:N, PR:N, UI:N with high impact on confidentiality, integrity and availability (CWE-77). A successful run executes code with the application's privileges: files, environment variables and API keys are all reachable.
This is the prompt-to-code path common in LLM apps. The exposure is limited to apps that call the vulnerable safe_eval on model output.
Who is affected
pip package llama-index-core before 0.10.24. Check:
pip show llama-index-coreIt matters if your app uses a component that evaluates LLM-generated code through safe_eval. The sources do not list which query engines do.
llama-index-core
- Ecosystem
- PyPI
- Affected
- < 0.10.24
- Fixed in
- 0.10.24
- Check
pip show llama-index-core
How to fix it
Upgrade to llama-index-core 0.10.24.
pip install --upgrade "llama-index-core>=0.10.24"Commit 5fbcb5a hardens exec_utils.py: it removes getattr, hasattr, setattr, iter and next from the allowed builtins, and the checker now flags any name not in the allowed list, not just names starting with an underscore. The advisory names no workaround. As a precaution, do not run code-generating engines on untrusted input unless the process is sandboxed with no secrets in its environment.
How to tell if you were hit
Review application logs for model-generated code that contains os, subprocess, eval or exec calls. Watch for unexpected child processes spawned by the Python process running LlamaIndex, and for outbound connections it does not normally make. Check which of your engines pass LLM output to safe_eval. Beam records agent shell commands and file access when an AI agent runs on the same machine.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
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.
Questions
- Is llama-index-core 0.10.24 safe?
It is the patched release listed in the advisory. Versions below it are affected.
- Does the attacker need access to the server?
No. The vector is network-based with no privileges and no user interaction. The attacker must influence the code the model generates.
- What is wrong with the underscore check?
It tries to block dangerous names by rejecting underscores, but code can reach OS commands without any underscore.
References
Read for this analysis:
- https://github.com/run-llama/llama_index/commit/5fbcb5a8b9f20f81b791c7fc8849e352613ab475
- https://github.com/advisories/GHSA-r6gp-rff2-p3hf
- https://nvd.nist.gov/vuln/detail/CVE-2024-3271
- https://huntr.com/bounties/9b32490e-7cf9-470e-8d49-ba083ae7a279
- https://github.com/run-llama/llama_index/commit/2c92e88838a5f481d50840240b1dd3180066c6f5
- https://github.com/pypa/advisory-database/tree/main/vulns/llama-index-core/PYSEC-2026-396.yaml
- https://pypi.org/project/llama-index-core
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
