abetlen llama-cpp-python up to 0.2.71 llama.py to_chat_handler equivalent special elements

CVSS Meta Temp Score
CVSS is a standardized scoring system to determine possibilities of attacks. The Temp Score considers temporal factors like disclosure, exploit and countermeasures. The unique Meta Score calculates the average score of different sources to provide a normalized scoring system.
Current Exploit Price (≈)
Our analysts are monitoring exploit markets and are in contact with vulnerability brokers. The range indicates the observed or calculated exploit price to be seen on exploit markets. A good indicator to understand the monetary effort required for and the popularity of an attack.
CTI Interest Score
Our Cyber Threat Intelligence team is monitoring different web sites, mailing lists, exploit markets and social media networks. The CTI Interest Score identifies the interest of attackers and the security community for this specific vulnerability in real-time. A high score indicates an elevated risk to be targeted for this vulnerability.
7.9$0-$5k0.00

Summaryinfo

A vulnerability identified as critical has been detected in abetlen llama-cpp-python up to 0.2.71. Affected is the function to_chat_handler of the file llama.py. The manipulation leads to improper neutralization of equivalent special elements. This vulnerability is uniquely identified as CVE-2024-34359. The attack is possible to be carried out remotely. No exploit exists.

Detailsinfo

A vulnerability was found in abetlen llama-cpp-python up to 0.2.71 and classified as critical. This issue affects the function to_chat_handler of the file llama.py. The manipulation with an unknown input leads to a improper neutralization of equivalent special elements vulnerability. Using CWE to declare the problem leads to CWE-76. The product correctly neutralizes certain special elements, but it improperly neutralizes equivalent special elements. Impacted is confidentiality, integrity, and availability. The summary by CVE 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 `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.

It is possible to read the advisory at github.com. The identification of this vulnerability is CVE-2024-34359 since 05/02/2024. The exploitation is known to be easy. The attack may be initiated remotely. No form of authentication is needed for a successful exploitation. It demands that the victim is doing some kind of user interaction. Technical details of the vulnerability are known, but there is no available exploit.

There is no information about possible countermeasures known. It may be suggested to replace the affected object with an alternative product.

Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.

Productinfo

Type

Vendor

Name

Version

Website

CPE 2.3info

CPE 2.2info

CVSSv4info

VulDB Vector: 🔍
VulDB Reliability: 🔍

CVSSv3info

VulDB Meta Base Score: 7.9
VulDB Meta Temp Score: 7.9

VulDB Base Score: 6.3
VulDB Temp Score: 6.3
VulDB Vector: 🔍
VulDB Reliability: 🔍

CNA Base Score: 9.6
CNA Vector: 🔍

CVSSv2info

AVACAuCIA
💳💳💳💳💳💳
💳💳💳💳💳💳
💳💳💳💳💳💳
VectorComplexityAuthenticationConfidentialityIntegrityAvailability
UnlockUnlockUnlockUnlockUnlockUnlock
UnlockUnlockUnlockUnlockUnlockUnlock
UnlockUnlockUnlockUnlockUnlockUnlock

VulDB Base Score: 🔍
VulDB Temp Score: 🔍
VulDB Reliability: 🔍

Exploitinginfo

Class: Improper neutralization of equivalent special elements
CWE: CWE-76 / CWE-707 / CWE-20
CAPEC: 🔍
ATT&CK: 🔍

Physical: No
Local: No
Remote: Yes

Availability: 🔍
Status: Not defined

EPSS Score: 🔍
EPSS Percentile: 🔍

Price Prediction: 🔍
Current Price Estimation: 🔍

0-DayUnlockUnlockUnlockUnlock
TodayUnlockUnlockUnlockUnlock

Threat Intelligenceinfo

Interest: 🔍
Active Actors: 🔍
Active APT Groups: 🔍

Countermeasuresinfo

Recommended: no mitigation known
Status: 🔍

0-Day Time: 🔍

Timelineinfo

05/02/2024 🔍
05/10/2024 +8 days 🔍
05/10/2024 +0 days 🔍
03/30/2025 +324 days 🔍

Sourcesinfo

Product: github.com

Advisory: github.com
Status: Confirmed

CVE: CVE-2024-34359 (🔍)
GCVE (CVE): GCVE-0-2024-34359
GCVE (VulDB): GCVE-100-263867

Entryinfo

Created: 05/10/2024 20:42
Updated: 03/30/2025 23:13
Changes: 05/10/2024 20:42 (62), 03/30/2025 23:13 (3)
Complete: 🔍
Cache ID: 216::103

Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.

Discussion

 Anonymous User
(+0)
2 years ago
Good morning.
As this vulnerability allows attackers to execute arbitrary code resulting from improper use of the Jinja2 template engine.
Over 6,000 HuggingFace AI models using llama_cpp_python and Jinja2 are vulnerable.
For this reason you could add the following cpe:
jinja2:jinja2
Pocoo:jinja2
We would appreciate it very much.
Best Regards,
TEAM CERT
At the moment it is unclear what kind of dependencies are given. We have to remain to assign the core product only for now. Thank you for your understanding.

Want to know what is going to be exploited?

We predict KEV entries!