
Cloud Vulnerability DB
A community-led vulnerabilities database
maxParamLength is documented as a guard against ReDoS, but for regex parametric routes (/:id(<regex>)) find-my-way runs the route's regular expression on the full, unbounded path segment and only checks the length of the captured groups afterwards. When the regex does not match, the length check is never reached. An attacker can therefore send an arbitrarily long segment to a route whose regex backtracks badly and block the event loop, regardless of the configured maxParamLength.
Plain parametric routes (/:id) are not affected: their length is checked before anything else.
Both lookup paths have the same ordering problem:
index.js, Router.prototype.find): currentNode.regex.exec(param) is executed first; matchedParam.length > maxParamLength is only evaluated when the regex matched.lib/compiler.js, emitRegexChild): the generated code calls regex.exec(value) and compares capture-group lengths to maxParamLength only inside the !== null branch.safe-regex2 accepts patterns such as ^(a|aa)+$, so these routes register without needing allowUnsafeRegex.
The regression was introduced in v6.0.0. v5.x checked the segment length before running the regex.
const FindMyWay = require('find-my-way')
const router = FindMyWay({ maxParamLength: 10 })
router.on('GET', '/regex/:id(^(a|aa)+$)', () => {})
const url = '/regex/' + 'a'.repeat(38) + '!'
const t = Date.now()
router.find('GET', url) // null, after several seconds of backtracking
console.log(Date.now() - t, 'ms')Locally, on main (9.10.0), a 33-byte segment takes about 100 ms and each added character multiplies the time by roughly 1.6, in both interpreter and compileRoutes() mode. The original Fastify report measured about 8.3 s for a 40-byte segment with maxParamLength: 10, compared with about 20 ms for a 414 on a normal parametric route of the same length.
Denial of service. One request can block the Node.js event loop for seconds, and a few concurrent requests can make the service unavailable. Exploitation requires the application to define a regex route whose pattern backtracks badly, but maxParamLength (and Fastify's routerOptions.maxParamLength) is documented to bound this and does not.
Check the raw segment length against maxParamLength before calling regex.exec() in both the interpreter and the compiled matcher.
Originally reported to Fastify by @vinzabe in GHSA-q52c-7jrj-qxgx.
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."