CVE-2025-32381: Xgrammar Denial of Service Vulnerability
MODERATECVE-2025-32381 is a MODERATE (CVSS 6.5) denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Xgrammar libraries in the PyPI ecosystem. The issue involves xgrammar vulnerable to denial of service (dos) by abusing unbounded cache in memory. Remediation is available by upgrading affected packages to version 0.1.18.
CVE-2025-32381 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2025-32381
To remediate this vulnerability, upgrade all affected Xgrammar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install xgrammar>=0.1.18
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show xgrammar
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-32381, inspect your installed packages using pip:
pip show xgrammar
Analyze the terminal output to locate any version of Xgrammar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.1.18), your application is affected.
Note: The pip show xgrammar command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Xgrammar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-32381 Affected Xgrammar Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
xgrammar
|
PyPI |
< 0.1.18
|
0.1.18
|
References
Frequently Asked Questions
What is CVE-2025-32381?
Which Xgrammar versions are affected?
What version fixes CVE-2025-32381?
Is xgrammar affected?
What is the CVSS score of CVE-2025-32381?
What CWE is associated with CVE-2025-32381?
How can I check PyPI dependencies for CVE-2025-32381?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-389x-67px-mjg3",
"modified" : "2026-06-08T20:04:11Z",
"published" : "2025-04-09T13:08:59Z",
"aliases" : [ "CVE-2025-32381" ],
"summary" : "xgrammar Vulnerable to Denial of Service (DoS) by abusing unbounded cache in memory",
"details" : "### Summary\n\nXgrammar includes a cache for compiled grammars to increase performance with repeated use of the same grammar. This cache is held in memory. Since the cache is unbounded, a system making use of xgrammar can be abused to fill up a host's memory and case a denial of service. For example, sending many small requests to an LLM inference server with unique JSON schemas would eventually cause this denial of service to occur.\n\n### Details\n\nThe fix is to add a limit to the cache size. This was done in https://github.com/mlc-ai/xgrammar/pull/243\n\nAn example of making use of the new cache size limit can be found in vLLM here: https://github.com/vllm-project/vllm/pull/16283\n\n### Impact\n\nAny system making use of Xgrammar and taking requests as input from potentially untrusted parties would be vulnerable to this denial of service issue.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "xgrammar"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.1.18"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-389x-67px-mjg3"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-32381"
}, {
"type" : "WEB",
"url" : "https://github.com/mlc-ai/xgrammar/pull/243"
}, {
"type" : "WEB",
"url" : "https://github.com/vllm-project/vllm/pull/16283"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mlc-ai/xgrammar"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/xgrammar/PYSEC-2025-235.yaml"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-770" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-04-09T13:08:59Z",
"nvd_published_at" : "2025-04-09T16:15:26Z"
}
}