{"id":"CVE-2024-34359","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.","aliases":["GHSA-56xg-wfcc-g829","PYSEC-2026-392"],"modified":"2026-08-12T03:51:11.089507882Z","published":"2024-05-10T17:07:18.850Z","database_specific":{"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/34xxx/CVE-2024-34359.json","cna_assigner":"GitHub_M","cwe_ids":["CWE-76"]},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/34xxx/CVE-2024-34359.json"},{"type":"ADVISORY","url":"https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-34359"},{"type":"FIX","url":"https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185df"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://github.com/abetlen/llama-cpp-python","events":[{"introduced":"656f3d896845d428f994dd205b28d8f524cbff67"},{"fixed":"b454f40a9a1787b2b5659cd2cb00819d983185df"}],"database_specific":{"extracted_events":[{"introduced":"0.2.30"},{"last_affected":"0.2.71"}],"source":["AFFECTED_FIELD","REFERENCES"]}}],"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"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H"}]}