CVE-2024-34359CWE-76

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

Critical · published May 10, 2024

CVSS v3.1
9.7
EPSS
26%
Percentile
98.0
In the wild
Unconfirmed
What it is

🚨 A sneaky server-side template injection flaw in `llama-cpp-python` means attackers can execute remote code without breaking a sweat! 🔥 Think of this like a restaurant kitchen where the chef takes special orders from customers without verifying the recipe — a dangerous mix-up could lead to unexpected dishes, or worse! This vulnerability allows an attacker to serve up their own code instead of the intended chat templates. An attacker could craft a malicious payload, leading to remote code execution within your application. This could result in complete control over the system, allowing unauthorized access to sensitive data, manipulation of settings, or even total system compromise — absolutely devastating!

Put simply

Think of this like a restaurant kitchen where the chef takes special orders from customers without verifying the recipe — a dangerous mix-up could lead to unexpected dishes, or worse! This vulnerability allows an attacker to serve up their own code instead of the intended chat templates. This vulnerability arises because the `Jinja2ChatFormatter` uses a sandbox-less `jinja2.Environment` to parse and execute chat templates from `.gguf` metadata, making it easy for attackers to inject harmful code into the prompt interaction process.

What to do

An attacker could craft a malicious payload, leading to remote code execution within your application. This could result in complete control over the system, allowing unauthorized access to sensitive data, manipulation of settings, or even total system compromise — absolutely devastating! To secure your system, upgrade to the patched version of `llama-cpp-python` as soon as it’s available. Additionally, review your use of any templates and enforce input validation to limit the risk of injection attacks. Don't forget to monitor your systems for any unauthorized changes. You've got this! Just follow these steps, and you'll have your system locked down in no time! 🛡️

The record
Technical detail
CVSS v3.1
9.7 · CRITICAL
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
CVSS v4.0
Not supplied
EPSS
0.26001 · 98.0th percentile
Weakness
CWE-76 · Improper Neutralization of Equivalent Special Elements
Published
2024-05-10T17:07Z
EPSS history
Timeline
  • 10 MAY 17:07Z
    llama-cpp-python vulnerable to Remote Code Execution by Server-Side Template Injection in Model Metadata
    cvelistv5