---
title: "CVE-2024-34359: llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata"
url: https://erroneo.us/security/cve/CVE-2024-34359/
description: "CVE-2024-34359 (llama-cpp-python (PyPI)): llama-cpp-python is the Python bindings for llama.cpp. llama-cpp-python depends on class Llama in llama.py to load…"
type: vulnerability-record
section: "Security Digest"
date_published: 2024-05-10
date_modified: 2024-08-02
publisher: erroneo.us
author: erroneo.us Security Desk
cve: "CVE-2024-34359"
kev: false
cvss: 9.7
epss: 0.26001
license: All rights reserved. Quote with attribution and a link.
---

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

**Signal:** High exploit likelihood. EPSS ranks it in the top 5% of all CVEs for likely exploitation in the next 30 days. (Computed from CISA KEV, EPSS and CVSS; not an editorial verdict.)

## Should you act?

- Not in CISA KEV , but CISA’s SSVC assessment records a public proof-of-concept, so attack code exists.
- EPSS 26.0% , percentile 98: FIRST’s model estimates a 26.0% chance of exploitation activity in the next 30 days, higher than 98% of all scored CVEs (very high). EPSS is a probability, not a verdict.
- Needs a user to click or open something. Phishing makes that realistic, but it is not wormable.
- Only applies if your dependency tree includes llama-cpp-python (PyPI) >= 0.2.30, <= 0.2.71, fixed in 0.2.72 . Check your lockfile, including transitive dependencies.

## What it is

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 llamachatformat.Jinja2ChatFormatter.tochathandler() to construct the self.chathandler 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.

## Affected packages

- PyPI `llama-cpp-python` >= 0.2.30, <= 0.2.71 → fixed: 0.2.72

## Affected products (CVE record)

- abetlen llama-cpp-python: >= 0.2.30, <= 0.2.71

## Severity

- GitHub_M CVSS 3.1: 9.7 `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 `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H`

## Exploitation

- CISA KEV: not listed (no confirmed in-the-wild exploitation known to CISA).
- CISA SSVC assessment: exploitation poc , automatable no , technical impact total .
- FIRST EPSS (model of 2026-10-21): 26.00% probability of exploitation activity in the next 30 days; percentile 98.

## Sources

- [GitHub Advisory GHSA-56xg-wfcc-g829](https://github.com/advisories/GHSA-56xg-wfcc-g829)
- [CVE.org record CVE-2024-34359](https://www.cve.org/CVERecord?id=CVE-2024-34359)
- [NVD entry CVE-2024-34359](https://nvd.nist.gov/vuln/detail/CVE-2024-34359)
- [github.com](https://github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829)
- [github.com](https://github.com/abetlen/llama-cpp-python/commit/b454f40a9a1787b2b5659cd2cb00819d983185df)

---
Source page: https://erroneo.us/security/cve/CVE-2024-34359/ · Security Digest: https://erroneo.us/security/ · More: https://erroneo.us/llms.txt
