Improper Authentication Affecting @fastify/express package, versions >=4.0.5 <4.0.10


Severity

Recommended
0.0
critical
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.87% (60th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Improper Authentication vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-FASTIFYEXPRESS-23050797
  • published30 Nov 2026
  • disclosed21 Nov 2026
  • creditkleju13

Introduced: 21 Nov 2026

NewCVE-2026-124626  (opens in a new tab)
CWE-287  (opens in a new tab)

How to fix?

Upgrade @fastify/express to version 4.0.10 or higher.

Overview

@fastify/express is an Express compatibility layer for Fastify

Affected versions of this package are vulnerable to Improper Authentication via the compileDynamicMountMatchers function, which compiles path-scoped Express middleware matchers using path-to-regexp. This library requires a non-empty value for a dynamic segment, while Fastify's router (find-my-way) accepts an empty parameter or wildcard value. When a route and an Express middleware mount share a dynamic pattern, a request with an empty segment (e.g., GET /tenant/) matches the Fastify route and runs the handler while the middleware mounted on that pattern is skipped entirely. On a scoped mount such as app.use('/tenant/:tenantId', authMiddleware), an unauthenticated request can therefore reach the protected handler.

Workaround

Enforce authentication in a Fastify hook (such as preHandler) that runs after the router has resolved the request, or mount the middleware on a static parent path (for example /tenant instead of /tenant/:tenantId) so that an empty dynamic segment cannot skip it.

CVSS Base Scores

version 4.0
version 3.1