
Fastify Middleware Bypass: Patch @fastify/express and middie
Fastify middleware bypass explained: affected @fastify/express and middie versions, a lockfile check we ran, the preHandler fix and the interview concepts.
- What happened: Fastify maintainers published nine path-matching advisories for @fastify/express and @fastify/middie, most rated CVSS 9.1.
- Who is affected: Fastify apps that protect routes with path-scoped Express-style middleware, such as
app.use('/admin', auth). - What to do now: Upgrade to @fastify/express 4.0.10 and @fastify/middie 9.3.8, then move auth into a
preHandlerhook. - Interview angle: Parser differentials: two components reading one URL differently, the root of many auth bypasses.
The Fastify middleware bypass is a set of November 2026 flaws where path-scoped middleware in @fastify/express or @fastify/middie skipped a request that the Fastify router still served. An auth check mounted on a path could be missed. Upgrade to @fastify/express 4.0.10 and @fastify/middie 9.3.8, and enforce auth in a route hook.
A parser differential is a bug where two components parse the same input differently and make decisions from their own reading. In web apps it usually means a security layer and a router disagree about which path a request targets. The request passes the check meant for one path and reaches the handler for another.
The Fastify middleware bypass landed on 20 November 2026, when the maintainers shipped fixes for a batch of path-matching flaws in two plugins. @fastify/express lets Fastify run Express middleware. @fastify/middie runs connect-style middleware. Both let you scope middleware to a path, often for authentication.
The middie advisory says plainly that “No special configuration is required” for its headline issue. So a default setup can be exposed. Below: which versions are affected, how the mismatch works, a lockfile check we ran, and the interview concepts behind it.
What changed in the Fastify middleware bypass advisories?
The OpenJS Foundation CNA list shows five @fastify/express advisories and four @fastify/middie advisories from 18 to 21 November 2026. The fixed releases reached npm on 20 November: middie 9.3.8 at 15:54 UTC and express 4.0.10 at 18:00 UTC, per the npm registry.
| CVE | Package | Trigger | CVSS 3.1 | Affected → fixed | Needs non-default config? |
|---|---|---|---|---|---|
| CVE-2026-124626 | @fastify/express | Empty route parameters and wildcards | 9.1 | 4.0.5–4.0.9 → 4.0.10 | No |
| CVE-2026-129504 | @fastify/express | Plugin prefix and mount path joined as strings | 9.1 | 4.0.0–4.0.9 → 4.0.10 | Prefix ending in “/” or mount without leading “/” |
| CVE-2026-133120 | @fastify/express | URL decoding and normalization | 9.1 | < 4.0.10 → 4.0.10 | No |
| CVE-2026-133867 | @fastify/express | RegExp mounts under a parameterised prefix | 9.1 | 4.0.7–4.0.9 → 4.0.10 | Prefix like /tenant/:id + RegExp mount |
| CVE-2026-129850 | @fastify/express | Unicode case folding | 7.4 | 4.0.0–4.0.9 → 4.0.10 | caseSensitive: false |
| CVE-2026-133250 | @fastify/middie | Empty params, * targets, literal % in mounts |
9.1 | ≤ 9.3.7 → 9.3.8 | No |
| CVE-2026-132133 | @fastify/middie | Duplicate-slash mount path | 4.8 | < 9.3.7 → 9.3.7 | ignoreDuplicateSlashes |
| CVE-2026-132128 | @fastify/middie | Unicode case folding | 7.4 | ≤ 9.3.6 → 9.3.7 | caseSensitive: false |
| CVE-2026-132131 | @fastify/middie | Array mount-path type confusion | See advisory | See advisory | See advisory |
This is not a one-off. The same plugin already had path-matching advisories this year: percent-encoding in January, path doubling in April and non-string mount paths in June. If you patched those, you still need this release.
On exploitation, Ostorlab reported on 21 November that none of the issues was known to be exploited or listed in CISA KEV.
How does the Fastify middleware bypass work?
Two libraries read one URL. The middleware layer uses path-to-regexp-style matching to decide whether auth runs. The Fastify router, find-my-way, decides which handler runs. The middie advisory describes the flow:
- A request arrives for a path that is slightly unusual, for example with an empty parameter segment.
- The middleware matcher requires at least one character in that segment, so it says “not my path” and skips auth.
- The router accepts the empty segment and matches the protected route anyway.
- The handler runs without the auth middleware ever executing.
The other advisories are the same story with a different trigger. One layer decodes %25 twice, per the decoding advisory. Another folds the Unicode Kelvin sign to “k” while the other does not, per the case-folding advisory.
The vulnerable pattern and the safer one
// Risky on unpatched plugins: auth depends on the middleware matcher
await app.register(require('@fastify/express'));
app.use('/tenant/:id/admin', requireAdmin);
// Safer: decide in a route hook, from the route that actually matched
app.addHook('preHandler', async (req, reply) => {
if (req.routeOptions.url === '/tenant/:id/admin' && !isAdmin(req)) {
return reply.code(401).send({ error: 'unauthorized' });
}
});
This is the workaround the express advisory and the middie advisory both give. The hook runs after routing, so the check and the handler can never disagree.
What should Fastify developers do right now?
- Detect. Run
npm ls @fastify/express @fastify/middie. Nested copies count too. - Patch.
npm i @fastify/express@^4.0.10 @fastify/middie@^9.3.8, then rebuild your lockfile and images. - Verify. Run the lockfile check below in CI so an old copy cannot creep back.
- Mitigate. Move auth into
preHandlerkeyed onrequest.routeOptions.url. KeepcaseSensitiveandignoreDuplicateSlashesat defaults unless you need them.
We ran a lockfile check and a hook test
We ran these with Node.js v22.23.5 in our Linux sandbox, using fastify 5.12.8, @fastify/middie 9.3.9 and @fastify/express 4.0.12. First, a script that flags old versions in package-lock.json:
// check_fastify_mw.mjs — flag @fastify/express and @fastify/middie versions hit by the Nov 2026 advisories.
// Usage: node check_fastify_mw.mjs [path/to/package-lock.json]
import { readFileSync } from 'node:fs';
const FIXED = { '@fastify/express': '4.0.10', '@fastify/middie': '9.3.8' };
const lock = JSON.parse(readFileSync(process.argv[2] ?? 'package-lock.json', 'utf8'));
const cmp = (a, b) => { const x = a.split('.').map(Number), y = b.split('.').map(Number);
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] - y[i]; return 0; };
let bad = 0;
for (const [path, meta] of Object.entries(lock.packages ?? {})) {
const name = path.replace(/^.*node_modules\//, '');
if (!FIXED[name] || !meta.version) continue;
const ok = cmp(meta.version, FIXED[name]) >= 0;
if (!ok) bad++;
console.log(`[${ok ? 'OK ' : 'FAIL'}] ${name}@${meta.version} at ${path} (needs >= ${FIXED[name]})`);
}
process.exitCode = bad ? 1 : 0;
Raw output from our run, against a current lockfile and one pinned to the last vulnerable releases:
$ node check_fastify_mw.mjs package-lock.json
[OK ] @fastify/express@4.0.12 at node_modules/@fastify/express (needs >= 4.0.10)
[OK ] @fastify/middie@9.3.9 at node_modules/@fastify/middie (needs >= 9.3.8)
exit 0
$ node check_fastify_mw.mjs old/package-lock.json
[FAIL] @fastify/express@4.0.9 at node_modules/@fastify/express (needs >= 4.0.10)
[FAIL] @fastify/middie@9.3.7 at node_modules/@fastify/middie (needs >= 9.3.8)
exit 1
Second, the hook-based guard, tested with app.inject():
// hook_guard.mjs — auth decided in preHandler from the matched route, not the raw URL.
import Fastify from 'fastify';
const app = Fastify();
const PROTECTED = ['/tenant/:id/admin'];
app.addHook('preHandler', async (req, reply) => {
if (!PROTECTED.includes(req.routeOptions.url)) return;
if (req.headers.authorization !== 'Bearer good-token') {
return reply.code(401).send({ error: 'unauthorized' });
}
});
app.get('/tenant/:id/admin', async (req) => ({ ok: true, url: req.url, route: req.routeOptions.url }));
for (const [url, auth] of [['/tenant/acme/admin'], ['/tenant//admin'], ['/tenant/acme/admin', 'Bearer good-token']]) {
const res = await app.inject({ url, headers: auth ? { authorization: auth } : {} });
console.log(`${url.padEnd(20)} auth=${auth ? 'yes' : 'no '} -> ${res.statusCode} ${res.body}`);
}
$ node hook_guard.mjs
/tenant/acme/admin auth=no -> 401 {"error":"unauthorized"}
/tenant//admin auth=no -> 401 {"error":"unauthorized"}
/tenant/acme/admin auth=yes -> 200 {"ok":true,"url":"/tenant/acme/admin","route":"/tenant/:id/admin"}
The second line is the useful one. The router mapped the empty-segment URL to /tenant/:id/admin, exactly as the advisory describes. Because the hook keys on the matched route, it still demanded a token.
We covered the same patch-then-verify routine for the runtime itself in our Node.js November 2026 security release guide.
Interview questions this update prepares you for
Why is path-prefix middleware a weak place to enforce authorization?
Prefix middleware decides from the raw URL, while the router decides from its own parsed view. Any difference between the two, in decoding, slashes, case or parameters, creates a gap. The safer design puts authorization where the route is already resolved: a route hook, a guard on the handler, or a policy check inside the service.
Follow-up they may ask: How would you make “every route has an auth policy” a test that fails in CI?
What is a parser differential, and where else does it cause bugs?
A parser differential happens when two components parse the same input differently and each acts on its own result. Classic examples are HTTP request smuggling between a proxy and a backend, URL parsing differences that defeat SSRF allow-lists, and JSON parsers that disagree on duplicate keys. The defence is to parse once, pass the parsed result along, and make security decisions from that single reading.
Follow-up they may ask: How can two URL parsers disagree on the host of the same URL?
What does URL canonicalisation mean, and why is double-decoding dangerous?
Canonicalisation turns equivalent forms of a URL into one standard form before comparison. That includes decoding percent escapes once, resolving dot segments and handling duplicate slashes consistently. Double-decoding is dangerous because %2561 becomes %61 after one pass and a after two. A check that ran after the first pass sees a different path than code that ran after the second.
Follow-up they may ask: Should you normalise before or after the security check, and why?
Why is toLowerCase() unsafe for security comparisons?
Case conversion in Unicode is not a simple ASCII mapping. Some characters fold to ASCII letters: the Kelvin sign U+212A lowercases to “k”. If one layer folds case and another does not, the two see different strings. For identifiers like paths, usernames or hostnames, compare in one agreed form, prefer case-sensitive matching, or normalise with a defined algorithm such as NFKC plus case folding everywhere.
Follow-up they may ask: How do homoglyph attacks affect usernames and domain names?
In Fastify’s lifecycle, why put auth in preHandler rather than onRequest?
onRequest runs very early, before the body is parsed, and it is good for cheap rejects like rate limits. preHandler runs after routing, parsing and validation, just before the handler. At that point request.routeOptions tells you which route matched, so the auth decision uses the router’s own result.
Follow-up they may ask: What is Fastify plugin encapsulation, and how does it scope hooks?
Broken access control often hides in layers like this one. Our RLS policy privilege escalation lessons show the same “two places think they own the check” problem at the database level.
The NexGismo verdict: Patch both plugins today; it is a minor-version bump with no API change in the advisories. My recommendation goes further: stop using path-scoped middleware as your auth boundary in Fastify at all. This plugin has had path-matching advisories in January, April, June and now November, and a preHandler guard keyed on the matched route removes the whole class.
- Fastify maintainers published nine path-matching advisories for @fastify/express and @fastify/middie between 18 and 21 November 2026.
- Most @fastify/express issues and the main middie issue are rated CVSS 3.1 9.1.
- @fastify/express 4.0.10 and @fastify/middie 9.3.8 contain the fixes, both published on npm on 20 November 2026.
- The headline middie and express issues need no special router configuration.
- The recommended workaround is an auth check in a preHandler hook based on request.routeOptions.url.
Frequently Asked Questions
Which versions fix the Fastify middleware bypass?
Upgrade @fastify/express to 4.0.10 or later and @fastify/middie to 9.3.8 or later. Both fixes were published on npm on 20 November 2026. Some middie issues were already fixed in 9.3.7, but CVE-2026-133250 needs 9.3.8, so treat 9.3.8 as the floor. Check every copy in your lockfile, including nested ones.
Is plain Fastify affected by these middleware bypass CVEs?
The November 2026 advisories are filed against the @fastify/express and @fastify/middie plugins, which add Express-style middleware to Fastify. If your app does not install either plugin and enforces auth in Fastify hooks, these CVEs do not apply to you. Run npm ls @fastify/express @fastify/middie to be sure.
Are these Fastify CVEs being exploited?
As of 21 November 2026, Ostorlab reported no known exploitation and said none of the issues was in the CISA KEV catalog. That can change quickly for a bug class this simple, so patch anyway and check the KEV catalog before you close the ticket.
How do I protect Fastify routes if I cannot upgrade today?
The advisories recommend moving the auth check into a Fastify hook such as preHandler and deciding from request.routeOptions.url, the route that actually matched, instead of request.url. That closes the gap because the decision uses the router’s own view of the request. Keep router options at their defaults until you patch.
This is a small fix with a big lesson. Upgrade @fastify/express to 4.0.10 and @fastify/middie to 9.3.8, add the lockfile check to CI, and move auth into a hook that reads the matched route. Then search your codebase for app.use('/ lines guarding sensitive paths. If you find other places where two layers parse the same input, our LiteLLM guardrail escape write-up is a good next read.
Sources
- GitHub — fastify/middie advisory GHSA-gcf6-j9m3-p97x (CVE-2026-133250)
- GitHub — fastify/middie advisory GHSA-56jq-34pf-p873 (CVE-2026-132133)
- GitHub — fastify/middie advisory GHSA-r5h5-r25j-5vhr (CVE-2026-132128)
- GitHub — fastify-express advisory GHSA-662w-h4p6-jq4p (CVE-2026-124626)
- GitHub — fastify-express advisory GHSA-f44m-4qwg-5587 (CVE-2026-129504)
- GitHub — fastify-express advisory GHSA-w877-hjcp-88rc (CVE-2026-133120)
- GitHub — fastify-express advisory GHSA-84w6-xrf3-f8q8 (CVE-2026-133867)
- GitHub — fastify-express advisory GHSA-6rmc-f24g-hmp6 (CVE-2026-129850)
- OpenJS Foundation CNA — Security advisories
- npm — @fastify/express
- npm — @fastify/middie
- Ostorlab — Fastify middleware bypass exposes protected routes