vLLM, Regular Expression Denial of Service (ReDoS), CVE-2023-XXXX (Critical)

Listen to this Post

How the CVE Works

The vulnerability arises from a poorly optimized regex pattern in vLLM’s pythonic_tool_parser.py. The regex `r”\[([a-zA-Z]+\w\(([a-zA-Z]+\w=.,\s)([a-zA-Z]+\w=.\s)?\),\s)([a-zA-Z]+\w\(([a-zA-Z]+\w=.,\s)([a-zA-Z]+\w=.\s)?\)\s)\]”` contains nested quantifiers and optional groups, leading to catastrophic backtracking. When processing malicious inputs like [A(A= )A(A=, )A(A=, )...], the regex engine enters exponential time complexity (O(2^N)), causing CPU exhaustion. This disrupts vLLM’s API, GPU memory retention, and overall service stability.

DailyCVE Form

Platform: vLLM
Version: Pre-fix versions
Vulnerability: ReDoS
Severity: Critical
Date: 2023-XX-XX

Prediction: Patch expected within 30 days.

What Undercode Say:

Exploit:

malicious_input = "[A(A=\t)A(A=,\t" 50 + "]" Triggers ReDoS
import re
regex = r"[([a-zA-Z]+\w(([a-zA-Z]+\w=.,\s)([a-zA-Z]+\w=.\s)?),\s)([a-zA-Z]+\w(([a-zA-Z]+\w=.,\s)([a-zA-Z]+\w=.\s)?)\s)]"
re.match(regex, malicious_input) CPU spikes

Mitigation:

  1. Regex Optimization: Replace with a non-backtracking parser (e.g., re2):
    import re2
    safe_regex = re2.compile(r"[([a-zA-Z]+\w([^)]))]") Linear time
    

2. Input Sanitization:

def sanitize_tool_input(input_str: str, max_length=100) -> bool:
if len(input_str) > max_length or "A(A=" in input_str:
raise ValueError("Suspicious input")

3. Rate Limiting:

Use Nginx to throttle requests
limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;

Detection:

Monitor CPU spikes (Linux)
top -b -n 1 | grep python | awk '{if ($9 > 90) print "ReDoS suspected"}'

Patch Analysis:

The fix (18454) reduced complexity to O(N²), but a full rewrite using AST parsing is recommended:

import ast
def validate_tool_calls(input_str: str) -> bool:
try:
ast.parse(input_str)
return True
except SyntaxError:
return False

GPU Memory Recovery:

Kill stuck processes holding GPU memory
nvidia-smi --query-compute-apps=pid --format=csv | xargs kill -9

References:

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image

Scroll to Top