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.
                
            Metrics
Affected Vendors & Products
References
        History
                    Wed, 27 Aug 2025 14:00:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| First Time appeared | Ggml Ggml llama.cpp | |
| CPEs | cpe:2.3:a:ggml:llama.cpp:*:*:*:*:*:*:*:* | |
| Vendors & Products | Ggml Ggml llama.cpp | 
Wed, 18 Jun 2025 14:15:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| Metrics | ssvc 
 | 
Tue, 17 Jun 2025 20:15:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| Title | llama.cpp Vulnerable to Buffer Overflow via Malicious GGUF Model | 
Tue, 17 Jun 2025 20:45:00 +0000
| Type | Values Removed | Values Added | 
|---|---|---|
| Description | 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. | |
| Weaknesses | CWE-119 CWE-195 | |
| References |  | |
| Metrics | cvssV3_1 
 | 
 MITRE
                        MITRE
                    Status: PUBLISHED
Assigner: GitHub_M
Published: 2025-06-17T20:04:40.893Z
Updated: 2025-06-18T13:41:11.407Z
Reserved: 2025-06-11T14:33:57.800Z
Link: CVE-2025-49847
 Vulnrichment
                        Vulnrichment
                    Updated: 2025-06-18T13:40:46.678Z
 NVD
                        NVD
                    Status : Analyzed
Published: 2025-06-17T20:15:32.437
Modified: 2025-08-27T13:48:14.223
Link: CVE-2025-49847
 Redhat
                        Redhat
                    No data.