# GHSA-662W-H4P6-JQ4P: @fastify/express vulnerable to middleware bypass via empty route parameters and wildcards

- Database: GitHub
- Severity: CVSS 9.1 (Critical)
- Published: 2026-11-20
- Modified: 2026-11-20

## Tracked as

- [CVE-2026-124626](https://cve.now/CVE-2026-124626.md): Fastify Express auth bypass in middleware via empty route parameters

## Affected versions

- @fastify/express (npm): from 4.0.5, fixed in 4.0.10

## Description

### Impact

`@fastify/express` matches path-scoped Express middleware with `path-to-regexp`, which requires a non-empty value for a dynamic segment, while Fastify's router (find-my-way) accepts an empty parameter or wildcard. When a route and an Express middleware mount share a dynamic pattern, a request with an empty segment such as `GET /tenant/` or `GET /files/` matches the Fastify route and runs the handler while the middleware mounted on that pattern is skipped. On a scoped mount such as `app.use('/tenant/:tenantId', authMiddleware)`, an unauthenticated request can reach the protected handler. The default router configuration is sufficient. The practical impact depends on what the empty value selects in the application.

### Patches

Upgrade to `@fastify/express` 4.0.10 or later.

### Workarounds

Enforce authentication in a Fastify hook (such as `preHandler`) that runs after the router has resolved the request, or mount the middleware on a static parent path (for example `/tenant` instead of `/tenant/:tenantId`) so that an empty dynamic segment cannot skip it.

### References

- [GHSA-6h42-57hq-9746](https://github.com/fastify/fastify-express/security/advisories/GHSA-6h42-57hq-9746) (CVE-2026-112362), a related `@fastify/express` path-scoped middleware bypass
- [GHSA-3wf5-7852-vcfq](https://github.com/fastify/fastify-express/security/advisories/GHSA-3wf5-7852-vcfq) (CVE-2026-6556), a related `@fastify/express` middleware bypass via non-string mount paths

## References

- https://github.com/fastify/fastify-express/security/advisories/GHSA-662w-h4p6-jq4p

Page: https://cve.now/GHSA-662W-H4P6-JQ4P
