CVE-2026-129504: @fastify/express path-scoped middleware bypass can expose protected routes
@fastify/express 4.0.0 through 4.0.9 can silently skip path-scoped Express middleware when used inside a prefixed Fastify plugin, potentially exposing authentication/authorization-protected routes. Fixed in 4.0.10.
Overview
CVE-2026-129504 affects @fastify/express, the compatibility layer that lets Express middleware run inside Fastify. In versions 4.0.0 through 4.0.9, the plugin joins a path-scoped middleware's mount path to the Fastify plugin prefix using string concatenation. If the plugin prefix ends with a slash or the mount path omits its leading slash, the Express mount path no longer matches the route Fastify serves. Express then passes the request through without running the middleware, while Fastify still dispatches the route.
This means path-scoped Express middleware used for authentication or authorization inside a prefixed plugin can be silently skipped. No crafted request or non-default option is required. String, array, and regular-expression mount paths are all affected.
Affected versions
- @fastify/express 4.0.0 through 4.0.9
Fixed versions
- @fastify/express 4.0.10 and later
References
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-129504 - OpenJS Foundation advisory listing: https://cna.openjsf.org/security-advisories.html - GitHub advisory: https://github.com/fastify/fastify-express/security/advisories/GHSA-f44m-4qwg-5587
What to do
1. Upgrade @fastify/express to 4.0.10 or later in all Node.js services that use Fastify with Express middleware. 2. If you cannot upgrade immediately, audit any prefixed Fastify plugin that relies on path-scoped Express middleware for authentication or authorization, and verify that the middleware is actually being invoked for protected routes. 3. Review the vendor advisory and NVD entry before changing production, and confirm the exact fixed version matches your package manager's resolved version. 4. As a temporary mitigation, avoid relying on path-scoped Express middleware inside prefixed plugins until the upgrade is complete; consider applying middleware at the Fastify route level or using Fastify-native hooks. 5. After upgrading, run tests that exercise protected routes both with and without valid credentials to confirm the middleware is enforced.