CVE-2025-57809 XGrammar affected by Denial of Service by infinite recursion grammars
High 7.7
Published
Updated
Check this codebase for CVE-2025-57809 and fix it if it is affected.
What it is: CVE-2025-57809 is a high-severity vulnerability in mlc-ai xgrammar, published on 25 Aug 2025.
Exploitation: There is no known exploitation of CVE-2025-57809 in the wild and no public exploit code.
Affected packages and fixed versions:
- xgrammar (PyPI): affected all versions; fixed in 0.1.21
- xgrammar (PyPI): affected all versions; fixed in 0.1.21
- xgrammar (PyPI): affected all versions; fixed in 0.1.21
Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.
Reference: https://insights.sbomify.com/CVE-2025-57809/ (Markdown: https://insights.sbomify.com/CVE-2025-57809/index.md)
- Exploited in the wild
- Not known
- Fix
- Available
What is CVE-2025-57809?
CVE-2025-57809 is a high-severity vulnerability in mlc-ai xgrammar, published on 25 Aug 2025.
Official description
XGrammar is an open-source library for efficient, flexible, and portable structured generation. Prior to version 0.1.21, XGrammar has an infinite recursion issue in the grammar. This issue has been resolved in version 0.1.21.
Weakness: CWE-674
Which versions are affected by CVE-2025-57809?
3 open source packages ship an affected version, including xgrammar. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
xgrammar PyPI | All versions | 0.1.21 |
xgrammar PyPI | All versions | 0.1.21 |
xgrammar PyPI | All versions | 0.1.21 |
Products include Mlc-Ai Xgrammar.
How do I fix CVE-2025-57809?
Upgrade xgrammar to 0.1.21 or later.
Is CVE-2025-57809 being exploited?
There is no known exploitation of CVE-2025-57809 in the wild and no public exploit code.
Other vulnerabilities in mlc-ai xgrammar
Sources
Also known as GHSA-5cmr-4px5-23pc, PYSEC-2026-2054.