llama.cpp CVE-2024-21836
HIGHAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
ReconHost malicious .gguf on model hub
-
DeliveryVictim downloads crafted file
-
Exploitllama.cpp parses GGUF header
-
InstallInteger overflow in n_tensors allocation
-
C2Heap buffer overflow writes attacker data
-
ExecuteHijacked control flow executes shellcode
-
ImpactCode execution in user context
Vulnerability Assessment
| Weakness |
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Integer overflow checks
MITRE ATT&CK
1 technique across 1 tactic: Execution The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires the victim to load a specially crafted .gguf model file using llama.cpp built from commit 18c2e17 or an equivalent vulnerable build (UI:R user interaction is mandatory per the CVSS vector). No authentication to the target is required (PR:N) and attack complexity is low (AC:L), but the attacker must first deliver the malicious file - typically by hosting it on a model repository, sending it through a collaboration channel, or compromising a model distribution mirror. Deployments that only load locally produced models from trusted internal pipelines, or that gate model ingestion behind signature verification, are not realistically exposed. |
| Impact | The CVSS 3.1 vector (AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H) scores 8.8 with network reach but requires user interaction - a victim must load the malicious .gguf file. EPSS at 0.15% (35th percentile) and absence from CISA KEV indicate no widespread exploitation, yet publicly available exploit code raises the practical risk for targeted attacks against developers, researchers, and ML platforms that ingest community-supplied models from sources like Hugging Face. The CVSS AV:N rating is somewhat optimistic: real-world exploitation requires social engineering or a compromised model distribution channel rather than direct network reachability, so this is best treated as a serious supply-chain risk against ML toolchains rather than a wormable network bug. |
| Exploit ScenarioDerived | An attacker publishes a backdoored quantized model on a public model hub or shares a .gguf file via a research collaboration channel, naming it after a popular fine-tune to entice download. When a developer or inference server loads the file with vulnerable llama.cpp, header parsing of the crafted n_tensors field triggers the heap overflow and executes attacker-supplied shellcode with the user's privileges. Public exploit code lowers the skill barrier for this scenario. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAI
Heap-based buffer overflow in llama.cpp's GGUF library header parser (commit 18c2e17) enables code execution when a victim loads a maliciously crafted .gguf model file. The CWE-190 integer overflow in the n_tensors field corrupts heap allocations, leading to attacker-controlled memory writes. Publicly available exploit code exists, though EPSS remains low at 0.15% (35th percentile), and there is no public exploit identified as actively used per CISA KEV.
RemediationAI
Upstream fix available (PR/commit); released patched version not independently confirmed from the provided data, so users should update llama.cpp to the latest main-branch build past commit 18c2e17 and rebuild any downstream wrappers (Python bindings, server binaries) that statically link the GGUF parser. Consult the Cisco Talos advisory referenced by talos-cna@cisco.com for the exact remediation commit. Until updated, treat .gguf files as untrusted input: only load model files from cryptographically verified sources, validate checksums against publisher signatures, and isolate inference workloads in containers or sandboxed user accounts with no access to credentials or sensitive data. Avoid auto-loading models supplied through web uploads or chat attachments, which removes a convenient delivery vector at the cost of workflow friction.
Affects your stack
Find out whether the stacks and servers you run are on an affected version.
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
llama.cpp is the widely-used C/C++ inference engine for LLaMA-family large language models, distributed by the ggml project (CPE cpe:2.3:a:ggml:llama.cpp). The GGUF file format is its native serialization for model weights and metadata, replacing the older GGML format. The vulnerability resides in header parsing where the n_tensors field - an attacker-controlled count - feeds into heap allocation arithmetic. CWE-190 (Integer Overflow or Wraparound) describes the root cause: oversized n_tensors values wrap during size computation, producing an undersized buffer that subsequent tensor metadata writes overflow, corrupting adjacent heap chunks.
Know when Llama Cpp gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Primary rating from NVD · only source for this CVE.
CVSS VectorNVD
DescriptionCVE.org
A heap-based buffer overflow vulnerability exists in the GGUF library header.n_tensors functionality of llama.cpp Commit 18c2e17. A specially crafted .gguf file can lead to code execution. An attacker can provide a malicious file to trigger this vulnerability.
Executive ViewAI
A critical heap-based buffer overflow in llama.cpp's GGUF model file parser (CVE-2024-21836, CVSS 8.8) enables remote code execution when users load maliciously crafted model files. Publicly available exploit code exists, though the vulnerability has not been observed in active exploitation. Organizations using llama.cpp should immediately restrict model file sources and implement protective controls given the severe technical impact.
No vendor-released patch identified at time of analysis. Interim mitigations: (1) Restrict all .gguf model file sources to internally-vetted, cryptographically-signed repositories; (2) Enforce containerization or OS-level sandboxing to limit attack surface; (3) Implement file validation (checksums/cryptographic signatures) for all model files; (4) Apply principle of least privilege to llama.cpp processes; (5) Deploy runtime monitoring for process behavior anomalies during model loading operations.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
A buffer overflow occurs when a program writes more data to a memory buffer than it was allocated to hold, causing the excess data to spill into adjacent memory regions.
Integer overflow occurs when an arithmetic operation produces a result that exceeds the maximum value a given integer type can store.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
Affected Products (CPE)CVE.org
Arbitrary memory write in llama.cpp's RPC server allows remote unauthenticated attackers to corrupt arbitrary memory add
Remote code execution in llama.cpp (commit 18c2e17) is possible when a user opens a malicious .gguf model file, triggeri
Llama.cpp server endpoints fail to validate the n_discard parameter from JSON input, allowing negative values that trigg
Remote code execution in llama.cpp (commit 18c2e17) is possible when a victim loads a malicious .gguf model file, trigge
Remote code execution in llama.cpp (GGUF library) allows attackers to achieve arbitrary code execution by tricking a use
Remote code execution in llama.cpp (commit 18c2e17) occurs when the GGUF library's gguf_fread_str function parses a mali
CVE-2025-52566 is a signed vs. unsigned integer overflow vulnerability in llama.cpp's tokenizer (llama_vocab::tokenize f
Remote code execution in llama.cpp RPC backend allows unauthenticated attackers with TCP access to achieve arbitrary mem
llama.cpp provides LLM inference in C/C++. Rated medium severity (CVSS 5.3), this vulnerability is remotely exploitable,
Heap buffer overflow in llama.cpp's server KV cache state-restore path (builds b4882 through b9058) lets an attacker who
Stack-based out-of-bounds write in llama.cpp's ggml-rpc RDMA receive path (builds b8841 through b11865) lets unauthentic
Remote code execution in llama.cpp's llama-server (builds b7492 through b9060) allows unauthenticated attackers to run a
NVD
CVE.org
EPSS
GitHub PoC
Exploit-DB