# CVE-2024-58400: llama.cpp out-of-bounds read in decode/encode functions

Source: https://junglewise.ai/threats/cve-2024-58400-llama-cpp-before-b3701-contains-an-out-of-bounds-read  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-27. Updated: 2026-10-27  
License: CC BY 4.0 with a link back

CVE-2024-58400 · Severity: high · CVSS 8.2 · Published 2026-10-27

llama.cpp is a language model inference library used to run AI models locally. An unauthenticated attacker can send specially crafted requests to the llama-server endpoint with invalid token IDs, causing the server to read memory outside intended bounds. This can leak sensitive data from memory or crash the service.

Technologies: [Ggml-Org Llama.Cpp](https://junglewise.ai/threats/technologies/ggml-org-llama-cpp). Vendors: [Ggml-Org](https://junglewise.ai/threats/vendors/ggml-org).

## Quick answers

**Is CVE-2024-58400 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2024-58400 being exploited in the wild.

**How severe is CVE-2024-58400?** High severity, with a CVSS score of 8.2, published 27 October 2026.

**Which products and versions are affected?** Ggml-Org Llama.Cpp before b3701.

**Is there a fix for CVE-2024-58400?** Yes: fixed in b3701 or later (commit eae5971 and related). Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2024-58400 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2024-58400?** Check whether you run Ggml-Org Llama.Cpp at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Fixed in b3701 or later (commit eae5971 and related)

## Technical details

An out-of-bounds read vulnerability exists in llama_decode_internal and llama_encode_internal functions due to insufficient validation of token ID values. The functions fail to check that token IDs fall within the valid range (0 to n_vocab), allowing attackers to read arbitrary embedding memory via the /completion endpoint by supplying integer-array prompts with IDs outside valid bounds.

## Affected products

- ggml-org llama.cpp before b3701

## Timeline

- 2026-10-27: disclosed

## References

- [https://github.com/ggml-org/llama.cpp/blob/b3681/examples/server/server.cpp](https://github.com/ggml-org/llama.cpp/blob/b3681/examples/server/server.cpp)
- [https://github.com/ggml-org/llama.cpp/commit/eae597182cb61bbde0b26e7cec5999d28b9327fe](https://github.com/ggml-org/llama.cpp/commit/eae597182cb61bbde0b26e7cec5999d28b9327fe)

## Related threats

- [llama.cpp ggml-rpc server denial of service](https://junglewise.ai/threats/cve-2026-119052-llama-cpp-b2877-before-b11935-contains-an-uncaught-exception)
- [llama.cpp out-of-bounds write in ggml-rpc RDMA transport](https://junglewise.ai/threats/cve-2026-118375-llama-cpp-b8841-before-b11865-contains-an-out-of-bounds-write)
- [llama.cpp integer overflow in gguf_init_from_reader](https://junglewise.ai/threats/cve-2026-116829-llama-cpp-b10398-before-b11301-contains-an-integer-overflow)
- [llama.cpp heap out-of-bounds write in PLAMO2 tokenizer](https://junglewise.ai/threats/cve-2026-116816-llama-cpp-b5899-before-b10261-contains-a-heap-out-of-bounds)
- [llama.cpp heap out-of-bounds read in tokenizer loading](https://junglewise.ai/threats/cve-2025-71439-llama-cpp-before-b5649-contains-a-heap-out-of-bounds-read)
