@fastify/express v4.0.4 and earlier contains a path handling bug in the onRegister function that causes middleware paths to be doubled when inherited by child plugins. When a child plugin is registered with a prefix that matches a middleware path, the middleware path is prefixed a second time, causing it to never match incoming requests. This results in complete bypass of Express middleware security controls, including authentication, authorization, and rate limiting, for all routes defined within affected child plugin scopes. No special configuration or request crafting is required. Upgrade to @fastify/express v4.0.5 or later.
The bug is located in the onRegister function responsible for registering child plugins. When a child plugin is registered with a prefix matching the middleware path, the onRegister function duplicates this prefix, causing the middleware path to never match incoming HTTP requests. As a result, all routes defined within the scope of affected child plugins are handled without passing through configured middleware layers, such as authentication, authorization, or rate limiting.
An attacker can completely bypass authentication, authorization, and rate limiting mechanisms defined as Express middleware, gaining unauthorized access to protected resources and application functions.
The @fastify/express library should be updated to version 4.0.5 or newer.
@fastify/express in version 4.0.4 and earlier
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:NFastify Fastify\/express
APPFastify< 4.0.5
Related vulnerabilities
Pominięcie middleware w @fastify/express — obejście uwierzytelniania
Pominięcie uwierzytelnienia w @fastify/express via znormalizowane URL
Pominięcie rewrite prefiksu URL w @fastify/http-proxy – dostęp do ukrytych zasobów
Fastify/Middie: pominięcie middleware przez zakodowany slash w URL
Pominięcie uwierzytelnienia w @fastify/middie — brak dziedziczenia middleware