CVE-2024-34359
llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata
CVE-2024-34359 affects Abetlen Llama-cpp-python (CVSS 9.6, Critical).
No known exploitation. EPSS puts it in the 72nd percentile. Fixed in 0.2.72.
No public exploit knownFix0.2.72Upgrade to this build
No ready-made check. Neither Nuclei nor OpenVAS has one for this CVE yet.
What to do
Find your product and version, then upgrade to the build on the right.
- Abetlen Llama-cpp-pythonAffected: >= 0.2.30, <= 0.2.71Upgrade to: not statedStated by: CVE record
- PyPI llama-cpp-pythonAffected: ≥ 0.2.30, < 0.2.72Upgrade to: 0.2.72Stated by: GitHub advisory
Versions as the sources state them. Full version matrix after sign-in
Steps
Written by AI from the record- Check if your application uses the llama-cpp-python Python package to load AI model files (ask your developer or check requirements.txt/dependency lists).
- Identify the installed version — any version before 0.2.72 is vulnerable.
- Upgrade to llama-cpp-python 0.2.72 or later.
- Only load model files (.gguf) from sources you fully trust until the upgrade is done — treat untrusted model downloads like untrusted executable files.
- After upgrading, confirm your application still loads and runs models correctly, since template handling changed.
pip install --upgrade llama-cpp-python>=0.2.72What it is
From the CVE record
llama-cpp-python is the Python bindings for llama.cpp. `llama-cpp-python` depends on class `Llama` in `llama.py` to load `.gguf` llama.cpp or Latency Machine Learning Models. The `__init__` constructor built in the `Llama` takes several parameters to configure the loading and running of the model. Other than `NUMA, LoRa settings`, `loading tokenizers,` and `hardware settings`, `__init__` also loads the `chat template` from targeted `.gguf` 's Metadata and furtherly parses it to `llama_chat_format.Jinja2ChatFormatter.to_chat_handler()` to construct the `self.chat_handler` for this model. Nevertheless, `Jinja2ChatFormatter` parse the `chat template` within the Metadate with sandbox-less `jinja2.Environment`, which is furthermore rendered in `__call__` to construct the `prompt` of interaction. This allows `jinja2` Server Side Template Injection which leads to remote code execution by a carefully constructed payload.
In plain language
Written by AI from the recordIf your business uses apps built with llama-cpp-python to run AI models, a malicious model file could let an attacker run their own code on your server, but you need to act on it — this is not currently being exploited in the wild, but a fix exists (0.2.72) and should be applied soon.
llama-cpp-python's Llama class loads chat-template Jinja2 code embedded in GGUF model metadata and renders it with an unsandboxed jinja2.Environment, allowing Server-Side Template Injection that achieves remote code execution when a malicious model file is loaded.
If you're affected
- Full server takeover
- Data theft from AI application
- Malware/ransomware deployment
- Operational disruption
Exploitation
Where each signal puts this CVE on the scale from published to confirmed exploited.
- CISA KEV
Not in the catalog. CISA has not confirmed exploitation.
- Public exploits
No public exploit or proof of concept found in the sources we track.
- EPSS
1.3% chance of exploitation activity in the next 30 days, which ranks it in the 72nd percentile of scored CVEs.
Exploit Prediction Scoring System, FIRST.org. A probability, not a confirmation.
Lifecycle
9 events over 929 days, from the signal feeds we watch.
- EPSS band changemoderate → 0epss band change
- EPSS band changehigh → moderate
- EPSS band changemoderate → high
- EPSS band changehigh → moderate
- Patch availablerecord updated
- Publishedweakness classified
Affected products
Technical detail
CVSS 3.1 vector
Open in the CVSS calculatorCVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
Scored 9.6 by NVD.
How it is reached
- Attack Vector NetworkExploitable remotely over the network without any special conditions
- Attack Complexity LowNo special conditions — the attack can be reliably reproduced
- Privileges Required NoneNo authentication required — anyone can exploit this
- User Interaction RequiredA user must click a link, open a file, or perform some action
Scope
- Scope ChangedThe exploit can affect other components (e.g. sandbox escape, host compromise from VM)
Impact if exploited
- Confidentiality HighTotal information disclosure — all data in the component is compromised
- Integrity HighTotal loss of integrity — attacker can modify any data in the component
- Availability HighTotal denial of service — the component is completely unavailable
Weaknesses
Sources
Questions about CVE-2024-34359
- Is CVE-2024-34359 being exploited?
- No exploitation is confirmed and no public exploit is known. EPSS puts the chance of exploitation in the next 30 days at 1.3%.
- Which versions are affected by CVE-2024-34359?
- Llama-cpp-python: >= 0.2.30, <= 0.2.71. Llama-cpp-python: ≥ 0.2.30, < 0.2.72.
- How do I fix or mitigate CVE-2024-34359?
- Upgrade to 0.2.72 or later. The advisory is on github.com.
Last updated
Related articles
All articlesWatch the software you run.
My Stack ranks new CVEs for your products by real-world exploitation, so the next serious one reaches you without reading every advisory.
We'll flag the next CVE, public exploit or patch for Llama-cpp-python, not every advisory.
A free account adds
- The full version matrix and every affected product
- Exploit links, proofs of concept and Metasploit modules
- Email alerts for the products you watch
- The same data over REST API, MCP and CLI