CVE-2024-34359

Source
https://nvd.nist.gov/vuln/detail/CVE-2024-34359
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-34359.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2024-34359
Aliases
Published
2024-05-10T17:07:18.850Z
Modified
2025-11-20T12:26:36.334129Z
Severity
  • 9.6 (Critical) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H CVSS Calculator
Summary
llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata
Details

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.

Database specific
{
    "cwe_ids": [
        "CWE-76"
    ]
}
References

Affected packages

Git / github.com/abetlen/llama-cpp-python

Affected ranges

Type
GIT
Repo
https://github.com/abetlen/llama-cpp-python
Events

Affected versions

v0.*

v0.2.30
v0.2.31
v0.2.32
v0.2.33
v0.2.34
v0.2.35
v0.2.36
v0.2.37
v0.2.38
v0.2.39
v0.2.40
v0.2.41
v0.2.42
v0.2.43
v0.2.44
v0.2.45
v0.2.46
v0.2.47
v0.2.48
v0.2.49
v0.2.50
v0.2.51
v0.2.52
v0.2.53
v0.2.54
v0.2.55
v0.2.56
v0.2.57
v0.2.58
v0.2.59
v0.2.59-cu121
v0.2.59-cu122
v0.2.59-cu123
v0.2.59-metal
v0.2.60
v0.2.60-cu121
v0.2.60-cu122
v0.2.60-cu123
v0.2.60-metal
v0.2.61
v0.2.61-cu121
v0.2.61-cu122
v0.2.61-cu123
v0.2.61-metal
v0.2.62
v0.2.62-cu121
v0.2.62-cu122
v0.2.62-cu123
v0.2.62-metal
v0.2.63
v0.2.63-cu121
v0.2.63-cu122
v0.2.63-cu123
v0.2.63-metal
v0.2.64
v0.2.64-cu121
v0.2.64-cu122
v0.2.64-cu123
v0.2.64-metal
v0.2.65
v0.2.65-cu121
v0.2.65-cu122
v0.2.65-cu123
v0.2.65-metal
v0.2.66
v0.2.66-cu121
v0.2.66-cu122
v0.2.66-cu123
v0.2.66-cu124
v0.2.66-metal
v0.2.67
v0.2.67-cu121
v0.2.67-cu122
v0.2.67-cu123
v0.2.67-cu124
v0.2.67-metal
v0.2.68
v0.2.68-cu121
v0.2.68-cu122
v0.2.68-cu123
v0.2.68-cu124
v0.2.68-metal
v0.2.69
v0.2.69-cu121
v0.2.69-cu122
v0.2.69-cu123
v0.2.69-cu124
v0.2.69-metal
v0.2.70
v0.2.70-cu121
v0.2.70-cu122
v0.2.70-cu123
v0.2.70-cu124
v0.2.70-metal
v0.2.71
v0.2.71-cu121
v0.2.71-cu122
v0.2.71-cu123
v0.2.71-cu124
v0.2.71-metal