Severity:

CRITICAL RISK

(9.1)

Input Validation / Routing Normalization Mismatch

CVE-2026-2880

Analyzed

Vulnerability type

Category:

Input Validation / Routing Normalization Mismatch

CWE:

CWE-20

Impact:

Authentication and Authorization Bypass

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

@fastify/middie versions prior to 9.2.0 contain an input validation flaw where path-scoped middleware (for example, app.use('/secret', auth)) can be bypassed under certain router normalization settings.

When Fastify routing options like ignoreDuplicateSlashes, useSemicolonDelimiter, or related trailing-slash behaviors are enabled, specially crafted request paths may skip authentication/authorization middleware while still reaching handlers that are assumed to be protected.

Affected context

The issue affects Node.js applications that:

  • Use @fastify/middie for Express-style middleware in Fastify
  • Attach security-sensitive middleware using path prefixes (e.g., app.use('/admin', auth))
  • Enable Fastify router normalization options such as:
  • ignoreDuplicateSlashes
  • useSemicolonDelimiter
  • Trailing slash normalization and related behaviors

In these setups, the routing layer and the middleware path matching can disagree on what constitutes the same URL path, creating a gap where some requests reach protected routes without passing through the intended middleware.

Exploit preconditions

  • Attack surface: HTTP(S) endpoints served by Fastify using @fastify/middie
  • Required access: Network access to the affected routes; no prior authentication is required if the bypass targets initial auth checks
  • Trigger point: A request path crafted to be normalized by Fastify routing into a protected path (e.g., /secret) while not matching the middleware's path-scoped configuration (e.g., app.use('/secret', auth))
  • Why exploitation is possible: Middleware path matching and Fastify router normalization apply different interpretations of equivalent paths. This mismatch allows requests to bypass path-scoped middleware while still being routed to handlers that assume middleware has already run.

Why this happens

The vulnerability stems from inconsistent input handling between the Fastify router's path normalization logic and @fastify/middie's path-based middleware matching.

When options like ignoreDuplicateSlashes, useSemicolonDelimiter, or trailing slash normalization are enabled, the router may treat multiple syntactic variants of a URL as the same logical route. However, @fastify/middie evaluates middleware scope against the raw or differently processed path. This discrepancy is an example of CWE-20: Improper Input Validation, where the system fails to apply a consistent, canonical representation of inputs across components, leading to security checks being applied in one interpretation but not another.

Potential impact

  • Requests may bypass authentication middleware and reach endpoints that assume users are logged in.
  • Authorization checks implemented as path-scoped middleware can be skipped, exposing restricted operations or data.
  • Security logging, rate limiting, or CSRF protection implemented via middleware may not run for certain crafted paths.
  • Attackers can potentially access administrative panels, privileged APIs, or sensitive resources without proper credentials.

General mitigation guidance

Mitigation should focus on ensuring that security checks are not dependent on ambiguous or inconsistent path processing.

Recommended defensive patterns include:

  • Prefer route-level guards (e.g., Fastify hooks like onRequest or preHandler) or explicit per-route checks rather than relying solely on path-scoped middleware prefixes for critical authentication and authorization.
  • Normalize or canonicalize request paths once, early in the request lifecycle, and base all security decisions on this canonical form.
  • Align router and middleware configurations so that both use the same normalization semantics and constraints.
  • Centralize authentication/authorization logic in a single, well-defined layer that cannot be bypassed by path variations.
  • Use a deny-by-default approach for sensitive routes, requiring explicit checks for every access rather than relying on implicit middleware coverage.

How teams detect issues like this

Potential detection and validation approaches include:

  • Static analysis / code review:
  • Look for critical auth/authorization logic placed in @fastify/middie path-scoped middleware (e.g., app.use('/secret', auth)).
  • Flag combinations of @fastify/middie with Fastify router options like ignoreDuplicateSlashes, useSemicolonDelimiter, or custom trailing slash handling.
  • Review any assumptions that "everything under /admin goes through this middleware" and verify they hold under all path variants.
  • Dynamic testing / fuzzing:
  • Automatically generate path variations (duplicate slashes, semicolons, added trailing slashes, encoded separators) for protected routes and confirm middleware is invoked consistently.
  • Use integration tests that assert both route handler execution and associated middleware execution for sensitive endpoints.
  • Policy enforcement:
  • CI/CD checks that warn when path-scoped middleware is used for core security functions instead of route hooks or global guards.
  • Optional use of automated review tools configured to highlight routing and middleware configuration mismatches.

Sources

SourceLink
github.comgithub.com/fastify/middie/security/advisories/GHSA-8p85-9qpw-fwgw

Frequently asked

questions

Yes. Any attacker with network access to the application can attempt to craft request paths that exploit the mismatch between router normalization and middleware path matching.

Typically no. The vulnerability specifically affects authentication/authorization middleware, so an unauthenticated attacker may be able to reach endpoints that are intended to be protected.

Move critical authentication and authorization checks into Fastify's route-level mechanisms (such as onRequest or preHandler hooks) or other centralized guard layers that see the same normalized path as the router, and ensure all security checks are based on a canonical request representation.

Design applications so that security decisions do not depend on ambiguous path parsing. Apply consistent input normalization across the stack, avoid relying solely on path prefixes for enforcing access control, and include automated tests that exercise multiple URL variants for protected routes.

Find out what's already
exploitable in your codebase.