GHSA-GCF6-J9M3-P97X
@fastify/middie vulnerable to path-scoped middleware bypass via request path matching mismatches
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-GCF6-J9M3-P97X divulgada · CVSS 9.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
`@fastify/middie` matches path-scoped middleware against its own reading of the request path, which can differ from the path Fastify's router (find-my-way) uses to dispatch. When the two disagree, the router routes a request to a handler that a middleware mount covers while middie skips that middleware, so an unauthenticated client reaches a handler that an authentication, authorization or rate-limiting middleware was meant to protect. No special configuration is required.
Three request forms trigger the mismatch. An empty parameter or wildcard value matches in find-my-way but not in middie's path-to-regexp mount, which needs at least one character, so `/tenant//admin` reaches a `/tenant/:id/admin` mount with `id` empty, `/user/` reaches `/user/:id`, and `/files/` reaches `/files/*path`; multiple parameters in one segment and plugin prefixes behave the same way. A request target that starts with `*`, such as `*admin`, is routed to `/admin` by find-my-way, which skips the first character of the path, while middie matches the target as sent. And a literal `%` in a mount path is kept encoded as `%25` by find-my-way but decoded once more by middie, so `/100%25` reaches a `/100%` mount that middie skips. All releases up to 9.3.7 are affected.
Patches
Upgrade to `@fastify/middie` 9.3.8 or later. middie now matches middleware against the path find-my-way routes: empty parameter and wildcard values are allowed, request targets that do not start with `/` other than the asterisk-form are rejected, and a literal `%` in a mount path is matched as the router keeps it encoded.
Workarounds
Enforce authentication in a Fastify hook (such as `preHandler`) that runs after the router has resolved the request, and base the decision on the matched route (`request.routeOptions.url`) rather than `request.url`. This covers all three vectors.
References
- delvedor/find-my-way#471
https://github.com/delvedor/find-my-way/pull/471, which stops find-my-way from routing a path that does not start with `/`. - GHSA-hx87-8wv7-pjv8
https://github.com/fastify/middie/security/advisories/GHSA-hx87-8wv7-pjv8, a middleware bypass of the same kind via absolute-form request targets.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@fastify/middie |
Sin parche | — | — | 9.3.6 afectada |
9.3.8Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/fastify/middie/security/advisories/GHSA-gcf6-j9m3-p97xLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
