
Cloud Vulnerability DB
A community-led vulnerabilities database
MCPSanitizer.sanitize() is also affected when the payload arrives as a JSON string with type: 'nosql'. Since safePatternTest cannot interrupt a running regex, the fix replaces the checks with a single linear pass. Fixed in 1.4.5 (#19). CVE requested; thanks again.ReDoS in NoSQL pattern detection: a crafted $regex value blocks the event loop.
The NoSQL injection detector in mcp-sanitizer is vulnerable to ReDoS. When it finds a MongoDB $regex operator, it runs the operator's value through several checks that decide whether the regex looks dangerous. Those checks are backtracking regexes that run with no timeout and no length limit, so a crafted string can freeze the Node.js event loop for tens of seconds. In practice the ReDoS guard is itself where the ReDoS lives.
This affects mcp-sanitizer 1.4.4 (npm). It maps to CWE-1333 and CWE-400. A single input of about 8 KB blocks the event loop for roughly 23 seconds, and the cost grows cubically (O(n^3), about ×8 each time the input doubles).
When the detector sees a $regex operator, src/patterns/nosql-injection.js calls _analyzeRegexComplexity(value) with the attacker controlled value (around line 410). That function (around line 609) tests the value against backtracking regexes such as:
/\([^)]*\*[^)]*\*[^)]*\)/
/\([^)]*\+[^)]*\+[^)]*\)/It runs them through testRegex() in src/utils/redos-safe-patterns.js (around line 215), which has no protection at all:
function testRegex (pattern, input) {
pattern.lastIndex = 0;
const result = pattern.test(input); // no timeout, no length cap
pattern.lastIndex = 0;
return result;
}The same file already defines safePatternTest(), which enforces a 10 ms timeout and a 10,000-character cap, but the detector never calls it. The detection path also applies no maxStringLength, so inputs well under 10,000 characters still reach the backtracking regexes.
The problem is reachable through the public exports detectAllPatterns, hasSecurityPatterns, analyzeSecurityPatterns, detectInjection, detectNoSQLInjection, hasNoSQLInjection and detectBulkNoSQLInjection. It does not affect MCPSanitizer.sanitize(), because that path blocks $-prefixed keys before any analysis runs.
The smallest change is to route _analyzeRegexComplexity() through the existing safePatternTest(), so the timeout and length cap apply. It would also help to cap the $regex value length before analysis, or to replace the detector regexes with linear time equivalents.
Reproduced on 2026-11-19 in an isolated, network container (Node 24):
const nosql = require('mcp-sanitizer/src/patterns/nosql-injection');
// Open paren, then many "a*", never closed: forces cubic backtracking
const mk = n => '(' + 'a*'.repeat(n);
for (const n of [500, 1000, 2000, 4000]) {
const payload = mk(n);
const t = process.hrtime.bigint();
nosql.detectNoSQLInjection({ $regex: payload }); // blocks here
const ms = Number(process.hrtime.bigint() - t) / 1e6;
console.log(payload.length, ms.toFixed(0), 'ms');
}
// Measured timings (length -> time):
// 1001 -> 58 ms
// 2001 -> 394 ms (x6.8)
// 4001 -> 2985 ms (x7.6)
// 8001 -> 23545 ms (x7.9) ~23.5 s, event loop blockedThis was found through static analysis and a local, isolated proof of concept. No third party data was accessed and nothing has been published. I'm proposing a private report now and public disclosure after a fix is released or about 90 days, whichever comes first. Happy to coordinate. Please credit me as the reporter (@gecr07, Gerardo Cruz) in the published advisory and CVE.
Reproduced on 2026-11-19 in an isolated, network-less container (Node 24):
const nosql = require('mcp-sanitizer/src/patterns/nosql-injection');
// Open paren, then many "a*", never closed: forces cubic backtracking
const mk = n => '(' + 'a*'.repeat(n);
for (const n of [500, 1000, 2000, 4000]) {
const payload = mk(n);
const t = process.hrtime.bigint();
nosql.detectNoSQLInjection({ $regex: payload }); // blocks here
const ms = Number(process.hrtime.bigint() - t) / 1e6;
console.log(payload.length, ms.toFixed(0), 'ms');
}
// Measured timings (length -> time):
// 1001 -> 58 ms
// 2001 -> 394 ms (x6.8)
// 4001 -> 2985 ms (x7.6)
// 8001 -> 23545 ms (x7.9) ~23.5 s, event loop blockedmcp-sanitizer exists to process untrusted input, such as MCP tool parameters and other LLM adjacent data. Any service that passes untrusted input to one of the affected detection functions can be stalled by a single crafted $regex value: about 8 KB of input pins one CPU core at 100% for roughly 23 seconds with the event loop fully blocked, and a longer value pushes that time higher. During that window the Node process serves no other requests, so this is a denial of service for the whole application, triggered by one small request.
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."