Lack of data validation - Path Traversal In @fastify/express
Description
@fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding)
Summary
A security vulnerability exists in @fastify/express where middleware registered with a specific path prefix can be bypassed using URL-encoded characters (e.g., /%61dmin instead of /admin). While the middleware engine fails to match the encoded path and skips execution, the underlying Fastify router correctly decodes the path and matches the route handler, allowing attackers to access protected endpoints without the middleware constraints.
Details
The vulnerability is caused by how @fastify/express matches requests against registered middleware paths.
PoC
Step 1: Run the following Fastify application (save as app.js):
const fastify = require('fastify')({ logger: true }); async function start() { // Register fastify-express for Express-style middleware support await fastify.register(require('@fastify/express')); // Middleware to block /admin route fastify.use('/admin', (req, res, next) => {...
Step 2: Execute the attack.
➜ ~ curl http://206.189.140.29:3000/%61dmin <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body>...
It differs from CVE-2026-22031 because this is a different npm module with its own code.
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
npm | 4.0.3 |
Aliases
References