# GHSA-F9QF-HFC5-7XPJ: @fastify/express vulnerable to middleware bypass via empty route parameters in Express routers and sub-applications

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

## Tracked as

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

## Affected versions

- @fastify/express (npm): fixed in 4.0.14

## Description

### Impact

`@fastify/express` 4.0.10 rejects a request when an empty parameter or wildcard value would let it skip middleware mounted with `fastify.use()` on a dynamic path ([GHSA-662w-h4p6-jq4p](https://github.com/fastify/fastify-express/security/advisories/GHSA-662w-h4p6-jq4p)). That check only covers the mount paths passed to `fastify.use()`. Middleware mounted inside an Express Router or application that is itself passed to `fastify.use()`, which is how the README adds a complete Express application, is matched by Express with `path-to-regexp`, which requires a non-empty value for a dynamic segment, while Fastify's router (find-my-way) accepts an empty one.

A request with an empty value therefore reaches the Fastify route handler while the middleware is skipped. For example, `GET /tenants//admin` runs the handler for `/tenants/:tenant/admin` without `router.use('/tenants/:tenant/admin', auth)`, `GET /files/` runs the handler for `/files/*` without `router.all('/files/*path', auth)`, and `GET /reports/2026-` runs the handler for `/reports/:year-:month` without a mount on the same pattern. The same check also misses a RegExp mount passed to `fastify.use()` that is not anchored: it tests the pattern anywhere in the path, while Express only runs a RegExp mount whose match starts the path, so with `fastify.use(/\/users\/[^/]+/, auth)`, `GET /users//users/x` runs the handler for `/users/:id/*` without the middleware. 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.14 or later.

### Workarounds

Enforce authentication in a Fastify hook (such as `preHandler`) that runs after the router has resolved the request, mount the middleware on a static parent path (for example `router.use('/tenants', auth)`), or require non-empty values in the route's `params` schema (`minLength: 1`) so that an empty value is rejected before the handler runs.

### References

- [GHSA-662w-h4p6-jq4p](https://github.com/fastify/fastify-express/security/advisories/GHSA-662w-h4p6-jq4p) (CVE-2026-124626), the same bypass for mount paths passed to `fastify.use()`

## References

- https://github.com/fastify/fastify-express/security/advisories/GHSA-f9qf-hfc5-7xpj

Page: https://cve.now/GHSA-F9QF-HFC5-7XPJ

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
