Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. llama-cpp-python
  4. ›
  5. CVE-2024-34359

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

May 13, 2024

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 RCE by a carefully constructed payload.

References

  • github.com/abetlen/llama-cpp-python
  • github.com/abetlen/llama-cpp-python/security/advisories/GHSA-56xg-wfcc-g829
  • github.com/advisories/GHSA-56xg-wfcc-g829
  • nvd.nist.gov/vuln/detail/CVE-2024-34359

Code Behaviors & Features

Detect and mitigate CVE-2024-34359 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions starting from 0.2.30 up to 0.2.71

Solution

Unfortunately, there is no solution available yet.

Impact 9.6 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-76: Improper Neutralization of Equivalent Special Elements

Source file

pypi/llama-cpp-python/CVE-2024-34359.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Fri, 30 Oct 2026 12:15:58 +0000.