CVE-2026-25048: xgrammar DoS Vulnerability via Multi-Layer Nesting

xgrammar Updated 05 Mar 2026

Summary

05/03/2026
Yes i
High
8.7

CVE-2026-25048: xgrammar vulnerable to DoS via multi-layer nesting. Affects xgrammar versions < 0.1.32. Fixed in 0.1.32. 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

xgrammar is a Python library designed for efficient and flexible structured generation, particularly for tasks involving mathematical expression generation. It leverages advanced machine learning models to create complex outputs based on defined grammar rules. However, the library is susceptible to a denial-of-service (DoS) vulnerability due to its handling of deeply nested syntax, which can lead to significant resource exhaustion.

Vulnerability Detail

The vulnerability arises from the ability to create a malicious grammar rule that contains an excessive number of nested parentheses (up to 30,000 layers). This can trigger a stack overflow or memory exhaustion, resulting in a segmentation fault and crashing the application. The issue is rooted in the way xgrammar processes nested structures, making it vulnerable to crafted inputs that exploit this limitation.

How To Fix

Latest published version: 0.2.8 as of 23 Oct 2026

pip install --upgrade "xgrammar==0.2.8"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.1.32

This is the first release that contains the fix.

pip install --upgrade "xgrammar==0.1.32"

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

Workaround

As a temporary workaround, avoid using deeply nested grammar rules in xgrammar. If you must use complex structures, limit the nesting to a safe level to prevent triggering the vulnerability.

Conclusion

The xgrammar library has a critical vulnerability (CVE-2026-25048) that can lead to denial-of-service attacks through excessive nesting in grammar rules. Users are advised to update to the latest version to mitigate this risk and to avoid deep nesting in the meantime.

See every vulnerability recorded for xgrammar →

Share this vulnerability

FAQ

The vulnerability is a denial-of-service (DoS) issue caused by excessive multi-layer nesting in grammar rules, leading to segmentation faults.

You can use Vulert, which monitors open-source vulnerabilities in real-time. Visit the Vulert playground at Vulert Scanner to check your application without needing to sign up.

The CVSS score for this vulnerability is 8.7, indicating a high severity level.

If an immediate update is not possible, avoid using deeply nested grammar rules as a temporary measure to mitigate the risk.

You can find more information about xgrammar on its official repository or documentation pages, which provide insights into its features and usage.

Related vulnerabilities

Recent vulnerabilities recorded for xgrammar.

How To Fix

Latest published version: 0.2.8 as of 23 Oct 2026

pip install --upgrade "xgrammar==0.2.8"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.1.32

This is the first release that contains the fix.

pip install --upgrade "xgrammar==0.1.32"

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