Empty Route Parameters Broke the Middleware Assumption in @fastify/express
Two routers can agree on a path pattern and disagree on whether a parameter may be empty. CVE-2026-135279 affected @fastify/express before 4.0.14 because Fastify accepted an empty dynamic route value while Express middleware mounted for that path treated the parameter as requiring content.
The bypass
The CVE record says an empty dynamic route parameter could reach a Fastify route handler while middleware inside an Express Router or sub-application was skipped. An unanchored regular-expression mount passed to the plugin could be bypassed in the same way. An earlier fix covered mounts passed directly to the plugin but not middleware inside a routed Express application.
The result is an interpretation conflict. Authentication and access-control middleware can run in Express while a route is eventually dispatched through Fastify. If one layer routes the request and another decides which security code applies, an empty value becomes a policy difference.
Impact
The advisory assigns CVSS 3.1 a base score of 9.1 with no privileges or user interaction. The practical outcome depends on the application. An empty parameter might select a default tenant, a public route, a parent resource, or a handler that assumes earlier middleware already authenticated the caller.
A generic score cannot tell an operator whether a particular route is sensitive. That requires a route inventory and an understanding of which middleware was mounted inside Express sub-applications. Applications that keep authentication only in the Express layer are the highest priority.
Remediation
Upgrade @fastify/express to 4.0.14 or later. The vendor lists three workarounds for deployments that cannot update immediately: enforce authentication in a Fastify hook such as preHandler that runs after routing, mount middleware on a static parent path, or require non-empty values in the route parameter schema.
The workarounds are useful because they move the decision to the router that will dispatch the request. They should be tested across every mounted application and regex path, including paths that were added after the first fix.
Testing the composition
Build a route inventory for the application. Record the Fastify route, Express mount, middleware chain, parameter schema, and final handler. Send an empty dynamic parameter and confirm that authentication still executes and authorization still examines the normalized request.
Test a regular-expression mount with an empty path segment. Test parent and child applications separately. Compare the decision in the Fastify hook with the decision in Express middleware. If the two disagree, the request should fail closed until the routing model is corrected.
Logs should include the matched route template rather than only the raw URL, plus the middleware decision and handler identity. Raw paths can differ in encoding or empty segments and still resolve to the same route.
Broader lesson
Framework composition creates security boundaries that are not obvious from either framework's documentation alone. Upgrading closes this specific mismatch. The durable control is to keep authorization after final route selection and to test the complete chain for empty, repeated, encoded, and default parameter values.
Top comments (0)