/

CVE-2026-124626

Severity:

CRITICAL RISK

(9.1)

Authentication Bypass (CWE-287) in @fastify/express

CVE-2026-124626

Awaiting Analysis

Vulnerability type

Category:

Authentication Bypass

CWE:

CWE-287, CWE-436

Impact:

Unauthorized access to protected route handlers

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

A path-matching discrepancy in @fastify/express can cause a request with an empty dynamic path segment to reach a Fastify route while skipping Express middleware mounted on the matching pattern. If that middleware provides authentication or authorization, an unauthenticated request may reach a handler that it is meant to protect.

Affected context

The issue affects applications using @fastify/express versions 4.0.5 through 4.0.9, where Express middleware is mounted on a dynamic path pattern that overlaps with a Fastify route. The middleware matcher requires a non-empty dynamic segment, while Fastify's router can match an empty parameter or wildcard value. Practical impact depends on the handler and what the empty value selects; no special configuration is required for the mismatch to occur.

Exploit preconditions

  • Attack surface: An HTTP endpoint served by an affected application
  • Required access: A request can be made to the application; authentication may not be required if the skipped middleware is the control intended to require it
  • Trigger point: Routing a request whose path contains an empty dynamic segment matching both the middleware mount and a Fastify route
  • Why exploitation is possible: The middleware matcher and Fastify router interpret the empty segment differently, allowing the route handler to run without the scoped middleware

Why this happens

The underlying bug is inconsistent path interpretation between the @fastify/express middleware matcher and Fastify's router. The matcher excludes empty dynamic values that the router accepts, so middleware enforcement can be bypassed for a route sharing the dynamic pattern. This is an authentication-bypass risk (CWE-287) arising from inconsistent security-relevant interpretation of input, also associated with CWE-436.

Potential impact

  • An unauthenticated user may reach a handler protected by scoped middleware
  • An attacker could access or alter data depending on the handler's behavior and permissions
  • Security controls implemented only in the skipped middleware may not apply to the affected request

General mitigation guidance

Defensive approaches include aligning route and middleware path-matching semantics so security controls apply consistently to every matching request. Prefer framework-supported authentication and authorization mechanisms that are enforced at the route or handler boundary, and avoid relying solely on path-scoped middleware where routing behavior can diverge. Treat path parameters as untrusted, validate them explicitly, and apply least privilege to handlers and their downstream operations.

How teams detect issues like this

  • Review route and middleware registrations for overlapping dynamic patterns
  • Test empty path parameters and wildcard values to verify that authentication and authorization run before protected handlers
  • Use static analysis or code review checks to flag security controls attached only through path-scoped middleware
  • Enforce policy checks in CI so route changes cannot introduce paths that bypass required controls

Sources

SourceLink
cna.openjsf.orgcna.openjsf.org/security-advisories.html
github.comgithub.com/fastify/fastify-express/security/advisories/GHSA-662w-h4p6-jq4p

Frequently asked

questions

The issue concerns HTTP requests to an application using the affected middleware integration and overlapping dynamic route patterns. Its practical impact depends on the handler selected by the empty path value.

Not necessarily. If the skipped middleware is responsible for authentication, an unauthenticated request may reach the handler. Application exposure and other access controls affect the actual requirements.

Ensure authentication and authorization are enforced consistently at the route or handler boundary, rather than depending solely on path-scoped middleware matching.

Test routing edge cases, including empty dynamic segments, and review middleware and route patterns together. Use automated checks to verify that protected handlers cannot be reached without their required access controls.

Find out what's already
exploitable in your codebase.