XGrammar Infinite Recursion Vulnerability Leading to Denial-of-Service

Vulnerability

A denial-of-service vulnerability has been identified in XGrammar, an open-source library for structured generation. Prior to version 0.1.21, the library's grammar processing could enter an infinite recursion, causing a segmentation fault. This issue arises from certain grammar rules that create recursive loops, which can be exploited by passing user-defined grammars to XGrammar. The vulnerability has been patched in version 0.1.21.

Impact

Exploitation of this vulnerability causes a segmentation fault, leading to a crash of the application using XGrammar.

Reproduction

The vulnerability can be reproduced by using the XGrammar library to compile a grammar that includes implicit left recursion or certain right recursion patterns. This can be done by creating a grammar rule that references itself in a way that creates a loop, such as 'root ::= rule1 | (rule1 rule1 rule1 rule3)+', and then compiling this grammar with the XGrammar compiler.

Remediation

Users can upgrade to XGrammar version 0.1.21 or later, where this vulnerability has been fixed.

Added: Aug 25, 2025, 10:22 PM
Updated: Aug 25, 2025, 10:22 PM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
2.5
exploitability
8.7
remediation
7.7
relevance
0.4
threat
6.4
urgency
2.9
incentive
5.8

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