CVE-2025-32381: Xgrammar Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-389x-67px-mjg3
CVSS 6.5
CWE-770
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2025-32381
GHSA Identifier GHSA-389x-67px-mjg3
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Xgrammar
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (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.

xgrammar fixed: 0.1.18
pip install xgrammar>=0.1.18
Verify Direct and Transitive Dependencies

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

### Summary Xgrammar 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. ### Details The fix is to add a limit to the cache size. This was done in https://github.com/mlc-ai/xgrammar/pull/243 An example of making use of the new cache size limit can be found in vLLM here: https://github.com/vllm-project/vllm/pull/16283 ### Impact Any system making use of Xgrammar and taking requests as input from potentially untrusted parties would be vulnerable to this denial of service issue.

CVE-2025-32381 Affected Xgrammar Versions

1 component(s)
Fixed Versions:
0.1.18
Product / Package Ecosystem Affected Versions Fixed Version
xgrammar
PyPI
< 0.1.18
0.1.18

References

Frequently Asked Questions

What is CVE-2025-32381?
CVE-2025-32381 is a security vulnerability in Xgrammar involving xgrammar Vulnerable to Denial of Service (DoS) by abusing unbounded cache in memory under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Xgrammar versions are affected?
Affected versions include releases prior to 0.1.18 across affected packages: xgrammar.
What version fixes CVE-2025-32381?
Upgrading to 0.1.18 (or the latest patched release for your respective branch) resolves the vulnerability.
Is xgrammar affected?
Yes, xgrammar is affected in releases prior to 0.1.18. Upgrade your dependency to 0.1.18 or later.
What is the CVSS score of CVE-2025-32381?
CVE-2025-32381 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2025-32381?
CVE-2025-32381 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (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.).
How can I check PyPI dependencies for CVE-2025-32381?
Run the dependency tree command: 'pip show xgrammar'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}