CVE-2026-132131: @fastify/middie path-scoped middleware bypass (auth/rate-limit skip)
@fastify/middie 8.3.0 through 9.3.6 mishandles array mount paths, causing path-scoped middleware to be skipped for subroutes. Fixed in 9.3.7. Upgrade or apply the preHandler workaround.
Overview
CVE-2026-132131 affects @fastify/middie, the middleware engine that adds Express/Connect-style middleware support to Fastify. In versions 8.3.0 through 9.3.6, the internal mount-path normalization helper only handles string inputs. When use() is called with an array of mount paths, the array is passed through unchanged, so normalization is skipped.
This leads to two failure modes:
- A trailing slash on an array element survives into the generated route-matching regular expression. - An element exactly equal to the root path (/) is dropped entirely, meaning a catch-all mount is lost.
As a result, requests to subroutes of the affected mount paths skip the path-scoped middleware (e.g. authentication, authorization, rate limiting), while Fastify's router still dispatches those requests to the handler. This can allow unauthenticated clients to reach protected routes.
Applications are affected when they mount middleware on an array of paths where an element ends with a slash (including a plugin prefix that ends with a slash) or is exactly the root path.
The issue is fixed in @fastify/middie 9.3.7. No exploitation in the wild is noted in the provided sources, but the security impact is high because it can bypass authentication/authorization controls.
What to do
1. Upgrade @fastify/middie to 9.3.7 or later in all affected applications. This is the primary fix. 2. If you cannot upgrade immediately, review all use() calls that pass an array of mount paths. Remove any trailing slashes from array elements and do not use / as a catch-all element for security-relevant middleware. 3. As a workaround, enforce authorization in a Fastify hook such as preHandler that runs after routing, rather than relying solely on path-scoped middleware. 4. Audit logs and access patterns for requests that reached protected routes without passing through expected middleware, especially if you were on an affected version. 5. Verify the vendor advisory before changing production: see the GitHub Security Advisory GHSA-hfwp-44m5-9364 and the OpenJS Foundation CNA advisory linked from the NVD entry.
References
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-132131 - GitHub Security Advisory: https://github.com/fastify/middie/security/advisories/GHSA-hfwp-44m5-9364 - OpenJS Foundation CNA: https://cna.openjsf.org/security-advisories.html