{"id":"CVE-2024-34359","published":"2024-05-10T17:07:18Z","modified":"2024-08-02T02:51:10Z","title":"llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata","vendor":"abetlen","product":"llama-cpp-python","tier":"tail","description":{"text":"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.","provenance":"source","from":"CVE.org"},"cvss":{"score":9.7,"severity":"CRITICAL","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.26001,"percentile":0.98029,"provenance":"source"},"cwes":[{"id":"CWE-76","name":"Improper Neutralization of Equivalent Special Elements"}],"references":[{"url":"https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185df","tags":["x_refsource_MISC"]}],"priority":{"score":26.4,"factors":[{"name":"EPSS percentile","points":19.61},{"name":"CVSS severity","points":6.79}]},"vendorSlug":"abetlen","affectedVersions":[{"vendor":"abetlen","product":"llama-cpp-python","versions":[">= 0.2.30, <= 0.2.71"]}],"ssvc":{"exploitation":"poc","automatable":"no","technicalImpact":"total","timestamp":"2024-05-15T19:35:24.408358Z","from":"CISA ADP","provenance":"source"},"affected":[{"ecosystem":"PyPI","package":"llama-cpp-python","vulnerableRanges":[">=0.2.30, <0.2.72"],"patched":["0.2.72"],"from":["GHSA-56xg-wfcc-g829","PYSEC-2026-392"],"provenance":"source"}],"summary":{"text":"The llama-cpp-python Python bindings for llama.cpp, specifically the Llama class constructor in llama.py, load the chat template from a model's .gguf metadata and render it through an unsandboxed jinja2.Environment in the Jinja2ChatFormatter, so the template is treated as trusted code. An attacker who can supply a crafted .gguf model file can achieve remote code execution through server-side template injection, with the attack vector listed as network-reachable, low complexity, and requiring user interaction and no privileges.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T06:30:45Z"},"euvd":{"id":"EUVD-2024-1433","exploited":false,"provenance":"source"}}