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

- Severity: Critical 9.7 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 26.0%, higher than 98% of CVEs (2026-12-01)
- Published: 2024-05-10T17:07:18.850Z
- Modified: 2026-11-16T15:30:04.589Z
- Also known as: GHSA-56xg-wfcc-g829, PYSEC-2026-392
- Weaknesses: CWE-76
- SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total
- Assigned by: GitHub_M

## 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.

(As written by CVE List.)

## Affected

- abetlen llama-cpp-python: >= 0.2.30, <= 0.2.71; from 0.2.30 up to 0.2.71
- llama-cpp-python (PyPI): from 0.2.30 before 0.2.72

## Every score

- GitHub_M: CVSS:3.1 9.7 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H`
- GitHub: CVSS:3.1 9.6 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H`
- PyPA Advisory Database: CVSS:3.1 9.6 Critical `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H`

## References

- <https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829> (web)
- <https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185df> (web)
- <https://nvd.nist.gov/vuln/detail/CVE-2024-34359> (advisory)
- <https://github.com/abetlen/llama-cpp-python> (package)
- <https://github.com/pypa/advisory-database/tree/main/vulns/llama-cpp-python/PYSEC-2026-392.yaml> (web)
- <https://pypi.org/project/llama-cpp-python> (package, web)
- <https://github.com/advisories/GHSA-56xg-wfcc-g829> (advisory)

## Sources

- CVE List: [CVE-2024-34359](https://www.cve.org/CVERecord?id=CVE-2024-34359), CVE Terms of Use, modified 2024-08-02
- GitHub Advisory Database: [GHSA-56xg-wfcc-g829](https://github.com/advisories/GHSA-56xg-wfcc-g829), CC-BY-4.0, modified 2026-11-16
- NVD: [CVE-2024-34359](https://nvd.nist.gov/vuln/detail/CVE-2024-34359), Public domain, modified 2026-06-17
- PyPA Advisory Database: [PYSEC-2026-392](https://osv.dev/vulnerability/PYSEC-2026-392), CC-BY-4.0, modified 2026-07-13

---

Page: https://cve.day/CVE-2024-34359 · Whole record: https://cve.day/CVE-2024-34359.json · Rebuilt by cve.day 2026-11-25T22:58:40.178Z
