CVE-2026-27940 llama.cpp has a Heap Buffer Overflow via Integer Overflow in `mem_size` Calculation — Bypass of CVE-2025-53630 Fix
An integer overflow in llama.cpp allows heap buffer overflows via crafted GGUF files, potentially enabling code execution or crashes.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2026-27940?
CVE-2026-27940 is a high-severity vulnerability in ggml-org llama.cpp, published on 12 Mar 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Official description
llama.cpp is an inference of several LLM models in C/C++. Prior to b8146, the gguf_init_from_file_impl() in gguf.cpp is vulnerable to an Integer overflow, leading to an undersized heap allocation. Using the subsequent fread() writes 528+ bytes of attacker-controlled data past the buffer boundary. This is a bypass of a similar bug in the same file - CVE-2025-53630, but the fix overlooked some areas. This vulnerability is fixed in b8146.
Which versions are affected by CVE-2026-27940?
It affects 1 product.
Products include Ggml Llama.cpp.
How do I fix CVE-2026-27940?
Upgrade to a fixed version.
Is CVE-2026-27940 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-27940 exists.
Public exploit code: 1 proofs of concept on GitHub.
Other vulnerabilities in ggml-org llama.cpp
- CVE-2024-42479 llama.cpp allows write-what-where in rpc_server::set_tensor
- CVE-2026-34159 llama.cpp: Unauthenticated RCE via GRAPH_COMPUTE buffer=0 bypass in llama.cpp RPC backend
- CVE-2026-43629 llama.cpp b4882–b9058 Buffer Overflow in KV Cache State Restore
- CVE-2026-43631 llama.cpp b7492–b9060 Use-After-Free RCE via llama-server
- CVE-2026-43632 llama.cpp b7492–b9060 Use-After-Free in Tokenization Endpoints
Sources
Also known as DEBIAN-CVE-2026-27940, GHSA-3p4r-fq3f-q74v, UBUNTU-CVE-2026-27940.