ggml-org llama.cpp Stack-Based Buffer Overflow Vulnerability in GBNF Grammar Handler

Vulnerability

A stack-based buffer overflow vulnerability has been identified in ggml-org llama.cpp versions prior to commit 55abc39. The issue arises in the GBNF Grammar Handler, specifically within the function llama_grammar_advance_stack, located in the file llama.cpp/src/llama-grammar.cpp. This vulnerability is triggered by nested repetition patterns in GBNF grammar, leading to infinite recursion and a stack overflow. The vulnerability must be exploited locally, and a public exploit is available.

Impact

Exploitation of this vulnerability causes a stack-based buffer overflow, leading to a denial-of-service condition where the application crashes due to exhausted stack space.

Reproduction

The vulnerability can be reproduced by loading a GBNF grammar file that contains nested repetition patterns, such as '(...*)*', into an application using ggml-org llama.cpp prior to version 55abc39. The function llama_grammar_advance_stack will recursively process the nested repetitions, leading to a stack overflow. This behavior can be observed by using the AddressSanitizer, which will detect the stack overflow and abort the program.

Remediation

Users are advised to update to the version of ggml-org llama.cpp that includes the patch for this vulnerability.

Added: Feb 7, 2026, 12:40 AM
Updated: Feb 7, 2026, 12:40 AM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
2.5
exploitability
4.2
remediation
0.0
relevance
2.6
threat
6.4
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.