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 JavaScript fetch() and how to fix it

A critical Server-Side Request Forgery vulnerability in `popup.js` allowed attackers to inject malicious URLs from scraped webpages directly into fetch() calls, potentially accessing internal network resources and AWS metadata endpoints. The fix adds URL validation to ensure only HTTP/HTTPS protocols are used and blocks requests to private IP ranges and localhost addresses.

high

How NO_PROXY bypass via crafted URL happens in Node.js axios and how to fix it

A high-severity vulnerability (CVE-2026-42043) in axios versions prior to 1.15.1 allowed attackers to bypass NO_PROXY environment variable restrictions using specially crafted URLs. This meant HTTP requests intended to stay internal could be routed through an attacker-controlled proxy, potentially exposing sensitive data. The fix upgrades axios to version 1.15.1, which correctly validates URLs against NO_PROXY rules.

critical

How JSON request validation bypass happens in Node.js API handlers and how to fix it

A critical validation bypass in the `/api/agents/jobs` endpoint allowed attackers to send malformed JSON with arbitrary properties that could trigger prototype pollution or unexpected behavior. The fix added comprehensive validation checks including array detection and property existence verification to prevent malicious payloads from reaching downstream processing logic.

critical

How Server-Side Request Forgery happens in Node.js httpProxy.js and how to fix it

A critical Server-Side Request Forgery (SSRF) vulnerability was discovered in `hubcmdui/routes/httpProxy.js` where the `/proxy/test` endpoint passed a user-controlled `testUrl` parameter directly to `axios.get()` without any validation. An attacker could exploit this to probe internal infrastructure — including AWS metadata endpoints, Redis instances, and private network ranges. The fix introduces a strict URL validation function that blocks private IP ranges, loopback addresses, and non-HTTP(S)

critical

How Remote Configuration Injection happens in JavaScript fetch() and how to fix it

A critical vulnerability in `js/config.js` allowed attackers to inject malicious configuration data through DNS spoofing or man-in-the-middle attacks. The application fetched remote JSON configuration from GitHub without validating the response structure, enabling arbitrary code execution through crafted payloads. A single validation check now ensures only properly-formed configuration objects are accepted.

high

How missing Dependabot cooldown configuration happens in GitHub Actions and how to fix it

A high-severity vulnerability was discovered in the `.github/dependabot.yml` configuration file where no cooldown period was set for dependency updates. This exposed the Node.js library and its downstream consumers to potentially malicious or unstable packages immediately after publication. The fix adds a 7-day cooldown period to all package ecosystem entries, providing a critical safety buffer before accepting newly published package versions.