CVE-2025-57809: Xgrammar Denial of Service Vulnerability
HIGHCVE-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
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).
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.
pip install xgrammar>=0.1.21
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
CVE-2025-57809 Affected Xgrammar Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
xgrammar
|
PyPI |
< 0.1.21
|
0.1.21
|
References
Frequently Asked Questions
What is CVE-2025-57809?
Which Xgrammar versions are affected?
What version fixes CVE-2025-57809?
Is xgrammar affected?
What is the CVSS score of CVE-2025-57809?
What CWE is associated with CVE-2025-57809?
How can I check PyPI dependencies for CVE-2025-57809?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}