🔍 CVE-2024-34359

9.6
CVSS Score
CRITICAL
2024-05-14
2026-04-15 00:35
✅ 완료

🇰🇷 한글 설명

llama-cpp-python의 Llama 클래스가 .gguf 파일의 메타데이터에서 채팅 템플릿을 샌드박스 없이 Jinja2로 파싱하여 렌더링하는 과정에서 Jinja2 SSTI 취약점이 발생합니다. 공격자가 특별히 제작된 .gguf 파일을 제공하면 원격 코드 실행이 가능합니다.

💡 쉬운 설명

llama 모델을 로드할 때 특정 템플릿이 안전하지 않게 처리되어 악의적인 모델 파일을 통해 임의의 코드를 실행할 수 있습니다. 모델 파일의 내용이 검증 없이 실행되는 문제입니다.

🇺🇸 원문 (English)

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.

📍 영향받는 시스템

llama-cpp-python 패키지 (0.2.10 버전 이전)

⚔️ 공격 벡터

악의적으로 제작된 .gguf 모델 파일의 메타데이터 채팅 템플릿 필드를 통한 Jinja2 템플릿 주입 공격

🛡️ 대응 방법

llama-cpp-python을 0.2.11 이상으로 업데이트하거나 Jinja2 환경에 샌드박스 설정 적용

🔧 검증 코드

설치된 llama-cpp-python 버전을 확인하여 0.2.11 이상이면 안전, 이전 버전이면 즉시 업데이트 필요

Shell / Script
pip show llama-cpp-python 2>/dev/null | grep Version || echo 'not installed'

📊 CVSS Vector String

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

💻 영향받는 소프트웨어

Python