CVE-2026-137057: llama.cpp b7118 before b12604 Integer Underflow in Grammar Parser parse_sequence
llama.cpp from b7118 before b12604 contains an integer underflow vulnerability in llamagrammarparser::parsesequence() that allows unauthenticated remote attackers to cause denial of service by supplying GBNF repetitions with max lower than min. Attackers can send a grammar like {5,2} in the grammar field of a llama-server /completion request, wrapping nopt to generate endless repetition rules that hang the process and exhaust memory.
Affected Software
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments running llama.cpp versions from b7118 before b12604 are affected when they expose llama-server and accept /completion requests containing a grammar field.
What does an attacker need to exploit the flaw?
An attacker needs only network access to send an unauthenticated /completion request to llama-server. They can supply a GBNF repetition whose maximum is lower than its minimum, such as {5,2}.
What is the operational impact of successful exploitation?
The malformed repetition causes an integer underflow that can generate endless repetition rules. This can hang the process and exhaust memory, resulting in denial of service.
How can defenders identify attempted exploitation?
Inspect llama-server /completion requests that include a grammar field for GBNF repetition ranges where the maximum value is lower than the minimum value, such as {5,2}.