Summary
CVE-2024-58400 is an out-of-bounds read vulnerability (CWE-129, Improper Validation of Array Index) in llama.cpp, affecting all versions before b3701. A remote, unauthenticated attacker can send crafted token IDs to the llama-server /completion endpoint to read memory out of bounds or crash the process. The CVE record lists a CVSS v4.0 score of 8.8 (High) and a CVSS v3.1 score of 8.2 (High).
Technical details
- Root cause:
llama_decode_internalandllama_encode_internaldo not validate that token IDs fall within the valid vocabulary range before using them to index embedding memory. - Trigger conditions: The attacker sends an integer-array prompt to the llama-server
/completionendpoint containing IDs outside the range 0 ton_vocab. - Attack vector: Network. No authentication or user interaction is required.
- Impact: Out-of-bounds read of embedding memory (limited confidentiality impact) or a process crash (denial of service).
Affected software
- llama.cpp (ggml-org): all versions before b3701
Severity
- CVSS v4.0 base score: 8.8 (High),
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N - CVSS v3.1 base score: 8.2 (High),
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H
Mitigation and recommended actions
- Immediate: upgrade llama.cpp to b3701 or later (fixed via pull request #9359).
- If you cannot upgrade immediately: do not expose llama-server to untrusted networks. Restrict access with network controls such as firewall rules or an authenticated reverse proxy.

