CVE-2026-135264: @fastify/express vulnerable to middleware bypass via nested arrays of mount paths
@fastify/express is the plugin that lets an application run Express middleware and Express applications inside the Fastify web framework. In versions from 4.0.7 before 4.0.14, when middleware is mounted on a nested array of mount paths the plugin rewrites only the top level of the array, so paths inside a nested array are not adjusted for a plugin registered under a prefix and the middleware never runs for them, a nested regular-expression mount keeps its global or sticky flag and is matched statefully so it is skipped on alternating requests, a nested regular expression is not matched case-insensitively when case sensitivity is disabled, and nested dynamic paths are not covered by the earlier empty-segment check. An attacker can use any of these to bypass authentication or other middleware-based access controls on the affected routes. The issue is fixed in @fastify/express 4.0.14, and users should upgrade to 4.0.14 or later. As a workaround, flatten mount path arrays before passing them to the plugin, or enforce authentication in a Fastify hook such as preHandler that runs after the router resolves the request.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
@fastify/expressto a version that resolves this vulnerability.Fixed in 4.0.14 - Compensating control
Flatten mount path arrays before passing them to @fastify/express, or enforce authentication in a Fastify preHandler hook that runs after the router resolves the request.
Event History
Frequently Asked Questions
Which deployments are affected?
Deployments using @fastify/express versions 4.0.7 through 4.0.13 are affected when middleware is mounted using nested arrays of mount paths. The risk is particularly significant where that middleware enforces authentication or other access controls and the Fastify plugin is registered under a prefix.
What does an attacker need to exploit this issue?
An attacker only needs network access to send requests to affected routes; no credentials or user interaction are required. Exploitation depends on the application using one of the affected nested mount-path patterns, allowing the middleware to be skipped or inconsistently matched.
How can I mitigate the issue if I cannot upgrade immediately?
Flatten mount-path arrays before passing them to the plugin. Alternatively, enforce authentication in a Fastify hook such as preHandler, which runs after the router resolves the request.
How can I determine whether my application is exposed?
Check whether @fastify/express is version 4.0.7 through 4.0.13 and inspect middleware registrations for nested arrays of mount paths. Pay particular attention to nested regular expressions, dynamic paths, and middleware registered beneath a Fastify plugin prefix.