@fastify/middie Middleware Authentication Bypass Vulnerability in Child Plugin Scopes

Vulnerability

A vulnerability exists in @fastify/middie versions through 9.3.1, where inherited middleware is not properly registered on child plugin instances. This issue allows unauthenticated requests to access routes in child plugins that should be protected by parent-scoped authentication middleware. The vulnerability arises because the middleware paths are incorrectly modified when passed to child plugins, causing the authentication checks to be bypassed. As a result, security controls such as authentication, authorization, and rate limiting are not enforced on affected routes.

Impact

Exploitation of this vulnerability leads to a complete bypass of authentication and authorization checks, allowing unauthenticated requests to access protected routes in child plugin scopes. This also affects any nested child scopes, creating a silent bypass of essential security controls without any errors or warnings.

Reproduction

To reproduce this vulnerability, create a Fastify application and register authentication middleware in the parent scope. Then, register a child plugin with a prefix that overlaps with the parent middleware. The child plugin's routes will bypass the authentication middleware, allowing unauthenticated access.

Remediation

Upgrade to @fastify/middie version 9.3.2 or later.

Added: Apr 16, 2026, 2:26 PM
Updated: Apr 16, 2026, 2:26 PM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
5.6
exploitability
8.7
remediation
0.0
relevance
6.0
threat
6.4
urgency
2.9
incentive
4.2

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.