CVE-2025-57809: Xgrammar Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-5cmr-4px5-23pc
CVSS 7.5
CWE-674
Published
Advisory Summary

CVE-2025-57809 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-674: Uncontrolled Recursion) affecting Xgrammar libraries in the PyPI ecosystem. The issue involves xgrammar affected by denial of service by infinite recursion grammars. Remediation is available by upgrading affected packages to version 0.1.21.

CVE-2025-57809 at a Glance

CVE Identifier CVE-2025-57809
GHSA Identifier GHSA-5cmr-4px5-23pc
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-674: Uncontrolled Recursion
Affected Product Xgrammar
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
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-57809

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.21
pip install xgrammar>=0.1.21
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-57809, 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.21), 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-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. 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 This issue: http://github.com/mlc-ai/xgrammar/issues/250 should have it's own security advisory. Since several tools accept and pass user supplied grammars to xgrammar, and it is so easy to trigger it seems like a High.

CVE-2025-57809 Affected Xgrammar Versions

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

References

Frequently Asked Questions

What is CVE-2025-57809?
CVE-2025-57809 is a security vulnerability in Xgrammar involving XGrammar affected by Denial of Service by infinite recursion grammars under CWE-674: Uncontrolled Recursion.
Which Xgrammar versions are affected?
Affected versions include releases prior to 0.1.21 across affected packages: xgrammar.
What version fixes CVE-2025-57809?
Upgrading to 0.1.21 (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.21. Upgrade your dependency to 0.1.21 or later.
What is the CVSS score of CVE-2025-57809?
CVE-2025-57809 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2025-57809?
CVE-2025-57809 is classified under CWE-674: Uncontrolled Recursion (The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.).
How can I check PyPI dependencies for CVE-2025-57809?
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-5cmr-4px5-23pc",
  "modified" : "2025-09-10T21:06:51Z",
  "published" : "2025-08-25T20:43:45Z",
  "aliases" : [ "CVE-2025-57809" ],
  "summary" : "XGrammar affected by Denial of Service by infinite recursion grammars",
  "details" : "### Summary\nThis issue: http://github.com/mlc-ai/xgrammar/issues/250 should have it's own security advisory. Since several tools accept and pass user supplied grammars to xgrammar, and it is so easy to trigger it seems like a High.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "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/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "xgrammar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.1.21"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mlc-ai/xgrammar/security/advisories/GHSA-5cmr-4px5-23pc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-57809"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mlc-ai/xgrammar/issues/250"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mlc-ai/xgrammar/commit/b943feacb5a1caf4d39de8ec3bf7c7ce066dcee5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mlc-ai/xgrammar"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-08-25T20:43:45Z",
    "nvd_published_at" : "2025-08-25T22:15:33Z"
  }
}