CVE-2026-27940 llama.cpp has a Heap Buffer Overflow via Integer Overflow in `mem_size` Calculation — Bypass of CVE-2025-53630 Fix

High 7.8 Published Updated

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.

Weakness: CWE-190, CWE-122

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.

Sources

Also known as DEBIAN-CVE-2026-27940, GHSA-3p4r-fq3f-q74v, UBUNTU-CVE-2026-27940.

Is CVE-2026-27940 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free