@fastify/express vulnerable to path-scoped middleware bypass via Unicode case folding
Description
Impact
When Fastify routing is case-insensitive (routerOptions.caseSensitive: false), find-my-way folds the request path with toLowerCase(), which maps the Unicode character U+212A KELVIN SIGN to the ASCII letter k. @fastify/express passes Express the decoded path without applying that folding, and Express matches mount paths with a case-insensitive regular expression that does not fold non-ASCII characters. The two disagree, so a request such as /api/%E2%84%AAeys is routed to the /api/keys handler while a path-scoped middleware mounted at /api/keys (authentication, authorization, rate limiting) never matches and is skipped. An unauthenticated client reaches the protected handler by spelling a k in the mount path as %E2%84%AA. Only a mount path containing k is affected, and only when the application enables caseSensitive: false.
Patches
Upgrade to @fastify/express 4.0.10 or later. The request path Express matches path-scoped middleware on is now folded with the same toLowerCase() the router uses when caseSensitive is false.
Workarounds
Enforce authorization in a Fastify hook (such as preHandler) that runs after the router has resolved the request, rather than relying solely on a path-scoped Express middleware. Leaving routing case-sensitive (the default) also avoids the issue.