Documented Incident · INC-2024-34359 · Critical severity

llama-cpp-python GGUF Chat Template Jinja2 Server-Side Template Injection RCE

CVE-2024-34359 exposed a critical server-side template injection (SSTI) flaw in `llama-cpp-python` when rendering `tokenizer.chat_template` strings embedded inside `.gguf` model headers. Because the Python wrapper passed untrusted Jinja2 template strings directly into an unsandboxed Jinja2 `Environment`, downloading and loading a maliciously modified GGUF file executed arbitrary host commands immediately at inference initialization. Even teams that avoided pickle files by migrating to GGUF were vulnerable via metadata headers. Maintainers patched the loader to use Jinja2's `ImmutableSandboxedEnvironment`.

Incident dossier metadata

Case ID
INC-2024-34359
Classification
Incident
Date
Severity
Critical
Sector
Cloud & AI Infrastructure
Attack vector
Supply Chain
System type
Open-Weight GGUF Inference Runtimes
CVE / reference
CVE-2024-34359
Reference URI
https://nvd.nist.gov/vuln/detail/CVE-2024-34359

Inspect INC-2024-34359 in Interactive Incidents & Cases Hub

Defensive takeaway

Render model chat templates exclusively with SandboxedEnvironment or deterministic string formatters and verify checksums of third-party GGUF artifacts.

Mapped AI security techniques

Mapped defensive controls

Source citation records