llama.cpp is an inference of several LLM models in C/C++. Prior to version b5662, an attacker‐supplied GGUF model vocabulary can trigger a buffer overflow in llama.cpp’s vocabulary‐loading code. Specifically, the helper _try_copy in llama.cpp/src/vocab.cpp: llama_vocab::impl::token_to_piece() casts a very large size_t token length into an int32_t, causing the length check (if (length < (int32_t)size)) to be bypassed. As a result, memcpy is still called with that oversized size, letting a malicious model overwrite memory beyond the intended buffer. This can lead to arbitrary memory corruption and potential code execution. This issue has been patched in version b5662.
{
"cna_assigner": "GitHub_M",
"cwe_ids": [
"CWE-119",
"CWE-195"
],
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/49xxx/CVE-2025-49847.json"
}{
"extracted_events": [
{
"cpe": "cpe:2.3:a:ggml:llama.cpp:*:*:*:*:*:*:*:*",
"range": [
{
"introduced": "0"
},
{
"fixed": "b5662"
}
],
"source": "CPE_RANGE"
},
{
"range": [
{
"fixed": "3cfbbdb44e08fd19429fed6cc85b982a91f0efd5"
}
],
"source": "REFERENCES_COMMIT"
}
]
}
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-49847.json"
[
{
"deprecated": false,
"digest": {
"function_hash": "8015454662303540258577735914882312653",
"length": 1923
},
"id": "CVE-2025-49847-07b1552b",
"signature_type": "Function",
"signature_version": "v1",
"source": "https://github.com/ggml-org/llama.cpp/commit/3cfbbdb44e08fd19429fed6cc85b982a91f0efd5",
"target": {
"file": "src/llama-vocab.cpp",
"function": "llama_vocab::impl::token_to_piece"
}
},
{
"deprecated": false,
"digest": {
"line_hashes": [
"107181731931003307835415921280185529094",
"8691874656937036198741476177498052342",
"222164472228642565232627721621558077667",
"285399850289128918143715716138429533503",
"24924994144946619123279070485198042904",
"140976667380492342565229348084105618674",
"187175746713085394777287030060410117073",
"86316017608384246037373863469345250372"
],
"threshold": 0.9
},
"id": "CVE-2025-49847-08f5bc97",
"signature_type": "Line",
"signature_version": "v1",
"source": "https://github.com/ggml-org/llama.cpp/commit/3cfbbdb44e08fd19429fed6cc85b982a91f0efd5",
"target": {
"file": "src/llama-vocab.cpp"
}
}
]
"2026-10-28T11:02:00Z"