CVE-2026-135205 in middie
Summary
by MITRE • 11/26/2026
@fastify/middie is the plugin that adds Express-style middleware support to the Fastify web framework. In versions 9.3.6 through 9.3.9, a route or mount path written without a leading slash inside a plugin registered under a prefix is handled inconsistently: the middleware is mounted with a separating slash after the prefix, while the route is concatenated directly onto the prefix, so a request to the concatenated path reaches the route handler without running the middleware mounted for it. An attacker can use this to bypass authentication or other middleware-based access controls on the affected routes. The issue is fixed in @fastify/middie 9.3.10, and users should upgrade to 9.3.10 or later. As a workaround, begin all route and mount paths with a slash, or enforce authentication in a Fastify hook such as preHandler that runs after the router resolves the request.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/26/2026
The vulnerability identified in @fastify/middie versions 9.3.6 through 9.3.9 represents a critical logic error in path resolution and middleware mounting within the Fastify web framework ecosystem. This plugin serves as an adapter to enable Express-style middleware compatibility, allowing developers to integrate standard Node.js middleware into Fastify applications. The core flaw arises from inconsistent handling of route paths that lack a leading slash when registered inside plugins that are themselves mounted under a specific prefix. In this scenario, the middleware component is correctly prefixed with a separating slash relative to its mount point, whereas the route handler path is concatenated directly without such separation. This discrepancy creates a divergence in how incoming HTTP requests are matched against defined routes versus where middleware logic is actually executed.
From an operational perspective, this inconsistency leads to a significant security bypass mechanism. When a request targets a specific endpoint that was registered with a non-leading slash inside a prefixed plugin, the router successfully matches and executes the route handler. However, because of the path mismatch caused by the missing leading slash on the middleware side, the associated authentication or access control middleware is not invoked for that particular request. Consequently, an attacker can craft requests to these specific endpoints that bypass all middleware-based security checks, including authentication tokens, session validation, and authorization policies. This effectively allows unauthorized access to protected resources without valid credentials, undermining the entire security architecture of the application layer dependent on this plugin.
This vulnerability aligns with CWE-284 Improper Access Control, as it involves a failure in enforcing intended restrictions on user actions or data access due to flawed implementation logic rather than a lack of controls. Furthermore, from an adversary perspective, this technique corresponds to ATT&CK T1078 Valid Accounts if the attacker exploits existing credentials but bypasses additional layers, or more broadly to techniques involving privilege escalation through misconfigured application logic where security checks are skipped during request processing. The impact is severe because it allows direct access to backend functionality that should be guarded by middleware, potentially leading to data breaches, unauthorized administrative actions, or further exploitation of downstream vulnerabilities within the unprotected routes.
The issue has been resolved in version 9.3.10 and later releases of @fastify/middie through corrected path normalization logic that ensures consistent prefixing for both route handlers and their associated middleware regardless of whether a leading slash is present in the definition. To mitigate this risk immediately, organizations should upgrade to version 9.3.10 or any subsequent stable release. For environments where an immediate upgrade is not feasible, a recommended workaround involves strictly enforcing that all route and mount paths begin with a forward slash when defined within prefixed plugins. Alternatively, developers can implement security checks using Fastify hooks such as preHandler, which execute after the router has resolved the request path but before the final handler runs, thereby ensuring that authentication logic is applied consistently regardless of middleware mounting inconsistencies.