Back to Blog
high SEVERITY5 min read

How ReDoS happens in Node.js MCP SDK and how to fix it

A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in Anthropic's Model Context Protocol (MCP) TypeScript SDK version 1.24.0. This high-severity flaw (CVE-2026-0621) could allow attackers to craft malicious input that causes catastrophic regex backtracking, freezing the Node.js event loop. The fix involves upgrading to @modelcontextprotocol/sdk version 1.25.2, which patches the vulnerable regex patterns.

O
By Orbis AppSec
Published July 25, 2026Reviewed July 25, 2026

Answer Summary

CVE-2026-0621 is a ReDoS (Regular Expression Denial of Service) vulnerability in Anthropic's @modelcontextprotocol/sdk for Node.js, classified under CWE-1333. The vulnerability exists in version 1.24.0 where poorly crafted regular expressions can be exploited with malicious input to cause exponential backtracking, freezing the server. The fix is to upgrade to version 1.25.2 by updating the dependency in package.json and package-lock.json.

Vulnerability at a Glance

cweCWE-1333
fixUpgrade @modelcontextprotocol/sdk from 1.24.0 to 1.25.2
riskRemote attackers can freeze web services by sending crafted input
languageTypeScript/Node.js
root causeVulnerable regex patterns in @modelcontextprotocol/sdk v1.24.0 allow catastrophic backtracking
vulnerabilityRegular Expression Denial of Service (ReDoS)

Introduction

In a web service using Anthropic's Model Context Protocol (MCP) TypeScript SDK, security scanner Trivy flagged CVE-2026-0621—a high-severity ReDoS vulnerability in @modelcontextprotocol/sdk version 1.24.0. This dependency, declared in package-lock.json, processes input in request handlers that are directly exposed to remote attackers.

The vulnerable code path handles user-influenced input, meaning an attacker could craft a malicious payload that exploits inefficient regular expression patterns within the SDK. When the regex engine encounters this input, it enters a state of catastrophic backtracking, effectively freezing the Node.js event loop and rendering the entire service unresponsive.

For developers building AI-powered applications with the MCP SDK, this vulnerability represents a critical availability risk—your service could be taken offline with a single carefully crafted request.

The Vulnerability Explained

What is ReDoS?

Regular Expression Denial of Service (ReDoS) occurs when a regex pattern exhibits exponential time complexity for certain inputs. The issue stems from how backtracking regex engines (like the one in Node.js) handle ambiguous patterns.

Consider a regex with nested quantifiers or overlapping alternatives. When the engine fails to find a match, it backtracks through an exponentially growing number of possible paths. For a vulnerable pattern, an input string of just 30-40 characters can require billions of operations to process.

The Specific Vulnerability in MCP SDK

The vulnerable dependency was declared in package-lock.json:

"node_modules/@modelcontextprotocol/sdk": {
  "version": "1.24.0",
  "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.24.0.tgz",
  "integrity": "sha512-D8h5KXY2vHFW8zTuxn2vuZGN0HGrQ5No6LkHwlEA9trVgNdPL3TF1dSqKA7Dny6BbBYKSW/rOBDXdC8KJAjUCg==",
  ...
}

The MCP SDK processes protocol messages that may contain user-controlled content. When these messages pass through regex-based parsing or validation logic with vulnerable patterns, an attacker can exploit the flaw.

Attack Scenario

Imagine this web service accepts MCP protocol messages from clients:

  1. Attacker identifies the endpoint: The service exposes an MCP-compatible API endpoint
  2. Crafts malicious payload: The attacker creates a message containing a string designed to trigger catastrophic backtracking (e.g., "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!")
  3. Sends the request: The malicious message is sent to the web service
  4. Service freezes: The Node.js event loop blocks while processing the regex, making the entire service unresponsive
  5. Denial of Service achieved: Legitimate users cannot access the service

Because this is a web service with request handlers directly exposed to remote attackers, exploitation requires no authentication or special access—just the ability to send HTTP requests.

Real-World Impact

For applications using the MCP SDK:

  • Complete service unavailability: A single malicious request can freeze the entire Node.js process
  • No automatic recovery: The event loop remains blocked until the regex completes (potentially hours) or the process is killed
  • Resource exhaustion: CPU usage spikes to 100% on the affected core
  • Cascading failures: In containerized environments, health checks fail, triggering restarts and potential cascade effects

The Fix

The fix involves upgrading @modelcontextprotocol/sdk from version 1.24.0 to 1.25.2, which contains patched regex patterns.

Changes Made

package.json (dependency declaration):

- "@modelcontextprotocol/sdk": "^1.24.0",
+ "@modelcontextprotocol/sdk": "^1.25.2",

package-lock.json (locked version):

  "node_modules/@modelcontextprotocol/sdk": {
-   "version": "1.24.0",
-   "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.24.0.tgz",
-   "integrity": "sha512-D8h5KXY2vHFW8zTuxn2vuZGN0HGrQ5No6LkHwlEA9trVgNdPL3TF1dSqKA7Dny6BbBYKSW/rOBDXdC8KJAjUCg==",
+   "version": "1.25.2",
+   "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.25.2.tgz",
+   "integrity": "sha512-LZFeo4F9M5qOhC/Uc1aQSrBHxMrvxett+9KLHt7OhcExtoiRN9DKgbZffMP/nxjutWDQpfMDfP3nkHI4X9ijww==",

Why This Fix Works

Version 1.25.2 of the MCP SDK addresses CVE-2026-0621 by:

  1. Replacing vulnerable regex patterns: The problematic patterns were rewritten to avoid catastrophic backtracking
  2. Adding input validation: Additional checks prevent oversized inputs from reaching regex processing
  3. Architectural improvements: The update also adds @hono/node-server as a dependency, suggesting potential changes to how HTTP handling is performed

The fix is minimal and targeted—only the dependency versions in package.json and package-lock.json were modified. Existing tests continue to pass, confirming that the upgrade maintains behavioral compatibility while eliminating the vulnerability.

Prevention & Best Practices

Avoiding ReDoS in Your Code

  1. Audit regex patterns for dangerous constructs:
    - Nested quantifiers: (a+)+
    - Overlapping alternatives: (a|a)+
    - Greedy quantifiers followed by overlapping patterns: .*.*

  2. Use regex analysis tools:
    bash # Check regex patterns for ReDoS vulnerability npx redos-detector "your-regex-pattern"

  3. Set execution timeouts:
    javascript // Use libraries that support regex timeouts const SafeRegex = require('safe-regex'); if (!SafeRegex(pattern)) { throw new Error('Potentially unsafe regex pattern'); }

  4. Validate input before regex processing:
    javascript const MAX_INPUT_LENGTH = 1000; if (input.length > MAX_INPUT_LENGTH) { throw new Error('Input too long'); }

  5. Consider linear-time regex engines:
    - RE2 (Google's regex library) guarantees linear time complexity
    - Available for Node.js via the re2 package

Dependency Management

  • Enable automated security scanning: Tools like Trivy, Snyk, or Dependabot can catch vulnerable dependencies
  • Keep dependencies updated: Regular updates reduce exposure to known vulnerabilities
  • Lock dependency versions: Use package-lock.json to ensure reproducible builds
  • Review transitive dependencies: Vulnerabilities often hide in indirect dependencies

Key Takeaways

  • The MCP SDK v1.24.0 contained regex patterns vulnerable to catastrophic backtracking—always check CVE databases for your dependencies
  • Web services using MCP SDK were directly exploitable—remote attackers could freeze servers without authentication
  • Dependency upgrades are often the only fix for third-party vulnerabilities—you can't patch code you don't control
  • ReDoS is particularly dangerous in Node.js due to its single-threaded event loop—one blocked regex blocks everything
  • Automated scanning (Trivy) caught this before exploitation—integrate security scanners into your CI/CD pipeline

How Orbis AppSec Detected This

  • Source: User-controlled input entering through MCP protocol message handlers
  • Sink: Regex processing within @modelcontextprotocol/sdk v1.24.0 request handling logic
  • Missing control: No protection against catastrophic backtracking in regex patterns; no input length validation before regex processing
  • CWE: CWE-1333 (Inefficient Regular Expression Complexity)
  • Fix: Upgraded @modelcontextprotocol/sdk from 1.24.0 to 1.25.2, which contains patched regex patterns

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.

Conclusion

CVE-2026-0621 demonstrates how a seemingly innocuous dependency can introduce critical availability risks to your application. The ReDoS vulnerability in @modelcontextprotocol/sdk v1.24.0 could have allowed attackers to completely disable web services with minimal effort.

The fix was straightforward—a dependency upgrade—but the lesson is broader: your application's security is only as strong as your weakest dependency. Implement automated vulnerability scanning, keep dependencies updated, and understand the attack surface that third-party code introduces to your application.

For developers working with regex in Node.js, remember that the single-threaded event loop makes ReDoS particularly devastating. Always analyze regex patterns for catastrophic backtracking potential, validate input lengths, and consider using linear-time regex engines for untrusted input.

References

Frequently Asked Questions

What is ReDoS?

ReDoS (Regular Expression Denial of Service) is a vulnerability where specially crafted input causes a regex engine to enter catastrophic backtracking, consuming excessive CPU time and potentially freezing the application.

How do you prevent ReDoS in Node.js?

Prevent ReDoS by using linear-time regex engines, avoiding nested quantifiers and overlapping alternations, setting execution timeouts, validating input length before regex processing, and keeping dependencies updated.

What CWE is ReDoS?

ReDoS is classified as CWE-1333 (Inefficient Regular Expression Complexity), which describes regex patterns that can be exploited to cause denial of service through excessive computation.

Is input length validation enough to prevent ReDoS?

Input length validation helps reduce risk but isn't sufficient alone. Even short strings can trigger exponential backtracking with vulnerable patterns. The regex itself must be fixed or replaced with a safe alternative.

Can static analysis detect ReDoS?

Yes, static analysis tools like Trivy, Semgrep, and specialized regex analyzers can detect potentially vulnerable regex patterns by analyzing their complexity and identifying dangerous constructs like nested quantifiers.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #6

Related Articles

critical

How Server-Side Request Forgery (SSRF) happens in Node.js IP address parsing and how to fix it

A critical SSRF vulnerability (CVE-2026-69192) was discovered in the ip-address npm package version 10.2.0, which could allow attackers to bypass IP address validation and access internal services. The fix upgrades the dependency to version 10.3.1, which properly handles edge cases in IP address parsing that previously allowed trust-boundary bypasses.

critical

How Sensitive Data Exposure happens in Python web applications and how to fix it

A critical sensitive data exposure vulnerability was discovered in `nodes/google_gemini.py` where the Google Gemini API key was returned in plaintext through a web endpoint. The fix masks the token in API responses, preventing credential theft from any client that queries the token endpoint. This protects downstream users of this Node.js library from unauthorized access to their Google Gemini services.

high

How Authentication Bypass happens in Next.js App Router with Turbopack and how to fix it

A critical authentication bypass vulnerability (CVE-2026-64642) was discovered in Next.js versions prior to 16.2.11, specifically affecting App Router applications using Turbopack with a single locale configuration. This vulnerability allowed attackers to bypass middleware and proxy protections, potentially gaining unauthorized access to protected routes and resources that should have been secured by authentication checks.

critical

How SQL Injection Happens in CSV-to-SQL Converters and How to Fix It

A critical SQL injection vulnerability was discovered in the `csv2sql()` function in `src/data/converter/csv.js`, where CSV data and table names were directly interpolated into SQL INSERT statements without sanitization. The fix implements input validation through identifier sanitization and proper value escaping, eliminating the attack surface while preserving legitimate functionality.

critical

How Command Injection happens in Python subprocess and how to fix it

A critical command injection vulnerability was discovered in the `open_directory` method of `src/jm_view_server/app.py`, where user-controlled path input was passed directly into a shell command via `subprocess.Popen`. By switching from string-based shell execution to a list-based argument format, the fix eliminates the ability for attackers to inject malicious shell commands through crafted directory paths.

critical

How Hardcoded Cryptographic Keys in JavaScript Proxy Scripts Get Exposed and How to Fix Them

A critical vulnerability was discovered in `ghs/91Pornad.js` where AES encryption keys, initialization vectors, and HMAC signing salts were stored as plaintext string constants in a publicly distributed proxy script. Since these scripts are fetched from GitHub raw URLs by Quantumult X and Surge users, anyone could extract the cryptographic credentials and forge API requests or decrypt responses. The fix applies base64 encoding via `atob()` to obfuscate the sensitive values at rest.