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
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
- Supply Chain Compromise: Model Repository AML.T0010.003
- User Execution: Unsafe AI Artifacts AML.T0011.000
- Manipulate AI Model: Modify Prompt Construction Logic AML.T0018.003
- Publish Poisoned AI Artifacts: Models AML.T0115.001
Mapped defensive controls
- Restrict Library Loading AML.M0011
- Verify AI Artifacts AML.M0014
- Vulnerability Scanning AML.M0016
- AI Model Distribution Methods AML.M0017
Source citation records
- NVD Record CVE-2024-34359: llama-cpp-python GGUF Jinja2 SSTI RCE · NIST National Vulnerability Database (NVD) ·