xgrammar is vulnerable to Denial of Service (DoS)
59
Medium Risk
The XML tool-calling schema converter wraps unconstrained string properties with redundant formatting-whitespace repetitions around the string value, so a run of whitespace produces a linear number of active Earley parser states and a quadratic rollback history. A grammar built from an XML tool-calling style schema with an unconstrained string, combined with model output containing many whitespace characters, drives unbounded parser state and memory growth. The cumulative Compact2DArray CSR offset can then overflow int32_t, feeding an invalid parser state into the scan path and causing a SIGSEGV in Release builds alongside extreme memory consumption. The fix omits the redundant whitespace rules for unconstrained XML strings and adds always-on pre-mutation bounds checks that raise a controlled error before the compact array offsets become unrepresentable.
You are affected if you are using a version that falls within the vulnerable range and generate grammars using an XML tool-calling style (for example Qwen, MiniMax, DeepSeek, or GLM XML) with an unconstrained string property.
xgrammar is vulnerable to Denial of Service (DoS) in versions 0.1.24 - 0.2.4.
Upgrade the xgrammar library to the patch version.
Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.
Free. No credit card required.

I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant