@fastify/middie vulnerable to middleware bypass via mount paths without a leading slash in prefixed plugins
Description
Impact
Inside a plugin registered with a prefix, Fastify joins a route path that does not start with / directly to the prefix: get('secret') under the prefix /api is served at /apisecret. Since 9.3.6 (GHSA-5p92-8765-9fv8), @fastify/middie puts a slash between the prefix and such a mount path instead, so use('secret', auth) is mounted on /api/secret. GET /apisecret then runs the route handler without the middleware, and use(':id', auth) with get(':id') is bypassed the same way by GET /api42.
Only route and mount paths written without a leading slash inside a prefixed plugin are affected.
Patches
Upgrade to @fastify/middie 9.3.10 or later.
Workarounds
Start route and mount paths with /, or enforce authentication in a Fastify hook (such as preHandler) that runs after the router has resolved the request.
References
- GHSA-5p92-8765-9fv8 (CVE-2026-112712), the prefix join fix that introduced this