Skip to content

CVE-2024-34359 llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata

CriticalCVSS 9.7 EPSS 26.0%
Published
Updated
Exploit status
No public exploit known
CISA SSVC
Proof of concept public · automatable: no · technical impact: total

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.

Upgrade path

2 packages: 2 fixed.

PackageAffectedFixed inStatus
abetlen llama-cpp-python = >= 0.2.30, <= 0.2.71; >= 0.2.30, <= 0.2.71 after 0.2.71 Fixed
pypi llama-cpp-python(PyPI) = 0.2.30; = 0.2.31; = 0.2.32; = 0.2.33 +40 more 0.2.72 Fixed

Affected products

ProductAffected versionsFixed in
pypi llama-cpp-python(PyPI) >= 0.2.30, < 0.2.72 0.2.72
pypi llama-cpp-python(PyPI) = 0.2.30 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.31 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.32 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.33 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.34 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.35 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.36 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.37 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.38 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.39 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.40 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.41 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.42 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.43 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.44 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.45 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.46 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.47 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.48 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.49 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.50 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.51 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.52 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.53 No fix listed
Show 21 more
ProductAffected versionsFixed in
pypi llama-cpp-python(PyPI) = 0.2.54 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.55 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.56 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.57 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.58 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.59 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.60 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.61 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.62 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.63 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.64 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.65 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.66 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.67 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.68 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.69 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.70 No fix listed
pypi llama-cpp-python(PyPI) = 0.2.71 No fix listed
abetlen llama-cpp-python = >= 0.2.30, <= 0.2.71 No fix listed
abetlen llama-cpp-python >= 0.2.30, <= 0.2.71 No fix listed
pypi llama-cpp-python(PyPI) >= 0.2.30, <= 0.2.71 No fix listed

References