CVE-2026-33807: @fastify/express Authentication Bypass Vulnerability
CRITICALCVE-2026-33807 is a CRITICAL (CVSS 9.1) authentication bypass vulnerability (CWE-436: Interpretation Conflict) affecting @fastify/express libraries in the npm ecosystem. The issue involves @fastify/express's middleware path doubling causes authentication bypass in child plugin scopes. Remediation is available by upgrading affected packages to version 4.0.5.
CVE-2026-33807 at a Glance
Security Impact
CVSS: 9.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N).
How to Fix CVE-2026-33807
To remediate this vulnerability, upgrade all affected @fastify/express dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @fastify/express@4.0.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @fastify/express
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-33807, inspect your project dependencies using npm:
npm ls @fastify/express
Analyze the terminal output to locate any version of @fastify/express in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.5), your application is affected.
Note: The npm ls @fastify/express command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-436: Interpretation Conflict, where product a handles inputs or steps differently than product b, which causes a to perform incorrect actions based on its perception of b's state. In @fastify/express, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-33807 Affected @fastify/express Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@fastify/express
|
npm |
< 4.0.5
|
4.0.5
|
References
Frequently Asked Questions
What is CVE-2026-33807?
Which @fastify/express versions are affected?
What version fixes CVE-2026-33807?
Is @fastify/express affected?
What is the CVSS score of CVE-2026-33807?
What CWE is associated with CVE-2026-33807?
How can I check npm dependencies for CVE-2026-33807?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-hrwm-hgmj-7p9c",
"modified" : "2026-04-16T01:03:25Z",
"published" : "2026-04-16T01:03:25Z",
"aliases" : [ "CVE-2026-33807" ],
"summary" : "@fastify/express's middleware path doubling causes authentication bypass in child plugin scopes",
"details" : "### Summary\n\n`@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.\n\n### Details\n\nThe 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.\n\nThe call flow demonstrates the problem:\n1. Parent scope registers middleware: `app.use('/admin', authFn)` — `use()` calculates path as `'' + '/admin' = '/admin'` — stores `['/admin', authFn]` in `kMiddlewares`\n2. Child plugin registers with `{ prefix: '/admin' }` — triggers `onRegister(instance)`\n3. `onRegister` copies parent middleware and calls `instance.use('/admin', authFn)` on child\n4. Child's `use()` function calculates path as `'/admin' + '/admin' = '/admin/admin'` — registers middleware with doubled path\n5. Routes in child scope use the child's Express instance, where middleware is registered under the incorrect path `/admin/admin`\n6. Requests to `/admin/secret` don't match `/admin/admin` — middleware is silently skipped\n\nThe 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.\n\n### PoC\n\n```javascript\nconst fastify = require('fastify');\nconst http = require('http');\n\nfunction get(port, url) {\n return new Promise((resolve, reject) => {\n http.get('http://localhost:' + port + url, (res) => {\n let data = '';\n res.on('data', (chunk) => data += chunk);\n res.on('end', () => resolve({ status: res.statusCode, body: data }));\n }).on('error', reject);\n });\n}\n\nasync function test() {\n const app = fastify({ logger: false });\n await app.register(require('@fastify/express'));\n \n // Middleware enforcing auth on /admin routes\n app.use('/admin', function(req, res, next) {\n if (!req.headers.authorization) {\n res.statusCode = 403;\n res.setHeader('content-type', 'application/json');\n res.end(JSON.stringify({ error: 'Forbidden' }));\n return;\n }\n next();\n });\n \n // Root scope route — middleware works correctly\n app.get('/admin/root-data', async () => ({ data: 'root-secret' }));\n \n // Child scope route — middleware BYPASSED\n await app.register(async function(child) {\n child.get('/secret', async () => ({ data: 'child-secret' }));\n }, { prefix: '/admin' });\n \n await app.listen({ port: 19876, host: '0.0.0.0' });\n \n // Root scope: correctly blocked\n let r = await get(19876, '/admin/root-data');\n console.log('/admin/root-data (no auth):', r.status, r.body);\n // Output: 403 {\"error\":\"Forbidden\"}\n \n // Child scope: BYPASSED — secret data returned without auth\n r = await get(19876, '/admin/secret');\n console.log('/admin/secret (no auth):', r.status, r.body);\n // Output: 200 {\"data\":\"child-secret\"}\n \n await app.close();\n}\ntest();\n```\n\nActual output:\n```\n/admin/root-data (no auth): 403 {\"error\":\"Forbidden\"}\n/admin/secret (no auth): 200 {\"data\":\"child-secret\"}\n```\n\n### Impact\n\nComplete 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.\n\n- No special request crafting is required — normal requests bypass the middleware\n- It affects the idiomatic Fastify plugin pattern commonly used in production\n- The bypass is silent with no errors or warnings\n- Developers' basic testing of root-scoped routes will pass, masking the vulnerability\n- Any child plugin scope that shares a prefix with middleware is affected\n\nApplications using `@fastify/express` with path-scoped middleware and child plugins with matching prefixes are vulnerable in default configurations.\n\n### Affected Versions\n\n- `@fastify/express` v4.0.4 (latest at time of discovery)\n- Fastify 5.x in default configuration\n- No special router options required (`ignoreDuplicateSlashes` not needed)\n- Affects any child plugin registration where the prefix overlaps with middleware path scoping\n- Does NOT affect middleware registered without path scoping (global middleware)\n- Does NOT affect middleware registered on root path (`/`) due to special case handling\n\n### Variant Testing\n\n| Scenario | Middleware Path | Child Prefix | Result |\n|---|---|---|---|\n| Root route `/admin/root-data` | `/admin` | N/A | Middleware runs (403) |\n| Child route `/admin/secret` | `/admin` | `/admin` | **BYPASS** (200) |\n| Child route `/api/data` | `/api` | `/api` | **BYPASS** (200) |\n| Nested child `/admin/sub/data` | `/admin` | `/admin/sub` | **BYPASS** — path becomes `/admin/sub/admin` |\n| Middleware on `/` with any child | `/` | `/api` | No bypass — `path === '/' && prefix.length > 0` special case |\n\n### Suggested Fix\n\nThe `onRegister` function should store and re-use the original unprefixed middleware paths, or avoid re-calling the `use()` function entirely. Options include:\n1. Store the original path and function separately in `kMiddlewares` before prefixing\n2. Strip the parent prefix before re-registering in child scopes\n3. Store already-constructed Express middleware objects rather than re-processing paths",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/express"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.0.5"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 4.0.4"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-express/security/advisories/GHSA-hrwm-hgmj-7p9c"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33807"
}, {
"type" : "WEB",
"url" : "https://cna.openjsf.org/security-advisories.html"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify-express"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-436" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2026-04-16T01:03:25Z",
"nvd_published_at" : "2026-04-15T10:16:48Z"
}
}