Executive brief
xgrammar is an open-source library used to ensure that AI models generate structured data, such as JSON or specific code formats. A vulnerability in how the library handles complex, nested instructions can cause the system to crash. This could allow an attacker to disrupt AI services, leading to a denial-of-service (DoS) condition where the AI becomes unavailable to legitimate users.
Technical details
A vulnerability exists in xgrammar prior to version 0.1.32 due to uncontrolled recursion (CWE-674) when parsing multi-level nested syntax. An attacker can exploit this by providing a malicious grammar rule containing deeply nested structures (e.g., 30,000 layers of parentheses), which triggers a stack overflow or memory exhaustion. This results in a segmentation fault and a core dump, leading to a denial-of-service (DoS) of the application utilizing the library. The issue is reachable over the network if the application allows user-defined or complex grammar inputs. The vulnerability has been patched in version 0.1.32.
Affected products
- mlc-ai xgrammar < 0.1.32
- Red Hat Red Hat AI Inference Server 3.2.2
- Red Hat Red Hat OpenShift AI 2.25.7
Timeline
- 2026-03-04: patched: Version 0.1.32 released
- 2026-03-05: advisory: GitHub Security Advisory published
- 2026-03-05: disclosed: CVE-2026-25048 published
- 2026-03-25: patched: Red Hat AI Inference Server 3.2.2 released
References
- https://github.com/mlc-ai/xgrammar/releases/tag/v0.1.32
- https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-7rgv-gqhr-fxg3
- https://access.redhat.com/errata/RHSA-2026:24977
- https://access.redhat.com/errata/RHSA-2026:5809
- https://access.redhat.com/errata/RHSA-2026:6761
- https://access.redhat.com/errata/RHSA-2026:6762
- https://access.redhat.com/security/cve/CVE-2026-25048