CVE-2026-135279: @fastify/express vulnerable to middleware bypass via empty route parameters in Express routers and sub-applications
@fastify/express is the plugin that lets an application run Express middleware and Express applications inside the Fastify web framework. In versions before 4.0.14, a request with an empty dynamic route parameter reaches a Fastify route handler while middleware mounted for that path inside an Express Router or sub-application is skipped, because Fastify's router accepts an empty value where Express requires a non-empty one, and an unanchored regular-expression mount passed to the plugin is bypassed the same way. An earlier fix covered only the mount paths passed to the plugin directly, not middleware mounted inside a routed Express application. An attacker can use this to bypass authentication or other middleware-based access controls on the affected routes, with the practical impact depending on what the empty value selects in the application. The issue is fixed in @fastify/express 4.0.14, and users should upgrade to 4.0.14 or later. As a workaround, enforce authentication in a Fastify hook such as preHandler that runs after routing, mount the middleware on a static parent path, or require non-empty values in the route params schema.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/@fastify/expressto a version that resolves this vulnerability.Fixed in 4.0.14 - Configuration
Mount the middleware on a static parent path.
Express middleware mounted in @fastify/express mount path = static parent path - Configuration
Require non-empty values in the route params schema.
Fastify route route params schema = require non-empty values - Compensating control
Enforce authentication in a Fastify preHandler hook that runs after routing.
Event History
Frequently Asked Questions
Which deployments are exposed to this bypass?
Deployments using @fastify/express before 4.0.14 are affected when Express Router or sub-application middleware is mounted on paths containing dynamic parameters, or when an unanchored regular-expression mount is passed to the plugin. The practical exposure depends on whether an empty parameter can select a Fastify handler protected only by that skipped middleware.
What does an attacker need to send to exploit the issue?
An attacker must be able to make a network request to an affected route using an empty dynamic route parameter. No privileges or user interaction are required; the malformed path causes Fastify to reach its handler while Express middleware for that path is skipped.
How can this be mitigated before upgrading?
Enforce authentication in a Fastify preHandler hook that runs after routing, mount the middleware on a static parent path, or require non-empty parameter values in the route parameter schema. These measures prevent empty parameter values from bypassing middleware-based controls.
How can I determine whether my application may already be affected?
Check whether @fastify/express is below 4.0.14 and review Express Routers and sub-applications for middleware mounted beneath dynamic paths. Test whether requests with an empty value for those parameters reach a Fastify route handler without the expected authentication or other middleware running.