SecurityContext

CVE-2024-34359: llama-cpp-python - Server Side Template Injection

  • Cve: CVE-2024-34359
  • Name: llama-cpp-python - Server Side Template Injection
  • 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.
  • Impact: Attackers can execute arbitrary code remotely by crafting malicious .gguf files, leading to full system compromise.
  • Remediation: Use sandboxed jinja2.Environment or sanitize templates before rendering; update llama-cpp-python to latest version with mitigations.
  • Vulnerability type: template_injection
  • Vulnerability impact: remote_code_execution
  • Requirement type: none
  • Labels source: projectdiscovery
  • Severity: critical
  • Cvss score: 9.6
  • Cvss vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
  • Epss score: 0.26001
  • Epss percentile: 0.9803
  • Assignee: [email protected]
  • Published at: 2024-05-14T15:38:45Z
  • Age in days: 923
  • Modified at: 2026-06-17T07:33:14Z
  • References total: 2
  • Products total: 1
  • Oss: yes
  • Projects total: 1
  • Advisory url: https://nvd.nist.gov/vuln/detail/CVE-2024-34359
  • Nvd status: deferred
  • Checked, none or zero: patch available, known exploited entries, nuclei templates, public exploits total, public exploits capped, public exploits, rejected by nvd
  • Not known: requirements, hackerone

Cwe

IdName
CWE-76Improper Neutralization of Equivalent Special Elements

References

UrlSourceTags
https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185dfnvd
https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829nvd

Products

ProductAffectedPlatform boundSourcesUrl
abetlen:llama-cpp-python>= 0.2.30, <= 0.2.71noadp_cpes/v1/products/abetlen/llama-cpp-python

Projects

RepositoryLink kindsIndexedUrl
abetlen/llama-cpp-pythoncommit, package, security_advisoryyes/v1/repositories/abetlen/llama-cpp-python

Index

  • Repositories: 23
  • Repositories high signal: 14
  • Packages: 1

Exploitation

  • Remote: yes
  • Checked, none or zero: known exploited, known exploited by, exploitation seen, public exploit, public exploit count, initial access, authentication required
  • Not known: known exploited since, vulncheck known exploited since, public exploit first date, nuclei template, initial access since, hackerone reports, exposed hosts