@fastify/express vulnerable to middleware bypass via nested arrays of mount paths
Description
Impact
Express accepts nested arrays of mount paths and flattens them, so fastify.use([ADMIN_PATHS, '/billing'], auth) with const ADMIN_PATHS = ['/admin', '/settings'] mounts the middleware on all three paths. @fastify/express only rewrites the top level of the array (GHSA-3wf5-7852-vcfq): the paths in a nested array are not prefixed in a plugin registered with a prefix, so the middleware never runs for GET /api/admin/users, and a nested RegExp keeps its g or y flag, so Express matches it statefully and skips the middleware on every other request. A nested RegExp is also not matched case-insensitively with caseSensitive: false, and nested dynamic paths are not covered by the empty-segment check of GHSA-662w-h4p6-jq4p.
Patches
Upgrade to @fastify/express 4.0.14 or later.
Workarounds
Flatten mount path arrays before passing them to fastify.use() (fastify.use([...ADMIN_PATHS, '/billing'], auth)), or enforce authentication in a Fastify hook (such as preHandler) that runs after the router has resolved the request.
References
- GHSA-3wf5-7852-vcfq (CVE-2026-6556), the non-string mount path fix