CVE-2025-32381 Denial of Service by abusing xgrammar unbounded cache in memory
An attacker can cause a denial of service by exhausting memory through unbounded caching of unique grammars in the XGrammar library.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2025-32381?
CVE-2025-32381 is a medium-severity denial of service vulnerability in mlc-ai xgrammar, published on 9 Apr 2025. Any signed-in user can exploit it over the network, with no action from the victim.
Official description
XGrammar is an open-source library for efficient, flexible, and portable structured generation. Prior to 0.1.18, 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. This vulnerability is fixed in 0.1.18.
Weakness: CWE-770
Which versions are affected by CVE-2025-32381?
3 open source packages ship an affected version, including xgrammar. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
xgrammar PyPI | All versions | 0.1.18 |
xgrammar PyPI | All versions | 0.1.18 |
xgrammar PyPI | All versions | 0.1.18 |
Products include Mlc-Ai Xgrammar.
How do I fix CVE-2025-32381?
Upgrade xgrammar to 0.1.18 or later.
Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.
Is CVE-2025-32381 being exploited?
There is no known exploitation of CVE-2025-32381 in the wild and no public exploit code.
Other vulnerabilities in mlc-ai xgrammar
Sources
Also known as GHSA-389x-67px-mjg3, PYSEC-2025-235.