Severity by source
CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Network-reachable and unauthenticated (AV:N/PR:N), but AC:H reflects the hard-to-win TOCTOU race plus the non-default --sleep-idle-seconds precondition; heap UAF supports high CIA potential.
Primary rating from Vendor (vulncheck).
CVSS VectorVendor: vulncheck
Lifecycle Timeline
2DescriptionCVE.org
llama.cpp builds b7492 through the latest b9060 contains a use-after-free vulnerability in llama-server affecting six tokenization endpoints (/tokenize, /detokenize, /infill, /apply-template, /rerank, and /anthropic/count_tokens) that bypass the task queue and access ctx_server.vocab directly on HTTP worker threads. Attackers can exploit a time-of-check-time-of-use race condition where the main thread destroys and frees vocab after the synchronization lock is released but before the handler finishes using it, causing a crash or potential code execution when --sleep-idle-seconds is configured.
AnalysisAI
Use-after-free in the llama-server component of llama.cpp (builds b7492 through b9060) lets remote unauthenticated attackers crash the server or potentially execute code by racing six tokenization endpoints (/tokenize, /detokenize, /infill, /apply-template, /rerank, /anthropic/count_tokens) that read ctx_server.vocab directly on HTTP worker threads instead of going through the task queue. The flaw is only reachable when the server is started with --sleep-idle-seconds, since idle-driven vocab teardown on the main thread is what frees the object mid-handler. No public exploit identified at time of analysis and it is not listed in CISA KEV; the CVSS 4.0 base score is 9.2 but real-world exploitation is constrained by a hard-to-win TOCTOU race.
Technical ContextAI
llama.cpp is a widely used C/C++ inference runtime for GGUF LLM models, and llama-server is its bundled HTTP server exposing REST endpoints for tokenization, templating, reranking, and generation. The root cause is CWE-367 (Time-of-Check Time-of-Use race condition): six endpoints short-circuit the normal task-queue synchronization and dereference the shared ctx_server.vocab object directly from HTTP worker threads. When --sleep-idle-seconds is configured, the main thread tears down and frees the model context (including vocab) after an idle window. Because the worker thread reads vocab after the synchronization lock is released but before it finishes using the pointer, the main thread can destroy and free that memory underneath an in-flight request, turning a benign read into a use-after-free on freed heap memory.
RemediationAI
Patch available per third-party advisory: the referenced repository https://github.com/Vladimir-tokarev-cyera/llama-cpp-security-patches provides fixes routing the six endpoints through the task queue rather than accessing ctx_server.vocab directly; a specific patched llama.cpp build/tag was not provided and could not be independently confirmed, so upgrade to the latest official build once the fix is merged upstream and verify the tokenization endpoints no longer bypass synchronization. As an immediate compensating control, do not run llama-server with --sleep-idle-seconds - removing that flag eliminates the vocab teardown that frees the object mid-request and closes the race entirely, at the cost of keeping the model resident in memory (higher idle RAM/VRAM usage). Additionally, restrict network exposure of llama-server: bind to localhost or place it behind an authenticating reverse proxy and block direct internet access to /tokenize, /detokenize, /infill, /apply-template, /rerank, and /anthropic/count_tokens, since the endpoints are unauthenticated by design.
Vendor StatusVendor
SUSE
Severity: ImportantShare
External POC / Exploit Code
Leaving vuln.today
EUVD-2026-54287
GHSA-3f2h-96vw-c84x