CVE-2025-58446: xgrammar Denial of Service Vulnerability Due to Slow Grammar Optimization

xgrammar Updated 02 Oct 2025

Summary

05/09/2025
Yes i
Moderate
Not published

CVE-2025-58446: xgrammar vulnerable to denial of service by huge enum grammar. Affects xgrammar versions >= 0.1.23, < 0.1.24. Fixed in 0.1.24. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

xgrammar is a Python package designed for parsing and processing grammars, particularly in the context of language models. It offers functionalities that allow users to define and manipulate complex grammar structures. However, a recent update introduced performance issues that can lead to denial of service (DoS) when handling large grammars, making it crucial for users to be aware of this vulnerability.

Vulnerability Detail

The vulnerability arises from a regression in the grammar optimizer introduced in version 0.1.23 of xgrammar. This optimizer is significantly slower when processing large grammars (over 100k characters), causing the parsing process to take an excessive amount of time. As a result, this can be exploited to perform denial of service attacks against model providers, as the parsing time can exceed the time taken by the models themselves. The issue was not present in earlier versions, such as 0.1.16, indicating that the problem is specifically linked to the changes made in the newer version.

How To Fix

Minimum fixed version

0.1.24

This is the first release that contains the fix.

pip install --upgrade "xgrammar==0.1.24"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate upgrading is not possible, users can avoid using large grammars (over 100k characters) until the package is updated. Additionally, users can implement their own optimizations or limit the size of the input grammars to mitigate the impact of this vulnerability.

Conclusion

The xgrammar package has a vulnerability (CVE-2025-58446) that can lead to denial of service when processing large grammars due to slow optimization in version 0.1.23. Users are advised to upgrade to version 0.1.24 or later to mitigate this issue. Temporary workarounds include avoiding large grammars until the update is applied.

See every vulnerability recorded for xgrammar →

Share this vulnerability

FAQ

CVE-2025-58446 is a vulnerability in the xgrammar package that can lead to denial of service due to slow grammar processing in version 0.1.23.

If your application uses xgrammar version 0.1.23 or earlier and processes large grammars, it may experience significant delays or become unresponsive, leading to potential denial of service.

As a temporary measure, avoid using large grammars or implement your own optimizations to reduce the size of the input grammars.

You can find detailed information about CVE-2025-58446 in the advisory database on GitHub or by visiting Vulert, which monitors open-source vulnerabilities.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Related vulnerabilities

Recent vulnerabilities recorded for xgrammar.

How To Fix

Minimum fixed version

0.1.24

This is the first release that contains the fix.

pip install --upgrade "xgrammar==0.1.24"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback