CVE-2026-135230: @fastify/express vulnerable to RegExp middleware bypass via encoded line terminators
@fastify/express is the plugin that lets an application run Express middleware and Express applications inside the Fastify web framework. In versions from 4.0.3 before 4.0.14, the plugin decodes certain percent-encoded characters in the request path that Express would otherwise keep encoded, including the Unicode line separator and paragraph separator characters, and leaves them raw. A JavaScript regular expression treats those two characters as line terminators, so a regular-expression mount path that relies on the dot metacharacter fails to match a request containing them while Fastify's own router still routes the request to its handler, and the middleware mounted on that regular-expression path is therefore skipped. An attacker can use this to bypass authentication or other middleware-based access controls on routes guarded by a regular-expression mount; string mount paths are not affected. The issue is fixed in @fastify/express 4.0.14, and users should upgrade to 4.0.14 or later. As a workaround, use string mount paths, avoid the dot metacharacter in regular-expression mounts by using a character class or the dotAll flag, or enforce authentication in a Fastify hook such as preHandler that runs after the router resolves the request.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 4.0.14 - Compensating control
For regular-expression mount paths, use string mount paths, avoid the dot metacharacter by using a character class or the dotAll flag, or enforce authentication in a Fastify preHandler hook.
Event History
Frequently Asked Questions
Which deployments are affected?
Deployments using @fastify/express versions 4.0.3 through 4.0.13 are affected when security-relevant middleware is mounted on a regular-expression path that relies on the dot metacharacter. String mount paths are not affected.
What does an attacker need to do to bypass the middleware?
An unauthenticated remote attacker can send a request path containing percent-encoded Unicode line separator or paragraph separator characters. These characters can cause the regular-expression mount not to match while Fastify still routes the request to its handler.
What should be done if an immediate upgrade is not possible?
Replace affected regular-expression mount paths with string mount paths where possible. Otherwise, avoid the dot metacharacter by using a character class or the dotAll flag, and ensure authentication is not solely dependent on the affected middleware mount.
How can I determine whether routes are exposed?
Review Express middleware mounted through the plugin for regular-expression paths, especially mounts protecting authentication or authorization. Prioritize expressions using a dot metacharacter and test requests containing percent-encoded Unicode line or paragraph separators.
What is the permanent fix?
Upgrade @fastify/express to version 4.0.14 or later.