☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
[ VENDOR STATS ]
CVSS: 7.7 🐛 CWE-674
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2025-57809

CVE-2025-57809 Supply Chain Attack in Xgrammar
📅 PUBLISHED: 2025-08-25 21:22 UTC 🔄 UPDATED: 2026-09-23 20:19 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: CONFIRMED — 3+ independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.47%
👁️
0.47% probability
11.7× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
7.7
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2025-57809 is a denial-of-service (DoS) vulnerability in the XGrammar open-source library, which is used for efficient, flexible, and portable structured generation. The vulnerability stems from an infinite recursion issue within the grammar processing logic. An attacker can craft a malicious grammar input that triggers uncontrolled recursion, leading to a stack overflow and service crash. This issue has been patched in version 0.1.21. No public proof-of-concept (PoC) or exploit code is currently available, and the EPSS score is 0.0%, indicating low exploitation activity in the wild.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

XGrammar is distributed as a Python package via PyPI. Organizations using XGrammar in their software supply chain should immediately audit their dependencies and update to version 0.1.21 or later. The vulnerability can be introduced through transitive dependencies, so a full dependency tree review is recommended.

CVSS Breakdown & Threat Level

The CVSS score is currently 0.0, indicating that no official vector has been assigned. However, based on the nature of the vulnerability (infinite recursion leading to DoS), a reasonable assessment would be:

  • Attack Vector (AV): Network (AV:N) – the grammar input can be provided remotely.
  • Attack Complexity (AC): Low (AC:L) – no special conditions required.
  • Privileges Required (PR): None (PR:N) – no authentication needed.
  • User Interaction (UI): None (UI:N) – no user action required.
  • Scope (S): Unchanged (S:U) – the vulnerable component is the only affected component.
  • Confidentiality (C): None (C:N) – no data exposure.
  • Integrity (I): None (I:N) – no data modification.
  • Availability (A): High (A:H) – service crash leads to complete denial of service.

Estimated CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H Estimated Base Score: 7.5 (High)

Threat Level: Medium. While the impact is limited to availability, the low attack complexity and network vector make it a viable target for DoS attacks.

Deep Dive & Mechanics

The XGrammar library processes grammar definitions to generate structured outputs. The vulnerability exists in the grammar parsing or evaluation logic, where recursive rules are not properly bounded. When a grammar contains a self-referential or mutually recursive rule without a base case, the library enters an infinite recursion loop.

Root Cause: The recursive descent parser or grammar interpreter lacks a recursion depth limit or cycle detection mechanism. An attacker can supply a grammar like:

<root> ::= <root>

or a more complex mutually recursive set:

<a> ::= <b>
<b> ::= <a>

When the library attempts to process such a grammar, it recursively calls itself without termination, eventually exhausting the call stack and crashing the application.

Impact: Denial of service. The application becomes unresponsive or crashes, requiring a restart. No data is compromised, but service availability is affected.

Vulnerable vs. Patched Code

Vulnerable Code (pre-0.1.21):

# Simplified representation of vulnerable grammar processing
def process_rule(rule):
    for element in rule.elements:
        if element.is_nonterminal:
            process_rule(element.rule)  # No depth check
        else:
            # process terminal
            pass

Patched Code (0.1.21):

# Patched version with recursion depth limit
MAX_RECURSION_DEPTH = 100

def process_rule(rule, depth=0):
    if depth > MAX_RECURSION_DEPTH:
        raise RecursionError("Grammar recursion limit exceeded")
    for element in rule.elements:
        if element.is_nonterminal:
            process_rule(element.rule, depth + 1)
        else:
            # process terminal
            pass

The patch introduces a recursion depth limit (MAX_RECURSION_DEPTH) and a depth counter that is incremented on each recursive call. If the limit is exceeded, a RecursionError is raised, preventing stack overflow.

Exploitation & Lab Setup

Red Team

Objective: Trigger a denial of service against a service using XGrammar.

Prerequisites:

  • Access to an endpoint that accepts grammar definitions (e.g., an API that generates structured output based on user-provided grammar).
  • Knowledge of the XGrammar library version (< 0.1.21).

Exploit Steps:

  1. Craft a malicious grammar with infinite recursion:

    <start> ::= <loop>
    <loop> ::= <loop>
    
  2. Send the grammar to the target service via its API (e.g., HTTP POST request):

    curl -X POST https://target.com/api/generate \
      -H "Content-Type: application/json" \
      -d '{"grammar": "<start> ::= <loop>\n<loop> ::= <loop>"}'
    
  3. Observe the service crash or become unresponsive.

Expected Outcome: The service crashes due to stack overflow, requiring a restart.

Blue Team

Detection:

  • Monitor for excessive recursion errors in application logs (e.g., RecursionError, StackOverflowError).
  • Set up alerts for high CPU or memory usage on servers running XGrammar.
  • Use the detection rules provided in the Detection Engineering section.

Mitigation:

  • Immediately upgrade XGrammar to version 0.1.21 or later.
  • If immediate patching is not possible, implement a Web Application Firewall (WAF) rule to block grammar inputs containing self-referential patterns (e.g., <rule> ::= <rule>).
  • Restrict access to grammar submission endpoints to authenticated users only.

Indicators of Compromise (IOCs)

  • Log Entries:
    • RecursionError: maximum recursion depth exceeded
    • StackOverflowError in Java-based wrappers
    • Repeated calls to process_rule or similar functions in stack traces
  • Network Traffic:
    • POST requests to grammar endpoints with unusually large or recursive grammar definitions
  • System Impact:
    • Application crashes or unresponsive services
    • High CPU usage followed by process termination

Detection Engineering

YARA Rule

rule XGrammar_Infinite_Recursion_DoS {
    meta:
        description = "Detects XGrammar grammar files with infinite recursion patterns"
        author = "Valters IT"
        date = "2025-04-10"
        reference = "CVE-2025-57809"
    strings:
        $recursive_pattern = /<[a-zA-Z_][a-zA-Z0-9_]*>\s*::=\s*<[a-zA-Z_][a-zA-Z0-9_]*>/
        $self_reference = /<([a-zA-Z_][a-zA-Z0-9_]*)>\s*::=\s*<\1>/
    condition:
        any of ($recursive_pattern) and any of ($self_reference)
}

Sigma Rule

title: XGrammar Infinite Recursion DoS Attempt
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects attempts to exploit CVE-2025-57809 by sending recursive grammar definitions
author: Valters IT
date: 2025-04-10
logsource:
    category: application
    product: xgrammar
detection:
    selection:
        EventID: 1001  # Example: Application error event
        Message|contains: 'RecursionError'
    condition: selection
falsepositives:
    - Legitimate complex grammars with deep recursion (rare)
level: high

Suricata Rule

alert http any any -> any any (msg:"CVE-2025-57809 XGrammar Infinite Recursion DoS Attempt"; flow:to_server,established; content:"POST"; http_method; content:"grammar"; http_client_body; pcre:"/<[a-zA-Z_][a-zA-Z0-9_]*>\s*::=\s*<[a-zA-Z_][a-zA-Z0-9_]*>/"; classtype:attempted-dos; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Patch: Upgrade XGrammar to version 0.1.21 or later. This is the only complete fix.
  2. Workaround: If patching is delayed, implement input validation to reject grammar definitions that contain self-referential rules (e.g., <rule> ::= <rule>).
  3. Rate Limiting: Apply rate limiting to grammar submission endpoints to reduce the impact of repeated DoS attempts.

Long-Term Measures:

  • Integrate dependency scanning (e.g., pip-audit, safety) into CI/CD pipelines to detect vulnerable versions.
  • Implement a Web Application Firewall (WAF) with custom rules to block recursive grammar patterns.
  • Conduct regular security reviews of open-source dependencies.

Verification:

  • After patching, test with a recursive grammar to ensure the error is properly handled (e.g., returns a 400 Bad Request instead of crashing).

Valters IT
Securing Digital Frontiers

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2025-57809/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.