Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-25048

CVE-2026-25048: xgrammar Library DoS Vulnerability

CVE-2026-25048 is a denial of service flaw in xgrammar library that causes segmentation faults through multi-level nested syntax. This article covers the technical details, affected versions, impact, and mitigation.

Published:

CVE-2026-25048 Overview

CVE-2026-25048 is an uncontrolled recursion vulnerability (CWE-674) in xgrammar, an open-source library for efficient, flexible, and portable structured generation. Prior to version 0.1.32, processing multi-level nested syntax triggers a segmentation fault (core dumped), causing the application to crash. This vulnerability allows remote attackers to cause a denial of service condition by sending specially crafted input with deeply nested structures.

Critical Impact

Remote attackers can crash applications using xgrammar by submitting maliciously crafted nested input, resulting in complete service disruption without requiring authentication.

Affected Products

  • xgrammar versions prior to 0.1.32
  • Applications and services utilizing the xgrammar library for structured generation
  • AI/ML pipelines incorporating xgrammar for grammar-based text generation

Discovery Timeline

  • March 5, 2026 - CVE-2026-25048 published to NVD
  • March 5, 2026 - Last updated in NVD database

Technical Details for CVE-2026-25048

Vulnerability Analysis

This vulnerability stems from uncontrolled recursion (CWE-674) in the xgrammar library's parsing functionality. When the library processes input containing multi-level nested syntax, it recursively descends into the nested structures without adequate depth limiting or stack protection mechanisms. This uncontrolled recursion eventually exhausts the available stack space, triggering a segmentation fault and causing the process to terminate with a core dump.

The network-accessible nature of this vulnerability means attackers can exploit it remotely without requiring authentication or user interaction. Applications that accept user-supplied grammar definitions or structured text input are particularly at risk. The vulnerability exclusively impacts availability—there is no data confidentiality or integrity compromise associated with this flaw.

Root Cause

The root cause is insufficient recursion depth control in the syntax parsing logic. The xgrammar library fails to implement proper bounds checking or iterative alternatives when processing nested grammar structures. As recursive calls accumulate on the call stack, memory is exhausted, leading to a segmentation fault. This is a classic example of CWE-674: Uncontrolled Recursion, where the depth of recursive function calls is not properly limited.

Attack Vector

An attacker can exploit this vulnerability by submitting input containing deeply nested grammar structures to any application using a vulnerable version of xgrammar. The attack requires no special privileges or authentication, and can be executed over the network. The attacker constructs a payload with multiple levels of nested syntax elements designed to trigger excessive recursion in the parsing engine.

The exploitation flow involves:

  1. Identifying an application endpoint that processes input through xgrammar
  2. Crafting a malicious payload with deeply nested structures (e.g., nested brackets, parentheses, or grammar rules)
  3. Submitting the payload to the target application
  4. The xgrammar parser recursively processes the nested input until stack exhaustion occurs
  5. A segmentation fault terminates the application process

Detection Methods for CVE-2026-25048

Indicators of Compromise

  • Unexpected application crashes with segmentation fault error messages in logs
  • Core dump files generated by processes using xgrammar
  • Repeated crash-restart cycles in services utilizing the xgrammar library
  • Anomalous input patterns containing deeply nested structures in application logs

Detection Strategies

  • Monitor application logs for segmentation fault errors associated with xgrammar-utilizing processes
  • Implement input validation to detect and reject excessively nested syntax before processing
  • Deploy application-level rate limiting to mitigate rapid exploitation attempts
  • Use crash monitoring tools to alert on unexpected process terminations

Monitoring Recommendations

  • Enable core dump analysis to identify crash patterns related to stack exhaustion
  • Configure alerting for repeated service restarts that may indicate ongoing exploitation
  • Monitor memory and stack usage metrics for processes using xgrammar
  • Implement logging for rejected inputs that exceed nesting depth thresholds

How to Mitigate CVE-2026-25048

Immediate Actions Required

  • Upgrade xgrammar to version 0.1.32 or later immediately
  • Audit applications to identify all instances where xgrammar is used
  • Implement input validation to reject excessively nested input before it reaches the parser
  • Consider temporarily disabling affected functionality if immediate patching is not possible

Patch Information

The xgrammar development team has addressed this vulnerability in version 0.1.32. The patch implements proper recursion depth controls to prevent stack exhaustion when processing nested syntax structures. Organizations should upgrade to this version or later to remediate the vulnerability.

For detailed information, refer to:

Workarounds

  • Implement application-level input validation to limit nesting depth before passing data to xgrammar
  • Deploy a web application firewall (WAF) rule to detect and block deeply nested payloads
  • Isolate xgrammar-dependent services in containers with restart policies to limit impact
  • Apply resource limits (ulimit) to constrain stack size and enable controlled failure
bash
# Example: Set stack size limit for xgrammar processes
ulimit -s 8192

# Example: Run xgrammar-dependent service with resource constraints
# Using systemd service configuration
# Add to service unit file:
# [Service]
# LimitSTACK=8388608

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.