Skip to content
CriticalVulnerabilityLLM-specific

CVE-2024-34359: llama-cpp-python remote code execution via chat template in GGUF metadata

Identifier
CVE-2024-34359
Published
Record updated
View JSON
Affected
  • llama-cpp-python >= 0.2.30, <= 0.2.71
Fixed in
0.2.72
  • released May 10, 2024, 4 days before disclosure
Known exploitation
Not listed in the CISA Known Exploited Vulnerabilities catalog at the last check.
EPSS
26.0%

Summary

llama-cpp-python, the Python bindings for llama.cpp, is affected by CVE-2024-34359. The Llama constructor in llama.py loads the chat template from a .gguf model's metadata and passes it to Jinja2ChatFormatter, which parses it with a non-sandboxed jinja2.Environment and renders it in __call__. A carefully constructed template payload therefore enables server-side template injection and remote code execution.

Mitigation

The source does not state a fix yet. Check the original advisory for updates.