CVE-2024-34359
Description
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.
Weakness
- CWE-76: Improper Neutralization of Equivalent Special Elements
CISA SSVC decision points
| Exploitation | poc |
|---|---|
| Automatable | no |
| Technical impact | total |
| Scored | 2024-05-15 |
Timeline
- 2024-05-10Published by the CNA17:07 UTC
- 2024-05-13GitHub advisory published (GHSA-56xg-wfcc-g829)3 days after publication
- 2024-05-15CISA SSVC decision recorded5 days after publication
Exploit and advisory records
GitHub advisory GHSA-56xg-wfcc-g829, affected packages:
| Package | Vulnerable versions | Fixed in |
|---|---|---|
| PyPI llama-cpp-python | from 0.2.30 before 0.2.72 | 0.2.72 |
Affected products
Products listed as vulnerable. Upgrade to the version under "Fixed in", or a later one.
| Product | Vulnerable versions | Fixed in |
|---|---|---|
| abetlen llama-cpp-python |
References
- https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185df
- https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829
Get more CVE data from the API.
curl 'https://api.contrastcyber.com/cve_lookup/CVE-2024-34359'curl 'https://api.contrastcyber.com/cve_risk_score/CVE-2024-34359'curl 'https://api.contrastcyber.com/cve_exploit/CVE-2024-34359'curl 'https://api.contrastcyber.com/cve_products/CVE-2024-34359'
Sources
- Vulnerability data from the National Vulnerability Database (NIST) and the CVE Program. CVE records: Copyright © 1999-2026, The MITRE Corporation, used under the CVE Program Terms of Use. CVE® is a registered trademark of The MITRE Corporation.
- CWE definitions: Copyright © 2006-2026, The MITRE Corporation, used under the CWE Terms of Use. CWE is a trademark of The MITRE Corporation.
- OWASP Top 10 categories by the OWASP Foundation (CC BY 3.0).
- EPSS scores by FIRST.org EPSS, used with attribution.
- KEV catalog and SSVC decisions by CISA.
- Advisory data from the GitHub Advisory Database through OSV.dev (CC BY 4.0).
- Exploit metadata from the Exploit Database (GPL-2.0-only, metadata only).
- Nuclei template names from nuclei-templates (MIT).