---
id: "CVE-2024-58400"
kind: "vulnerability"
aliases: ["CVE-2024-58400"]
title: "llama.cpp: out-of-bounds read via unvalidated token IDs in llama-server"
severity: "high"
cvss: 8.8
epss: null
exploited: false
status: "open"
category: "ai-tooling"
products: []
ecosystems: []
tags: ["ai-tooling", "llama-server", "llama.cpp", "local-llm", "self-hosted"]
not_affected_if: ["auth-required", "no-network-exposure"]
published_at: "2026-10-27T01:19:03+00:00"
first_seen_at: "2026-10-27T01:34:33+00:00"
updated_at: "2026-10-27T01:36:16+00:00"
sources: [{"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-58400", "first_seen_at": "2026-10-27T01:34:33+00:00"}]
---

# llama.cpp: out-of-bounds read via unvalidated token IDs in llama-server

llama.cpp before b3701 does not validate token IDs in llama_decode_internal and llama_encode_internal, so an out-of-range ID reads memory outside the embedding table. A remote unauthenticated attacker sending integer-array prompts to the llama-server /completion endpoint can read process memory or crash the server.

_Summary, check and fix written by a model from the sources; labelled as such._

## How to check

- Run `llama-server --version` or check the build tag on the host; anything older than `b3701` is affected.
- Check whether the llama-server port is reachable from untrusted networks.

## Fix

- Upgrade llama.cpp to `b3701` or later and rebuild llama-server.
- Until upgraded, restrict network access to the llama-server /completion endpoint.

## Timeline

- 2026-10-27T01:34:33+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2024-58400

## From the sources

llama.cpp before b3701 contains an out-of-bounds read vulnerability in llama_decode_internal and llama_encode_internal that allows remote unauthenticated attackers to read memory by supplying unvalidated token IDs. Attackers can send integer-array prompts to the llama-server /completion endpoint with IDs outside 0 to n_vocab to read embedding memory out of bounds or crash the process.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
