# GHSA-HFWP-44M5-9364: @fastify/middie vulnerable to path-scoped middleware bypass via array mount-path type confusion

- Database: GitHub
- Severity: CVSS 7.4 (High)
- Published: 2026-11-18
- Modified: 2026-11-19

## Tracked as

- [CVE-2026-132131](https://cve.now/CVE-2026-132131.md): Fastify Middie auth bypass in path-scoped middleware

## Affected versions

- @fastify/middie (npm): fixed in 9.3.7

## Description

### Impact

`@fastify/middie` versions `<= 9.3.6` normalize a path-scoped middleware's mount path with the internal `sanitizePrefixUrl` helper, which is written for string inputs, but `use()` also accepts an array of mount paths and passes the array straight through. The string operations silently do nothing on an array, so a trailing slash on an element such as `/secret/` survives into the generated route-matching regular expression, and an element of exactly `/` (a catch-all mount) is dropped entirely. The compiled regex then fails to match subroutes such as `/secret/data`, so the path-scoped middleware (authentication, authorization, rate limiting) is skipped while Fastify's router still dispatches the request to the handler. On 8.0.0 through 9.0.0, which use path-to-regexp 6, the impact is narrower: subroutes such as `/secret/data` are still matched, only the mount root itself (for example `/secret`) is skipped, and a `/` element is dropped only when it is the last element of the array. An application is affected when it mounts middleware on an array of paths where an element carries a trailing slash, including one introduced by joining a plugin prefix that ends in `/`, or is exactly `/`. No authentication is required.

### Patches

Upgrade to `@fastify/middie` v9.3.7 or later.

### Workarounds

Enforce authorization in a Fastify hook (such as `preHandler`) that runs after the router has resolved the request. Avoid array mount paths with a trailing-slash element for security-relevant middleware.

## References

- https://github.com/fastify/middie/security/advisories/GHSA-hfwp-44m5-9364

Page: https://cve.now/GHSA-HFWP-44M5-9364
