llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata
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.
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2024-34359
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 6 Nov 2026, 00:58 UTC · Revision 1
Source evidence
llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata
core-osv · Original sourcePublished 10 May 2024, 17:07 UTC
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.
osv:CVE-2024-34359
Complete source record
{
"id": "3f626f90977426e71c48d81fececba99985fea6d7566caaae7385b2b3a90c4f6",
"url": "https://osv.dev/vulnerability/CVE-2024-34359",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata",
"summary": "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.",
"evidence": "osv:CVE-2024-34359",
"products": [],
"severity": "critical",
"structured": {
"id": "CVE-2024-34359",
"aliases": [
"CVE-2024-34359",
"GHSA-56xg-wfcc-g829",
"PYSEC-2026-392"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/abetlen/llama-cpp-python",
"type": "GIT",
"events": [
{
"introduced": "656f3d896845d428f994dd205b28d8f524cbff67"
},
{
"fixed": "b454f40a9a1787b2b5659cd2cb00819d983185df"
}
],
"database_specific": {
"extracted_events": [
{
"range": [
{
"introduced": "0.2.30"
},
{
"last_affected": "0.2.71"
}
],
"source": "AFFECTED_FIELD",
"strategy": "StringRangeExpression"
},
{
"range": [
{
"fixed": "b454f40a9a1787b2b5659cd2cb00819d983185df"
}
],
"source": "REFERENCES_COMMIT"
}
]
}
}
],
"versions": [
"v0.2.71-metal",
"v0.2.71-cu124",
"v0.2.71-cu123",
"v0.2.71-cu122",
"v0.2.71-cu121",
"v0.2.71",
"v0.2.70-metal",
"v0.2.70-cu124",
"v0.2.70-cu123",
"v0.2.70-cu122",
"v0.2.70-cu121",
"v0.2.70",
"v0.2.69-metal",
"v0.2.69-cu124",
"v0.2.69-cu123",
"v0.2.69-cu122",
"v0.2.69-cu121",
"v0.2.69",
"v0.2.68-metal",
"v0.2.68-cu124",
"v0.2.68-cu123",
"v0.2.68-cu122",
"v0.2.68-cu121",
"v0.2.68",
"v0.2.67-metal",
"v0.2.67-cu124",
"v0.2.67-cu123",
"v0.2.67-cu122",
"v0.2.67-cu121",
"v0.2.67",
"v0.2.66-metal",
"v0.2.66-cu124",
"v0.2.66-cu123",
"v0.2.66-cu122",
"v0.2.66-cu121",
"v0.2.66",
"v0.2.65-metal",
"v0.2.65-cu123",
"v0.2.65-cu122",
"v0.2.65-cu121",
"v0.2.65",
"v0.2.64-metal",
"v0.2.64-cu123",
"v0.2.64-cu122",
"v0.2.64-cu121",
"v0.2.64",
"v0.2.62-metal",
"v0.2.62-cu123",
"v0.2.62-cu122",
"v0.2.62-cu121",
"v0.2.62",
"v0.2.61-metal",
"v0.2.61-cu123",
"v0.2.61-cu122",
"v0.2.61-cu121",
"v0.2.61",
"v0.2.60-metal",
"v0.2.60-cu123",
"v0.2.60-cu122",
"v0.2.60-cu121",
"v0.2.60",
"v0.2.59-metal",
"v0.2.59-cu123",
"v0.2.59-cu122",
"v0.2.59-cu121",
"v0.2.59",
"v0.2.58",
"v0.2.57",
"v0.2.56",
"v0.2.55",
"v0.2.54",
"v0.2.53",
"v0.2.52",
"v0.2.51",
"v0.2.50",
"v0.2.49",
"v0.2.48",
"v0.2.47",
"v0.2.46",
"v0.2.45",
"v0.2.44",
"v0.2.43",
"v0.2.42",
"v0.2.41",
"v0.2.40",
"v0.2.39",
"v0.2.38",
"v0.2.37",
"v0.2.36",
"v0.2.35",
"v0.2.34",
"v0.2.33",
"v0.2.32",
"v0.2.31",
"v0.2.30"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-34359.json"
}
}
],
"modified": "2026-10-28T02:30:45.596087141Z",
"provider": "osv",
"references": [
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/34xxx/CVE-2024-34359.json",
"https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829",
"https://nvd.nist.gov/vuln/detail/CVE-2024-34359",
"https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185df"
],
"provider_metadata": {
"cwe_ids": [
"CWE-76"
],
"cna_assigner": "GitHub_M",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/34xxx/CVE-2024-34359.json"
}
},
"related_cves": [
{
"value": "CVE-2024-34359",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 513668,
"published_at": "2024-05-10T17:07:18.85+00:00"
}